newFileLocation = resolvedFileName;
}
// Trace.trace("+++ New xml:" + resolvedFileName);
}
UimaCasInitializer u = UimaCasInitializer.createUimaCasProcessor (casInit,
newFileLocation/*resolvedFileName*/, this);
if (error > 0) {
u.setStatus(error);
u.setStatusDetails(details);
}
uimaCasInitializers.add(u);
}
}
}
/*****************************************************************/
if (cpeCasProcessorsSettings == null) {
cpeCasProcessorsSettings = new CpeCasProcessorsSettings();
}
try {
cpeCasProcessorsSettings.setCasPoolSize(((CpeCasProcessorsImpl) cpeDescription.getCpeCasProcessors()).getPoolSize());
// Cannot get processingUnitThreadCount
cpeCasProcessorsSettings.setDropCasOnException(((CpeCasProcessorsImpl) cpeDescription.getCpeCasProcessors()).getDropCasOnException());
} catch (CpeDescriptorException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// CPE Cas Processors
CpeCasProcessor[] casProcs = null;
try {
casProcs = cpeDescription.getCpeCasProcessors().getAllCpeCasProcessors();
} catch (CpeDescriptorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (casProcs == null) {
// Empty Cpe Descriptor
return ;
}
// Get list of CpeCasProcessor which can be an AE or a Cas Consumer
// For each CpeCasProcessor, get its type system (insert in cpeModel.typeSystemList)
// cpeModel.cpeCasProcessorModelList = new ArrayList();
// List specifierList = new ArrayList();
// List aeList = new ArrayList();
// List consumerList = new ArrayList();
// cpeModel.typeSystemList = new ArrayList();
for (int i=0; i < casProcs.length; i++) {
CpeComponentDescriptor cpeComponentDescriptor = casProcs[i].getCpeComponentDescriptor();
String newFileLocation = null;
if (cpeComponentDescriptor.getInclude() != null) {
newFileLocation = cpeComponentDescriptor.getInclude().get();
} else if (cpeComponentDescriptor.getImport() != null) {
newFileLocation = cpeComponentDescriptor.getImport().getLocation();
if (newFileLocation == null) {
newFileLocation = cpeComponentDescriptor.getImport().getName();
}
}
String specifierFile = resolveUimaXmlDescriptor(newFileLocation);
ResourceSpecifier specifier = null;
// Check for file existence
if ( specifierFile == null || specifierFile.trim().length() == 0 ) {
// Trace.err("EMPTY (no xml desc) Cas Processor " + casProcs[i].getName());
continue;
} else {
File f = new File(specifierFile);
error = 0;
details = 0;
if ( !f.isAbsolute() ) {
// Relative path
if ( ! f.exists() ) {
// Can NOT find file.
// Try to find it within CURRENT DIRECTORY
f = new File (currentDir, specifierFile);
if ( ! f.exists() ) {
// Trace.err("*** ERROR: Cannot find file: " + specifierFile);
error = STATUS_DEPLOYMENT_NODE_ERROR;
details = STATUS_DETAILS_FILE_NOT_FOUND;
// continue;
}
specifierFile = f.getAbsolutePath();
newFileLocation = specifierFile;
}
} else {
// Absolute Path
if ( ! f.exists() ) {
// Trace.err ("Cannot find xml file for " + casProcs[i].getName()
// + ": " + specifierFile);
error = STATUS_DEPLOYMENT_NODE_ERROR;
details = STATUS_DETAILS_FILE_NOT_FOUND;
// continue;
}
}
if (error == 0) {
// No error.
try {
specifier = UIMAFramework.getXMLParser().
parseResourceSpecifier(new XMLInputSource(specifierFile));
} catch (InvalidXMLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
}
}
// if (specifier != null) {
// specifierList.add(specifier);
//
// if (isCasConsumerSpecifier(specifier)) {
// consumerList.add(specifier);
// } else {
// aeList.add(specifier);
// }
// }
// Need to check duplication
UimaCasProcessor u = getUimaCasProcessor(casProcs[i].getName());
if (u != null) {
Trace.err("Duplicate with CasProcessor from CPE: " + casProcs[i].getName());
// Should we call the following code ?
if (testIt) {
UimaCasProcessor_impl.createUimaCasProcessorFrom(u, casProcs[i], specifier, this);
} else {
u.setCpeCasProcessor(casProcs[i]);
}
} else {
u = UimaCasProcessor_impl.createUimaCasProcessor(casProcs[i], specifier, this);
uimaCasProcessors.add(u);
}
if (error > 0) {
u.setStatus(error);
u.setStatusDetails(details);
}
// File path may be changed
// ((AbstractUimaCasProcessor) u).setXmlDescriptor(specifierFile);
((AbstractUimaCasProcessor) u).setXmlDescriptor(newFileLocation);
// Get CasProcessorErrorHandling
if (cpeDefaultErrorHandling == null) {
// Trace.bug("NO pre-setting for cpeDefaultErrorHandling");
cpeDefaultErrorHandling = CpeDescriptorFactory.produceCasProcessorErrorHandling();
}
// printErrorHandling(cpeDefaultErrorHandling);
if ( ! compareWithCpeDefaultErrorHandling(casProcs[i].getErrorHandling()) ) {
// Not the same values as CPE defaults
u.setCasProcessorErrorHandling(casProcs[i].getErrorHandling());
}
u.setBatchSize(casProcs[i].getBatchSize());
// Get type system
// cpeModel.typeSystemList.add(getTypeSystemDescription(specifier));
} // for
} // addCpeDescription