You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2012/11/07 10:53:02 UTC

svn commit: r1406513 - in /uima/sandbox/trunk/TextMarker: uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/ uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/ uimaj-ep-te...

Author: pkluegl
Date: Wed Nov  7 09:53:01 2012
New Revision: 1406513

URL: http://svn.apache.org/viewvc?rev=1406513&view=rev
Log:
UIMA-2495
- fixed NPE for missing parent nodes
- added error message if evaluated types are not defined

Modified:
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/FSTreeNode.java

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java?rev=1406513&r1=1406512&r2=1406513&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/searchStrategy/TestingSearchStrategy.java Wed Nov  7 09:53:01 2012
@@ -49,6 +49,9 @@ public class TestingSearchStrategy imple
     IPath relativeTo = location.makeRelativeTo(testFolder.getLocation());
     IPath segments = relativeTo.removeLastSegments(2);
     String scriptName = segments.lastSegment();
+    if(scriptName == null) {
+      return null;
+    }
     scriptName += "TypeSystem.xml";
     segments = segments.removeLastSegments(1);
     IFolder descPackageFolder = null;

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java?rev=1406513&r1=1406512&r2=1406513&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java Wed Nov  7 09:53:01 2012
@@ -25,6 +25,7 @@ import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
 import org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeNode;
 import org.apache.uima.textmarker.caseditor.view.tree.ITreeNode;
 import org.apache.uima.textmarker.caseditor.view.tree.TypeTreeNode;
@@ -49,7 +50,6 @@ public class TestEvaluationTree {
     // Creating RootNode and children that function as root nodes
     // for the FalsePositive /FalseNegative subtrees
     root = new TypeTreeNode(null, cas.getAnnotationType());
-    boolean containsEvalInfos = false;
 
     TypeTreeNode fproot = new TypeTreeNode(root, falsePositiveType);
     TypeTreeNode fnroot = new TypeTreeNode(root, falseNegativeType);
@@ -61,11 +61,9 @@ public class TestEvaluationTree {
     addEvalNodes(cas, falseNegativeType, fnroot);
     addEvalNodes(cas, truePositiveType, tproot);
 
-    // if (containsEvalInfos) {
     root.addChild(fproot);
     root.addChild(fnroot);
     root.addChild(tproot);
-    // }
   }
 
   private void addEvalNodes(CAS cas, Type falsePositiveType, TypeTreeNode fproot) {
@@ -82,7 +80,12 @@ public class TestEvaluationTree {
           fproot.addChild(parentTypeNode);
         }
         AnnotationTreeNode newNode = new AnnotationTreeNode(parentTypeNode, a);
-        parentTypeNode.addChild(newNode);
+        if (parentTypeNode != null) {
+          parentTypeNode.addChild(newNode);
+        } else {
+          TextMarkerAddonsPlugin.error(new IllegalArgumentException(
+                  "Trying to display unknown type for " + a));
+        }
       }
       iter.moveToNext();
     }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/FSTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/FSTreeNode.java?rev=1406513&r1=1406512&r2=1406513&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/FSTreeNode.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/FSTreeNode.java Wed Nov  7 09:53:01 2012
@@ -19,6 +19,7 @@
 
 package org.apache.uima.textmarker.caseditor.view.tree;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -34,7 +35,7 @@ public class FSTreeNode extends Abstract
   protected FeatureStructure fs;
 
   public FSTreeNode(ITreeNode parent, FeatureStructure annotation) {
-    this(parent, annotation, null);
+    this(parent, annotation, new ArrayList<Type>());
   }
 
   public FSTreeNode(ITreeNode parent, FeatureStructure annotation, List<Type> parentTypes) {
@@ -92,19 +93,17 @@ public class FSTreeNode extends Abstract
       }
     } else if (f.getRange() instanceof Type) {
       FeatureStructure featureValue = featureStructure.getFeatureValue(f);
-      if (featureValue instanceof AnnotationFS
-              && expandable(featureValue.getType(), parentTypes)) {
+      if (featureValue instanceof AnnotationFS && expandable(featureValue.getType(), parentTypes)) {
         parent.addChild(new AnnotationTreeNode(this, ((AnnotationFS) featureValue), parentTypes));
       }
     }
   }
 
-  
   private boolean expandable(Type type, List<Type> parentTypes) {
     int frequency = Collections.frequency(parentTypes, type);
     return frequency < 5;
   }
-  
+
   public Object getAdapter(Class adapter) {
 
     if (FSTreeNode.class.equals(adapter)) {