You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2007/05/07 23:29:00 UTC
svn commit: r535998 - in /incubator/uima/uimaj/trunk/uimaj-core/src:
main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java
test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java
Author: alally
Date: Mon May 7 14:28:59 2007
New Revision: 535998
URL: http://svn.apache.org/viewvc?view=rev&rev=535998
Log:
Fix handling of multiple Sofas
UIMA-325: https://issues.apache.org/jira/browse/UIMA-325
Modified:
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java
Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java?view=diff&rev=535998&r1=535997&r2=535998
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java Mon May 7 14:28:59 2007
@@ -39,6 +39,7 @@
import org.apache.uima.UimaContext;
import org.apache.uima.cas.ByteArrayFS;
import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.SofaFS;
import org.apache.uima.cas.Type;
@@ -228,6 +229,19 @@
indexRepositories.add(this.cas.getBaseIndexRepository());
// There should always be another index for the Initial View
indexRepositories.add(this.cas.getView(CAS.NAME_DEFAULT_SOFA).getIndexRepository());
+ //add an entry to indexRepositories for each Sofa in the CAS (which can only happen if
+ //a mergePoint was specified)
+ FSIterator sofaIter = this.cas.getSofaIterator();
+ while(sofaIter.hasNext()) {
+ SofaFS sofa = (SofaFS)sofaIter.next();
+ if (sofa.getSofaRef() == 1) {
+ cas.registerInitialSofa();
+ } else {
+ // add indexRepo for views other than the initial view
+ indexRepositories.add(cas.getSofaIndexRepository(sofa));
+ }
+ }
+
this.sofaTypeCode = cas.ts.getTypeCode(CAS.TYPE_NAME_SOFA);
this.sofaNumFeatCode = cas.ts.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFANUM);
this.sofaFeatCode = cas.ts.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFA);
Modified: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java?view=diff&rev=535998&r1=535997&r2=535998
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/XmiCasDeserializerTest.java Mon May 7 14:28:59 2007
@@ -439,6 +439,11 @@
serCasStream.close();
int numAnnotations = cas.getAnnotationIndex().size(); //for comparison later
String docText = cas.getDocumentText(); //for comparison later
+ //add a new Sofa to test that multiple Sofas in original CAS work
+ CAS preexistingView = cas.createView("preexistingView");
+ String preexistingViewText = "John Smith blah blah blah";
+ preexistingView.setDocumentText(preexistingViewText);
+ createPersonAnnot(preexistingView, 0, 10);
// do XMI serialization to a string, using XmiSerializationSharedData
// to keep track of maximum ID generated
@@ -551,6 +556,16 @@
assertEquals(annotText, targetAnnot2.getCoveredText());
assertTrue(targetView1.getSofa().getSofaRef() !=
targetView2.getSofa().getSofaRef());
+
+ CAS checkPreexistingView = cas.getView("preexistingView");
+ assertEquals(preexistingViewText, checkPreexistingView.getDocumentText());
+ Type personType = cas.getTypeSystem().getType("org.apache.uima.testTypeSystem.Person");
+ AnnotationFS targetAnnot3 = (AnnotationFS)
+ checkPreexistingView.getAnnotationIndex(personType).iterator().get();
+ assertEquals("John Smith", targetAnnot3.getCoveredText());
+
+ //try an initial CAS that contains multiple Sofas
+
}
public void testOutOfTypeSystemData() throws Exception {
@@ -763,7 +778,7 @@
//deserialize into a new CAS that has the full type system
CAS newCas = CasCreationUtils.createCas(typeSystem, null, indexes);
- deserialize(xmiStr, newCas, null, false, -1);
+ deserialize(xmiStr2, newCas, null, false, -1);
//compare
CasComparer.assertEquals(originalCas, newCas);