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; } }
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; }