Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse-by support for controlled vocabularies
- Loading branch information
1 parent
4cdb662
commit 66eb8a5
Showing
13 changed files
with
288 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabularyIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.content.authority; | ||
|
||
import java.util.Set; | ||
|
||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet; | ||
|
||
/** | ||
* Helper class to transform a {@link org.dspace.content.authority.DSpaceControlledVocabulary} into a | ||
* {@code BrowseIndexRest} | ||
* cached by {@link org.dspace.content.authority.service.ChoiceAuthorityService#getVocabularyIndex(String)} | ||
* | ||
* @author Marie Verdonck (Atmire) on 04/05/2023 | ||
*/ | ||
public class DSpaceControlledVocabularyIndex { | ||
|
||
protected DSpaceControlledVocabulary vocabulary; | ||
protected Set<String> metadataFields; | ||
protected DiscoverySearchFilterFacet facetConfig; | ||
|
||
public DSpaceControlledVocabularyIndex(DSpaceControlledVocabulary controlledVocabulary, Set<String> metadataFields, | ||
DiscoverySearchFilterFacet facetConfig) { | ||
this.vocabulary = controlledVocabulary; | ||
this.metadataFields = metadataFields; | ||
this.facetConfig = facetConfig; | ||
} | ||
|
||
public DSpaceControlledVocabulary getVocabulary() { | ||
return vocabulary; | ||
} | ||
|
||
public Set<String> getMetadataFields() { | ||
return this.metadataFields; | ||
} | ||
|
||
public DiscoverySearchFilterFacet getFacetConfig() { | ||
return this.facetConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...erver-webapp/src/main/java/org/dspace/app/rest/converter/HierarchicalBrowseConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.converter; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.dspace.app.rest.model.BrowseIndexRest; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.dspace.content.authority.DSpaceControlledVocabularyIndex; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* This is the converter from a {@link org.dspace.content.authority.DSpaceControlledVocabularyIndex} to a | ||
* {@link org.dspace.app.rest.model.BrowseIndexRest#BROWSE_TYPE_HIERARCHICAL} {@link org.dspace.app.rest.model.BrowseIndexRest} | ||
* | ||
* @author Marie Verdonck (Atmire) on 04/05/2023 | ||
*/ | ||
@Component | ||
public class HierarchicalBrowseConverter implements DSpaceConverter<DSpaceControlledVocabularyIndex, BrowseIndexRest> { | ||
|
||
@Override | ||
public BrowseIndexRest convert(DSpaceControlledVocabularyIndex obj, Projection projection) { | ||
BrowseIndexRest bir = new BrowseIndexRest(); | ||
bir.setProjection(projection); | ||
bir.setId(obj.getVocabulary().getPluginInstanceName()); | ||
bir.setBrowseType(BrowseIndexRest.BROWSE_TYPE_HIERARCHICAL); | ||
bir.setFacetType(obj.getFacetConfig().getIndexFieldName()); | ||
bir.setVocabulary(obj.getVocabulary().getPluginInstanceName()); | ||
bir.setMetadataList(new ArrayList<>(obj.getMetadataFields())); | ||
return bir; | ||
} | ||
|
||
@Override | ||
public Class<DSpaceControlledVocabularyIndex> getModelClass() { | ||
return DSpaceControlledVocabularyIndex.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.