svn commit: r712480 - in /ofbiz/trunk/framework/minilang: dtd/simple-methods.xsd src/org/ofbiz/minilang/method/entityops/CreateValue.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r712480 - in /ofbiz/trunk/framework/minilang: dtd/simple-methods.xsd src/org/ofbiz/minilang/method/entityops/CreateValue.java

jleroux@apache.org
Author: jleroux
Date: Sun Nov  9 02:49:03 2008
New Revision: 712480

URL: http://svn.apache.org/viewvc?rev=712480&view=rev
Log:
A patch from Chris Howe "Add createOrStore option to create-value in minilang" (https://issues.apache.org/jira/browse/OFBIZ-893) - OFBIZ-893

Modified:
    ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java

Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd?rev=712480&r1=712479&r2=712480&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd (original)
+++ ofbiz/trunk/framework/minilang/dtd/simple-methods.xsd Sun Nov  9 02:49:03 2008
@@ -3203,6 +3203,19 @@
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
+        <xs:attribute name="or-store" default="false">
+            <xs:annotation>
+                <xs:documentation>
+                    Store value if already exists, defaults to false
+                </xs:documentation>
+            </xs:annotation>
+            <xs:simpleType>
+                <xs:restriction base="xs:token">
+                    <xs:enumeration value="true"/>
+                    <xs:enumeration value="false"/>
+                </xs:restriction>
+            </xs:simpleType>
+        </xs:attribute>
     </xs:attributeGroup>
     <xs:element name="store-value" substitutionGroup="EntityValueOperations">
         <xs:annotation>

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java?rev=712480&r1=712479&r2=712480&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java Sun Nov  9 02:49:03 2008
@@ -45,11 +45,14 @@
     
     ContextAccessor<GenericValue> valueAcsr;
     String doCacheClearStr;
+    boolean testDuplicate;
+    boolean createOrStore;
 
     public CreateValue(Element element, SimpleMethod simpleMethod) {
         super(element, simpleMethod);
         valueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("value-name"));
         doCacheClearStr = element.getAttribute("do-cache-clear");
+        createOrStore = "true".equals(element.getAttribute("or-store"));
     }
 
     public boolean exec(MethodContext methodContext) {
@@ -68,10 +71,14 @@
             }
             return false;
         }
-
         try {
-            methodContext.getDelegator().create(value, doCacheClear);
+            if (createOrStore = true){
+                methodContext.getDelegator().createOrStore(value, doCacheClear);
+            } else {
+                methodContext.getDelegator().create(value, doCacheClear);
+            }
         } catch (GenericEntityException e) {
+            
             Debug.logError(e, module);
             String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem creating the " + valueAcsr + " value: " + e.getMessage() + "]";
             if (methodContext.getMethodType() == MethodContext.EVENT) {