use of org.mycore.common.content.transformer.MCRXSL2JAXBTransformer 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.common.content.transformer.MCRXSL2JAXBTransformer in project mycore by MyCoRe-Org.
the class MCRSolrTransformerInputDocumentFactory method getTransformer.
private static MCRContentTransformer getTransformer() {
String property = CONFIG_PREFIX + "SolrInputDocument.Transformer";
String transformerId = MCRConfiguration.instance().getString(property);
MCRContentTransformer contentTransformer = MCRContentTransformerFactory.getTransformer(transformerId);
isJAXBTransformer = contentTransformer instanceof MCRXSL2JAXBTransformer;
return contentTransformer;
}
use of org.mycore.common.content.transformer.MCRXSL2JAXBTransformer 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