Author: schor
Date: Fri Jan 20 04:03:53 2012
New Revision: 1233752

URL: http://svn.apache.org/viewvc?rev=1233752&view=rev
Log:
[UIMA-2350] make operational properties creation from xml have proper defaults

Modified:
    
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/OperationalProperties_impl.java

Modified: 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/OperationalProperties_impl.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/OperationalProperties_impl.java?rev=1233752&r1=1233751&r2=1233752&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/OperationalProperties_impl.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/resource/metadata/impl/OperationalProperties_impl.java
 Fri Jan 20 04:03:53 2012
@@ -20,6 +20,11 @@
 package org.apache.uima.resource.metadata.impl;
 
 import org.apache.uima.resource.metadata.OperationalProperties;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLParser;
+import org.apache.uima.util.XMLParser.ParsingOptions;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 public class OperationalProperties_impl extends MetaDataObject_impl implements
         OperationalProperties {
@@ -85,4 +90,29 @@ public class OperationalProperties_impl 
           new PropertyXmlInfo[] { new PropertyXmlInfo("modifiesCas"),
               new PropertyXmlInfo("multipleDeploymentAllowed"),
               new PropertyXmlInfo("outputsNewCASes") });
+
+  /* (non-Javadoc)
+   * @see 
org.apache.uima.resource.metadata.impl.MetaDataObject_impl#buildFromXMLElement(org.w3c.dom.Element,
 org.apache.uima.util.XMLParser, org.apache.uima.util.XMLParser.ParsingOptions)
+   */
+  @Override
+  public void buildFromXMLElement(Element aElement, XMLParser aParser, 
ParsingOptions aOptions)
+      throws InvalidXMLException {
+    // overridden to set proper defaults
+    // https://issues.apache.org/jira/browse/UIMA-2350
+    // These change depending on the element which is the parent of the parent 
of this element
+    String grandParentName = "";
+    Node p = aElement.getParentNode();
+    if (p instanceof Element) {
+      Node gp = p.getParentNode();
+      if (gp instanceof Element) {
+        grandParentName = ((Element) gp).getTagName();
+      }
+    }
+    setModifiesCas(grandParentName.equals("casConsumerDescription") ? false : 
true);
+    setOutputsNewCASes(grandParentName.equals("collectionReaderDescription") ? 
true : false);
+    
setMultipleDeploymentAllowed(grandParentName.equals("collectionReaderDescription")
 ||
+                                 
grandParentName.equals("casConsumerDescription") ? false : true);   
+    super.buildFromXMLElement(aElement, aParser, aOptions);
+  }
 }
+


Reply via email to