Skip to content

Commit 0786b7c

Browse files
AdamF42vins01-4science
authored andcommitted
Merged in task/main-cris/DSC-2728 (pull request DSpace#5393)
Task/main cris/DSC-2728 Approved-by: Vincenzo Mecca
2 parents 86c7539 + 7146074 commit 0786b7c

File tree

4 files changed

+552
-17
lines changed

4 files changed

+552
-17
lines changed

dspace-api/src/main/java/org/dspace/discovery/SharedWorkspaceSolrIndexPlugin.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.dspace.discovery;
1010

1111
import java.sql.SQLException;
12-
import java.util.Collection;
1312
import java.util.List;
1413
import java.util.Objects;
1514
import java.util.Optional;
@@ -18,9 +17,11 @@
1817
import org.apache.commons.lang3.StringUtils;
1918
import org.apache.solr.client.solrj.SolrQuery;
2019
import org.apache.solr.common.SolrInputDocument;
20+
import org.dspace.content.Collection;
2121
import org.dspace.content.Item;
2222
import org.dspace.content.MetadataValue;
2323
import org.dspace.content.WorkspaceItem;
24+
import org.dspace.content.service.CollectionService;
2425
import org.dspace.content.service.ItemService;
2526
import org.dspace.core.Context;
2627
import org.dspace.discovery.indexobject.IndexableWorkspaceItem;
@@ -48,6 +49,9 @@ public class SharedWorkspaceSolrIndexPlugin implements SolrServiceIndexPlugin, S
4849
@Autowired
4950
private ItemService itemService;
5051

52+
@Autowired
53+
private CollectionService collectionService;
54+
5155
@Autowired
5256
private EPersonService ePersonService;
5357

@@ -80,6 +84,7 @@ public void additionalIndex(Context context, IndexableObject indexableObject, So
8084
addRead(document, Optional.ofNullable(workspaceItem.getSubmitter()));
8185
addReadToAdditionalEpersons(context, document, item);
8286
addReadToCollectionAdmin(document, workspaceItem);
87+
addReadToCollectionSubmitters(context, document, workspaceItem);
8388
} catch (SQLException e) {
8489
log.error("Error while assigning reading privileges: {}", e.getMessage(),
8590
e);
@@ -91,6 +96,17 @@ private void addReadToCollectionAdmin(SolrInputDocument document, WorkspaceItem
9196
.ifPresent(group -> document.addField("read", "g" + group.getID().toString()));
9297
}
9398

99+
private void addReadToCollectionSubmitters(Context context,
100+
SolrInputDocument document,
101+
WorkspaceItem workspaceItem) {
102+
Collection collection = workspaceItem.getCollection();
103+
if (collectionService.isSharedWorkspace(context,
104+
collection)) {
105+
Optional.ofNullable(collection.getSubmitters())
106+
.ifPresent(group -> document.addField("read", "g" + group.getID().toString()));
107+
}
108+
}
109+
94110
private void addReadToAdditionalEpersons(Context context, SolrInputDocument document, Item item)
95111
throws SQLException {
96112

@@ -112,7 +128,7 @@ private List<MetadataValue> otherAllowed(Item item) {
112128

113129
return additionalReadMetadata.stream()
114130
.map(mds -> itemService.getMetadataByMetadataString(item, mds))
115-
.flatMap(Collection::stream)
131+
.flatMap(java.util.Collection::stream)
116132
.collect(Collectors.toList());
117133
}
118134

dspace-server-webapp/src/test/data/dspaceFolder/config/spring/api/test-discovery.xml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<!-- "workspace" is a special entry to search for your own workspace items -->
122122
<entry key="workspace" value-ref="workspaceConfiguration" />
123123
<entry key="supervisedWorkspace" value-ref="supervisedWorkspaceConfiguration" />
124+
<entry key="otherworkspace" value-ref="otherWorkspaceConfiguration" />
124125
<!-- "workflow" is a special entry to search for your own workflow tasks -->
125126
<entry key="workflow" value-ref="workflowConfiguration" />
126127
<!-- "workflowAdmin" is a special entry to search for all workflow items if you are an administrator -->
@@ -2084,6 +2085,82 @@
20842085
<property name="spellCheckEnabled" value="true"/>
20852086
</bean>
20862087

2088+
<!--The other workspace configuration settings for discovery -->
2089+
<bean id="otherWorkspaceConfiguration"
2090+
class="org.dspace.discovery.configuration.DiscoveryConfiguration"
2091+
scope="prototype">
2092+
<property name="id" value="otherworkspace" />
2093+
<!--Which sidebar facets are to be displayed -->
2094+
<property name="sidebarFacets">
2095+
<list>
2096+
<ref bean="searchFilterObjectNamedType" />
2097+
<ref bean="searchFilterType" />
2098+
<ref bean="searchFilterIssued" />
2099+
</list>
2100+
</property>
2101+
<!--The search filters which can be used on the discovery search page -->
2102+
<property name="searchFilters">
2103+
<list>
2104+
<ref bean="searchFilterObjectNamedType" />
2105+
<ref bean="searchFilterType" />
2106+
<ref bean="searchFilterIssued" />
2107+
<ref bean="searchFilterEntityType" />
2108+
</list>
2109+
</property>
2110+
<!--The sort filters for the discovery search-->
2111+
<property name="searchSortConfiguration">
2112+
<bean class="org.dspace.discovery.configuration.DiscoverySortConfiguration">
2113+
<!--The default sort filter to use for the initial workspace loading-->
2114+
<property name="defaultSortField" ref="sortLastModified" />
2115+
<property name="sortFields">
2116+
<list>
2117+
<ref bean="sortLastModified" />
2118+
<ref bean="sortTitleAsc" />
2119+
<ref bean="sortDateIssuedDesc" />
2120+
</list>
2121+
</property>
2122+
</bean>
2123+
</property>
2124+
<!--Any default filter queries, these filter queries will be used for all
2125+
queries done by discovery for this configuration -->
2126+
<property name="defaultFilterQueries">
2127+
<list>
2128+
<!--Only find items, workspace and accepted for workflow -->
2129+
<value>search.resourcetype:WorkspaceItem</value>
2130+
</list>
2131+
</property>
2132+
<!--Default result per page -->
2133+
<property name="defaultRpp" value="10" />
2134+
<property name="hitHighlightingConfiguration">
2135+
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
2136+
<property name="metadataFields">
2137+
<list>
2138+
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
2139+
<property name="field" value="dc.title"/>
2140+
<property name="snippets" value="5"/>
2141+
</bean>
2142+
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
2143+
<property name="field" value="dc.contributor.author"/>
2144+
<property name="snippets" value="5"/>
2145+
</bean>
2146+
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
2147+
<property name="field" value="dc.description.abstract"/>
2148+
<property name="maxSize" value="250"/>
2149+
<property name="snippets" value="2"/>
2150+
</bean>
2151+
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
2152+
<property name="field" value="fulltext"/>
2153+
<property name="maxSize" value="250"/>
2154+
<property name="snippets" value="2"/>
2155+
</bean>
2156+
</list>
2157+
</property>
2158+
</bean>
2159+
</property>
2160+
<!-- When true a "did you mean" example will be displayed, value can be true or false -->
2161+
<property name="spellCheckEnabled" value="true"/>
2162+
</bean>
2163+
20872164
<!--The workflow configuration settings for discovery -->
20882165
<bean id="workflowConfiguration"
20892166
class="org.dspace.discovery.configuration.DiscoveryConfiguration"

0 commit comments

Comments
 (0)