forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DSC-1436] - Extend SolrServiceFileInfoPlugin in order to allow cunfi…
…gurable metadata
- Loading branch information
1 parent
4064512
commit f0ed448
Showing
10 changed files
with
285 additions
and
149 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
31 changes: 31 additions & 0 deletions
31
...e-api/src/main/java/org/dspace/discovery/index/adder/BitstreamMetadataSolrIndexAdder.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,31 @@ | ||
/** | ||
* 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.index.adder; | ||
|
||
import java.util.Collection; | ||
|
||
import org.apache.solr.common.SolrInputDocument; | ||
|
||
/** | ||
* Implementation of {@link IndexAdder} defining default bitstream metadata index adder. | ||
*/ | ||
public class BitstreamMetadataSolrIndexAdder implements IndexAdder { | ||
|
||
private static final String BITSTREAM_METADATA_SOLR_PREFIX_KEYWORD = "bitstreams."; | ||
|
||
@Override | ||
public void add(SolrInputDocument document, String solrFieldName, String value) { | ||
String baseIndex = BITSTREAM_METADATA_SOLR_PREFIX_KEYWORD.concat(solrFieldName); | ||
Collection<Object> fieldValues = document.getFieldValues(baseIndex); | ||
if (fieldValues == null || !fieldValues.contains(value)) { | ||
document.addField(solrFieldName, value); | ||
document.addField(solrFieldName.concat(SOLR_POSTFIX_KEYWORD), value); | ||
document.addField(solrFieldName.concat(SOLR_POSTFIX_FILTER), value); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
dspace-api/src/main/java/org/dspace/discovery/index/adder/DefaultSolrIndexAdder.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,28 @@ | ||
/** | ||
* 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.index.adder; | ||
|
||
import java.util.Collection; | ||
|
||
import org.apache.solr.common.SolrInputDocument; | ||
|
||
/** | ||
* Implementation of {@link IndexAdder} defining default index adder. | ||
*/ | ||
public class DefaultSolrIndexAdder implements IndexAdder { | ||
|
||
@Override | ||
public void add(SolrInputDocument document, String solrFieldName, String value) { | ||
Collection<Object> fieldValues = document.getFieldValues(solrFieldName); | ||
if (fieldValues == null || !fieldValues.contains(value)) { | ||
document.addField(solrFieldName, value); | ||
document.addField(solrFieldName.concat(SOLR_POSTFIX_KEYWORD), value); | ||
document.addField(solrFieldName.concat(SOLR_POSTFIX_FILTER), value); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
dspace-api/src/main/java/org/dspace/discovery/index/adder/IndexAdder.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,29 @@ | ||
/** | ||
* 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.index.adder; | ||
|
||
import org.apache.solr.common.SolrInputDocument; | ||
|
||
/** | ||
* Interface for defining strategy of adding an index. | ||
*/ | ||
public interface IndexAdder { | ||
|
||
String SOLR_POSTFIX_FILTER = "_filter"; | ||
|
||
String SOLR_POSTFIX_KEYWORD = "_keyword"; | ||
|
||
/** | ||
* Adds new index to the document based on passed solr field name and value. | ||
* | ||
* @param document document which will get a new index | ||
* @param solrField solr field name | ||
* @param value solr field value. | ||
*/ | ||
void add(SolrInputDocument document, String solrField, String value); | ||
} |
26 changes: 26 additions & 0 deletions
26
dspace-api/src/main/java/org/dspace/discovery/index/adder/SimpleSolrIndexAdder.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,26 @@ | ||
/** | ||
* 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.index.adder; | ||
|
||
import java.util.Collection; | ||
|
||
import org.apache.solr.common.SolrInputDocument; | ||
|
||
/** | ||
* Implementation of {@link IndexAdder} defining simple index adder without any postfixes. | ||
*/ | ||
public class SimpleSolrIndexAdder implements IndexAdder { | ||
|
||
@Override | ||
public void add(SolrInputDocument document, String solrFieldName, String value) { | ||
Collection<Object> fieldValues = document.getFieldValues(solrFieldName); | ||
if (fieldValues == null || !fieldValues.contains(value)) { | ||
document.addField(solrFieldName, value); | ||
} | ||
} | ||
} |
Oops, something went wrong.