Revision 9021
Added by ben leinfelder about 10 years ago
metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/annotation/RdfXmlSubprocessor.java | ||
---|---|---|
43 | 43 |
import org.dataone.cn.indexer.annotation.SparqlField; |
44 | 44 |
import org.dataone.cn.indexer.annotation.TripleStoreService; |
45 | 45 |
import org.dataone.cn.indexer.convert.SolrDateConverter; |
46 |
import org.dataone.cn.indexer.parser.AbstractDocumentSubprocessor; |
|
47 | 46 |
import org.dataone.cn.indexer.parser.IDocumentSubprocessor; |
48 |
import org.dataone.cn.indexer.parser.ISolrField; |
|
47 |
import org.dataone.cn.indexer.parser.ISolrDataField;
|
|
49 | 48 |
import org.dataone.cn.indexer.solrhttp.SolrDoc; |
50 | 49 |
import org.dataone.cn.indexer.solrhttp.SolrElementField; |
51 | 50 |
import org.dataone.service.exceptions.NotFound; |
... | ... | |
78 | 77 |
* The solr doc of the RDF/XML object only has the system metadata information. |
79 | 78 |
* The solr docs of the science metadata doc and data file have the annotation information. |
80 | 79 |
*/ |
81 |
public class RdfXmlSubprocessor extends AbstractDocumentSubprocessor implements IDocumentSubprocessor {
|
|
80 |
public class RdfXmlSubprocessor implements IDocumentSubprocessor { |
|
82 | 81 |
|
83 | 82 |
private static final String QUERY ="q=id:"; |
84 | 83 |
private static Log log = LogFactory.getLog(RdfXmlSubprocessor.class); |
84 |
|
|
85 |
/** |
|
86 |
* If xpath returns true execute the processDocument Method |
|
87 |
*/ |
|
88 |
private List<String> matchDocuments = null; |
|
89 |
private List<ISolrDataField> fieldList = new ArrayList<ISolrDataField>(); |
|
90 |
|
|
85 | 91 |
private static SolrServer solrServer = null; |
86 | 92 |
static { |
87 | 93 |
try { |
... | ... | |
90 | 96 |
log.error("RdfXmlSubprocessor - can't generate the SolrServer since - "+e.getMessage()); |
91 | 97 |
} |
92 | 98 |
} |
93 |
|
|
99 |
|
|
100 |
/** |
|
101 |
* Returns true if subprocessor should be run against object |
|
102 |
* |
|
103 |
* @param formatId the the document to be processed |
|
104 |
* @return true if this processor can parse the formatId |
|
105 |
*/ |
|
106 |
public boolean canProcess(String formatId) { |
|
107 |
return matchDocuments.contains(formatId); |
|
108 |
} |
|
109 |
|
|
110 |
public List<String> getMatchDocuments() { |
|
111 |
return matchDocuments; |
|
112 |
} |
|
113 |
|
|
114 |
public void setMatchDocuments(List<String> matchDocuments) { |
|
115 |
this.matchDocuments = matchDocuments; |
|
116 |
} |
|
94 | 117 |
@Override |
95 | 118 |
public Map<String, SolrDoc> processDocument(String identifier, Map<String, SolrDoc> docs, InputStream is) throws Exception { |
96 | 119 |
SolrDoc resourceMapDoc = docs.get(identifier); |
... | ... | |
130 | 153 |
|
131 | 154 |
// process each field query |
132 | 155 |
Map<String, SolrDoc> documentsToIndex = new HashMap<String, SolrDoc>(); |
133 |
for (ISolrField field: this.getFieldList()) {
|
|
156 |
for (ISolrDataField field: this.fieldList) {
|
|
134 | 157 |
String q = null; |
135 | 158 |
if (field instanceof SparqlField) { |
136 | 159 |
q = ((SparqlField) field).getQuery(); |
Also available in: Unified diff
use ISolrDataField because RDF subprocessor uses the SparqlField subclass.