overrideParameterSettings(colReaderSp, cit.getConfigurationParameterSettings(),
descriptorPath, "Collection Reader");
// compute sofa mapping for the CAS Initializer
CpeSofaMappings sofanamemappings = cit.getSofaNameMappings();
HashMap sofamap = new HashMap();
if (sofanamemappings != null) {
CpeSofaMapping[] sofaNameMappingArray = sofanamemappings.getSofaNameMappings();
for (int i = 0; sofaNameMappingArray != null && i < sofaNameMappingArray.length; i++) {
CpeSofaMapping aSofaMap = sofaNameMappingArray[i];
// if no component sofa name, then set it to default
if (aSofaMap.getComponentSofaName() == null)
aSofaMap.setComponentSofaName(CAS.NAME_DEFAULT_TEXT_SOFA);
sofamap.put(aSofaMap.getComponentSofaName(), aSofaMap.getCpeSofaName());
}
}
// create child UimaContext for the CollectionReader
UimaContextAdmin collectionReaderContext = uimaContext.createChild("_CollectionReader",
sofamap);
Map additionalParams = new HashMap();
additionalParams.put(Resource.PARAM_UIMA_CONTEXT, collectionReaderContext);
colreader = (BaseCollectionReader) UIMAFramework.produceResource(BaseCollectionReader.class,
colReaderSp, getResourceManager(), additionalParams);
CpeCollectionReaderCasInitializer casInit = reader.getCasInitializer();
if (casInit != null) {
if (casInit.getDescriptor() == null) {
throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
new Object[] { "<descriptor>", "<casInitializer>" }, new Exception(
CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_required_element__WARNING", new Object[] {
Thread.currentThread().getName(), "<descriptor>" })));
}
if (casInit.getDescriptor().getInclude() == null) {
throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
new Object[] { "<include>", "<casInitializer>" }, new Exception(
CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_required_element__WARNING", new Object[] {
Thread.currentThread().getName(), "<include>" })));
}
if (casInit.getDescriptor().getInclude().get() == null
|| casInit.getDescriptor().getInclude().get().length() == 0) {
throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
new Object[] { "<href>", "<casInitializer>" }, new Exception(CpmLocalizedMessage
.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING",
new Object[] { Thread.currentThread().getName(), "<href>",
"<casInitializer>" })));
}
descriptorPath = CPMUtils.convertToAbsolutePath(System.getProperty("CPM_HOME"), CPM_HOME,
casInit.getDescriptor().getInclude().get());
File casInitializerSpecifierFile = new File(descriptorPath);
XMLInputSource in4 = new XMLInputSource(casInitializerSpecifierFile);
ResourceSpecifier casIniSp = UIMAFramework.getXMLParser().parseCasInitializerDescription(
in4);
overrideParameterSettings(casIniSp, casInit.getConfigurationParameterSettings(),
descriptorPath, "Cas Initializer");
// compute sofa mapping for the CAS Initializer
CpeSofaMappings sofaNamemappings = casInit.getSofaNameMappings();
sofamap = new HashMap();
if (sofaNamemappings != null) {
CpeSofaMapping[] sofaNameMappingArray = sofaNamemappings.getSofaNameMappings();
for (int i = 0; sofaNameMappingArray != null && i < sofaNameMappingArray.length; i++) {
CpeSofaMapping aSofaMap = sofaNameMappingArray[i];
// if no component sofa name, then set it to default
if (aSofaMap.getComponentSofaName() == null)
aSofaMap.setComponentSofaName(CAS.NAME_DEFAULT_TEXT_SOFA);