You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2016/11/04 20:48:53 UTC

svn commit: r1768092 - in /uima/uimaj/trunk/uimaj-json/src: main/java/org/apache/uima/json/JsonCasSerializer.java test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt

Author: schor
Date: Fri Nov  4 20:48:53 2016
New Revision: 1768092

URL: http://svn.apache.org/viewvc?rev=1768092&view=rev
Log:
[UIMA-5171] use the same comparator for binarysearch as was used in sorting.  misc comment updates too.  Update one test expected result

Modified:
    uima/uimaj/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java
    uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt

Modified: uima/uimaj/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java?rev=1768092&r1=1768091&r2=1768092&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java (original)
+++ uima/uimaj/trunk/uimaj-json/src/main/java/org/apache/uima/json/JsonCasSerializer.java Fri Nov  4 20:48:53 2016
@@ -554,7 +554,7 @@ public class JsonCasSerializer {
         jch.writeNlJustBeforeNext();
         String viewName = (0 == sofaAddr) ?  
             CAS.NAME_DEFAULT_SOFA :
-            cds.cas.getStringValue(sofaAddr, cds.tsi.sofaIdFeatCode);
+            cds.cas.getStringValue(sofaAddr, TypeSystemImpl.sofaIdFeatCode);
         jg.writeFieldName(viewName);  // view namne
         jg.writeStartObject();
         for (Integer fs : fssInView) {
@@ -836,7 +836,10 @@ public class JsonCasSerializer {
              parent != null; 
              parent = (TypeImpl) parent.getSuperType()) {
           final int parentCode = parent.getCode();
-          if (Arrays.binarySearch(tiArray,  parent) < 0 ) {  // if parentCode not contained in tiArray
+          // next comparator must match the one used for sorting the tiArray
+          // https://issues.apache.org/jira/browse/UIMA-5171
+          // if parent not contained in tiArray 
+          if (Arrays.binarySearch(tiArray, parent, CasSerializerSupport.COMPARATOR_SHORT_TYPENAME) < 0 ) {  
             if (!parentTypesWithNoInstances.contains(parentCode)) {
               parentTypesWithNoInstances.add(parentCode);
             }
@@ -872,12 +875,18 @@ public class JsonCasSerializer {
     }
 
 
+    /*
+     * keep map from short type name to XmlElementName (full name, namespace, etc)
+     *   This map starts out empty
+     *     first use of type puts entry in
+     *     first use of type with different full name adds namespace to both
+     */
     @Override
     protected void checkForNameCollision(XmlElementName xmlElementName) {
       XmlElementName xel    = usedTypeName2XmlElementName.get(xmlElementName.localName);
       if (xel != null) {
         if (xel.nsUri.equals(xmlElementName.nsUri)) {  // nsUri is the fully qualified name
-          return;  // don't need name spaces yet
+          return;  // don't need name spaces yet, or have already added them for this item
         } else {
           addNameSpace(xel);
           addNameSpace(xmlElementName);

Modified: uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt?rev=1768092&r1=1768091&r2=1768092&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt (original)
+++ uima/uimaj/trunk/uimaj-json/src/test/resources/CasSerialization/expected/json/topWithNamedViewOmits.txt Fri Nov  4 20:48:53 2016
@@ -1 +1 @@
-{"_context":{"_types":{"Annotation":{"_id":"uima.tcas.Annotation","_feature_types":{"sofa":"_ref"}},"Sofa":{"_id":"uima.cas.Sofa","_feature_types":{"sofaArray":"_ref"}},"TOP":{"_id":"uima.cas.TOP"},"Token":{"_id":"org.apache.uima.test.Token","_feature_types":{"sofa":"_ref"}},"AnnotationBase":{"_id":"uima.cas.AnnotationBase","_feature_types":{"sofa":"_ref"}},"TOP":{"_id":"uima.cas.TOP"},"Annotation":{"_id":"uima.tcas.Annotation","_feature_types":{"sofa":"_ref"}}}},"_views":{"_InitialView":{"TOP":[{}],"Token":[{"sofa":6}]},"basicView":{"Annotation":[{"sofa":13}]}},"_referenced_fss":{"6":{"_type":"Sofa","sofaNum":1,"sofaID":"_InitialView"},"13":{"_type":"Sofa","sofaNum":2,"sofaID":"basicView"}}}
\ No newline at end of file
+{"_context":{"_types":{"Annotation":{"_id":"uima.tcas.Annotation","_feature_types":{"sofa":"_ref"}},"Sofa":{"_id":"uima.cas.Sofa","_feature_types":{"sofaArray":"_ref"}},"TOP":{"_id":"uima.cas.TOP"},"Token":{"_id":"org.apache.uima.test.Token","_feature_types":{"sofa":"_ref"}},"AnnotationBase":{"_id":"uima.cas.AnnotationBase","_feature_types":{"sofa":"_ref"}}}},"_views":{"_InitialView":{"TOP":[{}],"Token":[{"sofa":6}]},"basicView":{"Annotation":[{"sofa":13}]}},"_referenced_fss":{"6":{"_type":"Sofa","sofaNum":1,"sofaID":"_InitialView"},"13":{"_type":"Sofa","sofaNum":2,"sofaID":"basicView"}}}
\ No newline at end of file