Revision 61341
Added by Alessia Bardi almost 3 years ago
OpenaireResultSubmitter.java | ||
---|---|---|
12 | 12 |
import eu.dnetlib.functionality.index.solr.feed.StreamingInputDocumentFactory; |
13 | 13 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
14 | 14 |
import eu.dnetlib.openaire.directindex.objects.ResultEntry; |
15 |
import eu.dnetlib.openaire.directindex.objects.ResultEntryToOaf; |
|
15 | 16 |
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory; |
16 | 17 |
import org.apache.commons.lang.exception.ExceptionUtils; |
17 | 18 |
import org.apache.commons.logging.Log; |
... | ... | |
120 | 121 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
121 | 122 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
122 | 123 |
|
123 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
124 |
final String openaireId = ResultEntryToOaf.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class));
|
|
124 | 125 |
return deleteResult(openaireId); |
125 | 126 |
} |
126 | 127 |
|
... | ... | |
131 | 132 |
@RequestParam(value = "collectedFromId", required = true) final String collectedFromId, |
132 | 133 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception { |
133 | 134 |
|
134 |
final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class)); |
|
135 |
final String openaireId = ResultEntryToOaf.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class));
|
|
135 | 136 |
return deleteResult(openaireId); |
136 | 137 |
} |
137 | 138 |
|
... | ... | |
143 | 144 |
private String feed(final ResultEntry pub) throws DirecIndexApiException { |
144 | 145 |
log.debug(pub); |
145 | 146 |
try { |
147 |
ResultEntryToOaf toOaf = new ResultEntryToOaf(); |
|
146 | 148 |
final IndexDsInfo info = indexDSRetriever.calculateCurrentIndexDsInfo(); |
147 |
final String oafRecord = pub.asOafRecord(velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation, community_api);
|
|
149 |
final String oafRecord = toOaf.asOafRecord(pub, velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation, community_api);
|
|
148 | 150 |
final SolrInputDocument solrDocument = prepareSolrDocument(oafRecord, info.getIndexDsId(), oafToIndexRecordFactory.newTransformer(info.getFormat())); |
149 | 151 |
|
150 | 152 |
clientManager.getClient(info).add(solrDocument); |
... | ... | |
162 | 164 |
try { |
163 | 165 |
StreamingInputDocumentFactory documentFactory = new StreamingInputDocumentFactory(); |
164 | 166 |
String version = (new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'")).format(new Date()); |
165 |
String indexRecord = (String)toIndexRecord.evaluate(record);
|
|
167 |
String indexRecord = toIndexRecord.evaluate(record); |
|
166 | 168 |
if (log.isDebugEnabled()) { |
167 | 169 |
log.debug("***************************************\nSubmitting index record:\n" + indexRecord + "\n***************************************\n"); |
168 | 170 |
} |
Also available in: Unified diff
When the label of the context cannot be resolved, the context tag is not added.
To ensure tests do not make any external calls, the code has been refactored so that the proper mock could be defined.