Skip to content
Snippets Groups Projects
Commit 154d8498 authored by Lars Johansson's avatar Lars Johansson
Browse files

Fix issue for verification of data migration for structures, refactor verification, improve javadoc

Fix issue for verification of data migration for structures.
Refactor verification for readability.
Improve javadoc.
parent e9db6c7d
No related branches found
No related tags found
No related merge requests found
Pipeline #152221 passed
...@@ -47,12 +47,14 @@ import org.openepics.names.repository.model.DeviceGroup; ...@@ -47,12 +47,14 @@ import org.openepics.names.repository.model.DeviceGroup;
import org.openepics.names.repository.model.DeviceType; import org.openepics.names.repository.model.DeviceType;
import org.openepics.names.repository.model.Discipline; import org.openepics.names.repository.model.Discipline;
import org.openepics.names.repository.model.Name; import org.openepics.names.repository.model.Name;
import org.openepics.names.repository.model.Structure;
import org.openepics.names.repository.model.Subsystem; import org.openepics.names.repository.model.Subsystem;
import org.openepics.names.repository.model.System; import org.openepics.names.repository.model.System;
import org.openepics.names.repository.model.SystemGroup; import org.openepics.names.repository.model.SystemGroup;
import org.openepics.names.repository.old.IDeviceRevisionRepository; import org.openepics.names.repository.old.IDeviceRevisionRepository;
import org.openepics.names.repository.old.INamePartRevisionRepository; import org.openepics.names.repository.old.INamePartRevisionRepository;
import org.openepics.names.util.HolderIRepositories; import org.openepics.names.util.HolderIRepositories;
import org.openepics.names.util.ValidateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -116,8 +118,8 @@ import io.swagger.v3.oas.annotations.Hidden; ...@@ -116,8 +118,8 @@ import io.swagger.v3.oas.annotations.Hidden;
* Note * Note
* <ul> * <ul>
* <li>log statements and output are technical and implementation-like, and meant to give detailed information</li> * <li>log statements and output are technical and implementation-like, and meant to give detailed information</li>
* <li>after migration has been done and verified, this part of REST API no longer holds any function and may be removed. * <li>after migration has been done and verified, this part of REST API no longer holds any function and may be removed
* As a suggestion, this may done in the second release of the software.</li> * together with related code not used elsewhere. As a suggestion, this may done in the second release of the software.</li>
* </ul> * </ul>
* *
* <p> * <p>
...@@ -199,32 +201,10 @@ public class VerificationController { ...@@ -199,32 +201,10 @@ public class VerificationController {
// all entries ok // all entries ok
// no entry nok // no entry nok
// check // e.g. if there has been usage of new database tables (new entries) before verification, there are more rows in those tables
// check entry by entry // which means new and more ids than in old database tables
// each attribute as expected // which means those new ids don't exist in old database tables
// ---------- // --> retrieval of device revisions for those ids will give null
// to check parent uuid
// ----------
// date may be in different format for different objects, to be formatted before being compared
// ----------
// e.g.
// system.id = namepartrevision.id
// system.version = namepartrevision.version
// system.uuid = namepartrevision.namepart_id (namepart.id --> namepart.uuid)
// ( system.parent_uuid = namepartrevision.parent_id (namepart.id --> namepart.uuid) )
// system.name = namepartrevision.name
// system.mnemonic = namepartrevision.mnemonic
// system.mnemonic_equivalence = namepartrevision.mnemoniceqclass
// system.description = namepartrevision.description
// system.status = namepartrevision.status
// system.latest = true if id = get max id for uuid (consider status, but not PENDING)
// system.deleted = namepartrevision.deleted
// system.requested = namepartrevision.requestdate
// system.requested_by = namepartrevision.requestedby_id (useraccount.id --> useraccount.username)
// system.requested_comment = namepartrevision.requestercomment
// system.processed = namepartrevision.processdate
// system.processed_by = namepartrevision.processedby_id (useraccount.id --> useraccount.username)
// system.processed_comment = namepartrevision.processorcomment
StringBuilder reportHtml = new StringBuilder(); StringBuilder reportHtml = new StringBuilder();
...@@ -336,37 +316,9 @@ public class VerificationController { ...@@ -336,37 +316,9 @@ public class VerificationController {
for (SystemGroup systemGroup : systemGroups) { for (SystemGroup systemGroup : systemGroups) {
namePartRevision = mapIdNamePartRevision.get(systemGroup.getId()); namePartRevision = mapIdNamePartRevision.get(systemGroup.getId());
check = namePartRevision != null; // no check for parent uuid
check = namePartRevision != null
check = check && systemGroup.getId().equals(namePartRevision.getId()); && equals(systemGroup, namePartRevision, mapUuidMaxIdSystemGroup);
check = check && systemGroup.getVersion().equals(namePartRevision.getVersion());
check = check && systemGroup.getUuid().equals(namePartRevision.getNamePart().getUuid());
// no parent uuid for system group
check = check && StringUtils.equals(systemGroup.getName(), namePartRevision.getName());
check = check && StringUtils.equals(systemGroup.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(systemGroup.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(systemGroup.getDescription(), namePartRevision.getDescription());
check = check && ((systemGroup.getStatus() == null && namePartRevision.getStatus() == null)
|| (systemGroup.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && systemGroup.isLatest() == systemGroup.getId().equals(mapUuidMaxIdSystemGroup.get(systemGroup.getUuid()));
check = check && systemGroup.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((systemGroup.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(systemGroup.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (systemGroup.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(systemGroup.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(systemGroup.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((systemGroup.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(systemGroup.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (systemGroup.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(systemGroup.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(systemGroup.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -384,38 +336,9 @@ public class VerificationController { ...@@ -384,38 +336,9 @@ public class VerificationController {
for (System system : systems) { for (System system : systems) {
namePartRevision = mapIdNamePartRevision.get(system.getId()); namePartRevision = mapIdNamePartRevision.get(system.getId());
check = namePartRevision != null; check = namePartRevision != null
&& equals(system, namePartRevision, mapUuidMaxIdSystem)
check = check && system.getId().equals(namePartRevision.getId()); && system.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && system.getVersion().equals(namePartRevision.getVersion());
check = check && system.getUuid().equals(namePartRevision.getNamePart().getUuid());
// parent uuid
check = check && system.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && StringUtils.equals(system.getName(), namePartRevision.getName());
check = check && StringUtils.equals(system.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(system.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(system.getDescription(), namePartRevision.getDescription());
check = check && ((system.getStatus() == null && namePartRevision.getStatus() == null)
|| (system.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && system.isLatest() == system.getId().equals(mapUuidMaxIdSystem.get(system.getUuid()));
check = check && system.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((system.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(system.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (system.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(system.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(system.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((system.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(system.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (system.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(system.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(system.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -433,38 +356,9 @@ public class VerificationController { ...@@ -433,38 +356,9 @@ public class VerificationController {
for (Subsystem subsystem : subsystems) { for (Subsystem subsystem : subsystems) {
namePartRevision = mapIdNamePartRevision.get(subsystem.getId()); namePartRevision = mapIdNamePartRevision.get(subsystem.getId());
check = namePartRevision != null; check = namePartRevision != null
&& equals(subsystem, namePartRevision, mapUuidMaxIdSubsystem)
check = check && subsystem.getId().equals(namePartRevision.getId()); && subsystem.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && subsystem.getVersion().equals(namePartRevision.getVersion());
check = check && subsystem.getUuid().equals(namePartRevision.getNamePart().getUuid());
// parent uuid
check = check && subsystem.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && StringUtils.equals(subsystem.getName(), namePartRevision.getName());
check = check && StringUtils.equals(subsystem.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(subsystem.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(subsystem.getDescription(), namePartRevision.getDescription());
check = check && ((subsystem.getStatus() == null && namePartRevision.getStatus() == null)
|| (subsystem.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && subsystem.isLatest() == subsystem.getId().equals(mapUuidMaxIdSubsystem.get(subsystem.getUuid()));
check = check && subsystem.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((subsystem.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(subsystem.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (subsystem.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(subsystem.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(subsystem.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((subsystem.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(subsystem.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (subsystem.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(subsystem.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(subsystem.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -482,37 +376,9 @@ public class VerificationController { ...@@ -482,37 +376,9 @@ public class VerificationController {
for (Discipline discipline : disciplines) { for (Discipline discipline : disciplines) {
namePartRevision = mapIdNamePartRevision.get(discipline.getId()); namePartRevision = mapIdNamePartRevision.get(discipline.getId());
check = namePartRevision != null; // no check for parent uuid
check = namePartRevision != null
check = check && discipline.getId().equals(namePartRevision.getId()); && equals(discipline, namePartRevision, mapUuidMaxIdDiscipline);
check = check && discipline.getVersion().equals(namePartRevision.getVersion());
check = check && discipline.getUuid().equals(namePartRevision.getNamePart().getUuid());
// no parent uuid for discipline
check = check && StringUtils.equals(discipline.getName(), namePartRevision.getName());
check = check && StringUtils.equals(discipline.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(discipline.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(discipline.getDescription(), namePartRevision.getDescription());
check = check && ((discipline.getStatus() == null && namePartRevision.getStatus() == null)
|| (discipline.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && discipline.isLatest() == discipline.getId().equals(mapUuidMaxIdDiscipline.get(discipline.getUuid()));
check = check && discipline.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((discipline.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(discipline.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (discipline.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(discipline.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(discipline.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((discipline.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(discipline.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (discipline.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(discipline.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(discipline.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -530,38 +396,9 @@ public class VerificationController { ...@@ -530,38 +396,9 @@ public class VerificationController {
for (DeviceGroup deviceGroup : deviceGroups) { for (DeviceGroup deviceGroup : deviceGroups) {
namePartRevision = mapIdNamePartRevision.get(deviceGroup.getId()); namePartRevision = mapIdNamePartRevision.get(deviceGroup.getId());
check = namePartRevision != null; check = namePartRevision != null
&& equals(deviceGroup, namePartRevision, mapUuidMaxIdDeviceGroup)
check = check && deviceGroup.getId().equals(namePartRevision.getId()); && deviceGroup.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && deviceGroup.getVersion().equals(namePartRevision.getVersion());
check = check && deviceGroup.getUuid().equals(namePartRevision.getNamePart().getUuid());
// parent uuid
check = check && deviceGroup.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && StringUtils.equals(deviceGroup.getName(), namePartRevision.getName());
check = check && StringUtils.equals(deviceGroup.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(deviceGroup.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(deviceGroup.getDescription(), namePartRevision.getDescription());
check = check && ((deviceGroup.getStatus() == null && namePartRevision.getStatus() == null)
|| (deviceGroup.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && deviceGroup.isLatest() == deviceGroup.getId().equals(mapUuidMaxIdDeviceGroup.get(deviceGroup.getUuid()));
check = check && deviceGroup.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((deviceGroup.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(deviceGroup.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (deviceGroup.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(deviceGroup.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(deviceGroup.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((deviceGroup.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(deviceGroup.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (deviceGroup.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(deviceGroup.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(deviceGroup.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -579,38 +416,9 @@ public class VerificationController { ...@@ -579,38 +416,9 @@ public class VerificationController {
for (DeviceType deviceType : deviceTypes) { for (DeviceType deviceType : deviceTypes) {
namePartRevision = mapIdNamePartRevision.get(deviceType.getId()); namePartRevision = mapIdNamePartRevision.get(deviceType.getId());
check = namePartRevision != null; check = namePartRevision != null
&& equals(deviceType, namePartRevision, mapUuidMaxIdDeviceType)
check = check && deviceType.getId().equals(namePartRevision.getId()); && deviceType.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && deviceType.getVersion().equals(namePartRevision.getVersion());
check = check && deviceType.getUuid().equals(namePartRevision.getNamePart().getUuid());
// parent uuid
check = check && deviceType.getParentUuid().equals(namePartRevision.getParent().getUuid());
check = check && StringUtils.equals(deviceType.getName(), namePartRevision.getName());
check = check && StringUtils.equals(deviceType.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(deviceType.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(deviceType.getDescription(), namePartRevision.getDescription());
check = check && ((deviceType.getStatus() == null && namePartRevision.getStatus() == null)
|| (deviceType.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && deviceType.isLatest() == deviceType.getId().equals(mapUuidMaxIdDeviceType.get(deviceType.getUuid()));
check = check && deviceType.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((deviceType.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(deviceType.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (deviceType.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(deviceType.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(deviceType.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((deviceType.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(deviceType.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (deviceType.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(deviceType.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(deviceType.getProcessedComment(), namePartRevision.getProcessorComment());
// add to count // add to count
if (check) { if (check) {
...@@ -661,35 +469,10 @@ public class VerificationController { ...@@ -661,35 +469,10 @@ public class VerificationController {
// all entries ok // all entries ok
// no entry nok // no entry nok
// check // e.g. if there has been usage of new database tables (new entries) before verification, there are more rows in those tables
// check entry by entry // which means new and more ids than in old database tables
// each attribute as expected // which means those new ids don't exist in old database tables
// ---------- // --> retrieval of device revisions for those ids will give null
// to check 1st, 2nd, 3rd parent to determine if systemgroup, system or subsystem
// otherwise not clear how to make sure if it is supposed to be systemgroup and not system, subsystem and vice versa
// ----------
// date may be in different format for different objects, to be formatted before being compared
// ----------
// name.id = devicerevision.id
// name.version = devicerevision.version
// name.uuid = devicerevision.device_id (device.id --> device.uuid)
// name.namepartrevision_systemgroup_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_system_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_subsystem_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_devicetype_uuid = devicerevision.devicetype_id (namepart.id --> namepart.uuid
// name.instance_index = devicerevision.instanceindex
// name.convention_name = devicerevision.conventionname
// name.convention_name_equivalence = devicerevision.conventionnameeqclass
// name.description = devicerevision.additionalinfo
// name.status = null
// name.latest = true if id = get max id for uuid (not consider status)
// name.deleted = devicerevision.deleted
// name.requested = devicerevision.requestdate
// name.requested_by = devicerevision.requestedby_id (useraccount.id --> useraccount.username)
// name.requested_comment = null
// name.processed = null
// name.processed_by = null
// name.processed_comment = devicerevision.processorcomment
StringBuilder reportHtml = new StringBuilder(); StringBuilder reportHtml = new StringBuilder();
...@@ -747,70 +530,10 @@ public class VerificationController { ...@@ -747,70 +530,10 @@ public class VerificationController {
DeviceRevision deviceRevision = null; DeviceRevision deviceRevision = null;
try { try {
for (Name name : names) { for (Name name : names) {
// e.g. if there has been usage of new database tables (new entries) before verification, there are more rows in those tables
// which means new and more ids than in old database tables
// which means those new ids don't exist in old database tables
// --> retrieval of device revisions for those ids will give null
deviceRevision = mapIdDeviceRevision.get(name.getId()); deviceRevision = mapIdDeviceRevision.get(name.getId());
check = deviceRevision != null;
if (check) { check = deviceRevision != null
check = check && name.getId().equals(deviceRevision.getId()); && equals(name, deviceRevision, mapUuidMaxIdName, mapUuidNamePartRevision);
check = check && name.getVersion().equals(deviceRevision.getVersion());
check = check && name.getUuid().equals(deviceRevision.getDevice().getUuid());
// to check 1st, 2nd, 3rd parent to determine if systemgroup, system or subsystem
// otherwise not clear how to make sure if it is supposed to be systemgroup and not system, subsystem and vice versa
NamePartRevision parent1 = deviceRevision.getSection() != null
? mapUuidNamePartRevision.get(deviceRevision.getSection().getUuid())
: null;
NamePartRevision parent2 = parent1 != null && parent1.getParent() != null
? mapUuidNamePartRevision.get(parent1.getParent().getUuid())
: null;
NamePartRevision parent3 = parent2 != null && parent2.getParent() != null
? mapUuidNamePartRevision.get(parent2.getParent().getUuid())
: null;
// parent 1 but not parent 2, 3 - system group
// parent 1, 2 but not parent 3 - system
// parent 1, 2, 3 - subsystem
// else nok
UUID systemGroupUuid = name.getSystemGroupUuid();
UUID systemUuid = name.getSystemUuid();
UUID subsystemUuid = name.getSubsystemUuid();
UUID sectionUuid = deviceRevision.getSection().getUuid();
if (parent1 != null && parent2 == null && parent3 == null) {
check = check && sectionUuid.equals(systemGroupUuid) && systemUuid == null && subsystemUuid == null;
} else if (parent1 != null && parent2 != null && parent3 == null) {
check = check && sectionUuid.equals(systemUuid) && systemGroupUuid == null && subsystemUuid == null;
} else if (parent1 != null && parent2 != null && parent3 != null) {
check = check && sectionUuid.equals(subsystemUuid) && systemGroupUuid == null && systemUuid == null;
} else {
check = false;
}
check = check && ((name.getDeviceTypeUuid() == null && deviceRevision.getDeviceType() == null)
|| (name.getDeviceTypeUuid().equals(deviceRevision.getDeviceType().getUuid())));
check = check && StringUtils.equals(name.getInstanceIndex(), deviceRevision.getInstanceIndex());
check = check && StringUtils.equals(name.getConventionName(), deviceRevision.getConventionName());
check = check && StringUtils.equals(name.getConventionNameEquivalence(), deviceRevision.getConventionNameEqClass());
check = check && StringUtils.equals(name.getDescription(), deviceRevision.getAdditionalInfo());
check = check && name.getStatus() == null;
// latest
// true if id = get max id for uuid
check = check && name.isLatest() == name.getId().equals(mapUuidMaxIdName.get(name.getUuid()));
check = check && name.isDeleted() == deviceRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((name.getRequested() == null && deviceRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(name.getRequested()), SDF.format(deviceRevision.getRequestDate())));
check = check && StringUtils.equals(name.getRequestedBy(), deviceRevision.getRequestedBy().getUsername());
check = check && name.getRequestedComment() == null;
check = check && name.getProcessed() == null;
check = check && name.getProcessedBy() == null;
check = check && StringUtils.equals(name.getProcessedComment(), deviceRevision.getProcessorComment());
}
// add to count // add to count
if (check) { if (check) {
...@@ -1104,4 +827,180 @@ public class VerificationController { ...@@ -1104,4 +827,180 @@ public class VerificationController {
} }
} }
/**
* Utility method to compare Structure with NamePartRevision.
* No check for parent uuid in this method.
*
* @param structure structure
* @param namePartRevision name part revision
* @param mapUuidMaxId map with max id for APPROVED entry in line of uuid for structure
* @return
*/
private boolean equals(Structure structure, NamePartRevision namePartRevision, HashMap<UUID, Long> mapUuidMaxId) {
// check
// check entry by entry
// each attribute as expected
// ----------
// to check parent uuid
// ----------
// date may be in different format for different objects, to be formatted before being compared
// ----------
// e.g.
// system.id = namepartrevision.id
// system.version = namepartrevision.version
// system.uuid = namepartrevision.namepart_id (namepart.id --> namepart.uuid)
// ( system.parent_uuid = namepartrevision.parent_id (namepart.id --> namepart.uuid) )
// system.name = namepartrevision.name
// system.mnemonic = namepartrevision.mnemonic
// system.mnemonic_equivalence = namepartrevision.mnemoniceqclass
// system.description = namepartrevision.description
// system.status = namepartrevision.status
// system.latest = true if id = get max id for uuid (consider status, but not PENDING)
// system.deleted = namepartrevision.deleted
// system.requested = namepartrevision.requestdate
// system.requested_by = namepartrevision.requestedby_id (useraccount.id --> useraccount.username)
// system.requested_comment = namepartrevision.requestercomment
// system.processed = namepartrevision.processdate
// system.processed_by = namepartrevision.processedby_id (useraccount.id --> useraccount.username)
// system.processed_comment = namepartrevision.processorcomment
if (ValidateUtil.isAnyNull(structure, namePartRevision, mapUuidMaxId)) {
return false;
}
boolean check = structure.getId().equals(namePartRevision.getId());
check = check && structure.getVersion().equals(namePartRevision.getVersion());
check = check && structure.getUuid().equals(namePartRevision.getNamePart().getUuid());
// no check for parent uuid in this method
check = check && StringUtils.equals(structure.getName(), namePartRevision.getName());
check = check && StringUtils.equals(structure.getMnemonic(), namePartRevision.getMnemonic());
check = check && StringUtils.equals(structure.getMnemonicEquivalence(), namePartRevision.getMnemonicEqClass());
check = check && StringUtils.equals(structure.getDescription(), namePartRevision.getDescription());
check = check && ((structure.getStatus() == null && namePartRevision.getStatus() == null)
|| (structure.getStatus().name().equals(namePartRevision.getStatus().name())));
// latest
// true if id = get max id for uuid
// special rules for pending, not consider pending
check = check && structure.isLatest() == structure.getId().equals(mapUuidMaxId.get(structure.getUuid()));
check = check && structure.isDeleted() == namePartRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((structure.getRequested() == null && namePartRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(structure.getRequested()), SDF.format(namePartRevision.getRequestDate())));
check = check && (structure.getRequestedBy() == null && namePartRevision.getRequestedBy() == null
|| StringUtils.equals(structure.getRequestedBy(), namePartRevision.getRequestedBy().getUsername()));
check = check && StringUtils.equals(structure.getRequestedComment(), namePartRevision.getRequesterComment());
check = check && ((structure.getProcessed() == null && namePartRevision.getProcessDate() == null)
|| StringUtils.equals(SDF.format(structure.getProcessed()), SDF.format(namePartRevision.getProcessDate())));
check = check && (structure.getProcessedBy() == null && namePartRevision.getProcessedBy() == null
|| StringUtils.equals(structure.getProcessedBy(), namePartRevision.getProcessedBy().getUsername()));
check = check && StringUtils.equals(structure.getProcessedComment(), namePartRevision.getProcessorComment());
return check;
}
/**
* Utility method to compare Name with DeviceRevision.
*
* @param name name
* @param deviceRevision device revision
* @param mapUuidMaxIdName map with max id for entry in line of uuid for name
* @param mapUuidNamePartRevision map with uuid for name part revision
* @return
*/
private boolean equals(Name name, DeviceRevision deviceRevision, HashMap<UUID, Long> mapUuidMaxIdName, HashMap<UUID, NamePartRevision> mapUuidNamePartRevision) {
// check
// check entry by entry
// each attribute as expected
// ----------
// to check 1st, 2nd, 3rd parent to determine if systemgroup, system or subsystem
// otherwise not clear how to make sure if it is supposed to be systemgroup and not system, subsystem and vice versa
// ----------
// date may be in different format for different objects, to be formatted before being compared
// ----------
// name.id = devicerevision.id
// name.version = devicerevision.version
// name.uuid = devicerevision.device_id (device.id --> device.uuid)
// name.namepartrevision_systemgroup_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_system_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_subsystem_uuid = devicerevision.section_id (namepart.id --> namepart.uuid
// name.namepartrevision_devicetype_uuid = devicerevision.devicetype_id (namepart.id --> namepart.uuid
// name.instance_index = devicerevision.instanceindex
// name.convention_name = devicerevision.conventionname
// name.convention_name_equivalence = devicerevision.conventionnameeqclass
// name.description = devicerevision.additionalinfo
// name.status = null
// name.latest = true if id = get max id for uuid (not consider status)
// name.deleted = devicerevision.deleted
// name.requested = devicerevision.requestdate
// name.requested_by = devicerevision.requestedby_id (useraccount.id --> useraccount.username)
// name.requested_comment = null
// name.processed = null
// name.processed_by = null
// name.processed_comment = devicerevision.processorcomment
if (ValidateUtil.isAnyNull(name, deviceRevision, mapUuidMaxIdName)) {
return false;
}
boolean check = name.getId().equals(deviceRevision.getId());
check = check && name.getVersion().equals(deviceRevision.getVersion());
check = check && name.getUuid().equals(deviceRevision.getDevice().getUuid());
// to check 1st, 2nd, 3rd parent to determine if systemgroup, system or subsystem
// otherwise not clear how to make sure if it is supposed to be systemgroup and not system, subsystem and vice versa
NamePartRevision parent1 = deviceRevision.getSection() != null
? mapUuidNamePartRevision.get(deviceRevision.getSection().getUuid())
: null;
NamePartRevision parent2 = parent1 != null && parent1.getParent() != null
? mapUuidNamePartRevision.get(parent1.getParent().getUuid())
: null;
NamePartRevision parent3 = parent2 != null && parent2.getParent() != null
? mapUuidNamePartRevision.get(parent2.getParent().getUuid())
: null;
// parent 1 but not parent 2, 3 - system group
// parent 1, 2 but not parent 3 - system
// parent 1, 2, 3 - subsystem
// else nok
UUID systemGroupUuid = name.getSystemGroupUuid();
UUID systemUuid = name.getSystemUuid();
UUID subsystemUuid = name.getSubsystemUuid();
UUID sectionUuid = deviceRevision.getSection().getUuid();
if (parent1 != null && parent2 == null && parent3 == null) {
check = check && sectionUuid.equals(systemGroupUuid) && systemUuid == null && subsystemUuid == null;
} else if (parent1 != null && parent2 != null && parent3 == null) {
check = check && sectionUuid.equals(systemUuid) && systemGroupUuid == null && subsystemUuid == null;
} else if (parent1 != null && parent2 != null && parent3 != null) {
check = check && sectionUuid.equals(subsystemUuid) && systemGroupUuid == null && systemUuid == null;
} else {
check = false;
}
check = check && ((name.getDeviceTypeUuid() == null && deviceRevision.getDeviceType() == null)
|| (name.getDeviceTypeUuid().equals(deviceRevision.getDeviceType().getUuid())));
check = check && StringUtils.equals(name.getInstanceIndex(), deviceRevision.getInstanceIndex());
check = check && StringUtils.equals(name.getConventionName(), deviceRevision.getConventionName());
check = check && StringUtils.equals(name.getConventionNameEquivalence(), deviceRevision.getConventionNameEqClass());
check = check && StringUtils.equals(name.getDescription(), deviceRevision.getAdditionalInfo());
check = check && name.getStatus() == null;
// latest
// true if id = get max id for uuid
check = check && name.isLatest() == name.getId().equals(mapUuidMaxIdName.get(name.getUuid()));
check = check && name.isDeleted() == deviceRevision.isDeleted();
// date may be in different format for different objects, to be formatted before being compared
check = check && ((name.getRequested() == null && deviceRevision.getRequestDate() == null)
|| StringUtils.equals(SDF.format(name.getRequested()), SDF.format(deviceRevision.getRequestDate())));
check = check && StringUtils.equals(name.getRequestedBy(), deviceRevision.getRequestedBy().getUsername());
check = check && name.getRequestedComment() == null;
check = check && name.getProcessed() == null;
check = check && name.getProcessedBy() == null;
check = check && StringUtils.equals(name.getProcessedComment(), deviceRevision.getProcessorComment());
return check;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment