Skip to content

Commit

Permalink
Merged in DSC-714 (pull request DSpace#1797)
Browse files Browse the repository at this point in the history
DSC-714 expose the authority in the VocabularyEntryDetails when and only when it should be saved in the metadata

Approved-by: Giuseppe Digilio
  • Loading branch information
abollini authored and atarix83 committed Feb 27, 2024
2 parents 76b843f + ade2999 commit 4a71402
Show file tree
Hide file tree
Showing 10 changed files with 2,402 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public boolean isPublic() {

@Override
public boolean storeAuthorityInMetadata() {
init();
return storeAuthority;
}

Expand Down
3 changes: 2 additions & 1 deletion dspace-api/src/test/data/dspaceFolder/config/local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,5 @@ choices.presentation.dspace.object.owner = suggest
authority.controlled.dspace.object.owner = true

# force the event system to work synchronously during test
system-event.thread.size = 0
system-event.thread.size = 0
vocabulary.plugin.srsc-noauthority.authority.store = false
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import org.dspace.app.rest.RestResourceController;

/**
Expand All @@ -28,6 +30,8 @@ public class VocabularyEntryDetailsRest extends BaseObjectRest<String> {
public static final String CHILDREN = "children";
private String display;
private String value;
@JsonInclude(Include.NON_NULL)
private String authority;
private Map<String, String> otherInformation;
private boolean selectable;
@JsonIgnore
Expand Down Expand Up @@ -60,6 +64,14 @@ public void setValue(String value) {
this.value = value;
}

public void setAuthority(String authority) {
this.authority = authority;
}

public String getAuthority() {
return authority;
}

public static String getName() {
return NAME;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Page<VocabularyEntryDetailsRest> getChildren(@Nullable HttpServletRequest
pageable.getPageSize(), context.getCurrentLocale().toString());
for (Choice value : choices.values) {
results.add(authorityUtils.convertEntryDetails(fix, value, vocabularyName, authority.isHierarchical(),
utils.obtainProjection()));
authority.storeAuthorityInMetadata(), utils.obtainProjection()));
}
Page<VocabularyEntryDetailsRest> resources = new PageImpl<VocabularyEntryDetailsRest>(results, pageable,
choices.total);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public VocabularyEntryDetailsRest getParent(@Nullable HttpServletRequest request
throw new NotFoundException();
}
return authorityUtils.convertEntryDetails(fix, choice, vocabularyName, authority.isHierarchical(),
utils.obtainProjection());
authority.storeAuthorityInMetadata(), utils.obtainProjection());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public VocabularyEntryDetailsRest findOne(Context context, String name) {
fix = true;
}
VocabularyEntryDetailsRest entryDetails = authorityUtils.convertEntryDetails(fix, choice, vocabularyName,
source.isHierarchical(), utils.obtainProjection());
source.isHierarchical(), source.storeAuthorityInMetadata(), utils.obtainProjection());
//FIXME hack to deal with an improper use on the angular side of the node id (otherinformation.id) to
// build a vocabulary entry details ID
if (source instanceof DSpaceControlledVocabulary && !StringUtils.startsWith(vocabularyId, vocabularyName)
Expand Down Expand Up @@ -114,7 +114,7 @@ public Page<VocabularyEntryDetailsRest> findAllTop(@Parameter(value = "vocabular
}
for (Choice value : choices.values) {
results.add(authorityUtils.convertEntryDetails(fix, value, vocabularyId, source.isHierarchical(),
utils.obtainProjection()));
source.storeAuthorityInMetadata(), utils.obtainProjection()));
}
Page<VocabularyEntryDetailsRest> resources = new PageImpl<VocabularyEntryDetailsRest>(results, pageable,
choices.total);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,26 @@ public String getPresentation(String schema, String element, String qualifier) {
/**
* TODO the authorityName MUST be a part of Choice model
*
* @param fix if true mean that we need to deal with a
* DSpaceControlledVocabulary that requires to have the
* vocabulary name in both the authority than in the entry
* id. An entry id with a double vocabulary name would cause issue to angular
* if the vocabulary entry was requested using just one occurrence of the name
* FIXME hack to deal with an improper use on the angular side of the node id
* (otherinformation.id) to build a vocabulary entry details ID
* @param choice
* @param authorityName
* @param projection the name of the projection to use, or {@code null}.
* @param fix if true mean that we need to deal with a
* DSpaceControlledVocabulary that requires to have the
* vocabulary name in both the authority than in the entry
* id. An entry id with a double vocabulary name would
* cause issue to angular if the vocabulary entry was
* requested using just one occurrence of the name FIXME
* hack to deal with an improper use on the angular side
* of the node id (otherinformation.id) to build a
* vocabulary entry details ID
* @param choice the choice to convert
* @param authorityName the name of the authority to which the choice belongs
* @param isHierarchical <code>true</code> if it is an hierarchical vocabulary
* @param storeAuthority <code>true</code> if the authority is configured to store the
* authority in the metadata
* {@link ChoiceAuthority#storeAuthorityInMetadata()}
* @param projection the name of the projection to use, or {@code null}.
* @return
*/
public VocabularyEntryDetailsRest convertEntryDetails(boolean fix, Choice choice, String authorityName,
boolean isHierarchical, Projection projection) {
boolean isHierarchical, boolean storeAuthority, Projection projection) {
if (choice == null) {
return null;
}
Expand All @@ -98,6 +103,9 @@ public VocabularyEntryDetailsRest convertEntryDetails(boolean fix, Choice choice
if (!fix) {
entry.setId(authorityName + ":" + entry.getId());
}
if (storeAuthority) {
entry.setAuthority(choice.authority);
}
entry.setInHierarchicalVocabulary(isHierarchical);
return entry;
}
Expand Down
Loading

0 comments on commit 4a71402

Please sign in to comment.