Revision 55808
Added by Claudio Atzori almost 5 years ago
SolrDocumentMapperFactory.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.functionality.index.model.Any.ValueType; |
6 | 6 |
import eu.dnetlib.functionality.index.model.document.IndexDocument; |
7 | 7 |
import eu.dnetlib.functionality.index.model.document.Status; |
8 |
import eu.dnetlib.functionality.index.model.util.SolrIndexDocument;
|
|
8 |
import eu.dnetlib.functionality.index.query.SolrIndexDocument;
|
|
9 | 9 |
import eu.dnetlib.functionality.index.utils.MetadataReference; |
10 | 10 |
import org.springframework.beans.factory.annotation.Required; |
11 | 11 |
|
... | ... | |
28 | 28 |
final String dsId, |
29 | 29 |
final String version) { |
30 | 30 |
|
31 |
return new Function<String, IndexDocument>() { |
|
32 |
|
|
33 |
@Override |
|
34 |
public IndexDocument apply(final String doc) { |
|
35 |
SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId); |
|
36 |
try { |
|
37 |
indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT)); |
|
38 |
} catch (XMLStreamException e) { |
|
39 |
return indexDocument.setMarked(); |
|
40 |
} |
|
41 |
indexDocument.setStatus(Status.OK); |
|
42 |
return indexDocument; |
|
31 |
return doc -> { |
|
32 |
SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId); |
|
33 |
try { |
|
34 |
indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT)); |
|
35 |
} catch (XMLStreamException e) { |
|
36 |
return indexDocument.setMarked(); |
|
43 | 37 |
} |
38 |
indexDocument.setStatus(Status.OK); |
|
39 |
return indexDocument; |
|
44 | 40 |
}; |
45 | 41 |
} |
46 | 42 |
|
... | ... | |
48 | 44 |
public Function<String, IndexDocument> getRecordMapper(final Map<String, ValueType> schema, final MetadataReference mdRef, final String dsId, final String version, final boolean emptyResult) { |
49 | 45 |
if (emptyResult == false) return getRecordMapper(schema, dsId, version); |
50 | 46 |
else { |
51 |
return new Function<String, IndexDocument>() { |
|
47 |
return doc -> { |
|
48 |
SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId); |
|
49 |
try { |
|
52 | 50 |
|
53 |
@Override |
|
54 |
public IndexDocument apply(final String doc) { |
|
55 |
SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId); |
|
56 |
try { |
|
57 |
|
|
58 |
ResultTransformer transformer = new ResultTransformer(ResultTransformer.Mode.empty) { |
|
59 |
@Override |
|
60 |
public String apply(String input) { |
|
61 |
return input; |
|
62 |
} |
|
63 |
}; |
|
64 |
indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT, transformer)); |
|
65 |
} catch (XMLStreamException e) { |
|
66 |
return indexDocument.setMarked(); |
|
67 |
} |
|
68 |
indexDocument.setStatus(Status.OK); |
|
69 |
return indexDocument; |
|
51 |
ResultTransformer transformer = new ResultTransformer(ResultTransformer.Mode.empty) { |
|
52 |
@Override |
|
53 |
public String apply(String input) { |
|
54 |
return input; |
|
55 |
} |
|
56 |
}; |
|
57 |
indexDocument.setContent(documentFactory.parseDocument(version, doc, dsId, DNETRESULT, transformer)); |
|
58 |
} catch (XMLStreamException e) { |
|
59 |
return indexDocument.setMarked(); |
|
70 | 60 |
} |
61 |
indexDocument.setStatus(Status.OK); |
|
62 |
return indexDocument; |
|
71 | 63 |
}; |
72 | 64 |
} |
73 | 65 |
} |
Also available in: Unified diff
reintegrated branch solr75 -r53828:HEAD