new XMLInputSource(inCollectionReaderDescripton,
new File("")));
}
catch (InvalidXMLException e)
{
throw new InvocationTargetException(e, "CorporaCollectionReader.xml"
+ " could ne be parsed!");
}
NlpProject project =
mConfiguration.getConsumerElement().getNlpProject();
InputStream inTypeSystemDescription;
try
{
inTypeSystemDescription =
project.getDotCorpus().getTypeSystemFile().getContents();
}
catch (CoreException e)
{
throw new InvocationTargetException(e);
}
TypeSystemDescription typeSystemDescriptor;
try
{
typeSystemDescriptor = UIMAFramework.getXMLParser()
.parseTypeSystemDescription(
new XMLInputSource(inTypeSystemDescription, new File("")));
typeSystemDescriptor.resolveImports();
}
catch (InvalidXMLException e)
{
throw new InvocationTargetException(e);
}
// set type system to collection reader
ProcessingResourceMetaData collectionReaderMetaData =
collectionReaderDescripton.getCollectionReaderMetaData();
collectionReaderMetaData.setTypeSystem(typeSystemDescriptor);
XMLParser xmlParser = UIMAFramework.getXMLParser();
InputStream inIndex = getClass().getResourceAsStream(
"Index.xml");
if (inIndex == null)
{
throw new InvocationTargetException(null,
"org/apache/uima/caseditor/ui/action/Index.xml"
+ " is missing on the classpath");
}
XMLInputSource xmlIndexSource = new XMLInputSource(inIndex,
new File(""));
FsIndexDescription indexDesciptor;
try
{
indexDesciptor = (FsIndexDescription) xmlParser
.parse(xmlIndexSource);
}
catch (InvalidXMLException e)
{
throw new InvocationTargetException(e);
}
collectionReaderMetaData.setFsIndexes(new FsIndexDescription[]
{indexDesciptor});
CollectionReader collectionReader;
try
{
collectionReader = UIMAFramework
.produceCollectionReader(collectionReaderDescripton);
}
catch (ResourceInitializationException e)
{
throw new InvocationTargetException(e);
}
((CorporaCollectionReader) collectionReader).setCorpora(mCorpora);
InputStream in = getClass().getResourceAsStream("DummyTAE.xml");
// load dummy descriptor
ResourceSpecifier textAnalysisEngineSpecifier;
try
{
textAnalysisEngineSpecifier = UIMAFramework.getXMLParser()
.parseResourceSpecifier(
new XMLInputSource(in, new File("")));
}
catch (InvalidXMLException e)
{
throw new InvocationTargetException(e);
}
AnalysisEngine textAnalysisEngine;
try
{
textAnalysisEngine = UIMAFramework
.produceAnalysisEngine(textAnalysisEngineSpecifier);
}
catch (ResourceInitializationException e)
{
throw new InvocationTargetException(e);
}
CollectionProcessingManager collectionProcessingEngine = UIMAFramework
.newCollectionProcessingManager();
try
{
collectionProcessingEngine.setAnalysisEngine(textAnalysisEngine);
}
catch (ResourceConfigurationException e)
{
throw new InvocationTargetException(e);
}
try
{
collectionProcessingEngine.addCasConsumer(mConfiguration
.createConsumer());
}
catch (ResourceConfigurationException e)
{
throw new InvocationTargetException(e);
}
collectionProcessingEngine.setPauseOnException(false);
collectionProcessingEngine.addStatusCallbackListener(
new StatusCallbackListener(){
public void entityProcessComplete(CAS cas,
EntityProcessStatus status)
{
// not implemented
}
public void aborted()
{
finishProcessing();
}
public void batchProcessComplete()
{
// not implemented
}
public void collectionProcessComplete()
{
finishProcessing();
}
public void initializationComplete()
{
// not implemented
}
public void paused()
{
// not implemented
}
public void resumed()
{
// not implemented
}
private void finishProcessing()
{
synchronized (ConsumerActionRunnable.this)
{
mIsProcessing = false;
ConsumerActionRunnable.this.notifyAll();
}
}
});
monitor.subTask("Feeding comsumer, please stand by.");
try
{
collectionProcessingEngine.process(collectionReader);
}
catch (ResourceInitializationException e)
{
throw new InvocationTargetException(e);
}
synchronized(this)
{
// TODO: for cancel poll here