use of org.mycore.solr.index.document.jaxb.MCRSolrInputDocumentList in project mycore by MyCoRe-Org.
the class MCRSolrInputDocumentGenerator method getSolrInputDocument.
public static List<SolrInputDocument> getSolrInputDocument(MCRContent source) throws JAXBException, IOException {
if (source instanceof MCRJAXBContent) {
@SuppressWarnings("unchecked") MCRJAXBContent<MCRSolrInputDocumentList> jaxbContent = (MCRJAXBContent<MCRSolrInputDocumentList>) source;
return getSolrInputDocuments(jaxbContent.getObject().getDoc());
}
Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
MCRSolrInputDocumentList solrDocuments = (MCRSolrInputDocumentList) unmarshaller.unmarshal(source.getSource());
return getSolrInputDocuments(solrDocuments.getDoc());
}
use of org.mycore.solr.index.document.jaxb.MCRSolrInputDocumentList in project mycore by MyCoRe-Org.
the class MCRSolrTransformerInputDocumentFactory method getDocuments.
@Override
public Iterator<SolrInputDocument> getDocuments(Map<MCRObjectID, MCRContent> contentMap) throws IOException, SAXException {
if (contentMap.isEmpty()) {
return Collections.emptyIterator();
}
try {
Document doc = getMergedDocument(contentMap);
if (isJAXBTransformer) {
MCRParameterCollector param = new MCRParameterCollector();
@SuppressWarnings("unchecked") MCRXSL2JAXBTransformer<MCRSolrInputDocumentList> jaxbTransformer = (MCRXSL2JAXBTransformer<MCRSolrInputDocumentList>) transformer;
MCRSolrInputDocumentList input = jaxbTransformer.getJAXBObject(new MCRJDOMContent(doc), param);
return MCRSolrInputDocumentGenerator.getSolrInputDocuments(input.getDoc()).iterator();
} else {
MCRContent result = transformer.transform(new MCRJDOMContent(doc));
return getSolrInputDocuments(result);
}
} catch (TransformerConfigurationException | JAXBException | JDOMException | ParserConfigurationException e) {
throw new IOException(e);
}
}
use of org.mycore.solr.index.document.jaxb.MCRSolrInputDocumentList in project mycore by MyCoRe-Org.
the class MCRSolrTransformerInputDocumentFactory method getDocument.
/* (non-Javadoc)
* @see org.mycore.solr.index.document.MCRSolrInputDocumentFactory#getDocument(org.mycore.datamodel.metadata.MCRObjectID, org.mycore.common.content.MCRContent)
*/
@Override
public SolrInputDocument getDocument(MCRObjectID id, MCRContent content) throws SAXException, IOException {
// we need no parameter for searchfields - hopefully
try {
SolrInputDocument document;
if (isJAXBTransformer) {
MCRParameterCollector param = new MCRParameterCollector();
@SuppressWarnings("unchecked") MCRXSL2JAXBTransformer<MCRSolrInputDocumentList> jaxbTransformer = (MCRXSL2JAXBTransformer<MCRSolrInputDocumentList>) transformer;
MCRSolrInputDocumentList input = jaxbTransformer.getJAXBObject(content, param);
document = MCRSolrInputDocumentGenerator.getSolrInputDocument(input.getDoc().iterator().next());
} else {
MCRContent result = transformer.transform(content);
document = MCRSolrInputDocumentGenerator.getSolrInputDocument(result.asXML().getRootElement());
}
return document;
} catch (TransformerConfigurationException | JAXBException | JDOMException | ParserConfigurationException e) {
throw new IOException(e);
}
}
Aggregations