Example #1
0
 public AddModuleResultModel addModule(AddModuleModel model) {
   String name = model.getName();
   Set<Configuration> configurations = new HashSet<Configuration>();
   for (ConfigurationModel configurationModel : model.getConfigurations()) {
     Configuration configuration = new Configuration();
     configuration.setId(configurationModel.getId());
     configuration.setDisplayName(configurationModel.getDisplayName());
     configuration.setKey(configurationModel.getKey());
     configurations.add(configuration);
   }
   UUID moduleId = this.getModuleService().addModule(name, configurations);
   if (moduleId == null) {
     AddModuleResultModel result = new AddModuleResultModel();
     result.setMessage("fail");
     result.setModuleId(null);
     result.setSuccess(false);
     return result;
   } else {
     AddModuleResultModel result = new AddModuleResultModel();
     result.setMessage("success");
     result.setModuleId(moduleId);
     result.setSuccess(true);
     return result;
   }
 }
Example #2
0
 public ModuleModel getModule(UUID moduleId) {
   Module module = this.getModuleService().getModule(moduleId);
   if (module == null) {
     return null;
   }
   ModuleModel moduleModel = new ModuleModel();
   moduleModel.setId(module.getId());
   moduleModel.setName(module.getName());
   moduleModel.setConfigurations(new HashSet<ConfigurationModel>());
   for (Configuration configuration : module.getConfigurations()) {
     ConfigurationModel model = new ConfigurationModel();
     model.setDisplayName(configuration.getDisplayName());
     model.setId(configuration.getId());
     model.setKey(configuration.getKey());
     moduleModel.getConfigurations().add(model);
   }
   return moduleModel;
 }
Example #3
0
 public ModuleListModel getModuleList() {
   List<Module> moduleList = this.getModuleService().getModuleList();
   ModuleListModel moduleListModel = new ModuleListModel();
   moduleListModel.setModules(new ArrayList<ModuleBriefModel>());
   for (Module module : moduleList) {
     ModuleBriefModel moduleBriefModel = new ModuleBriefModel();
     moduleBriefModel.setId(module.getId());
     moduleBriefModel.setName(module.getName());
     moduleBriefModel.setConfigurations(new HashSet<ConfigurationModel>());
     for (Configuration configuration : module.getConfigurations()) {
       ConfigurationModel model = new ConfigurationModel();
       model.setDisplayName(configuration.getDisplayName());
       model.setId(configuration.getId());
       model.setKey(configuration.getKey());
       moduleBriefModel.getConfigurations().add(model);
     }
     moduleListModel.getModules().add(moduleBriefModel);
   }
   return moduleListModel;
 }
Example #4
0
 public ModifyModuleResultModel modifyModule(UUID moduleId, ModifyModuleModel model) {
   String newName = model.getNewName();
   Set<Configuration> newConfigurations = new HashSet<Configuration>();
   for (ConfigurationModel configurationModel : model.getNewConfigurations()) {
     Configuration configuration = new Configuration();
     configuration.setId(configurationModel.getId());
     configuration.setDisplayName(configurationModel.getDisplayName());
     configuration.setKey(configurationModel.getKey());
     newConfigurations.add(configuration);
   }
   boolean success = this.getModuleService().modifyModule(moduleId, newName, newConfigurations);
   ModifyModuleResultModel result = new ModifyModuleResultModel();
   result.setModuleId(moduleId);
   result.setSuccess(success);
   if (success) {
     result.setMessage("success");
   } else {
     result.setMessage("fail");
   }
   return result;
 }