Skip to content

Commit

Permalink
IQSS#9060 IQSS#7482 review + added i18n on license facet
Browse files Browse the repository at this point in the history
  • Loading branch information
luddaniel committed Jan 18, 2024
1 parent 07b1646 commit 69bace8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
1 change: 0 additions & 1 deletion conf/solr/9.3.0/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@
<!-- incomplete datasets issue 8822 -->
<field name="datasetValid" type="boolean" stored="true" indexed="true" multiValued="false"/>

<!-- license searchable and facetable issues 9060 and 7482 -->
<field name="license" type="string" stored="true" indexed="true" multiValued="false"/>

<!--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Search by License

License facet has been added and will be displayed as long as there is more one license in datasets and datafiles the result page. This facet allow you to filter by license.
Also, Search API does handle license filtering using `fq` parameter, for example : `/api/search?q=*&fq=license%3A%22CC0+1.0%22` for CC0 1.0. See PR #10204
A browse/search facet called "License" has been added and will be displayed as long as there is more than one license in datasets and datafiles in browse/search results. This facet allow you to filter by license such as CC0, etc.
Also, the Search API now handles license filtering using the `fq` parameter, for example : `/api/search?q=*&fq=license%3A%22CC0+1.0%22` for CC0 1.0. See PR #10204


Original file line number Diff line number Diff line change
Expand Up @@ -1617,8 +1617,12 @@ private List<String> getDataversePathsFromSegments(List<String> dataversePathSeg
}

private void addLicenseToSolrDoc(SolrInputDocument solrInputDocument, DatasetVersion datasetVersion) {
if (datasetVersion != null && datasetVersion.getTermsOfUseAndAccess() != null && datasetVersion.getTermsOfUseAndAccess().getLicense() != null) {
solrInputDocument.addField(SearchFields.DATASET_LICENSE, datasetVersion.getTermsOfUseAndAccess().getLicense().getName());
if (datasetVersion != null && datasetVersion.getTermsOfUseAndAccess() != null) {
String licenseName = "Custom Terms";
if(datasetVersion.getTermsOfUseAndAccess().getLicense() != null) {
licenseName = datasetVersion.getTermsOfUseAndAccess().getLicense().getName();
}
solrInputDocument.addField(SearchFields.DATASET_LICENSE, licenseName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,12 @@ public List<String> getFriendlyNamesFromFilterQuery(String filterQuery) {
friendlyNames.add(friendlyName.get());
return friendlyNames;
}
} else if (key.equals(SearchFields.DATASET_LICENSE)) {
try {
friendlyNames.add(BundleUtil.getStringFromPropertyFile("license." + valueWithoutQuotes.toLowerCase().replace(" ","_") + ".name", "License"));
} catch (Exception e) {
logger.fine(String.format("action=getFriendlyNamesFromFilterQuery cannot find friendlyName for key=%s value=%s", key, value));
}
}

friendlyNames.add(valueWithoutQuotes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,13 @@ public SolrQueryResponse search(
}

localefriendlyName = metadataBlockFacet.get().getMetadataBlock().getLocaleDisplayFacet();
} else {
} else if (facetField.getName().equals(SearchFields.DATASET_LICENSE)) {
try {
localefriendlyName = BundleUtil.getStringFromPropertyFile("license." + facetFieldCount.getName().toLowerCase().replace(" ","_") + ".name", "License");
} catch (Exception e) {
localefriendlyName = facetFieldCount.getName();
}
} else {
try {
localefriendlyName = BundleUtil.getStringFromPropertyFile(facetFieldCount.getName(), "Bundle");
} catch (Exception e) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/propertyFiles/License.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ license.cc0_1.0.description=Creative Commons CC0 1.0 Universal Public Domain Ded
license.cc_by_4.0.description=Creative Commons Attribution 4.0 International License.
license.cc0_1.0.name=CC0 1.0
license.cc_by_4.0.name=CC BY 4.0
license.custom_terms.name=Custom Terms

0 comments on commit 69bace8

Please sign in to comment.