From 9c3554feab04ff474a0d4324fc9a449b6dd590dd Mon Sep 17 00:00:00 2001 From: Lars Johansson <lars.johansson@ess.eu> Date: Fri, 3 Feb 2023 17:43:14 +0100 Subject: [PATCH] Refactor variable names for clarity --- .../old/DeviceNamesControllerV0.java | 64 +++---- .../names/service/DeviceGroupService.java | 34 ++-- .../names/service/DeviceTypeService.java | 30 +-- .../names/service/DisciplineService.java | 34 ++-- .../openepics/names/service/NamesService.java | 62 +++--- .../names/service/StructuresService.java | 178 +++++++++--------- .../names/service/SubsystemService.java | 34 ++-- .../names/service/SystemGroupService.java | 38 ++-- .../names/service/SystemService.java | 38 ++-- .../util/HolderSystemDeviceStructure.java | 3 +- .../openepics/names/util/NameElementUtil.java | 10 +- .../org/openepics/names/util/NameUtil.java | 18 +- .../names/util/StructureElementUtil.java | 96 +++++----- .../openepics/names/util/StructureUtil.java | 80 ++++---- .../names/util/ValidateNameElementUtil.java | 42 ++--- .../util/ValidateStructureElementUtil.java | 82 ++++---- .../util/notification/NotificationUtil.java | 36 ++-- .../names/util/old/DeviceNameElementUtil.java | 24 +-- 18 files changed, 450 insertions(+), 453 deletions(-) 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 310cae9b..2cf766d3 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 @@ -116,11 +116,11 @@ public class DeviceNamesControllerV0 { // create collection with known initial capacity final List<DeviceNameElement> deviceNameElements = new ArrayList<>(names.size()); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } LOGGER.log(Level.FINE, "findNames, deviceNameElement s.size: {0}", deviceNameElements.size()); @@ -158,12 +158,12 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.getNameRepository().findLatestNotDeleted(); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name namee : names) { if (pattern.matcher(namee.getConventionName()).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(namee, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(namee, holderStructure)); } } @@ -186,21 +186,21 @@ public class DeviceNamesControllerV0 { // exact match // case sensitive - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); final List<DeviceNameElement> deviceNameElements = Lists.newArrayList(); List<Name> namesSystemGroup = holderIRepositories.getNameRepository().findLatestBySystemGroupMnemonic(system); for (Name name : namesSystemGroup) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } List<Name> namesSystem = holderIRepositories.getNameRepository().findLatestBySystemMnemonic(system); List<Name> namesSystemThroughSubsystem = holderIRepositories.getNameRepository().findLatestBySystemMnemonicThroughSubsystem(system); for (Name name : namesSystem) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } for (Name name : namesSystemThroughSubsystem) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } LOGGER.log(Level.FINE, "findNamesBySystem, system: {0}", system); @@ -234,13 +234,13 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.getNameRepository().findLatestNotDeleted(); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractSystem(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -269,11 +269,11 @@ public class DeviceNamesControllerV0 { final List<DeviceNameElement> deviceNameElements = new ArrayList<>(names.size()); if (!names.isEmpty()) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -308,13 +308,13 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.getNameRepository().findLatestNotDeleted(); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractSubsystem(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -343,11 +343,11 @@ public class DeviceNamesControllerV0 { final List<DeviceNameElement> deviceNameElements = new ArrayList<>(names.size()); if (!names.isEmpty()) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -382,13 +382,13 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.getNameRepository().findLatestNotDeleted(); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractDiscipline(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -417,11 +417,11 @@ public class DeviceNamesControllerV0 { final List<DeviceNameElement> deviceNameElements = new ArrayList<>(names.size()); if (!names.isEmpty()) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } @@ -456,13 +456,13 @@ public class DeviceNamesControllerV0 { List<Name> names = holderIRepositories.getNameRepository().findLatestNotDeleted(); - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (Name name : names) { String sub = NamingConventionUtil.extractDeviceType(name.getConventionName()); if (!StringUtils.isEmpty(sub) && pattern.matcher(sub).find()) { - deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holder)); + deviceNameElements.add(DeviceNameElementUtil.getDeviceNameElement(name, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/DeviceGroupService.java b/src/main/java/org/openepics/names/service/DeviceGroupService.java index f945cba2..edea5ab7 100644 --- a/src/main/java/org/openepics/names/service/DeviceGroupService.java +++ b/src/main/java/org/openepics/names/service/DeviceGroupService.java @@ -83,7 +83,7 @@ public class DeviceGroupService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.CREATE, null, null, deviceGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DEVICEGROUP, StructureCommand.DELETE, null, null, deviceGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder); + deviceTypeService.deleteStructure(command, when, username, holderStructure); } for (StructureElementCommand command : commands) { - deviceTypeService.approveStructure(command, when, username, holder); + deviceTypeService.approveStructure(command, when, username, holderStructure); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(deviceGroup, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, deviceGroup, holder)); + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, deviceGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceGroup, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICEGROUP, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceGroup, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/DeviceTypeService.java b/src/main/java/org/openepics/names/service/DeviceTypeService.java index 3a2756b0..194a3472 100644 --- a/src/main/java/org/openepics/names/service/DeviceTypeService.java +++ b/src/main/java/org/openepics/names/service/DeviceTypeService.java @@ -76,7 +76,7 @@ public class DeviceTypeService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.CREATE, null, null, deviceType, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DEVICETYPE, StructureCommand.DELETE, null, null, deviceType, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.APPROVE, previous, deviceType, holder)); + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.APPROVE, previous, deviceType, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(deviceType, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DEVICETYPE, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, deviceType, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/DisciplineService.java b/src/main/java/org/openepics/names/service/DisciplineService.java index b6d4100c..cc7a6021 100644 --- a/src/main/java/org/openepics/names/service/DisciplineService.java +++ b/src/main/java/org/openepics/names/service/DisciplineService.java @@ -86,7 +86,7 @@ public class DisciplineService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.CREATE, null, null, discipline, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.DISCIPLINE, StructureCommand.DELETE, null, null, discipline, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder); + deviceGroupService.deleteStructure(command, when, username, holderStructure); } for (StructureElementCommand command : commands) { - deviceGroupService.approveStructure(command, when, username, holder); + deviceGroupService.approveStructure(command, when, username, holderStructure); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(discipline, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.APPROVE, previous, discipline, holder)); + StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.APPROVE, previous, discipline, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(discipline, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.DISCIPLINE, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, discipline, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/NamesService.java b/src/main/java/org/openepics/names/service/NamesService.java index 2de0369a..36e227be 100644 --- a/src/main/java/org/openepics/names/service/NamesService.java +++ b/src/main/java/org/openepics/names/service/NamesService.java @@ -148,13 +148,13 @@ public class NamesService { // no notify // return name elements for created names - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); final List<NameElement> createdNameElements = Lists.newArrayList(); for (NameElementCommand nameElementCommand : nameElementCommands) { - NameElement createdNameElement = createName(nameElementCommand, when, username, holder); + NameElement createdNameElement = createName(nameElementCommand, when, username, holderStructure); 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 holder) { + public NameElement createName(NameElementCommand nameElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, index, holder); + derivedName = NameUtil.getName(system, deviceType, index, holderStructure); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, index, holder); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); } // create @@ -443,11 +443,11 @@ public class NamesService { LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, "Is valid to create name", "name", name)); - // initiate holder of containers for system and device structure content, for performance reasons + // initiate holder of system and device structure content, for performance reasons // note false to not include deleted entries - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories, false); + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories, false); - ValidateNameElementUtil.validateNameDataCreate(name, namingConvention, holderRepositories, holder); + ValidateNameElementUtil.validateNameDataCreate(name, namingConvention, holderRepositories, holderStructure); return Boolean.TRUE; } @@ -457,7 +457,7 @@ public class NamesService { public void validateNamesCreate(NameElementCommand nameElement) { validateNamesCreate(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateNamesCreate(NameElementCommand nameElement, HolderSystemDeviceStructure holder) { + public void validateNamesCreate(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { // validate name element // input // input itself @@ -469,21 +469,21 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputCreate(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataCreate(nameElement, namingConvention, holderIRepositories, nameRepository, holder); + ValidateNameElementUtil.validateNameElementDataCreate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); } public void validateNamesCreate(List<NameElementCommand> nameElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesCreate(nameElement, holder); + validateNamesCreate(nameElement, holderStructure); } } public void validateNamesUpdate(NameElementCommand nameElement) { validateNamesUpdate(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateNamesUpdate(NameElementCommand nameElement, HolderSystemDeviceStructure holder) { + public void validateNamesUpdate(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { // validate name element // input // input itself @@ -495,21 +495,21 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputUpdate(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataUpdate(nameElement, namingConvention, holderIRepositories, nameRepository, holder); + ValidateNameElementUtil.validateNameElementDataUpdate(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); } public void validateNamesUpdate(List<NameElementCommand> nameElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesUpdate(nameElement, holder); + validateNamesUpdate(nameElement, holderStructure); } } public void validateNamesDelete(NameElementCommand nameElement) { validateNamesDelete(nameElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateNamesDelete(NameElementCommand nameElement, HolderSystemDeviceStructure holder) { + public void validateNamesDelete(NameElementCommand nameElement, HolderSystemDeviceStructure holderStructure) { // validate name element // input // input itself @@ -521,14 +521,14 @@ public class NamesService { ValidateNameElementUtil.validateNameElementInputDelete(nameElement); // validate data - ValidateNameElementUtil.validateNameElementDataDelete(nameElement, namingConvention, holderIRepositories, nameRepository, holder); + ValidateNameElementUtil.validateNameElementDataDelete(nameElement, namingConvention, holderIRepositories, nameRepository, holderStructure); } public void validateNamesDelete(List<NameElementCommand> nameElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (NameElementCommand nameElement : nameElements) { - validateNamesDelete(nameElement, holder); + validateNamesDelete(nameElement, holderStructure); } } @@ -551,8 +551,8 @@ public class NamesService { // attributes // uuid, parentSystemStructure, parentDeviceStructure, index, description, comment - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); final List<NameElement> updatedNameElements = Lists.newArrayList(); @@ -574,7 +574,7 @@ public class NamesService { // skip if name element has same content as name // proceed without fail - if (NameElementUtil.hasSameContent(nameElementCommand, name, holderIRepositories, holder)) { + if (NameElementUtil.hasSameContent(nameElementCommand, name, holderIRepositories, holderStructure)) { continue; } @@ -594,11 +594,11 @@ public class NamesService { String derivedName = null; if (systemGroup != null) { - derivedName = NameUtil.getName(systemGroup, deviceType, index, holder); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, index, holder); + derivedName = NameUtil.getName(system, deviceType, index, holderStructure); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, index, holder); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); } // create diff --git a/src/main/java/org/openepics/names/service/StructuresService.java b/src/main/java/org/openepics/names/service/StructuresService.java index 7088dfff..6016b56f 100644 --- a/src/main/java/org/openepics/names/service/StructuresService.java +++ b/src/main/java/org/openepics/names/service/StructuresService.java @@ -166,8 +166,8 @@ public class StructuresService { // notify // return structure elements for created structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(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, holder); + structureElementNotification = systemGroupService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.createStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = systemService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.createStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = subsystemService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.createStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = disciplineService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.createStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = deviceGroupService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.createStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = deviceTypeService.createStructure(structureElement, when, username, namingConvention, holderStructure); } else { continue; } @@ -257,8 +257,8 @@ public class StructuresService { } } - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); final List<StructureElement> structureElements = Lists.newArrayList(); Long totalCount = null; @@ -276,7 +276,7 @@ public class StructuresService { systemGroups = Lists.newArrayList(); totalCount = 0L; } - structureElements.addAll(StructureElementUtil.getStructureElementsForSystemGroups(systemGroups, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSystemGroups(systemGroups, holderStructure, structureChoice)); } else if (Type.SYSTEM.equals(type)) { List<System> systems = holderRepositories.getSystemRepository().readSystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, @@ -284,7 +284,7 @@ public class StructuresService { totalCount = holderRepositories.getSystemRepository().countSystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, includeHistory); - structureElements.addAll(StructureElementUtil.getStructureElementsForSystems(systems, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSystems(systems, holderStructure, structureChoice)); } else if (Type.SUBSYSTEM.equals(type)) { List<Subsystem> subsystems = holderRepositories.getSubsystemRepository().readSubsystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, @@ -292,7 +292,7 @@ public class StructuresService { totalCount = holderRepositories.getSubsystemRepository().countSubsystems(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, includeHistory); - structureElements.addAll(StructureElementUtil.getStructureElementsForSubsystems(subsystems, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForSubsystems(subsystems, holderStructure, structureChoice)); } else if (Type.DISCIPLINE.equals(type)) { // discipline has no parent uuid List<Discipline> disciplines = null; @@ -307,7 +307,7 @@ public class StructuresService { disciplines = Lists.newArrayList(); totalCount = 0L; } - structureElements.addAll(StructureElementUtil.getStructureElementsForDisciplines(disciplines, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDisciplines(disciplines, holderStructure, structureChoice)); } else if (Type.DEVICEGROUP.equals(type)) { List<DeviceGroup> deviceGroups = holderRepositories.getDeviceGroupRepository().readDeviceGroups(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, @@ -315,7 +315,7 @@ public class StructuresService { totalCount = holderRepositories.getDeviceGroupRepository().countDeviceGroups(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, includeHistory); - structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceGroups(deviceGroups, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceGroups(deviceGroups, holderStructure, structureChoice)); } else if (Type.DEVICETYPE.equals(type)) { List<DeviceType> deviceTypes = holderRepositories.getDeviceTypeRepository().readDeviceTypes(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, @@ -323,7 +323,7 @@ public class StructuresService { totalCount = holderRepositories.getDeviceTypeRepository().countDeviceTypes(statuses, deleted, uuid, parent, name, mnemonic, mnemonicEquivalence, mnemonicPath, description, includeHistory); - structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceTypes(deviceTypes, holder, structureChoice)); + structureElements.addAll(StructureElementUtil.getStructureElementsForDeviceTypes(deviceTypes, holderStructure, structureChoice)); } ResponsePageStructureElements response = new ResponsePageStructureElements(structureElements, totalCount, structureElements.size(), offset, limit); @@ -571,11 +571,11 @@ public class StructuresService { LOGGER.log(Level.FINE, MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, "Is valid to create structure", "mnemonicPath", mnemonicPath)); } - // initiate holder of containers for system and device structure content, for performance reasons + // initiate holder of system and device structure content, for performance reasons // note false to not include deleted entries - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories, false); + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories, false); - ValidateStructureElementUtil.validateStructureDataCreate(type, mnemonicPath, namingConvention, holderIRepositories, holder); + ValidateStructureElementUtil.validateStructureDataCreate(type, mnemonicPath, namingConvention, holderIRepositories, holderStructure); return Boolean.TRUE; } @@ -585,7 +585,7 @@ public class StructuresService { public void validateStructuresCreate(StructureElementCommand structureElement) { validateStructuresCreate(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresCreate(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresCreate(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -598,21 +598,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputCreate(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataCreate(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataCreate(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresCreate(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresCreate(structureElement, holder); + validateStructuresCreate(structureElement, holderStructure); } } public void validateStructuresUpdate(StructureElementCommand structureElement) { validateStructuresUpdate(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresUpdate(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresUpdate(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -625,21 +625,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputUpdate(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataUpdate(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataUpdate(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresUpdate(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresUpdate(structureElement, holder); + validateStructuresUpdate(structureElement, holderStructure); } } public void validateStructuresDelete(StructureElementCommand structureElement) { validateStructuresDelete(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresDelete(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresDelete(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -652,21 +652,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputDelete(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataDelete(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataDelete(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresDelete(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresDelete(structureElement, holder); + validateStructuresDelete(structureElement, holderStructure); } } public void validateStructuresApprove(StructureElementCommand structureElement) { validateStructuresApprove(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresApprove(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresApprove(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -679,21 +679,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputApprove(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataApprove(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataApprove(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresApprove(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresApprove(structureElement, holder); + validateStructuresApprove(structureElement, holderStructure); } } public void validateStructuresCancel(StructureElementCommand structureElement) { validateStructuresCancel(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresCancel(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresCancel(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -706,21 +706,21 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputCancel(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataCancel(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataCancel(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresCancel(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresCancel(structureElement, holder); + validateStructuresCancel(structureElement, holderStructure); } } public void validateStructuresReject(StructureElementCommand structureElement) { validateStructuresReject(structureElement, new HolderSystemDeviceStructure(holderIRepositories)); } - public void validateStructuresReject(StructureElementCommand structureElement, HolderSystemDeviceStructure holder) { + public void validateStructuresReject(StructureElementCommand structureElement, HolderSystemDeviceStructure holderStructure) { // validate structure element // input // type @@ -733,14 +733,14 @@ public class StructuresService { ValidateStructureElementUtil.validateStructureElementInputReject(structureElement, namingConvention); // validate data - ValidateStructureElementUtil.validateStructureElementDataReject(structureElement, namingConvention, holderRepositories, holder); + ValidateStructureElementUtil.validateStructureElementDataReject(structureElement, namingConvention, holderRepositories, holderStructure); } public void validateStructuresReject(List<StructureElementCommand> structureElements) { - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); for (StructureElementCommand structureElement : structureElements) { - validateStructuresReject(structureElement, holder); + validateStructuresReject(structureElement, holderStructure); } } @@ -758,8 +758,8 @@ public class StructuresService { // notify // return structure elements for updated structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -769,17 +769,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = systemGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = systemService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = subsystemService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = disciplineService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = deviceGroupService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.updateStructure(structureElement, when, username, namingConvention, holder); + structureElementNotification = deviceTypeService.updateStructure(structureElement, when, username, namingConvention, holderStructure); } else { continue; } @@ -821,8 +821,8 @@ public class StructuresService { // notify // return structure elements for deleted structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -832,17 +832,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = systemGroupService.deleteStructure(structureElement, when, username, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = systemService.deleteStructure(structureElement, when, username, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = subsystemService.deleteStructure(structureElement, when, username, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = disciplineService.deleteStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = deviceGroupService.deleteStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICETYPE.equals(type)) { - structureElementNotification = deviceTypeService.deleteStructure(structureElement, when, username, holder); + structureElementNotification = deviceTypeService.deleteStructure(structureElement, when, username, holderStructure); } else { continue; } @@ -884,8 +884,8 @@ public class StructuresService { // notify // return structure elements for approved structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); // approve // set not latest for current latest @@ -902,17 +902,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.approveStructure(structureElement, when, username, holder); + structureElementNotification = systemGroupService.approveStructure(structureElement, when, username, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.approveStructure(structureElement, when, username, holder); + structureElementNotification = systemService.approveStructure(structureElement, when, username, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.approveStructure(structureElement, when, username, holder); + structureElementNotification = subsystemService.approveStructure(structureElement, when, username, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.approveStructure(structureElement, when, username, holder); + structureElementNotification = disciplineService.approveStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.approveStructure(structureElement, when, username, holder); + structureElementNotification = deviceGroupService.approveStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.approveStructure(structureElement, when, username, holder); + structureElementNotification = deviceTypeService.approveStructure(structureElement, when, username, holderStructure); } else { continue; } @@ -952,8 +952,8 @@ public class StructuresService { // notify // return structure elements for cancelled structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -963,17 +963,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = systemGroupService.cancelStructure(structureElement, when, username, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = systemService.cancelStructure(structureElement, when, username, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = subsystemService.cancelStructure(structureElement, when, username, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = disciplineService.cancelStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = deviceGroupService.cancelStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.cancelStructure(structureElement, when, username, holder); + structureElementNotification = deviceTypeService.cancelStructure(structureElement, when, username, holderStructure); } else { continue; } @@ -1013,8 +1013,8 @@ public class StructuresService { // notify // return structure elements for rejected structures - // initiate holder of containers for system and device structure content, for performance reasons - HolderSystemDeviceStructure holder = new HolderSystemDeviceStructure(holderIRepositories); + // initiate holder of system and device structure content, for performance reasons + HolderSystemDeviceStructure holderStructure = new HolderSystemDeviceStructure(holderIRepositories); Date when = new Date(); List<NotificationStructure> notifications = Lists.newArrayList(); @@ -1024,17 +1024,17 @@ public class StructuresService { StructureElementNotification structureElementNotification = null; if (Type.SYSTEMGROUP.equals(type)) { - structureElementNotification = systemGroupService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = systemGroupService.rejectStructure(structureElement, when, username, holderStructure); } else if (Type.SYSTEM.equals(type)) { - structureElementNotification = systemService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = systemService.rejectStructure(structureElement, when, username, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - structureElementNotification = subsystemService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = subsystemService.rejectStructure(structureElement, when, username, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - structureElementNotification = disciplineService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = disciplineService.rejectStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - structureElementNotification = deviceGroupService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = deviceGroupService.rejectStructure(structureElement, when, username, holderStructure); } else if (Type.DEVICETYPE.equals(structureElement.getType())) { - structureElementNotification = deviceTypeService.rejectStructure(structureElement, when, username, holder); + structureElementNotification = deviceTypeService.rejectStructure(structureElement, when, username, holderStructure); } 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 2a05eca7..8d9d5484 100644 --- a/src/main/java/org/openepics/names/service/SubsystemService.java +++ b/src/main/java/org/openepics/names/service/SubsystemService.java @@ -77,7 +77,7 @@ public class SubsystemService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.CREATE, null, null, subsystem, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SUBSYSTEM, StructureCommand.DELETE, null, null, subsystem, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(subsystem, holderStructure)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, subsystem.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holder); + namesService.createName(nameElement, when, username, holderStructure); } } 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, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, subsystem, holder)); + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, subsystem, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(subsystem, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SUBSYSTEM, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, subsystem, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/SystemGroupService.java b/src/main/java/org/openepics/names/service/SystemGroupService.java index 77925e28..3c875ede 100644 --- a/src/main/java/org/openepics/names/service/SystemGroupService.java +++ b/src/main/java/org/openepics/names/service/SystemGroupService.java @@ -87,7 +87,7 @@ public class SystemGroupService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.CREATE, null, null, systemGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, StructureCommand.DELETE, null, null, systemGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(systemGroup, holderStructure)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, systemGroup.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holder); + namesService.createName(nameElement, when, username, holderStructure); } } 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, holder); + systemService.deleteStructure(command, when, username, holderStructure); } for (StructureElementCommand command : commands) { - systemService.approveStructure(command, when, username, holder); + systemService.approveStructure(command, when, username, holderStructure); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(systemGroup, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, systemGroup, holder)); + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.APPROVE, previous, systemGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(systemGroup, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEMGROUP, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, systemGroup, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/service/SystemService.java b/src/main/java/org/openepics/names/service/SystemService.java index 2e18c69d..ede7a6dd 100644 --- a/src/main/java/org/openepics/names/service/SystemService.java +++ b/src/main/java/org/openepics/names/service/SystemService.java @@ -87,7 +87,7 @@ public class SystemService { } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification createStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.CREATE, null, null, system, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holder) { + public StructureElementNotification updateStructure(StructureElementCommand structureElementCommand, Date when, String username, EssNamingConvention namingConvention, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification deleteStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + NotificationUtil.prepareNotification(Type.SYSTEM, StructureCommand.DELETE, null, null, system, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification approveStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder)); + boolean existsName = hasMnemonic && namesService.existsName(StructureUtil.getMnemonicPath(system, holderStructure)); if (hasMnemonic && !existsName) { NameElementCommand nameElement = new NameElementCommand(null, system.getUuid(), null, null, StructuresService.SYSTEM_STRUCTURE_ONLY, null); - namesService.createName(nameElement, when, username, holder); + namesService.createName(nameElement, when, username, holderStructure); } } 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, holder); + subsystemService.deleteStructure(command, when, username, holderStructure); } for (StructureElementCommand command : commands) { - subsystemService.approveStructure(command, when, username, holder); + subsystemService.approveStructure(command, when, username, holderStructure); } } LOGGER.log(Level.FINE, () -> MessageFormat.format(TextUtil.DESCRIPTION_NAME_VALUE, TextUtil.APPROVE_STRUCTURE, TextUtil.COMMAND, structureCommandCUD)); return new StructureElementNotification( - StructureElementUtil.getStructureElementProcessed(system, holder, StructureChoice.STRUCTURE), - NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, system, holder)); + StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), + NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.APPROVE, previous, system, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification cancelStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.CANCEL, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); } @Transactional(propagation = Propagation.MANDATORY) - public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holder) { + public StructureElementNotification rejectStructure(StructureElementCommand structureElementCommand, Date when, String username, HolderSystemDeviceStructure holderStructure) { // 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, holder, StructureChoice.STRUCTURE), + StructureElementUtil.getStructureElementProcessed(system, holderStructure, StructureChoice.STRUCTURE), NotificationUtil.prepareNotification(Type.SYSTEM, structureCommandCUD, StructureCommand.REJECT, - previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holder)); + previouses != null && !previouses.isEmpty() ? previouses.get(0) : null, system, holderStructure)); } } diff --git a/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java b/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java index e8dbaa02..3801249c 100644 --- a/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java +++ b/src/main/java/org/openepics/names/util/HolderSystemDeviceStructure.java @@ -31,8 +31,7 @@ import org.openepics.names.repository.model.System; import org.openepics.names.repository.model.SystemGroup; /** - * Utility class and holder of containers for system and device structure content - * that are used to populate REST API return elements. + * Utility class and holder of system and device structure content that are used to populate REST API return elements. * <p> * Class is used for performance reasons to speed up preparation of what is to be returned. * </p> diff --git a/src/main/java/org/openepics/names/util/NameElementUtil.java b/src/main/java/org/openepics/names/util/NameElementUtil.java index b39cf466..8f0e1955 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 holder holder repositories + * @param holderStructure 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 holder) { + public static boolean hasSameContent(NameElementCommand nameElement, Name name, HolderIRepositories holderIRepositories, HolderSystemDeviceStructure holderStructure) { // 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(), holder); + derivedName = NameUtil.getName(systemGroup, deviceType, nameElement.getIndex(), holderStructure); } else if (system != null) { - derivedName = NameUtil.getName(system, deviceType, nameElement.getIndex(), holder); + derivedName = NameUtil.getName(system, deviceType, nameElement.getIndex(), holderStructure); } else if (subsystem != null) { - derivedName = NameUtil.getName(subsystem, deviceType, nameElement.getIndex(), holder); + derivedName = NameUtil.getName(subsystem, deviceType, nameElement.getIndex(), holderStructure); } 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 cec7dc01..7f5c09a1 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 holderSystemDeviceStructure) { - String systemStructure = StructureUtil.getMnemonicPath(systemGroup, holderSystemDeviceStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderSystemDeviceStructure); + public static String getName(SystemGroup systemGroup, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { + String systemStructure = StructureUtil.getMnemonicPath(systemGroup, holderStructure); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); 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 holderSystemDeviceStructure) { - String systemStructure = StructureUtil.getMnemonicPath(system, holderSystemDeviceStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderSystemDeviceStructure); + public static String getName(System system, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { + String systemStructure = StructureUtil.getMnemonicPath(system, holderStructure); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); 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 holderSystemDeviceStructure) { - String systemStructure = StructureUtil.getMnemonicPath(subsystem, holderSystemDeviceStructure); - String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderSystemDeviceStructure); + public static String getName(Subsystem subsystem, DeviceType deviceType, String index, HolderSystemDeviceStructure holderStructure) { + String systemStructure = StructureUtil.getMnemonicPath(subsystem, holderStructure); + String deviceStructure = StructureUtil.getMnemonicPath(deviceType, holderStructure); 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 309ba5d3..0fc03b6d 100644 --- a/src/main/java/org/openepics/names/util/StructureElementUtil.java +++ b/src/main/java/org/openepics/names/util/StructureElementUtil.java @@ -61,14 +61,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for system groups. * * @param systemGroups system groups - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSystemGroups(List<SystemGroup> systemGroups, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (SystemGroup systemGroup : systemGroups) { // one or two return elements @@ -79,9 +79,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (systemGroup.getProcessed() != null && ((systemGroup.getProcessed().getTime() - systemGroup.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(systemGroup)); - structureElements.add(getStructureElementProcessed(systemGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(systemGroup, holderStructure, structureChoice)); } else if (systemGroup.getProcessed() != null && ((systemGroup.getProcessed().getTime() - systemGroup.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(systemGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(systemGroup, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(systemGroup)); } @@ -89,7 +89,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(systemGroup.getStatus())) { structureElements.add(getStructureElementRequested(systemGroup)); } else { - structureElements.add(getStructureElementProcessed(systemGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(systemGroup, holderStructure, structureChoice)); } } } @@ -99,14 +99,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for systems. * * @param systems systems - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSystems(List<System> systems, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (System system : systems) { // one or two return elements @@ -117,9 +117,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (system.getProcessed() != null && ((system.getProcessed().getTime() - system.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(system)); - structureElements.add(getStructureElementProcessed(system, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(system, holderStructure, structureChoice)); } else if (system.getProcessed() != null && ((system.getProcessed().getTime() - system.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(system, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(system, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(system)); } @@ -127,7 +127,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(system.getStatus())) { structureElements.add(getStructureElementRequested(system)); } else { - structureElements.add(getStructureElementProcessed(system, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(system, holderStructure, structureChoice)); } } } @@ -137,14 +137,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for subsystems. * * @param subsystems subsystems - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForSubsystems(List<Subsystem> subsystems, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (Subsystem subsystem : subsystems) { // one or two return elements @@ -155,9 +155,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (subsystem.getProcessed() != null && ((subsystem.getProcessed().getTime() - subsystem.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(subsystem)); - structureElements.add(getStructureElementProcessed(subsystem, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(subsystem, holderStructure, structureChoice)); } else if (subsystem.getProcessed() != null && ((subsystem.getProcessed().getTime() - subsystem.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(subsystem, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(subsystem, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(subsystem)); } @@ -165,7 +165,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(subsystem.getStatus())) { structureElements.add(getStructureElementRequested(subsystem)); } else { - structureElements.add(getStructureElementProcessed(subsystem, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(subsystem, holderStructure, structureChoice)); } } } @@ -176,14 +176,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for disciplines. * * @param disciplines disciplines - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDisciplines(List<Discipline> disciplines, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (Discipline discipline : disciplines) { // one or two return elements @@ -194,9 +194,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (discipline.getProcessed() != null && ((discipline.getProcessed().getTime() - discipline.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(discipline)); - structureElements.add(getStructureElementProcessed(discipline, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(discipline, holderStructure, structureChoice)); } else if (discipline.getProcessed() != null && ((discipline.getProcessed().getTime() - discipline.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(discipline, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(discipline, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(discipline)); } @@ -204,7 +204,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(discipline.getStatus())) { structureElements.add(getStructureElementRequested(discipline)); } else { - structureElements.add(getStructureElementProcessed(discipline, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(discipline, holderStructure, structureChoice)); } } } @@ -214,14 +214,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for device groups. * * @param deviceGroups device groups - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDeviceGroups(List<DeviceGroup> deviceGroups, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (DeviceGroup deviceGroup : deviceGroups) { // one or two return elements @@ -232,9 +232,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (deviceGroup.getProcessed() != null && ((deviceGroup.getProcessed().getTime() - deviceGroup.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(deviceGroup)); - structureElements.add(getStructureElementProcessed(deviceGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceGroup, holderStructure, structureChoice)); } else if (deviceGroup.getProcessed() != null && ((deviceGroup.getProcessed().getTime() - deviceGroup.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(deviceGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceGroup, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(deviceGroup)); } @@ -242,7 +242,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(deviceGroup.getStatus())) { structureElements.add(getStructureElementRequested(deviceGroup)); } else { - structureElements.add(getStructureElementProcessed(deviceGroup, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceGroup, holderStructure, structureChoice)); } } } @@ -252,14 +252,14 @@ public class StructureElementUtil { * Populate and return list of structure elements for device types. * * @param deviceTypes device types - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static List<StructureElement> getStructureElementsForDeviceTypes(List<DeviceType> deviceTypes, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { List<StructureElement> structureElements = Lists.newArrayList(); for (DeviceType deviceType : deviceTypes) { // one or two return elements @@ -270,9 +270,9 @@ public class StructureElementUtil { if (StructureChoice.HISTORY.equals(structureChoice)) { if (deviceType.getProcessed() != null && ((deviceType.getProcessed().getTime() - deviceType.getRequested().getTime()) > THOUSAND_MILLISECONDS)) { structureElements.add(getStructureElementRequested(deviceType)); - structureElements.add(getStructureElementProcessed(deviceType, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceType, holderStructure, structureChoice)); } else if (deviceType.getProcessed() != null && ((deviceType.getProcessed().getTime() - deviceType.getRequested().getTime()) <= THOUSAND_MILLISECONDS)) { - structureElements.add(getStructureElementProcessed(deviceType, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceType, holderStructure, structureChoice)); } else { structureElements.add(getStructureElementRequested(deviceType)); } @@ -280,7 +280,7 @@ public class StructureElementUtil { if (Status.PENDING.equals(deviceType.getStatus())) { structureElements.add(getStructureElementRequested(deviceType)); } else { - structureElements.add(getStructureElementProcessed(deviceType, holderSystemDeviceStructure, structureChoice)); + structureElements.add(getStructureElementProcessed(deviceType, holderStructure, structureChoice)); } } } @@ -316,11 +316,11 @@ public class StructureElementUtil { * Populate and return structure element for system group with focus on processed. * * @param systemGroup system group - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(SystemGroup systemGroup, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (systemGroup == null) { return null; } @@ -331,7 +331,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(systemGroup.isLatest() && Status.APPROVED.equals(systemGroup.getStatus())) ? null - : StructureUtil.getMnemonicPath(systemGroup, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(systemGroup, holderStructure); return getStructureElement( systemGroup.getUuid(), @@ -370,11 +370,11 @@ public class StructureElementUtil { * Populate and return structure element for system with focus on processed. * * @param system system - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(System system, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (system == null) { return null; } @@ -385,7 +385,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(system.isLatest() && Status.APPROVED.equals(system.getStatus())) ? null - : StructureUtil.getMnemonicPath(system, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(system, holderStructure); return getStructureElement( system.getUuid(), @@ -424,11 +424,11 @@ public class StructureElementUtil { * Populate and return structure element for subsystem with focus on processed. * * @param subsystem subsystem - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(Subsystem subsystem, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (subsystem == null) { return null; } @@ -439,7 +439,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(subsystem.isLatest() && Status.APPROVED.equals(subsystem.getStatus())) ? null - : StructureUtil.getMnemonicPath(subsystem, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(subsystem, holderStructure); return getStructureElement( subsystem.getUuid(), @@ -479,11 +479,11 @@ public class StructureElementUtil { * Populate and return structure element for discipline with focus on processed. * * @param discipline discipline - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(Discipline discipline, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (discipline == null) { return null; } @@ -494,7 +494,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(discipline.isLatest() && Status.APPROVED.equals(discipline.getStatus())) ? null - : StructureUtil.getMnemonicPath(discipline, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(discipline, holderStructure); return getStructureElement( discipline.getUuid(), @@ -533,11 +533,11 @@ public class StructureElementUtil { * Populate and return structure element for device group with focus on processed. * * @param deviceGroup device group - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(DeviceGroup deviceGroup, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (deviceGroup == null) { return null; } @@ -548,7 +548,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(deviceGroup.isLatest() && Status.APPROVED.equals(deviceGroup.getStatus())) ? null - : StructureUtil.getMnemonicPath(deviceGroup, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(deviceGroup, holderStructure); return getStructureElement( deviceGroup.getUuid(), @@ -587,11 +587,11 @@ public class StructureElementUtil { * Populate and return structure element for device type with focus on processed. * * @param deviceType device type - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure, StructureChoice structureChoice) { + public static StructureElement getStructureElementProcessed(DeviceType deviceType, HolderSystemDeviceStructure holderStructure, StructureChoice structureChoice) { if (deviceType == null) { return null; } @@ -602,7 +602,7 @@ public class StructureElementUtil { // latest & approved status String mnemonicPath = StructureChoice.HISTORY.equals(structureChoice) || !(deviceType.isLatest() && Status.APPROVED.equals(deviceType.getStatus())) ? null - : StructureUtil.getMnemonicPath(deviceType, holderSystemDeviceStructure); + : StructureUtil.getMnemonicPath(deviceType, holderStructure); 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 c5a6dfa1..a87569e9 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 holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(SystemGroup systemGroup, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(systemGroup, holderSystemDeviceStructure)) { + public static String getMnemonicPath(SystemGroup systemGroup, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(systemGroup, holderStructure)) { return null; } @@ -69,11 +69,11 @@ public class StructureUtil { * Return mnemonic path for system. * * @param system system - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(System system, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(system, holderSystemDeviceStructure)) { + public static String getMnemonicPath(System system, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(system, holderStructure)) { return null; } @@ -84,15 +84,15 @@ public class StructureUtil { * Return mnemonic path for subsystem. * * @param subsystem subsystem - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(Subsystem subsystem, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(subsystem, holderSystemDeviceStructure)) { + public static String getMnemonicPath(Subsystem subsystem, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(subsystem, holderStructure)) { return null; } - System system = holderSystemDeviceStructure.findSystemByUuid(subsystem.getParentUuid()); + System system = holderStructure.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 holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(Discipline discipline, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(discipline, holderSystemDeviceStructure)) { + public static String getMnemonicPath(Discipline discipline, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(discipline, holderStructure)) { return null; } @@ -117,15 +117,15 @@ public class StructureUtil { * Return mnemonic path for device group. * * @param deviceGroup device group - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(DeviceGroup deviceGroup, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(deviceGroup, holderSystemDeviceStructure)) { + public static String getMnemonicPath(DeviceGroup deviceGroup, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(deviceGroup, holderStructure)) { return null; } - Discipline discipline = holderSystemDeviceStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); + Discipline discipline = holderStructure.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 holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return mnemonic path */ - public static String getMnemonicPath(DeviceType deviceType, HolderSystemDeviceStructure holderSystemDeviceStructure) { - if (ValidateUtil.isAnyNull(deviceType, holderSystemDeviceStructure)) { + public static String getMnemonicPath(DeviceType deviceType, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(deviceType, holderStructure)) { return null; } - DeviceGroup deviceGroup = holderSystemDeviceStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); + DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); Discipline discipline = deviceGroup != null - ? holderSystemDeviceStructure.findDisciplineByUuid(deviceGroup.getParentUuid()) + ? holderStructure.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 holder holder of containers for system and device structure content + * @param holderStructure 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 holder, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSystemGroup(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, SystemGroup> entry : holder.getUuidSystemGroups().entrySet()) { + for (Entry<UUID, SystemGroup> entry : holderStructure.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 holder holder of containers for system and device structure content + * @param holderStructure 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 holder, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSystem(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, System> entry : holder.getUuidSystems().entrySet()) { + for (Entry<UUID, System> entry : holderStructure.getUuidSystems().entrySet()) { value = entry.getValue().getMnemonic(); if (mnemonicEquivalence) { @@ -205,16 +205,16 @@ public class StructureUtil { /** * Return a list of mnemonic paths for subsystems. * - * @param holder holder of containers for system and device structure content + * @param holderStructure 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 holder, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsSubsystem(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, Subsystem> entry : holder.getUuidSubsystems().entrySet()) { - System system = holder.findSystemByUuid(entry.getValue().getParentUuid()); + for (Entry<UUID, Subsystem> entry : holderStructure.getUuidSubsystems().entrySet()) { + System system = holderStructure.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 holder holder of containers for system and device structure content + * @param holderStructure 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 holder, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsDiscipline(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, Discipline> entry : holder.getUuidDisciplines().entrySet()) { + for (Entry<UUID, Discipline> entry : holderStructure.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 holder holder of containers for system and device structure content + * @param holderStructure 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 holder, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { + public static List<String> getMnemonicPathsDeviceType(HolderSystemDeviceStructure holderStructure, boolean mnemonicEquivalence, EssNamingConvention namingConvention) { List<String> mnemonicPaths = new ArrayList<>(); String value = null; - for (Entry<UUID, DeviceType> entry : holder.getUuidDeviceTypes().entrySet()) { - DeviceGroup deviceGroup = holder.findDeviceGroupByUuid(entry.getValue().getParentUuid()); - Discipline discipline = holder.findDisciplineByUuid(deviceGroup.getParentUuid()); + for (Entry<UUID, DeviceType> entry : holderStructure.getUuidDeviceTypes().entrySet()) { + DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(entry.getValue().getParentUuid()); + Discipline discipline = holderStructure.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 b347fa91..44da60ce 100644 --- a/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateNameElementUtil.java @@ -178,10 +178,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repository - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateNameElementDataCreate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holder) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holder, NameCommand.CREATE); + public static void validateNameElementDataCreate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.CREATE); } /** @@ -191,10 +191,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateNameElementDataUpdate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holder) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holder, NameCommand.UPDATE); + public static void validateNameElementDataUpdate(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.UPDATE); } /** @@ -204,10 +204,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateNameElementDataDelete(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holder) { - validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holder, NameCommand.DELETE); + public static void validateNameElementDataDelete(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure) { + validateNameElementData(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, NameCommand.DELETE); } /** @@ -217,10 +217,10 @@ public class ValidateNameElementUtil { * @param namingConvention naming convention * @param holderIRepositories holder repositories * @param nameRepository name repository - * @param holder holder + * @param holderStructure holder of system and device structure content * @param nameCommand name command */ - private static void validateNameElementData(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holder, NameCommand nameCommand) { + private static void validateNameElementData(NameElementCommand nameElementCommand, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, NameRepository nameRepository, HolderSystemDeviceStructure holderStructure, NameCommand nameCommand) { // command - attributes // create - parentSystemStructure, parentDeviceStructure, index, description, comment // update - uuid, parentSystemStructure, parentDeviceStructure, index, description, comment @@ -233,7 +233,7 @@ public class ValidateNameElementUtil { // ( - system structure uuid, device structure uuid ) // - system structure uuid, device structure uuid, index - if (ValidateUtil.isAnyNull(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holder, nameCommand)) { + if (ValidateUtil.isAnyNull(nameElementCommand, namingConvention, holderIRepositories, nameRepository, holderStructure, nameCommand)) { return; } @@ -300,15 +300,15 @@ public class ValidateNameElementUtil { if (systemGroup != null) { ExceptionUtil.validateConditionDataDeletedException(!systemGroup.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(systemGroup, deviceType, index, holder); + derivedName = NameUtil.getName(systemGroup, deviceType, index, holderStructure); } else if (system != null) { ExceptionUtil.validateConditionDataDeletedException(!system.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(system, deviceType, index, holder); + derivedName = NameUtil.getName(system, deviceType, index, holderStructure); } else if (subsystem != null) { ExceptionUtil.validateConditionDataDeletedException(!subsystem.isDeleted(), TextUtil.DATA_IS_DELETED, details, TextUtil.PARENTSYSTEMSTRUCTURE); - derivedName = NameUtil.getName(subsystem, deviceType, index, holder); + derivedName = NameUtil.getName(subsystem, deviceType, index, holderStructure); } else { throw ExceptionUtil.createDataNotFoundException(TextUtil.DATA_IS_NOT_FOUND, details, TextUtil.PARENTSYSTEMSTRUCTURE); } @@ -363,12 +363,12 @@ public class ValidateNameElementUtil { * @param name name * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content * * @see ValidateUtil#validateNameDataCreate(NameElement, EssNamingConvention, HolderIRepositories, NameRepository, HolderSystemDeviceStructure) */ - public static void validateNameDataCreate(String name, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - if (ValidateUtil.isAnyNull(name, namingConvention, holderRepositories, holder)) { + public static void validateNameDataCreate(String name, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(name, namingConvention, holderRepositories, holderStructure)) { return; } @@ -442,13 +442,13 @@ public class ValidateNameElementUtil { if (ValidateUtil.isSize(subsystems, 1)) { subsystem = subsystems.get(0); - derivedName = NameUtil.getName(subsystem, deviceType, NamingConventionUtil.extractInstanceIndex(name), holder); + derivedName = NameUtil.getName(subsystem, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); } else if (ValidateUtil.isSize(systems, 1)) { system = systems.get(0); - derivedName = NameUtil.getName(system, deviceType, NamingConventionUtil.extractInstanceIndex(name), holder); + derivedName = NameUtil.getName(system, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); } else if (ValidateUtil.isSize(systemGroups, 1)) { systemGroup = systemGroups.get(0); - derivedName = NameUtil.getName(systemGroup, deviceType, NamingConventionUtil.extractInstanceIndex(name), holder); + derivedName = NameUtil.getName(systemGroup, deviceType, NamingConventionUtil.extractInstanceIndex(name), holderStructure); } 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 d8287198..e79a9d79 100644 --- a/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateStructureElementUtil.java @@ -224,11 +224,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataCreate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.CREATE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.CREATE); + public static void validateStructureElementDataCreate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.CREATE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.CREATE); } /** @@ -237,11 +237,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataUpdate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.UPDATE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.UPDATE); + public static void validateStructureElementDataUpdate(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.UPDATE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.UPDATE); } /** @@ -250,11 +250,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataDelete(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.DELETE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.DELETE); + public static void validateStructureElementDataDelete(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.DELETE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.DELETE); } /** @@ -263,11 +263,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataApprove(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.APPROVE); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.APPROVE); + public static void validateStructureElementDataApprove(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.APPROVE); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.APPROVE); } /** @@ -276,11 +276,11 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataCancel(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.CANCEL); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.CANCEL); + public static void validateStructureElementDataCancel(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.CANCEL); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.CANCEL); } /** @@ -289,23 +289,21 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureElementDataReject(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder) { - validateStructureElementDataInItself(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.REJECT); - validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holder, StructureCommand.REJECT); + public static void validateStructureElementDataReject(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure) { + validateStructureElementDataInItself(structureElementCommand, holderRepositories, StructureCommand.REJECT); + validateStructureElementDataRelativeOtherData(structureElementCommand, namingConvention, holderRepositories, holderStructure, StructureCommand.REJECT); } /** * Validate structure element command data in itself. * * @param structureElementCommand structure element command - * @param namingConvention naming convention * @param holderRepositories holder respositories - * @param holder holder * @param structureCommand structure command */ - public static void validateStructureElementDataInItself(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder, StructureCommand structureCommand) { + public static void validateStructureElementDataInItself(StructureElementCommand structureElementCommand, HolderRepositories holderRepositories, StructureCommand structureCommand) { // command - attributes // create - type, parent, name, mnemonic, description, comment // update - uuid, type, parent, name, mnemonic, description, comment @@ -324,7 +322,7 @@ public class ValidateStructureElementUtil { // approve, reject, cancel // uuid - pending, latest, not deleted - list size 1 - if (ValidateUtil.isAnyNull(structureElementCommand, namingConvention, holderRepositories, holder, structureCommand)) { + if (ValidateUtil.isAnyNull(structureElementCommand, holderRepositories, structureCommand)) { return; } @@ -401,10 +399,10 @@ public class ValidateStructureElementUtil { * @param structureElementCommand structure element command * @param namingConvention naming convention * @param holderRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content * @param structureCommand structure command */ - public static void validateStructureElementDataRelativeOtherData(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holder, StructureCommand structureCommand) { + public static void validateStructureElementDataRelativeOtherData(StructureElementCommand structureElementCommand, EssNamingConvention namingConvention, HolderRepositories holderRepositories, HolderSystemDeviceStructure holderStructure, StructureCommand structureCommand) { // command - attributes // create - type, parent, name, mnemonic, description, comment // update - uuid, type, parent, name, mnemonic, description, comment @@ -430,7 +428,7 @@ public class ValidateStructureElementUtil { // additional checks if names are affected // comment not same as previous comment - if (ValidateUtil.isAnyNull(structureElementCommand, namingConvention, holderRepositories, holder, structureCommand)) { + if (ValidateUtil.isAnyNull(structureElementCommand, namingConvention, holderRepositories, holderStructure, structureCommand)) { return; } @@ -753,10 +751,10 @@ public class ValidateStructureElementUtil { * @param mnemonicPath mnemonic path * @param namingConvention naming convention * @param holderIRepositories holder repositories - * @param holder holder + * @param holderStructure holder of system and device structure content */ - public static void validateStructureDataCreate(Type type, String mnemonicPath, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, HolderSystemDeviceStructure holder) { - if (ValidateUtil.isAnyNull(type, mnemonicPath, namingConvention, holderIRepositories, holder)) { + public static void validateStructureDataCreate(Type type, String mnemonicPath, EssNamingConvention namingConvention, HolderIRepositories holderIRepositories, HolderSystemDeviceStructure holderStructure) { + if (ValidateUtil.isAnyNull(type, mnemonicPath, namingConvention, holderIRepositories, holderStructure)) { return; } @@ -793,7 +791,7 @@ public class ValidateStructureElementUtil { // check mnemonic, mnemonic equivalence // mnemonic path system group - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holder, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructure, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -801,7 +799,7 @@ public class ValidateStructureElementUtil { } // mnemonic path equivalence system group - mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holder, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystemGroup(holderStructure, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -809,7 +807,7 @@ public class ValidateStructureElementUtil { } // mnemonic path - mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holder, false, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructure, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -817,7 +815,7 @@ public class ValidateStructureElementUtil { } // mnemonic path equivalence - mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holder, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSystem(holderStructure, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -838,7 +836,7 @@ public class ValidateStructureElementUtil { type, details, field); } - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holder, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructure, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -855,7 +853,7 @@ public class ValidateStructureElementUtil { type, details, field); } - mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holder, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsSubsystem(holderStructure, true, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathequivalenceDuplicate( !StringUtils.equals(mnemonicpathEquivalence, namingConvention.equivalenceClassRepresentative(existingPath)), @@ -895,7 +893,7 @@ public class ValidateStructureElementUtil { // mnemonic path validateStructuresMnemonicpathDuplicate(!StringUtils.equals(path[0], path[1]), type, details, field); - List<String> mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holder, false, namingConvention); + List<String> mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructure, false, namingConvention); for (String existingPath : mnemonicPaths) { validateStructuresMnemonicpathDuplicate( !StringUtils.equals(mnemonicPath, existingPath), @@ -907,7 +905,7 @@ public class ValidateStructureElementUtil { !StringUtils.equals(namingConvention.equivalenceClassRepresentative(path[0]), namingConvention.equivalenceClassRepresentative(path[1])), type, details, field); - mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holder, true, namingConvention); + mnemonicPaths = StructureUtil.getMnemonicPathsDeviceType(holderStructure, 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 25faf35d..d58c03f6 100644 --- a/src/main/java/org/openepics/names/util/notification/NotificationUtil.java +++ b/src/main/java/org/openepics/names/util/notification/NotificationUtil.java @@ -168,16 +168,16 @@ public class NotificationUtil { * @param structureCommandACR structure command (approve cancel reject) * @param previous previous (structure) * @param structure structure - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure 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 holderSystemDeviceStructure) { + Structure previous, Structure structure, HolderSystemDeviceStructure holderStructure) { if (notifications == null) { return; } - NotificationStructure notification = NotificationUtil.prepareNotification(type, structureCommandCUD, structureCommandACR, previous, structure, holderSystemDeviceStructure); + NotificationStructure notification = NotificationUtil.prepareNotification(type, structureCommandCUD, structureCommandACR, previous, structure, holderStructure); 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 holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return notification */ public static NotificationStructure prepareNotification(Type type, StructureCommand structureCommandCUD, StructureCommand structureCommandACR, - Structure previous, Structure structure, HolderSystemDeviceStructure holderSystemDeviceStructure) { + Structure previous, Structure structure, HolderSystemDeviceStructure holderStructure) { 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(holderSystemDeviceStructure, type, structureCommandCUD, structure)) { + if (ValidateUtil.isAnyNull(holderStructure, 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, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) previous, holderStructure); } else if (Type.SYSTEM.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((System) previous, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((System) previous, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) previous, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) previous, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((Discipline) previous, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((Discipline) previous, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) previous, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) previous, holderStructure); } else if (Type.DEVICETYPE.equals(type)) { - oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) previous, holderSystemDeviceStructure); + oldMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) previous, holderStructure); } oldName = StringUtils.stripToEmpty(previous.getName()); @@ -296,17 +296,17 @@ public class NotificationUtil { } if (Type.SYSTEMGROUP.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((SystemGroup) structure, holderStructure); } else if (Type.SYSTEM.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((System) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((System) structure, holderStructure); } else if (Type.SUBSYSTEM.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((Subsystem) structure, holderStructure); } else if (Type.DISCIPLINE.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((Discipline) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((Discipline) structure, holderStructure); } else if (Type.DEVICEGROUP.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((DeviceGroup) structure, holderStructure); } else if (Type.DEVICETYPE.equals(type)) { - newMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) structure, holderSystemDeviceStructure); + newMnemonicpath = StructureUtil.getMnemonicPath((DeviceType) structure, holderStructure); } 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 5c75033b..83fd6703 100644 --- a/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java +++ b/src/main/java/org/openepics/names/util/old/DeviceNameElementUtil.java @@ -51,15 +51,15 @@ public class DeviceNameElementUtil { * Populate and return device name element for name. * * @param name name - * @param holderSystemDeviceStructure holder of containers for system and device structure content + * @param holderStructure holder of system and device structure content * @return device name element */ - public static DeviceNameElement getDeviceNameElement(Name name, HolderSystemDeviceStructure holderSystemDeviceStructure) { + public static DeviceNameElement getDeviceNameElement(Name name, HolderSystemDeviceStructure holderStructure) { if (name == null) { return null; } - // using holder of containers for system and device structure content + // using holder of system and device structure content // for performance reasons to speed up preparation of what is to be returned // find out how to populate return element for system structure, device structure @@ -74,9 +74,9 @@ public class DeviceNameElementUtil { // populate return element for system structure switch (levelSystemStructure) { case 3: { - Subsystem subsystem = holderSystemDeviceStructure.findSubsystemByUuid(name.getSubsystemUuid()); - System system = holderSystemDeviceStructure.findSystemByUuid(subsystem.getParentUuid()); - SystemGroup systemGroup = holderSystemDeviceStructure.findSystemGroupByUuid(system.getParentUuid()); + Subsystem subsystem = holderStructure.findSubsystemByUuid(name.getSubsystemUuid()); + System system = holderStructure.findSystemByUuid(subsystem.getParentUuid()); + SystemGroup systemGroup = holderStructure.findSystemGroupByUuid(system.getParentUuid()); deviceNameElement.setSubsystem(subsystem.getMnemonic()); deviceNameElement.setSystem(system.getMnemonic()); @@ -84,15 +84,15 @@ public class DeviceNameElementUtil { break; } case 2: { - System system = holderSystemDeviceStructure.findSystemByUuid(name.getSystemUuid()); - SystemGroup systemGroup = holderSystemDeviceStructure.findSystemGroupByUuid(system.getParentUuid()); + System system = holderStructure.findSystemByUuid(name.getSystemUuid()); + SystemGroup systemGroup = holderStructure.findSystemGroupByUuid(system.getParentUuid()); deviceNameElement.setSystem(system.getMnemonic()); deviceNameElement.setSystemGroup(systemGroup.getMnemonic()); break; } case 1: { - SystemGroup systemGroup = holderSystemDeviceStructure.findSystemGroupByUuid(name.getSystemGroupUuid()); + SystemGroup systemGroup = holderStructure.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 = holderSystemDeviceStructure.findDeviceTypeByUuid(name.getDeviceTypeUuid()); - DeviceGroup deviceGroup = holderSystemDeviceStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); - Discipline discipline = holderSystemDeviceStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); + DeviceType deviceType = holderStructure.findDeviceTypeByUuid(name.getDeviceTypeUuid()); + DeviceGroup deviceGroup = holderStructure.findDeviceGroupByUuid(deviceType.getParentUuid()); + Discipline discipline = holderStructure.findDisciplineByUuid(deviceGroup.getParentUuid()); deviceNameElement.setDeviceType(deviceType.getMnemonic()); deviceNameElement.setDiscipline(discipline.getMnemonic()); -- GitLab