示例#1
0
 public boolean hasSubModule(long id) {
   boolean hasSubModule = false;
   for (Module subModule : subModules) {
     if (subModule.getId() == id || subModule.hasSubModule(id)) {
       hasSubModule = true;
     }
   }
   return hasSubModule;
 }
示例#2
0
  public Element getModuleInXML(Module module) {
    Element xmlModule = new Element("Module");

    Element moduleType = new Element("type");
    moduleType.addContent(module.getClass().getSimpleName());
    xmlModule.addContent(moduleType);

    Element moduleDescription = new Element("description");
    moduleDescription.addContent(module.getDescription());
    xmlModule.addContent(moduleDescription);

    Element moduleId = new Element("id");
    moduleId.addContent(Long.toString(module.getId()));
    xmlModule.addContent(moduleId);

    Element moduleName = new Element("name");
    moduleName.addContent(module.getName());
    xmlModule.addContent(moduleName);

    /** build extra elements based on type (Module is generic) */
    if (module.getClass().getSimpleName().toLowerCase().equals("layer")) {
      Element moduleLevel = new Element("HierarchicalLevel");
      moduleLevel.addContent("" + ((Layer) module).getHierarchicalLevel());
      xmlModule.addContent(moduleLevel);
    }

    /** Check for units and add them to the XML root of this element */
    if (module.getUnits().size() > 0) {
      Element units = new Element("SoftwareUnitDefinitions");
      for (SoftwareUnitDefinition SUD : module.getUnits()) {
        units.addContent(this.getSoftwareUnitDefinitionInXML(SUD));
      }
      xmlModule.addContent(units);
    }

    /** Check for submodules and add them to the root of the parent (recursive call) */
    if (module.getSubModules().size() > 0) {
      Element subModule = new Element("SubModules");
      for (Module m : module.getSubModules()) {
        subModule.addContent(this.getModuleInXML(m));
      }
      xmlModule.addContent(subModule);
    }

    if (module.getUnits().size() > 0) {
      Element physicalPaths = new Element("PhysicalPaths");

      for (SoftwareUnitDefinition su : module.getUnits()) {
        physicalPaths.addContent(this.getPhysicalPathInXML(su.getName()));
      }

      xmlModule.addContent(physicalPaths);
    }

    return xmlModule;
  }