Skip to content

Commit

Permalink
Merge pull request #226 from BBMRI-ERIC/fix/access_forms
Browse files Browse the repository at this point in the history
fix: mechanism for combining access forms
  • Loading branch information
RadovanTomik authored Mar 15, 2024
2 parents f59db30 + 4fb543f commit 32a354f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ public void linkElementToSection(
accessFormSectionLink.getAccessFormSectionElementLinks().stream()
.filter(link -> link.getAccessFormElement().equals(element))
.findFirst();
if (sameLink.isPresent()) {
sameLink.get().setRequired(true);
sameLink.get().setElementOrder(elementOrder);
} else {
if (sameLink.isEmpty()) {
accessFormSectionLink.addElementLink(
new AccessFormSectionElementLink(
accessFormSectionLink, element, isRequired, elementOrder));
} else if (isRequired) {
sameLink.get().setRequired(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,10 @@ private static boolean allResourcesHaveTheSameForm(Request request, AccessForm f
.allMatch(resource -> resource.getAccessForm().getName().equals(finalAccessForm.getName()));
}

private static boolean sectionDoesntContainElement(
AccessFormElement accessFormElement, AccessFormSection matchedSection) {
return !matchedSection.getAccessFormElements().contains(accessFormElement);
}

private static boolean formDoesntContainSection(
AccessFormSection accessFormSection, AccessForm accessForm) {
return accessForm.getLinkedSections().stream()
.noneMatch(section -> section.getName().equals(accessFormSection.getName()));
.noneMatch(section -> section.equals(accessFormSection));
}

private AccessFormDTO getCombinedAccessForm(Request request, AccessForm accessForm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void getAccessFormForRequest_differenceInRequiredForElement_setToTrue() {
.getAccessFormElements()
.iterator()
.next();
newAccessForm.linkElementToSection(sameSection, sameElement, 0, !sameElement.isRequired());
newAccessForm.linkElementToSection(sameSection, sameElement, 0, true);
newAccessForm = accessFormRepository.save(newAccessForm);
assertFalse(newAccessForm.getLinkedSections().isEmpty());
resource.setAccessForm(newAccessForm);
Expand Down

0 comments on commit 32a354f

Please sign in to comment.