Skip to content

Commit

Permalink
Merge branch 'dspace-cris-7-orcid-metadata-visibility' into dspace-cr…
Browse files Browse the repository at this point in the history
…is-7
  • Loading branch information
atarix83 committed Nov 16, 2023
2 parents b6282cc + 5fd4e5f commit 18cc1aa
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ public abstract class AbstractOrcidProfileSectionFactory implements OrcidProfile

protected final OrcidProfileSyncPreference preference;

protected Integer maxAllowedMetadataVisibility = 0;

@Autowired
protected ItemService itemService;

@@ -70,4 +72,17 @@ protected List<MetadataValue> getMetadataValues(Item item, String metadataField)
return itemService.getMetadataByMetadataString(item, metadataField);
}

protected boolean isAllowedMetadataByVisibility(MetadataValue metadataValue) {
return metadataValue.getSecurityLevel() == null
|| metadataValue.getSecurityLevel() <= getMaxAllowedMetadataVisibility();
}

public Integer getMaxAllowedMetadataVisibility() {
return maxAllowedMetadataVisibility;
}

public void setMaxAllowedMetadataVisibility(Integer maxAllowedMetadataVisibility) {
this.maxAllowedMetadataVisibility = maxAllowedMetadataVisibility;
}

}
Original file line number Diff line number Diff line change
@@ -93,7 +93,13 @@ public List<String> getMetadataSignatures(Context context, Item item) {
int groupSize = metadataGroups.getOrDefault(organizationField, Collections.emptyList()).size();
for (int currentGroupIndex = 0; currentGroupIndex < groupSize; currentGroupIndex++) {
List<MetadataValue> metadataValues = getMetadataValueByPlace(metadataGroups, currentGroupIndex);
signatures.add(metadataSignatureGenerator.generate(context, metadataValues));
//only "visible" metadatavalues within this group
metadataValues = metadataValues.stream()
.filter(metadataValue -> isAllowedMetadataByVisibility(metadataValue))
.collect(Collectors.toList());
if (!metadataValues.isEmpty()) {
signatures.add(metadataSignatureGenerator.generate(context, metadataValues));
}
}

return signatures;
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ public Object create(Context context, List<MetadataValue> metadataValues) {
public List<String> getMetadataSignatures(Context context, Item item) {
return metadataFields.stream()
.flatMap(metadataField -> getMetadataValues(item, metadataField).stream())
.filter(metadataValue -> isAllowedMetadataByVisibility(metadataValue))
.map(metadataValue -> metadataSignatureGenerator.generate(context, List.of(metadataValue)))
.collect(Collectors.toList());
}

0 comments on commit 18cc1aa

Please sign in to comment.