Skip to content

Commit

Permalink
Customize CLARIN-DSpace search facets. (#203)
Browse files Browse the repository at this point in the history
* Added Community indexation

* Fixed checkstyle violation

* Add license header check and update signature

* Added doc

---------

Co-authored-by: MilanMajchrák <[email protected]>
  • Loading branch information
milanmajchrak and MilanMajchrák authored Feb 13, 2023
1 parent 842af9b commit a63fcbb
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dspace-api/src/main/java/org/dspace/app/util/ACE.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @author Michal Josífko
* Class is copied from the LINDAT/CLARIAH-CZ (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/

public class ACE {
Expand Down
2 changes: 1 addition & 1 deletion dspace-api/src/main/java/org/dspace/app/util/ACL.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @author Michal Josífko
* Class is copied from the LINDAT/CLARIAH-CZ (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/

@Component
Expand Down
4 changes: 2 additions & 2 deletions dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public boolean isMetadataField() {
/**
* Class representing a Map of the ComplexDefinition object
* Class is copied from UFAL/CLARIN-DSPACE (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public static class ComplexDefinitions {
/**
Expand Down Expand Up @@ -684,7 +684,7 @@ public static String getSeparator() {
/**
* Class representing a complex input field - multiple lines in input form
* Class is copied from UFAL/CLARIN-DSPACE (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public static class ComplexDefinition {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Helper class for request headers.
* Class is copied from UFAL/CLARIN-DSPACE (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class Headers {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* Parses all headers in ctor.
* Class is copied from UFAL/CLARIN-DSPACE (https://github.com/ufal/clarin-dspace) and modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class ShibHeaders {
// constants
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* 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.discovery;

import java.sql.SQLException;
import java.util.List;
import java.util.Objects;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.logging.log4j.Logger;
import org.apache.solr.common.SolrInputDocument;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.discovery.indexobject.IndexableItem;

/**
* Plugin for indexing the Items community. It helps search the Item by the community.
*
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class ClarinSolrItemsCommunityIndexPlugin implements SolrServiceIndexPlugin {

private static final Logger log = org.apache.logging.log4j.LogManager
.getLogger(ClarinSolrItemsCommunityIndexPlugin.class);

@Override
public void additionalIndex(Context context, IndexableObject indexableObject, SolrInputDocument document) {
if (indexableObject instanceof IndexableItem) {
Item item = ((IndexableItem) indexableObject).getIndexedObject();

String owningCommunity = this.getOwningCommunity(context, item);
document.addField("items_owning_community", owningCommunity);
}
}

private String getOwningCommunity(Context context, Item item) {
if (Objects.isNull(item)) {
return " ";
}
Collection owningCollection = item.getOwningCollection();
try {
List<Community> communities = owningCollection.getCommunities();
if (CollectionUtils.isEmpty(communities)) {
log.error("Community list of the owning collection is empty.");
return " ";
}

// First community is the owning community.
Community owningCommunity = communities.get(0);
if (Objects.isNull(owningCommunity)) {
log.error("Owning community is null.");
return " ";
}

return owningCommunity.getName();
} catch (SQLException e) {
log.error("Cannot getOwningCommunity for the Item: " + item.getID() + ", because: " + e.getSQLState());
}

return " ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Created by
* @author okosarko on 13.10.15.
* Modified by
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class Handle {

Expand Down
2 changes: 1 addition & 1 deletion dspace-api/src/test/java/org/dspace/app/util/ACLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* Test ACL for admin and user.
*
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class ACLTest extends AbstractUnitTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Unit Tests for class DCInputTest
*
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class DCInputTest extends AbstractUnitTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Unit Tests for class LocalMetadataTest
*
* @author Milan Majchrak (milan.majchrak at dataquest dot sk)
* @author Milan Majchrak (milan.majchrak at dataquest.sk)
*/
public class LocalMetadataTest extends AbstractUnitTest {

Expand Down
2 changes: 1 addition & 1 deletion dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ the email and the url is not on *.com domain and the part after schema:// is lon
##### HELP DESK #####
# `lr.help.mail` is exposed to the FE - must be set as exposed

rest.properties.exposed = lr.help.mail,authentication-shibboleth.netid-header,authentication-shibboleth.email-header,authentication-shibboleth.firstname-header,authentication-shibboleth.lastname-header,dspace.name,versioning.item.history.include.submitter,statistics.cache-server.uri
rest.properties.exposed = lr.help.mail,authentication-shibboleth.netid-header,authentication-shibboleth.email-header,authentication-shibboleth.firstname-header,authentication-shibboleth.lastname-header,dspace.name,versioning.item.history.include.submitter,statistics.cache-server.uri,dspace.ui.url
lr.help.mail = [email protected]
lr.help.phone = 0000

Expand Down
35 changes: 33 additions & 2 deletions dspace/config/spring/api/discovery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<!-- Additional indexing plugin enables searching by filenames and by file descriptions for files in ORIGINAL bundle -->
<bean id="solrServiceFileInfoPlugin" class="org.dspace.discovery.SolrServiceFileInfoPlugin"/>

<!-- Additional indexing plugin enables searching by Items communities. -->
<bean id="itemsOwningCommunityPlugin" class="org.dspace.discovery.ClarinSolrItemsCommunityIndexPlugin"/>

<!--Bean that is used for mapping communities/collections to certain discovery configurations.-->
<bean id="org.dspace.discovery.configuration.DiscoveryConfigurationService" class="org.dspace.discovery.configuration.DiscoveryConfigurationService">
<property name="map">
Expand Down Expand Up @@ -126,10 +129,12 @@
<list>
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<!-- <ref bean="searchFilterIssued" />-->
<ref bean="searchFilterRights" />
<ref bean="searchFilterLanguage" />
<ref bean="searchFilterContentInOriginalBundle"/>
<ref bean="searchFilterEntityType"/>
<ref bean="searchFilterItemsCommunity"/>
</list>
</property>
<!-- Set TagCloud configuration per discovery configuration -->
Expand All @@ -140,7 +145,7 @@
<ref bean="searchFilterTitle" />
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<!-- <ref bean="searchFilterIssued" />-->
<ref bean="searchFilterContentInOriginalBundle"/>
<ref bean="searchFilterFileNameInOriginalBundle" />
<ref bean="searchFilterFileDescriptionInOriginalBundle" />
Expand All @@ -151,6 +156,8 @@
<ref bean="searchFilterIsPublicationOfJournalIssueRelation"/>
<ref bean="searchFilterIsJournalOfPublicationRelation"/>
<ref bean="searchFilterRights" />
<ref bean="searchFilterLanguage" />
<ref bean="searchFilterItemsCommunity"/>
</list>
</property>
<!--The sort filters for the discovery search-->
Expand Down Expand Up @@ -1624,6 +1631,30 @@
<property name="sortOrderFilterPage" value="COUNT"/>
</bean>

<bean id="searchFilterLanguage" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
<property name="indexFieldName" value="language"/>
<property name="metadataFields">
<list>
<value>dc.language.iso</value>
</list>
</property>
<property name="facetLimit" value="5"/>
<property name="sortOrderSidebar" value="COUNT"/>
<property name="sortOrderFilterPage" value="COUNT"/>
<property name="type" value="standard"/>
</bean>

<bean id="searchFilterItemsCommunity" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
<property name="indexFieldName" value="items_owning_community"/>
<property name="metadataFields">
<list/>
</property>
<property name="facetLimit" value="5"/>
<property name="type" value="standard"/>
<property name="sortOrderSidebar" value="COUNT"/>
<property name="sortOrderFilterPage" value="COUNT"/>
</bean>

<bean id="searchFilterEntityType" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
<property name="indexFieldName" value="entityType"/>
<property name="metadataFields">
Expand Down
2 changes: 2 additions & 0 deletions dspace/solr/search/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@

<field name="has_content_in_original_bundle" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true" docValues="true" />

<field name="items_owning_community" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true" docValues="true" />

<!-- used to track which group(s) have submit permissions -->
<field name="submit" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true" docValues="true" />

Expand Down

0 comments on commit a63fcbb

Please sign in to comment.