XMI Delta CAS Serialization doesn't work when preexisting FS is indexed in a
new View
-------------------------------------------------------------------------------------
Key: UIMA-1965
URL: https://issues.apache.org/jira/browse/UIMA-1965
Project: UIMA
Issue Type: Bug
Components: Core Java Framework
Affects Versions: 2.3
Reporter: Adam Lally
I think I ran into a problem with XMI delta CAS serialization. Here's my use
case: I start with a CAS that has a FeatureStructure (not annotation) indexed
in the InitialView. I want to send this to a remote service, wihch will create
a new view and add the exisitng FeatureStructure to the indexes of that view.
With delta XMI CAS serialization, this does not seem to work. The
FeatureStructure is not present in the indexes of the new view.
Here is a unit test (to be added to XmiCasDeserializerTest.java) that
illustrates the problem:
public void testDeltaCasIndexExistingFsInNewView() throws Exception {
CAS cas1 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(),
indexes);
CAS cas2 = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(),
indexes);
cas1.setDocumentText("This is a test document in the initial view");
Type referentType =
cas1.getTypeSystem().getType("org.apache.uima.testTypeSystem.Referent");
FeatureStructure fs1 = cas1.createFS(referentType);
cas1.getIndexRepository().addFS(fs1);
//serialize complete
XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
String xml = serialize(cas1, sharedData);
System.out.println(xml);
int maxOutgoingXmiId = sharedData.getMaxXmiId();
//deserialize into cas2
XmiSerializationSharedData sharedData2 = new XmiSerializationSharedData();
this.deserialize(xml, cas2, sharedData2, true, -1);
CasComparer.assertEquals(cas1, cas2);
//create Marker, add/modify fs and serialize in delta xmi format.
Marker marker = cas2.createMarker();
//create View
CAS view = cas2.createView("NewView");
//add FS to index
Type referentType2 =
cas2.getTypeSystem().getType("org.apache.uima.testTypeSystem.Referent");
Iterator<FeatureStructure> fsIter =
cas2.getIndexRepository().getAllIndexedFS(referentType2);
while (fsIter.hasNext()) {
FeatureStructure fs = fsIter.next();
view.getIndexRepository().addFS(fs);
}
AnnotationFS cas2newAnnot = view.createAnnotation(cas2.getAnnotationType(),
6, 8);
view.getIndexRepository().addFS(cas2newAnnot);
// serialize cas2 in delta format
String deltaxml1 = serialize(cas2, sharedData2, marker);
System.out.println(deltaxml1);
//deserialize delta xmi into cas1
this.deserialize(deltaxml1, cas1, sharedData, true, maxOutgoingXmiId,
AllowPreexistingFS.allow);
//check that new View contains the FS
CAS deserView = cas1.getView("NewView");
Iterator<FeatureStructure> deserFsIter =
deserView.getIndexRepository().getAllIndexedFS(referentType);
assertTrue(deserFsIter.hasNext());
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.