示例#1
0
 public void removeSubModule(Module subModule) {
   if (subModules.contains(subModule) && this.hasSubModule(subModule.getName())) {
     subModules.remove(subModule);
   } else {
     System.out.println("This sub module does not exist!");
   }
 }
示例#2
0
 // Module
 public void addSubModule(Module subModule) {
   if (!subModules.contains(subModule) && !this.hasSubModule(subModule.getName())) {
     subModules.add(subModule);
   } else {
     System.out.println("This sub module has already been added!");
   }
 }
示例#3
0
 public boolean hasSubModule(String name) {
   boolean hasSubModule = false;
   for (Module subModule : subModules) {
     if (subModule.getName().equals(name) || subModule.hasSubModule(name)) {
       hasSubModule = true;
     }
   }
   return hasSubModule;
 }
示例#4
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;
  }