Skip to content

Commit

Permalink
fix(ecc): Reset Ecc Fields when Component type is changed.
Browse files Browse the repository at this point in the history
Signed-off-by: rudra-superrr <rudra.chopra@siemens.com>
  • Loading branch information
rudra-superrr committed Oct 18, 2022
1 parent 0524e5e commit 9a1dcb4
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class ComponentDatabaseHandler extends AttachmentAwareDatabaseHandler {
private static final String ECC_AUTOSET_COMMENT = "automatically set";
private static final String ECC_AUTOSET_VALUE = "N";
private static final String DEFAULT_CATEGORY = "Default_Category";
private static final String ECC_FIELDS_VALUE_RESET = "";

/**
* Connection to the couchDB database
Expand Down Expand Up @@ -619,6 +620,11 @@ public RequestStatus updateComponent(Component component, User user) throws SW36
if (isComponentNameChanged) {
updateComponentDependentFieldsForRelease(component,referenceDocLogList,user.getEmail());
}

if (component.getComponentType() != null && !component.getComponentType().equals(actual.getComponentType()) && !ComponentType.OSS.equals(component.getComponentType())) {
updateEccStatusForRelease(component);
}

dbHandlerUtil.addChangeLogs(component, actual, user.getEmail(), Operation.UPDATE, attachmentConnector,
referenceDocLogList, null, null);
} else {
Expand Down Expand Up @@ -679,6 +685,17 @@ private void updateComponentDependentFieldsForRelease(Component component, List<
referenceDocLogList.add(changeLog);
}
}

private void updateEccStatusForRelease(Component component) {
for (Release release : releaseRepository.getReleasesFromComponentId(component.getId())) {
EccInformation eccInfo = release.getEccInformation();
eccInfo.setEccStatus(ECCStatus.OPEN);
eccInfo.setAl(ECC_FIELDS_VALUE_RESET);
eccInfo.setEccn(ECC_FIELDS_VALUE_RESET);
eccInfo.setEccComment(ECC_FIELDS_VALUE_RESET);
releaseRepository.update(release);
}
}

private boolean changeWouldResultInDuplicate(Component before, Component after) {
if (before.getName().equals(after.getName())) {
Expand Down

0 comments on commit 9a1dcb4

Please sign in to comment.