Hi,
I'm trying to test a CollectionReader, but it seems that the
TypeSystem isn't initialized since I get this:
org.apache.uima.cas.CASRuntimeException: JCas type
"it.celi.types.SourceDocumentInformation" used in Java code, but was
not declared in the XML type descriptor.
at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:397)
at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:92)
at
org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:53)
at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:54)
at it.celi.types.Annotation.<init>(Annotation.java:41)
at
it.celi.types.SourceDocumentInformation.<init>(SourceDocumentInformation.java:41)
at
it.celi.components.collection.RecursiveFileSytemCollectionReader.getCurrent(RecursiveFileSytemCollectionReader.java:192)
at
it.celi.components.collection.RecursiveFileSytemCollectionReader.getNext(RecursiveFileSytemCollectionReader.java:158)
at
it.celi.components.retriever.TestRecursiveFileSytemCollectionReader.testGetNext(TestRecursiveFileSytemCollectionReader.java:70)
..........
Thes test is something like that:
....
private RecursiveFileSytemCollectionReader rfcr;
@Before
public void setUp() throws Exception {
File file;
file =
FileUtil.getFileAsResource("RecursiveFileSystemCollectionReader.xml");
ResourceSpecifier aSpecifier =
UIMAFramework.getXMLParser().parseCollectionReaderDescription(new
XMLInputSource(file));
rfcr = (RecursiveFileSytemCollectionReader)
UIMAFramework.produceCollectionReader(aSpecifier);
}
@Test
public void getNext() {
try {
CasManager casManager = rfcr.getCasManager();
casManager.defineCasPool("pool", 2, null);
while (rfcr.hasNext()) {
CAS cas = casManager.getCas("pool");
rfcr.getNext(cas);
Type fileLocType =
cas.getTypeSystem().getType(SourceDocumentInformation.class.getName());
Feature fileNameFeat =
fileLocType.getFeatureByBaseName("uri");
FSIterator it =
cas.getAnnotationIndex(fileLocType).iterator();
FeatureStructure fileLoc = it.get();
.......... a lot of catch
In the collection reader's xml descriptor are declared the typesystem
and the output capabilities. And, if deployed in a CPE this CR works!
Thanks in advance,
Roberto
--
Roberto Franchini
CELI s.r.l. (http://www.celi.it) - C.so Moncalieri 21 - 10131 Torino - ITALY
Tel +39-011-6600814 - Fax +39-011-6600687
jabber:[EMAIL PROTECTED] skype:ro.franchini