AnalysisEngineDescription aggDesc = UIMAFramework.getResourceSpecifierFactory()
.createAnalysisEngineDescription();
aggDesc.setPrimitive(false);
aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("UserAE", aeSpecifier);
aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("XmiWriter", casConsumerDesc);
FixedFlow flow = UIMAFramework.getResourceSpecifierFactory().createFixedFlow();
if (xmlDetaggerDesc != null) {
aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("XmlDetagger", xmlDetaggerDesc);
flow.setFixedFlow(new String[] {"XmlDetagger", "UserAE", "XmiWriter"});
//to run XmlDetagger we need sofa mappings
//XmlDetagger's "xmlDocument" input sofa gets mapped to the default sofa
SofaMapping sofaMapping1 = UIMAFramework.getResourceSpecifierFactory().createSofaMapping();
sofaMapping1.setComponentKey("XmlDetagger");
sofaMapping1.setComponentSofaName("xmlDocument");
sofaMapping1.setAggregateSofaName(CAS.NAME_DEFAULT_SOFA);
//for UserAE and XmiWriter, may default sofa to the "plainTextDocument" produced by the XmlDetagger
SofaMapping sofaMapping2 = UIMAFramework.getResourceSpecifierFactory().createSofaMapping();
sofaMapping2.setComponentKey("UserAE");
sofaMapping2.setAggregateSofaName("plainTextDocument");
SofaMapping sofaMapping3 = UIMAFramework.getResourceSpecifierFactory().createSofaMapping();
sofaMapping3.setComponentKey("XmiWriter");
sofaMapping3.setAggregateSofaName("plainTextDocument");
aggDesc.setSofaMappings(new SofaMapping[] {sofaMapping1, sofaMapping2, sofaMapping3});
}
else {
//no XML detagger needed in the aggregate in flow
flow.setFixedFlow(new String[] { "UserAE", "XmiWriter" });
}
aggDesc.getAnalysisEngineMetaData().setName("DocumentAnalyzerAE");
aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);