diff --git a/src/main/java/org/openepics/names/rest/controller/old/DeviceNamesControllerV0.java b/src/main/java/org/openepics/names/rest/controller/old/DeviceNamesControllerV0.java index be3c4b44ab34a9593aa45f6270b0b14a71dc6314..97972cdea6d0cfc22034c2c320a75a2296ca9423 100644 --- a/src/main/java/org/openepics/names/rest/controller/old/DeviceNamesControllerV0.java +++ b/src/main/java/org/openepics/names/rest/controller/old/DeviceNamesControllerV0.java @@ -39,7 +39,7 @@ import org.openepics.names.repository.ISystemRepository; import org.openepics.names.repository.model.Name; import org.openepics.names.rest.beans.old.DeviceNameElement; import org.openepics.names.util.HolderIRepositories; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.NamingConventionUtil; import org.openepics.names.util.old.DeviceNameElementUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -117,10 +117,10 @@ public class DeviceNamesControllerV0 { final List<DeviceNameElement> deviceNameElements = new ArrayList<>(names.size()); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } LOGGER.log(Level.FINE, "findNames, deviceNameElement s.size: {0}", deviceNameElements.size()); @@ -159,11 +159,11 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.nameRepository().findLatestNotDeleted(); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name namee : names) { if (pattern.matcher(namee.getConventionName()).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(namee, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(namee, holderStructures)); } } @@ -187,20 +187,20 @@ public class DeviceNamesControllerV0 { // case sensitive // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); final List<DeviceNameElement> deviceNameElements = Lists.newArrayList(); List<Name> namesSystemGroup = holderIRepositories.nameRepository().findLatestBySystemGroupMnemonic(system); for (Name name : namesSystemGroup) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } List<Name> namesSystem = holderIRepositories.nameRepository().findLatestBySystemMnemonic(system); List<Name> namesSystemThroughSubsystem = holderIRepositories.nameRepository().findLatestBySystemMnemonicThroughSubsystem(system); for (Name name : namesSystem) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } for (Name name : namesSystemThroughSubsystem) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } LOGGER.log(Level.FINE, "findNamesBySystem, system: {0}", system); @@ -235,12 +235,12 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.nameRepository().findLatestNotDeleted(); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractSystem(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -270,10 +270,10 @@ public class DeviceNamesControllerV0 { if (!names.isEmpty()) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -309,12 +309,12 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.nameRepository().findLatestNotDeleted(); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractSubsystem(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -344,10 +344,10 @@ public class DeviceNamesControllerV0 { if (!names.isEmpty()) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -383,12 +383,12 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.nameRepository().findLatestNotDeleted(); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractDiscipline(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -418,10 +418,10 @@ public class DeviceNamesControllerV0 { if (!names.isEmpty()) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } @@ -457,12 +457,12 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.nameRepository().findLatestNotDeleted(); // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractDeviceType(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/DeviceGroupService.java b/src/main/java/org/openepics/names/service/DeviceGroupService.java index 3f94ae75ca7a5f011f2380609fd73bc721a2f2aa..a45902e104dc42331c05e8515c31415aa365ce22 100644 --- a/src/main/java/org/openepics/names/service/DeviceGroupService.java +++ b/src/main/java/org/openepics/names/service/DeviceGroupService.java @@ -35,7 +35,7 @@ import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -83,7 +83,7 @@ public class DeviceGroupService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -113,11 +113,11 @@ public class DeviceGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceGroup), - NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.CREATE, null, null, deviceGroup, holderStructure)); + NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.CREATE, null, null, deviceGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -152,11 +152,11 @@ public class DeviceGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceGroup), NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -186,11 +186,11 @@ public class DeviceGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceGroup), - NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.DELETE, null, null, deviceGroup, holderStructure)); + NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.DELETE, null, null, deviceGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -261,22 +261,22 @@ public class DeviceGroupService { commands.add(new StructureElementCommand(deviceType.getUuid(), Type.DEVICETYPE, null, null, null, null, StructuresService.DELETE_AFTER_APPROVE_STRUCTURE_CHANGE)); } for (StructureElementCommand command : commands) { - deviceTypeService.deleteStructure(command, when, username, holderStructure); + deviceTypeService.deleteStructure(command, when, username, holderStructures); } for (StructureElementCommand command : commands) { - deviceTypeService.approveStructure(command, when, username, holderStructure); + deviceTypeService.approveStructure(command, when, username, holderStructures); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, deviceGroup, holderStructure)); + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, deviceGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -311,13 +311,13 @@ public class DeviceGroupService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -352,9 +352,9 @@ public class DeviceGroupService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/DeviceTypeService.java b/src/main/java/org/openepics/names/service/DeviceTypeService.java index 5fcbce5e791f383b47c402b8a2948cbd61c945e0..ab05f3356b35ebbdaa24cb8571f81056cbdec56d 100644 --- a/src/main/java/org/openepics/names/service/DeviceTypeService.java +++ b/src/main/java/org/openepics/names/service/DeviceTypeService.java @@ -33,7 +33,7 @@ import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -76,7 +76,7 @@ public class DeviceTypeService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -106,11 +106,11 @@ public class DeviceTypeService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceType), - NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.CREATE, null, null, deviceType, holderStructure)); + NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.CREATE, null, null, deviceType, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -145,11 +145,11 @@ public class DeviceTypeService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceType), NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -179,11 +179,11 @@ public class DeviceTypeService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(deviceType), - NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.DELETE, null, null, deviceType, holderStructure)); + NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.DELETE, null, null, deviceType, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -254,12 +254,12 @@ public class DeviceTypeService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.APPROVE, previous, deviceType, holderStructure)); + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.APPROVE, previous, deviceType, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -293,13 +293,13 @@ public class DeviceTypeService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -334,9 +334,9 @@ public class DeviceTypeService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/DisciplineService.java b/src/main/java/org/openepics/names/service/DisciplineService.java index 757ae531e6c9d95b954a14bee0850748c002c415..31639a1b1ba1ee36f063594dbcedbed1a014fd2f 100644 --- a/src/main/java/org/openepics/names/service/DisciplineService.java +++ b/src/main/java/org/openepics/names/service/DisciplineService.java @@ -35,7 +35,7 @@ import org.openepics.names.rest.beans.Status; import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -86,7 +86,7 @@ public class DisciplineService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -116,11 +116,11 @@ public class DisciplineService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(discipline), - NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.CREATE, null, null, discipline, holderStructure)); + NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.CREATE, null, null, discipline, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -155,11 +155,11 @@ public class DisciplineService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(discipline), NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -189,11 +189,11 @@ public class DisciplineService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(discipline), - NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.DELETE, null, null, discipline, holderStructure)); + NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.DELETE, null, null, discipline, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -265,22 +265,22 @@ public class DisciplineService { commands.add(new StructureElementCommand(deviceGroup.getUuid(), Type.DEVICEGROUP, null, null, null, null, StructuresService.DELETE_AFTER_APPROVE_STRUCTURE_CHANGE)); } for (StructureElementCommand command : commands) { - deviceGroupService.deleteStructure(command, when, username, holderStructure); + deviceGroupService.deleteStructure(command, when, username, holderStructures); } for (StructureElementCommand command : commands) { - deviceGroupService.approveStructure(command, when, username, holderStructure); + deviceGroupService.approveStructure(command, when, username, holderStructures); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.APPROVE, previous, discipline, holderStructure)); + StructureElementUtil.getStructureElementProcessed(discipline, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.APPROVE, previous, discipline, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -315,13 +315,13 @@ public class DisciplineService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(discipline, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -356,9 +356,9 @@ public class DisciplineService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(discipline, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/NamesService.java b/src/main/java/org/openepics/names/service/NamesService.java index 4aab2bb7f4f75db2556751cc49ed976d5a34bffa..5ac1cde7d5609788885f730bbf5d67036017d11a 100644 --- a/src/main/java/org/openepics/names/service/NamesService.java +++ b/src/main/java/org/openepics/names/service/NamesService.java @@ -57,7 +57,7 @@ import org.openepics.names.util.EssNamingConvention; import org.openepics.names.util.ExceptionUtil; import org.openepics.names.util.HolderIRepositories; import org.openepics.names.util.HolderRepositories; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.NameElementUtil; import org.openepics.names.util.NameUtil; import org.openepics.names.util.TextUtil; @@ -149,12 +149,12 @@ public class NamesService { // return name elements for created names // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); final List<NameElement> createdNameElements = Lists.newArrayList(); for (NameElementCommand nameElementCommand : nameElementCommands) { - NameElement createdNameElement = createName(nameElementCommand, when, username, holderStructure); + NameElement createdNameElement = createName(nameElementCommand, when, username, holderStructures); createdNameElements.add(createdNameElement); if (LOGGER.isLoggable(Level.FINER)) { @@ -172,7 +172,7 @@ public class NamesService { return createdNameElements; } @Transactional(propagation = Propagation.MANDATORY) - public NameElement createName(NameElementCommand nameElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public NameElement createName(NameElementCommand nameElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -204,11 +204,11 @@ public class NamesService { String derivedName = null; if (systemGroup != null) { - derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructures); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, index, holderStructure); + derivedName = NameUtil.getName(system, deviceType, index, holderStructures); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructures); } // create @@ -512,9 +512,9 @@ public class NamesService { // initiate holder of system and device structure content, for performance reasons // note false to not include deleted entries - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories, false); + HolderStructures holderStructures = new HolderStructures(holderIRepositories, false); - ValidateNameElementUtil.validateNameDataCreate(name, namingConvention, holderRepositories, holderStructure); + ValidateNameElementUtil.validateNameDataCreate(name, namingConvention, holderRepositories, holderStructures); return Boolean.TRUE; } @@ -522,9 +522,9 @@ public class NamesService { // ---------------------------------------------------------------------------------------------------- public void validateNamesCreate(NameElementCommand nameElement) { - validateNamesCreate(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateNamesCreate(nameElement, new HolderStructures(holderIRepositories)); } - public void validateNamesCreate(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { + public void validateNamesCreate(NameElementCommand nameElement, HolderStructures holderStructures) { // validate name element // input // input itself @@ -536,21 +536,21 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputCreate(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataCreate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); + ValidateNameElementUtil.validateNameElementDataCreate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructures); } public void validateNamesCreate(List<NameElementCommand> nameElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesCreate(nameElement, holderStructure); + validateNamesCreate(nameElement, holderStructures); } } public void validateNamesUpdate(NameElementCommand nameElement) { - validateNamesUpdate(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateNamesUpdate(nameElement, new HolderStructures(holderIRepositories)); } - public void validateNamesUpdate(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { + public void validateNamesUpdate(NameElementCommand nameElement, HolderStructures holderStructures) { // validate name element // input // input itself @@ -562,21 +562,21 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputUpdate(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataUpdate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); + ValidateNameElementUtil.validateNameElementDataUpdate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructures); } public void validateNamesUpdate(List<NameElementCommand> nameElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesUpdate(nameElement, holderStructure); + validateNamesUpdate(nameElement, holderStructures); } } public void validateNamesDelete(NameElementCommand nameElement) { - validateNamesDelete(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateNamesDelete(nameElement, new HolderStructures(holderIRepositories)); } - public void validateNamesDelete(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { + public void validateNamesDelete(NameElementCommand nameElement, HolderStructures holderStructures) { // validate name element // input // input itself @@ -588,14 +588,14 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputDelete(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataDelete(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); + ValidateNameElementUtil.validateNameElementDataDelete(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructures); } public void validateNamesDelete(List<NameElementCommand> nameElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesDelete(nameElement, holderStructure); + validateNamesDelete(nameElement, holderStructures); } } @@ -619,7 +619,7 @@ public class NamesService { // uuid, parentSystemStructure, parentDeviceStructure, index, description, comment // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); final List<NameElement> updatedNameElements = Lists.newArrayList(); @@ -641,7 +641,7 @@ public class NamesService { // skip if name element has same content as name // proceed without fail - if (NameElementUtil.hasSameContent(nameElementCommand, name, holderIRepositories, holderStructure)) { + if (NameElementUtil.hasSameContent(nameElementCommand, name, holderIRepositories, holderStructures)) { continue; } @@ -661,11 +661,11 @@ public class NamesService { String derivedName = null; if (systemGroup != null) { - derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructures); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, index, holderStructure); + derivedName = NameUtil.getName(system, deviceType, index, holderStructures); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructures); } // create diff --git a/src/main/java/org/openepics/names/service/StructuresService.java b/src/main/java/org/openepics/names/service/StructuresService.java index 21b183505a25aab52dac946e9dd494c7ee18672c..ce683068b7bfce838736a155ad171c3bb81876d5 100644 --- a/src/main/java/org/openepics/names/service/StructuresService.java +++ b/src/main/java/org/openepics/names/service/StructuresService.java @@ -54,7 +54,7 @@ import org.openepics.names.rest.beans.response.ResponsePageStructureElements; import org.openepics.names.util.EssNamingConvention; import org.openepics.names.util.HolderIRepositories; import org.openepics.names.util.HolderRepositories; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -167,7 +167,7 @@ public class StructuresService { // return structure elements for created structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -177,17 +177,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = systemGroupService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = systemService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = subsystemService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = disciplineService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = deviceGroupService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.createStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = deviceTypeService.createStructure(structureElement, when, username, namingConvention, holderStructures); } else { continue; } @@ -259,7 +259,7 @@ public class StructuresService { } // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); // one structure entry will give one or two structure elements // depends on history or not - history may give one or two elements, if not history then one element @@ -288,7 +288,7 @@ public class StructuresService { systemGroups = holderRepositories.systemGroupRepository().readSystemGroups(statuses, deleted, uuid, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.systemGroupRepository().countSystemGroups(statuses, deleted, uuid, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForSystemGroups(systemGroups, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSystemGroups(systemGroups, holderStructures, structureChoice)); } else if (Type.SYSTEM.equals(type)) { List<System> systems = null; if (Boolean.TRUE.equals(includeHistory)) { @@ -298,7 +298,7 @@ public class StructuresService { systems = holderRepositories.systemRepository().readSystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.systemRepository().countSystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForSystems(systems, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSystems(systems, holderStructures, structureChoice)); } else if (Type.SUBSYSTEM.equals(type)) { List<Subsystem> subsystems = null; if (Boolean.TRUE.equals(includeHistory)) { @@ -308,7 +308,7 @@ public class StructuresService { subsystems = holderRepositories.subsystemRepository().readSubsystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.subsystemRepository().countSubsystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForSubsystems(subsystems, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSubsystems(subsystems, holderStructures, structureChoice)); } else if (Type.DISCIPLINE.equals(type)) { List<Discipline> disciplines = null; if (Boolean.TRUE.equals(includeHistory)) { @@ -318,7 +318,7 @@ public class StructuresService { disciplines = holderRepositories.disciplineRepository().readDisciplines(statuses, deleted, uuid, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.disciplineRepository().countDisciplines(statuses, deleted, uuid, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForDisciplines(disciplines, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDisciplines(disciplines, holderStructures, structureChoice)); } else if (Type.DEVICEGROUP.equals(type)) { List<DeviceGroup> deviceGroups = null; if (Boolean.TRUE.equals(includeHistory)) { @@ -328,7 +328,7 @@ public class StructuresService { deviceGroups = holderRepositories.deviceGroupRepository().readDeviceGroups(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.deviceGroupRepository().countDeviceGroups(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceGroups(deviceGroups, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceGroups(deviceGroups, holderStructures, structureChoice)); } else if (Type.DEVICETYPE.equals(type)) { List<DeviceType> deviceTypes = null; if (Boolean.TRUE.equals(includeHistory)) { @@ -338,7 +338,7 @@ public class StructuresService { deviceTypes = holderRepositories.deviceTypeRepository().readDeviceTypes(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory, orderBy, isAsc, offset, limit); totalCount = holderRepositories.deviceTypeRepository().countDeviceTypes(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, who, includeHistory); } - structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceTypes(deviceTypes, holderStructure, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceTypes(deviceTypes, holderStructures, structureChoice)); } // pagination for history @@ -655,9 +655,9 @@ public class StructuresService { // initiate holder of system and device structure content, for performance reasons // note false to not include deleted entries - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories, false); + HolderStructures holderStructures = new HolderStructures(holderIRepositories, false); - ValidateStructureElementUtil.validateStructureDataCreate(type, mnemonicPath, namingConvention, holderIRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureDataCreate(type, mnemonicPath, namingConvention, holderIRepositories, holderStructures); return Boolean.TRUE; } @@ -665,9 +665,9 @@ public class StructuresService { // ---------------------------------------------------------------------------------------------------- public void validateStructuresCreate(StructureElementCommand structureElement) { - validateStructuresCreate(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresCreate(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresCreate(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresCreate(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -680,21 +680,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputCreate(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataCreate(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataCreate(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresCreate(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresCreate(structureElement, holderStructure); + validateStructuresCreate(structureElement, holderStructures); } } public void validateStructuresUpdate(StructureElementCommand structureElement) { - validateStructuresUpdate(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresUpdate(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresUpdate(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresUpdate(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -707,21 +707,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputUpdate(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataUpdate(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataUpdate(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresUpdate(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresUpdate(structureElement, holderStructure); + validateStructuresUpdate(structureElement, holderStructures); } } public void validateStructuresDelete(StructureElementCommand structureElement) { - validateStructuresDelete(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresDelete(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresDelete(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresDelete(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -734,21 +734,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputDelete(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataDelete(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataDelete(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresDelete(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresDelete(structureElement, holderStructure); + validateStructuresDelete(structureElement, holderStructures); } } public void validateStructuresApprove(StructureElementCommand structureElement) { - validateStructuresApprove(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresApprove(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresApprove(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresApprove(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -761,21 +761,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputApprove(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataApprove(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataApprove(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresApprove(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresApprove(structureElement, holderStructure); + validateStructuresApprove(structureElement, holderStructures); } } public void validateStructuresCancel(StructureElementCommand structureElement) { - validateStructuresCancel(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresCancel(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresCancel(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresCancel(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -788,21 +788,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputCancel(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataCancel(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataCancel(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresCancel(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresCancel(structureElement, holderStructure); + validateStructuresCancel(structureElement, holderStructures); } } public void validateStructuresReject(StructureElementCommand structureElement) { - validateStructuresReject(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); + validateStructuresReject(structureElement, new HolderStructures(holderIRepositories)); } - public void validateStructuresReject(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { + public void validateStructuresReject(StructureElementCommand structureElement, HolderStructures holderStructures) { // validate structure element // input // type @@ -815,14 +815,14 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputReject(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataReject(structureElement, namingConvention, holderRepositories, holderStructure); + ValidateStructureElementUtil.validateStructureElementDataReject(structureElement, namingConvention, holderRepositories, holderStructures); } public void validateStructuresReject(List<StructureElementCommand> structureElements) { // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresReject(structureElement, holderStructure); + validateStructuresReject(structureElement, holderStructures); } } @@ -841,7 +841,7 @@ public class StructuresService { // return structure elements for updated structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -851,17 +851,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = systemGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = systemService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = subsystemService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = disciplineService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = deviceGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.updateStructure(structureElement, when, username, namingConvention, holderStructure); + structureElementNotification = deviceTypeService.updateStructure(structureElement, when, username, namingConvention, holderStructures); } else { continue; } @@ -904,7 +904,7 @@ public class StructuresService { // return structure elements for deleted structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -914,17 +914,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemGroupService.deleteStructure(structureElement, when, username, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemService.deleteStructure(structureElement, when, username, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = subsystemService.deleteStructure(structureElement, when, username, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = disciplineService.deleteStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceGroupService.deleteStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.deleteStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceTypeService.deleteStructure(structureElement, when, username, holderStructures); } else { continue; } @@ -967,7 +967,7 @@ public class StructuresService { // return structure elements for approved structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); // approve // set not latest for current latest @@ -984,17 +984,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemGroupService.approveStructure(structureElement, when, username, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemService.approveStructure(structureElement, when, username, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = subsystemService.approveStructure(structureElement, when, username, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = disciplineService.approveStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceGroupService.approveStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.approveStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceTypeService.approveStructure(structureElement, when, username, holderStructures); } else { continue; } @@ -1035,7 +1035,7 @@ public class StructuresService { // return structure elements for cancelled structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -1045,17 +1045,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemGroupService.cancelStructure(structureElement, when, username, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemService.cancelStructure(structureElement, when, username, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = subsystemService.cancelStructure(structureElement, when, username, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = disciplineService.cancelStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceGroupService.cancelStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.cancelStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceTypeService.cancelStructure(structureElement, when, username, holderStructures); } else { continue; } @@ -1096,7 +1096,7 @@ public class StructuresService { // return structure elements for rejected structures // initiate holder of system and device structure content, for performance reasons - HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); + HolderStructures holderStructures = new HolderStructures(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -1106,17 +1106,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemGroupService.rejectStructure(structureElement, when, username, holderStructures); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = systemService.rejectStructure(structureElement, when, username, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = subsystemService.rejectStructure(structureElement, when, username, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = disciplineService.rejectStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceGroupService.rejectStructure(structureElement, when, username, holderStructures); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.rejectStructure(structureElement, when, username, holderStructure); + structureElementNotification = deviceTypeService.rejectStructure(structureElement, when, username, holderStructures); } else { continue; } diff --git a/src/main/java/org/openepics/names/service/SubsystemService.java b/src/main/java/org/openepics/names/service/SubsystemService.java index dfef5ee69f6daa1231aa5b21bbbc0621ecc093c0..977348739e6b67b616a91629b6548593bec1fbf7 100644 --- a/src/main/java/org/openepics/names/service/SubsystemService.java +++ b/src/main/java/org/openepics/names/service/SubsystemService.java @@ -34,7 +34,7 @@ import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.NameElementCommand; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -77,7 +77,7 @@ public class SubsystemService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -107,11 +107,11 @@ public class SubsystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(subsystem), - NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.CREATE, null, null, subsystem, holderStructure)); + NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.CREATE, null, null, subsystem, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -146,11 +146,11 @@ public class SubsystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(subsystem), NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -180,11 +180,11 @@ public class SubsystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(subsystem), - NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.DELETE, null, null, subsystem, holderStructure)); + NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.DELETE, null, null, subsystem, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -248,10 +248,10 @@ public class SubsystemService { // additional if (StructureCommand.CREATE.equals(structureCommandCUD)) { boolean hasMnemonic = !StringUtils.isEmpty(subsystem.getMnemonic()); - boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(subsystem, holderStructure)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(subsystem, holderStructures)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, subsystem.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holderStructure); + namesService.createName(nameElement, when, username, holderStructures); } } else if (StructureCommand.UPDATE.equals(structureCommandCUD)) { namesService.updateNames(previous, subsystem, username); @@ -262,12 +262,12 @@ public class SubsystemService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, subsystem, holderStructure)); + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, subsystem, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -302,13 +302,13 @@ public class SubsystemService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -343,9 +343,9 @@ public class SubsystemService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/SystemGroupService.java b/src/main/java/org/openepics/names/service/SystemGroupService.java index 046c6720d1fd5ca285c41c29e5fb002f5f935fdc..c742fcfd772dbd82e424125e03afea947873a2c0 100644 --- a/src/main/java/org/openepics/names/service/SystemGroupService.java +++ b/src/main/java/org/openepics/names/service/SystemGroupService.java @@ -36,7 +36,7 @@ import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.NameElementCommand; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -87,7 +87,7 @@ public class SystemGroupService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -117,11 +117,11 @@ public class SystemGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(systemGroup), - NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.CREATE, null, null, systemGroup, holderStructure)); + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.CREATE, null, null, systemGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -156,11 +156,11 @@ public class SystemGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(systemGroup), NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -190,11 +190,11 @@ public class SystemGroupService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(systemGroup), - NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.DELETE, null, null, systemGroup, holderStructure)); + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.DELETE, null, null, systemGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -258,10 +258,10 @@ public class SystemGroupService { // additional if (StructureCommand.CREATE.equals(structureCommandCUD)) { boolean hasMnemonic = !StringUtils.isEmpty(systemGroup.getMnemonic()); - boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(systemGroup, holderStructure)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(systemGroup, holderStructures)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, systemGroup.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holderStructure); + namesService.createName(nameElement, when, username, holderStructures); } } else if (StructureCommand.UPDATE.equals(structureCommandCUD)) { namesService.updateNames(previous, systemGroup, username); @@ -274,22 +274,22 @@ public class SystemGroupService { commands.add(new StructureElementCommand(system.getUuid(), Type.SYSTEM, null, null, null, null, StructuresService.DELETE_AFTER_APPROVE_STRUCTURE_CHANGE)); } for (StructureElementCommand command : commands) { - systemService.deleteStructure(command, when, username, holderStructure); + systemService.deleteStructure(command, when, username, holderStructures); } for (StructureElementCommand command : commands) { - systemService.approveStructure(command, when, username, holderStructure); + systemService.approveStructure(command, when, username, holderStructures); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, systemGroup, holderStructure)); + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, systemGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -324,13 +324,13 @@ public class SystemGroupService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -365,9 +365,9 @@ public class SystemGroupService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/service/SystemService.java b/src/main/java/org/openepics/names/service/SystemService.java index 6f5e06d4344d89bd996d56634cd78055022fb9f9..043efafbbed098846c98f64946c32c7fb06a3dd5 100644 --- a/src/main/java/org/openepics/names/service/SystemService.java +++ b/src/main/java/org/openepics/names/service/SystemService.java @@ -36,7 +36,7 @@ import org.openepics.names.rest.beans.Type; import org.openepics.names.rest.beans.element.NameElementCommand; import org.openepics.names.rest.beans.element.StructureElementCommand; import org.openepics.names.util.EssNamingConvention; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.StructureChoice; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureElementUtil; @@ -87,7 +87,7 @@ public class SystemService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -117,11 +117,11 @@ public class SystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(system), - NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.CREATE, null, null, system, holderStructure)); + NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.CREATE, null, null, system, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -156,11 +156,11 @@ public class SystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(system), NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.UPDATE, null, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -190,11 +190,11 @@ public class SystemService { return new StructureElementNotification( StructureElementUtil.getStructureElementRequested(system), - NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.DELETE, null, null, system, holderStructure)); + NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.DELETE, null, null, system, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -258,10 +258,10 @@ public class SystemService { // additional if (StructureCommand.CREATE.equals(structureCommandCUD)) { boolean hasMnemonic = !StringUtils.isEmpty(system.getMnemonic()); - boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(system, holderStructure)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(system, holderStructures)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, system.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holderStructure); + namesService.createName(nameElement, when, username, holderStructures); } } else if (StructureCommand.UPDATE.equals(structureCommandCUD)) { namesService.updateNames(previous, system, username); @@ -274,22 +274,22 @@ public class SystemService { commands.add(new StructureElementCommand(subsystem.getUuid(), Type.SUBSYSTEM, null, null, null, null, StructuresService.DELETE_AFTER_APPROVE_STRUCTURE_CHANGE)); } for (StructureElementCommand command : commands) { - subsystemService.deleteStructure(command, when, username, holderStructure); + subsystemService.deleteStructure(command, when, username, holderStructures); } for (StructureElementCommand command : commands) { - subsystemService.approveStructure(command, when, username, holderStructure); + subsystemService.approveStructure(command, when, username, holderStructures); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, system, holderStructure)); + StructureElementUtil.getStructureElementProcessed(system, holderStructures, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, system, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -324,13 +324,13 @@ public class SystemService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.CANCEL_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(system, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructures)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderStructures holderStructures) { // validation outside method // transaction // support a current transaction, throw an exception if none exists @@ -365,9 +365,9 @@ public class SystemService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.REJECT_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(system, holderStructures, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructures)); } } diff --git a/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java b/src/main/java/org/openepics/names/util/HolderStructures.java similarity index 97% rename from src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java rename to src/main/java/org/openepics/names/util/HolderStructures.java index 2be8214287faca2ad3f35e807e8d7a198056fc6c..087125c343f716d021aafb1640e7991a970edc62 100644 --- a/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java +++ b/src/main/java/org/openepics/names/util/HolderStructures.java @@ -38,7 +38,7 @@ import org.openepics.names.repository.model.SystemGroup; * * @author Lars Johansson */ -public class HolderSystemDeviceStructure { +public class HolderStructures { private HashMap<UUID, SystemGroup> systemGroups; private HashMap<UUID, System> systems; @@ -55,7 +55,7 @@ public class HolderSystemDeviceStructure { * * @param holderIRepositories */ - public HolderSystemDeviceStructure (HolderIRepositories holderIRepositories) { + public HolderStructures (HolderIRepositories holderIRepositories) { this(holderIRepositories, true); } @@ -65,7 +65,7 @@ public class HolderSystemDeviceStructure { * @param holderIRepositories holder of references to repositories * @param includeDeleted include deleted structure entries */ - public HolderSystemDeviceStructure (HolderIRepositories holderIRepositories, boolean includeDeleted) { + public HolderStructures (HolderIRepositories holderIRepositories, boolean includeDeleted) { List<SystemGroup> systemGroupsRead = null; List<System> systemsRead = null; List<Subsystem> subsystemsRead = null; diff --git a/src/main/java/org/openepics/names/util/NameElementUtil.java b/src/main/java/org/openepics/names/util/NameElementUtil.java index d625fef5de0b24712a40c2edc15b8ad61ce69985..502f6b9913f4e746125e06bfb45a69cb741f8fc4 100644 --- a/src/main/java/org/openepics/names/util/NameElementUtil.java +++ b/src/main/java/org/openepics/names/util/NameElementUtil.java @@ -142,10 +142,10 @@ public class NameElementUtil { * @param nameElement name element * @param name name * @param holderIRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return true if name element and name have same content, false otherwise */ - public static boolean hasSameContent(NameElementCommand nameElement, Name name, HolderIRepositories holderIRepositories, HolderSystemDeviceStructure holderStructure) { + public static boolean hasSameContent(NameElementCommand nameElement, Name name, HolderIRepositories holderIRepositories, HolderStructures holderStructures) { // NameElement // x parentSystemStructure (system group, system, subsystem) // x parentDeviceStructure (device type) @@ -179,11 +179,11 @@ public class NameElementUtil { String derivedName = null; if (systemGroup != null) { - derivedName = NameUtil.getName(systemGroup, deviceType, nameElement.getIndex(), holderStructure); + derivedName = NameUtil.getName(systemGroup, deviceType, nameElement.getIndex(), holderStructures); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, nameElement.getIndex(), holderStructure); + derivedName = NameUtil.getName(system, deviceType, nameElement.getIndex(), holderStructures); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, nameElement.getIndex(), holderStructure); + derivedName = NameUtil.getName(subsystem, deviceType, nameElement.getIndex(), holderStructures); } else { return false; } diff --git a/src/main/java/org/openepics/names/util/NameUtil.java b/src/main/java/org/openepics/names/util/NameUtil.java index 7f5c09a19c4497353fee1eb60b86160b45d96329..d519389034ad1071cf875c63a7228e54b1612cb6 100644 --- a/src/main/java/org/openepics/names/util/NameUtil.java +++ b/src/main/java/org/openepics/names/util/NameUtil.java @@ -99,9 +99,9 @@ public class NameUtil { : -1; } - public static String getName(SystemGroup systemGroup, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { - String systemStructure = StructureUtil.getMnemonicPath(systemGroup, holderStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); + public static String getName(SystemGroup systemGroup, DeviceType deviceType, String index, HolderStructures holderStructures) { + String systemStructure = StructureUtil.getMnemonicPath(systemGroup, holderStructures); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructures); return !StringUtils.isEmpty(systemStructure) ? !StringUtils.isEmpty(deviceStructure) && !StringUtils.isEmpty(index) @@ -110,9 +110,9 @@ public class NameUtil { : null; } - public static String getName(System system, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { - String systemStructure = StructureUtil.getMnemonicPath(system, holderStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); + public static String getName(System system, DeviceType deviceType, String index, HolderStructures holderStructures) { + String systemStructure = StructureUtil.getMnemonicPath(system, holderStructures); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructures); return !StringUtils.isEmpty(systemStructure) ? !StringUtils.isEmpty(deviceStructure) && !StringUtils.isEmpty(index) @@ -121,9 +121,9 @@ public class NameUtil { : null; } - public static String getName(Subsystem subsystem, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { - String systemStructure = StructureUtil.getMnemonicPath(subsystem, holderStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); + public static String getName(Subsystem subsystem, DeviceType deviceType, String index, HolderStructures holderStructures) { + String systemStructure = StructureUtil.getMnemonicPath(subsystem, holderStructures); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructures); return !StringUtils.isEmpty(systemStructure) ? !StringUtils.isEmpty(deviceStructure) && !StringUtils.isEmpty(index) diff --git a/src/main/java/org/openepics/names/util/StructureElementUtil.java b/src/main/java/org/openepics/names/util/StructureElementUtil.java index e040e5fdd4033c541117717d879cdc9d43b9284b..48a0f708a77283a3e42bbd47864c8b238c5f8ca5 100644 --- a/src/main/java/org/openepics/names/util/StructureElementUtil.java +++ b/src/main/java/org/openepics/names/util/StructureElementUtil.java @@ -58,14 +58,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for system groups. * * @param systemGroups system groups - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForSystemGroups(List<SystemGroup> systemGroups, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSystemGroups(List<SystemGroup> systemGroups, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (SystemGroup systemGroup : systemGroups) { // one or two return elements for history @@ -75,7 +75,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (systemGroup.getProcessed() != null) { structureElements.add(getStructureElementRequested(systemGroup)); - structureElements.add(getStructureElementProcessed(systemGroup, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(systemGroup, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(systemGroup)); } @@ -83,7 +83,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(systemGroup.getStatus())) { structureElements.add(getStructureElementRequested(systemGroup)); } else { - structureElements.add(getStructureElementProcessed(systemGroup, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(systemGroup, holderStructures, structureChoice)); } } } @@ -93,14 +93,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for systems. * * @param systems systems - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForSystems(List<System> systems, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSystems(List<System> systems, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (System system : systems) { // one or two return elements for history @@ -110,7 +110,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (system.getProcessed() != null) { structureElements.add(getStructureElementRequested(system)); - structureElements.add(getStructureElementProcessed(system, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(system, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(system)); } @@ -118,7 +118,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(system.getStatus())) { structureElements.add(getStructureElementRequested(system)); } else { - structureElements.add(getStructureElementProcessed(system, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(system, holderStructures, structureChoice)); } } } @@ -128,14 +128,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for subsystems. * * @param subsystems subsystems - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForSubsystems(List<Subsystem> subsystems, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSubsystems(List<Subsystem> subsystems, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (Subsystem subsystem : subsystems) { // one or two return elements for history @@ -145,7 +145,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (subsystem.getProcessed() != null) { structureElements.add(getStructureElementRequested(subsystem)); - structureElements.add(getStructureElementProcessed(subsystem, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(subsystem, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(subsystem)); } @@ -153,7 +153,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(subsystem.getStatus())) { structureElements.add(getStructureElementRequested(subsystem)); } else { - structureElements.add(getStructureElementProcessed(subsystem, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(subsystem, holderStructures, structureChoice)); } } } @@ -164,14 +164,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for disciplines. * * @param disciplines disciplines - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForDisciplines(List<Discipline> disciplines, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDisciplines(List<Discipline> disciplines, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (Discipline discipline : disciplines) { // one or two return elements for history @@ -181,7 +181,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (discipline.getProcessed() != null) { structureElements.add(getStructureElementRequested(discipline)); - structureElements.add(getStructureElementProcessed(discipline, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(discipline, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(discipline)); } @@ -189,7 +189,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(discipline.getStatus())) { structureElements.add(getStructureElementRequested(discipline)); } else { - structureElements.add(getStructureElementProcessed(discipline, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(discipline, holderStructures, structureChoice)); } } } @@ -199,14 +199,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for device groups. * * @param deviceGroups device groups - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForDeviceGroups(List<DeviceGroup> deviceGroups, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDeviceGroups(List<DeviceGroup> deviceGroups, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (DeviceGroup deviceGroup : deviceGroups) { // one or two return elements for history @@ -216,7 +216,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (deviceGroup.getProcessed() != null) { structureElements.add(getStructureElementRequested(deviceGroup)); - structureElements.add(getStructureElementProcessed(deviceGroup, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceGroup, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(deviceGroup)); } @@ -224,7 +224,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(deviceGroup.getStatus())) { structureElements.add(getStructureElementRequested(deviceGroup)); } else { - structureElements.add(getStructureElementProcessed(deviceGroup, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceGroup, holderStructures, structureChoice)); } } } @@ -234,14 +234,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for device types. * * @param deviceTypes device types - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective. * Structure perspective gives one StructureElement object (processed). * History perspective gives one or two StructureElement objects (requested, processed). * If choice not given then default as structure perspective (processed). * @return list of structure elements */ - public static List<StructureElement> getStructureElementsForDeviceTypes(List<DeviceType> deviceTypes, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDeviceTypes(List<DeviceType> deviceTypes, HolderStructures holderStructures, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (DeviceType deviceType : deviceTypes) { // one or two return elements for history @@ -251,7 +251,7 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (deviceType.getProcessed() != null) { structureElements.add(getStructureElementRequested(deviceType)); - structureElements.add(getStructureElementProcessed(deviceType, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceType, holderStructures, structureChoice)); } else { structureElements.add(getStructureElementRequested(deviceType)); } @@ -259,7 +259,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(deviceType.getStatus())) { structureElements.add(getStructureElementRequested(deviceType)); } else { - structureElements.add(getStructureElementProcessed(deviceType, holderStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceType, holderStructures, structureChoice)); } } } @@ -295,11 +295,11 @@ public class StructureElementUtil { * Populate and return structure element for system group with focus on processed. * * @param systemGroup system group - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(SystemGroup systemGroup, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(SystemGroup systemGroup, HolderStructures holderStructures, StructureChoice structureChoice) { if (systemGroup == null) { return null; } @@ -310,7 +310,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(systemGroup.isLatest() && Status.APPROVED.equals(systemGroup.getStatus())) ? null - : StructureUtil.getMnemonicPath(systemGroup, holderStructure); + : StructureUtil.getMnemonicPath(systemGroup, holderStructures); return getStructureElement( systemGroup.getUuid(), @@ -349,11 +349,11 @@ public class StructureElementUtil { * Populate and return structure element for system with focus on processed. * * @param system system - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(System system, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(System system, HolderStructures holderStructures, StructureChoice structureChoice) { if (system == null) { return null; } @@ -364,7 +364,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(system.isLatest() && Status.APPROVED.equals(system.getStatus())) ? null - : StructureUtil.getMnemonicPath(system, holderStructure); + : StructureUtil.getMnemonicPath(system, holderStructures); return getStructureElement( system.getUuid(), @@ -403,11 +403,11 @@ public class StructureElementUtil { * Populate and return structure element for subsystem with focus on processed. * * @param subsystem subsystem - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(Subsystem subsystem, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(Subsystem subsystem, HolderStructures holderStructures, StructureChoice structureChoice) { if (subsystem == null) { return null; } @@ -418,7 +418,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(subsystem.isLatest() && Status.APPROVED.equals(subsystem.getStatus())) ? null - : StructureUtil.getMnemonicPath(subsystem, holderStructure); + : StructureUtil.getMnemonicPath(subsystem, holderStructures); return getStructureElement( subsystem.getUuid(), @@ -458,11 +458,11 @@ public class StructureElementUtil { * Populate and return structure element for discipline with focus on processed. * * @param discipline discipline - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(Discipline discipline, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(Discipline discipline, HolderStructures holderStructures, StructureChoice structureChoice) { if (discipline == null) { return null; } @@ -473,7 +473,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(discipline.isLatest() && Status.APPROVED.equals(discipline.getStatus())) ? null - : StructureUtil.getMnemonicPath(discipline, holderStructure); + : StructureUtil.getMnemonicPath(discipline, holderStructures); return getStructureElement( discipline.getUuid(), @@ -512,11 +512,11 @@ public class StructureElementUtil { * Populate and return structure element for device group with focus on processed. * * @param deviceGroup device group - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(DeviceGroup deviceGroup, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(DeviceGroup deviceGroup, HolderStructures holderStructures, StructureChoice structureChoice) { if (deviceGroup == null) { return null; } @@ -527,7 +527,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(deviceGroup.isLatest() && Status.APPROVED.equals(deviceGroup.getStatus())) ? null - : StructureUtil.getMnemonicPath(deviceGroup, holderStructure); + : StructureUtil.getMnemonicPath(deviceGroup, holderStructures); return getStructureElement( deviceGroup.getUuid(), @@ -566,11 +566,11 @@ public class StructureElementUtil { * Populate and return structure element for device type with focus on processed. * * @param deviceType device type - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureChoice whether to consider content from structure perspective or history perspective * @return structure element */ - public static StructureElement getStructureElementProcessed(DeviceType deviceType, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(DeviceType deviceType, HolderStructures holderStructures, StructureChoice structureChoice) { if (deviceType == null) { return null; } @@ -581,7 +581,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(deviceType.isLatest() && Status.APPROVED.equals(deviceType.getStatus())) ? null - : StructureUtil.getMnemonicPath(deviceType, holderStructure); + : StructureUtil.getMnemonicPath(deviceType, holderStructures); return getStructureElement( deviceType.getUuid(), diff --git a/src/main/java/org/openepics/names/util/StructureUtil.java b/src/main/java/org/openepics/names/util/StructureUtil.java index a87569e965e5d6d4667bc0ade6efe827df7229f3..ca9848c0f83adbf12566f9a4b011695985783b78 100644 --- a/src/main/java/org/openepics/names/util/StructureUtil.java +++ b/src/main/java/org/openepics/names/util/StructureUtil.java @@ -52,11 +52,11 @@ public class StructureUtil { * Return mnemonic path for system group. * * @param systemGroup system group - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(SystemGroup systemGroup, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(systemGroup, holderStructure)) { + public static String getMnemonicPath(SystemGroup systemGroup, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(systemGroup, holderStructures)) { return null; } @@ -69,11 +69,11 @@ public class StructureUtil { * Return mnemonic path for system. * * @param system system - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(System system, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(system, holderStructure)) { + public static String getMnemonicPath(System system, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(system, holderStructures)) { return null; } @@ -84,15 +84,15 @@ public class StructureUtil { * Return mnemonic path for subsystem. * * @param subsystem subsystem - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(Subsystem subsystem, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(subsystem, holderStructure)) { + public static String getMnemonicPath(Subsystem subsystem, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(subsystem, holderStructures)) { return null; } - System system = holderStructure.findSystemByUuid(subsystem.getParentUuid()); + System system = holderStructures.findSystemByUuid(subsystem.getParentUuid()); return system != null ? system.getMnemonic() + "-" + subsystem.getMnemonic() : null; @@ -102,11 +102,11 @@ public class StructureUtil { * Return mnemonic path for discipline. * * @param discipline discipline - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(Discipline discipline, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(discipline, holderStructure)) { + public static String getMnemonicPath(Discipline discipline, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(discipline, holderStructures)) { return null; } @@ -117,15 +117,15 @@ public class StructureUtil { * Return mnemonic path for device group. * * @param deviceGroup device group - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(DeviceGroup deviceGroup, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(deviceGroup, holderStructure)) { + public static String getMnemonicPath(DeviceGroup deviceGroup, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(deviceGroup, holderStructures)) { return null; } - Discipline discipline = holderStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); + Discipline discipline = holderStructures.findDisciplineByUuid(deviceGroup.getParentUuid()); return discipline != null ? discipline.getMnemonic() : null; @@ -135,17 +135,17 @@ public class StructureUtil { * Return mnemonic path for device type. * * @param deviceType device type - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(DeviceType deviceType, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(deviceType, holderStructure)) { + public static String getMnemonicPath(DeviceType deviceType, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(deviceType, holderStructures)) { return null; } - DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); + DeviceGroup deviceGroup = holderStructures.findDeviceGroupByUuid(deviceType.getParentUuid()); Discipline discipline = deviceGroup != null - ? holderStructure.findDisciplineByUuid(deviceGroup.getParentUuid()) + ? holderStructures.findDisciplineByUuid(deviceGroup.getParentUuid()) : null; return discipline != null && deviceGroup != null ? discipline.getMnemonic() + "-" + deviceType.getMnemonic() @@ -157,15 +157,15 @@ public class StructureUtil { /** * Return a list of mnemonic paths for system groups. * - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param mnemonicEquivalence use mnemonic equivalence instead of mnemonic * @param namingConvention naming convention * @return a list of mnemonic paths for system groups */ - public static List<String> getMnemonicPathsSystemGroup(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSystemGroup(HolderStructures holderStructures, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, SystemGroup> entry : holderStructure.getUuidSystemGroups().entrySet()) { + for (Entry<UUID, SystemGroup> entry : holderStructures.getUuidSystemGroups().entrySet()) { if (!StringUtils.isEmpty(entry.getValue().getMnemonic())) { value = entry.getValue().getMnemonic(); } @@ -182,15 +182,15 @@ public class StructureUtil { /** * Return a list of mnemonic paths for systems. * - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param mnemonicEquivalence use mnemonic equivalence instead of mnemonic * @param namingConvention naming convention * @return a list of mnemonic paths for systems */ - public static List<String> getMnemonicPathsSystem(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSystem(HolderStructures holderStructures, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, System> entry : holderStructure.getUuidSystems().entrySet()) { + for (Entry<UUID, System> entry : holderStructures.getUuidSystems().entrySet()) { value = entry.getValue().getMnemonic(); if (mnemonicEquivalence) { @@ -205,16 +205,16 @@ public class StructureUtil { /** * Return a list of mnemonic paths for subsystems. * - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param mnemonicEquivalence use mnemonic equivalence instead of mnemonic * @param namingConvention naming convention * @return a list of mnemonic paths for subsystems */ - public static List<String> getMnemonicPathsSubsystem(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSubsystem(HolderStructures holderStructures, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, Subsystem> entry : holderStructure.getUuidSubsystems().entrySet()) { - System system = holderStructure.findSystemByUuid(entry.getValue().getParentUuid()); + for (Entry<UUID, Subsystem> entry : holderStructures.getUuidSubsystems().entrySet()) { + System system = holderStructures.findSystemByUuid(entry.getValue().getParentUuid()); value = system.getMnemonic() + "-" + entry.getValue().getMnemonic(); if (mnemonicEquivalence) { @@ -229,15 +229,15 @@ public class StructureUtil { /** * Return a list of mnemonic paths for disciplines. * - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param mnemonicEquivalence use mnemonic equivalence instead of mnemonic * @param namingConvention naming convention * @return a list of mnemonic paths for disciplines */ - public static List<String> getMnemonicPathsDiscipline(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsDiscipline(HolderStructures holderStructures, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, Discipline> entry : holderStructure.getUuidDisciplines().entrySet()) { + for (Entry<UUID, Discipline> entry : holderStructures.getUuidDisciplines().entrySet()) { if (!StringUtils.isEmpty(entry.getValue().getMnemonic())) { value = entry.getValue().getMnemonic(); } @@ -254,17 +254,17 @@ public class StructureUtil { /** * Return a list of mnemonic paths for device types. * - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param mnemonicEquivalence use mnemonic equivalence instead of mnemonic * @param namingConvention naming convention * @return a list of mnemonic paths for device types */ - public static List<String> getMnemonicPathsDeviceType(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsDeviceType(HolderStructures holderStructures, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, DeviceType> entry : holderStructure.getUuidDeviceTypes().entrySet()) { - DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(entry.getValue().getParentUuid()); - Discipline discipline = holderStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); + for (Entry<UUID, DeviceType> entry : holderStructures.getUuidDeviceTypes().entrySet()) { + DeviceGroup deviceGroup = holderStructures.findDeviceGroupByUuid(entry.getValue().getParentUuid()); + Discipline discipline = holderStructures.findDisciplineByUuid(deviceGroup.getParentUuid()); value = discipline.getMnemonic() + "-" + entry.getValue().getMnemonic(); if (mnemonicEquivalence) { diff --git a/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java b/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java index 0135ab51515419d87b1616f145ba86415655569a..b2c12f3849748115109986de2d451fbc4db798e9 100644 --- a/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java @@ -180,10 +180,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repository - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateNameElementDataCreate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.CREATE); + public static void validateNameElementDataCreate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderStructures holderStructures) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructures, NameCommand.CREATE); } /** @@ -193,10 +193,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateNameElementDataUpdate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.UPDATE); + public static void validateNameElementDataUpdate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderStructures holderStructures) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructures, NameCommand.UPDATE); } /** @@ -206,10 +206,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateNameElementDataDelete(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.DELETE); + public static void validateNameElementDataDelete(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderStructures holderStructures) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructures, NameCommand.DELETE); } /** @@ -219,10 +219,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repository - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param nameCommand name command */ - private static void validateNameElementData(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure, NameCommand nameCommand) { + private static void validateNameElementData(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderStructures holderStructures, NameCommand nameCommand) { // command - attributes // create - parentSystemStructure, parentDeviceStructure, index, description, comment // update - uuid, parentSystemStructure, parentDeviceStructure, index, description, comment @@ -235,7 +235,7 @@ public class ValidateNameElementUtil { // ( - system structure uuid, device structure uuid ) // - system structure uuid, device structure uuid, index - if (ValidateUtil.isAnyNull(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, nameCommand)) { + if (ValidateUtil.isAnyNull(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructures, nameCommand)) { return; } @@ -302,15 +302,15 @@ public class ValidateNameElementUtil { if (systemGroup != null) { ExceptionUtil.validateConditionDataDeletedException(!systemGroup.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructures); } else if (system != null) { ExceptionUtil.validateConditionDataDeletedException(!system.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(system, deviceType, index, holderStructure); + derivedName = NameUtil.getName(system, deviceType, index, holderStructures); } else if (subsystem != null) { ExceptionUtil.validateConditionDataDeletedException(!subsystem.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructures); } else { throw ExceptionUtil.createDataNotFoundException(TextUtil.DATA_IS_NOT_FOUND, details, TextUtil.PARENTSYSTEMSTRUCTURE); } @@ -365,12 +365,12 @@ public class ValidateNameElementUtil { * @param name name * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * - * @see ValidateUtil#validateNameDataCreate(NameElement, EssNamingConvention, HolderIRepositories, NameRepository, HolderSystemDeviceStructure) + * @see ValidateUtil#validateNameDataCreate(NameElement, EssNamingConvention, HolderIRepositories, NameRepository, HolderStructures) */ - public static void validateNameDataCreate(String name, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(name, namingConvention, holderRepositories, holderStructure)) { + public static void validateNameDataCreate(String name, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(name, namingConvention, holderRepositories, holderStructures)) { return; } @@ -444,13 +444,13 @@ public class ValidateNameElementUtil { if (ValidateUtil.isSize(subsystems, 1)) { subsystem = subsystems.get(0); - derivedName = NameUtil.getName(subsystem, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); + derivedName = NameUtil.getName(subsystem, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructures); } else if (ValidateUtil.isSize(systems, 1)) { system = systems.get(0); - derivedName = NameUtil.getName(system, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); + derivedName = NameUtil.getName(system, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructures); } else if (ValidateUtil.isSize(systemGroups, 1)) { systemGroup = systemGroups.get(0); - derivedName = NameUtil.getName(systemGroup, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); + derivedName = NameUtil.getName(systemGroup, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructures); } else { throw ExceptionUtil.createDataNotFoundException(TextUtil.SYSTEM_STRUCTURE_IS_NOT_FOUND, details, field); } diff --git a/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java b/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java index 69045d6d6c5aa79c607ef65a3cfc0e9a25fbb1b6..62306f1d47d521cdb8261f09c5d3baf9862f0940 100644 --- a/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java @@ -261,11 +261,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataCreate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataCreate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.CREATE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.CREATE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.CREATE); } /** @@ -274,11 +274,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataUpdate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataUpdate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.UPDATE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.UPDATE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.UPDATE); } /** @@ -287,11 +287,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataDelete(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataDelete(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.DELETE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.DELETE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.DELETE); } /** @@ -300,11 +300,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataApprove(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataApprove(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.APPROVE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.APPROVE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.APPROVE); } /** @@ -313,11 +313,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataCancel(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataCancel(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.CANCEL); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.CANCEL); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.CANCEL); } /** @@ -326,11 +326,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureElementDataReject(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + public static void validateStructureElementDataReject(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures) { validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.REJECT); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.REJECT); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructures, StructureCommand.REJECT); } /** @@ -436,10 +436,10 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @param structureCommand structure command */ - public static void validateStructureElementDataRelativeOtherData(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure, StructureCommand structureCommand) { + public static void validateStructureElementDataRelativeOtherData(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderStructures holderStructures, StructureCommand structureCommand) { // command - attributes // create - type, parent, name, mnemonic, description, comment // update - uuid, type, parent, name, mnemonic, description, comment @@ -465,7 +465,7 @@ public class ValidateStructureElementUtil { // additional checks if names are affected // comment not same as previous comment - if (ValidateUtil.isAnyNull(structureElementCommand, namingConvention, holderRepositories, holderStructure, structureCommand)) { + if (ValidateUtil.isAnyNull(structureElementCommand, namingConvention, holderRepositories, holderStructures, structureCommand)) { return; } @@ -788,10 +788,10 @@ public class ValidateStructureElementUtil { * @param mnemonicPath mnemonic path * @param namingConvention naming convention * @param holderIRepositories holder repositories - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ - public static void validateStructureDataCreate(Type type, String mnemonicPath, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, HolderSystemDeviceStructure holderStructure) { - if (ValidateUtil.isAnyNull(type, mnemonicPath, namingConvention, holderIRepositories, holderStructure)) { + public static void validateStructureDataCreate(Type type, String mnemonicPath, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, HolderStructures holderStructures) { + if (ValidateUtil.isAnyNull(type, mnemonicPath, namingConvention, holderIRepositories, holderStructures)) { return; } @@ -828,7 +828,7 @@ public class ValidateStructureElementUtil { // check mnemonic, mnemonic equivalence // mnemonic path system group - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructure, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructures, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -836,7 +836,7 @@ public class ValidateStructureElementUtil { } // mnemonic path equivalence system group - mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructure, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructures, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -844,7 +844,7 @@ public class ValidateStructureElementUtil { } // mnemonic path - mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructure, false, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructures, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -852,7 +852,7 @@ public class ValidateStructureElementUtil { } // mnemonic path equivalence - mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructure, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructures, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -873,7 +873,7 @@ public class ValidateStructureElementUtil { type, details, field); } - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructure, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructures, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -890,7 +890,7 @@ public class ValidateStructureElementUtil { type, details, field); } - mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructure, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructures, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -930,7 +930,7 @@ public class ValidateStructureElementUtil { // mnemonic path validateStructuresMnemonicpathDuplicate(!StringUtils.equals(path[0], path[1]), type, details, field); - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructure, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructures, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -942,7 +942,7 @@ public class ValidateStructureElementUtil { !StringUtils.equals(namingConvention.equivalenceClassRepresentative(path[0]), namingConvention.equivalenceClassRepresentative(path[1])), type, details, field); - mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructure, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructures, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), diff --git a/src/main/java/org/openepics/names/util/notification/NotificationUtil.java b/src/main/java/org/openepics/names/util/notification/NotificationUtil.java index d58c03f67ef6767bbb599c8f52af36199b4fc751..adf51cceabc5048894082d0bb88d75156fae7cf9 100644 --- a/src/main/java/org/openepics/names/util/notification/NotificationUtil.java +++ b/src/main/java/org/openepics/names/util/notification/NotificationUtil.java @@ -35,7 +35,7 @@ import org.openepics.names.repository.model.Subsystem; import org.openepics.names.repository.model.System; import org.openepics.names.repository.model.SystemGroup; import org.openepics.names.rest.beans.Type; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.NameCommand; import org.openepics.names.util.StructureCommand; import org.openepics.names.util.StructureUtil; @@ -168,16 +168,16 @@ public class NotificationUtil { * @param structureCommandACR structure command (approve cancel reject) * @param previous previous (structure) * @param structure structure - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content */ public static void prepareAddNotification(List<NotificationStructure> notifications, Type type, StructureCommand structureCommandCUD, StructureCommand structureCommandACR, - Structure previous, Structure structure, HolderSystemDeviceStructure holderStructure) { + Structure previous, Structure structure, HolderStructures holderStructures) { if (notifications == null) { return; } - NotificationStructure notification = NotificationUtil.prepareNotification(type, structureCommandCUD, structureCommandACR, previous, structure, holderStructure); + NotificationStructure notification = NotificationUtil.prepareNotification(type, structureCommandCUD, structureCommandACR, previous, structure, holderStructures); if (notification != null) { notifications.add(notification); } @@ -192,11 +192,11 @@ public class NotificationUtil { * @param structureCommandACR structure command (approve cancel reject) * @param previous previous (structure) * @param structure structure - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return notification */ public static NotificationStructure prepareNotification(Type type, StructureCommand structureCommandCUD, StructureCommand structureCommandACR, - Structure previous, Structure structure, HolderSystemDeviceStructure holderStructure) { + Structure previous, Structure structure, HolderStructures holderStructures) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.PREPARE_NOTIFICATION, "type", type)); LOGGER.log(Level.FINER, MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.PREPARE_NOTIFICATION, "structureCommandCUD", structureCommandCUD)); @@ -205,7 +205,7 @@ public class NotificationUtil { LOGGER.log(Level.FINER, MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.PREPARE_NOTIFICATION, "structure", structure)); } - if (ValidateUtil.isAnyNull(holderStructure, type, structureCommandCUD, structure)) { + if (ValidateUtil.isAnyNull(holderStructures, type, structureCommandCUD, structure)) { return null; } if (ValidateUtil.isAnyEqual(structureCommandCUD, StructureCommand.APPROVE, StructureCommand.CANCEL, StructureCommand.REJECT)) { @@ -276,17 +276,17 @@ public class NotificationUtil { if (ValidateUtil.isAnyEqual(structureCommandCUD, StructureCommand.UPDATE)) { if (Type.SYSTEMGROUP.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) previous, holderStructures); } else if (Type.SYSTEM.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((System) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((System) previous, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) previous, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((Discipline) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((Discipline) previous, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) previous, holderStructures); } else if (Type.DEVICETYPE.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) previous, holderStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) previous, holderStructures); } oldName = StringUtils.stripToEmpty(previous.getName()); @@ -296,17 +296,17 @@ public class NotificationUtil { } if (Type.SYSTEMGROUP.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) structure, holderStructures); } else if (Type.SYSTEM.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((System) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((System) structure, holderStructures); } else if (Type.SUBSYSTEM.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) structure, holderStructures); } else if (Type.DISCIPLINE.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((Discipline) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((Discipline) structure, holderStructures); } else if (Type.DEVICEGROUP.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) structure, holderStructures); } else if (Type.DEVICETYPE.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) structure, holderStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) structure, holderStructures); } newName = StringUtils.stripToEmpty(structure.getName()); newMnemonic = StringUtils.stripToEmpty(structure.getMnemonic()); diff --git a/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java b/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java index 9a940c312b2b925b35fb2429d5e5d61371a7a385..805fb005b43e8410e5cc4fb92105ac9af8dec11a 100644 --- a/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java +++ b/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java @@ -27,7 +27,7 @@ import org.openepics.names.repository.model.System; import org.openepics.names.repository.model.SystemGroup; import org.openepics.names.rest.beans.old.DeviceNameElement; import org.openepics.names.util.HolderIRepositories; -import org.openepics.names.util.HolderSystemDeviceStructure; +import org.openepics.names.util.HolderStructures; import org.openepics.names.util.NameUtil; /** @@ -51,10 +51,10 @@ public class DeviceNameElementUtil { * Populate and return device name element for name. * * @param name name - * @param holderStructure holder of system and device structure content + * @param holderStructures holder of system and device structure content * @return device name element */ - public static DeviceNameElement getDeviceNameElement(Name name, HolderSystemDeviceStructure holderStructure) { + public static DeviceNameElement getDeviceNameElement(Name name, HolderStructures holderStructures) { if (name == null) { return null; } @@ -74,9 +74,9 @@ public class DeviceNameElementUtil { // populate return element for system structure switch (levelSystemStructure) { case 3: { - Subsystem subsystem = holderStructure.findSubsystemByUuid(name.getSubsystemUuid()); - System system = holderStructure.findSystemByUuid(subsystem.getParentUuid()); - SystemGroup systemGroup = holderStructure.findSystemGroupByUuid(system.getParentUuid()); + Subsystem subsystem = holderStructures.findSubsystemByUuid(name.getSubsystemUuid()); + System system = holderStructures.findSystemByUuid(subsystem.getParentUuid()); + SystemGroup systemGroup = holderStructures.findSystemGroupByUuid(system.getParentUuid()); deviceNameElement.setSubsystem(subsystem.getMnemonic()); deviceNameElement.setSystem(system.getMnemonic()); @@ -84,15 +84,15 @@ public class DeviceNameElementUtil { break; } case 2: { - System system = holderStructure.findSystemByUuid(name.getSystemUuid()); - SystemGroup systemGroup = holderStructure.findSystemGroupByUuid(system.getParentUuid()); + System system = holderStructures.findSystemByUuid(name.getSystemUuid()); + SystemGroup systemGroup = holderStructures.findSystemGroupByUuid(system.getParentUuid()); deviceNameElement.setSystem(system.getMnemonic()); deviceNameElement.setSystemGroup(systemGroup.getMnemonic()); break; } case 1: { - SystemGroup systemGroup = holderStructure.findSystemGroupByUuid(name.getSystemGroupUuid()); + SystemGroup systemGroup = holderStructures.findSystemGroupByUuid(name.getSystemGroupUuid()); deviceNameElement.setSystemGroup(systemGroup.getMnemonic()); break; @@ -105,9 +105,9 @@ public class DeviceNameElementUtil { // populate return element for device structure switch (levelDeviceStructure) { case 3: { - DeviceType deviceType = holderStructure.findDeviceTypeByUuid(name.getDeviceTypeUuid()); - DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); - Discipline discipline = holderStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); + DeviceType deviceType = holderStructures.findDeviceTypeByUuid(name.getDeviceTypeUuid()); + DeviceGroup deviceGroup = holderStructures.findDeviceGroupByUuid(deviceType.getParentUuid()); + Discipline discipline = holderStructures.findDisciplineByUuid(deviceGroup.getParentUuid()); deviceNameElement.setDeviceType(deviceType.getMnemonic()); deviceNameElement.setDiscipline(discipline.getMnemonic());