svn commit: r1340408 - in /ofbiz/trunk/framework/minilang: dtd/ src/org/ofbiz/minilang/method/entityops/

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

svn commit: r1340408 - in /ofbiz/trunk/framework/minilang: dtd/ src/org/ofbiz/minilang/method/entityops/

adrianc
Author: adrianc
Date: Sat May 19 10:24:42 2012
New Revision: 1340408

URL: http://svn.apache.org/viewvc?rev=1340408&view=rev
Log:
Overhauled Mini-language <clear-cache-line>, <clear-entity-caches>, <clone-value>, and <create-value> elements.

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

Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd?rev=1340408&r1=1340407&r2=1340408&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd (original)
+++ ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd Sat May 19 10:24:42 2012
@@ -3036,76 +3036,79 @@ under the License.
     <xs:element name="clone-value" substitutionGroup="EntityValueOperations">
         <xs:annotation>
             <xs:documentation>
-                The clone-value tag make a copy of the value in the method environment field specified by value-field.
-                The resulting GenericValue object will be placed in the method environment using the specified new-value-field.
+                Creates a copy of an entity value.
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attributeGroup ref="attlist.clone-value"/>
+            <xs:attribute type="xs:string" name="value-field" use="required">
+                <xs:annotation>
+                    <xs:documentation>
+                        The name of the field that contains the GenericValue object.
+                        &lt;br/&gt;&lt;br/&gt;
+                        Required. Attribute type: expression.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+            <xs:attribute type="xs:string" name="new-value-field" use="required">
+                <xs:annotation>
+                    <xs:documentation>
+                        The name of the field that will contain the new GenericValue object.
+                        &lt;br/&gt;&lt;br/&gt;
+                        Required. Attribute type: expression.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
         </xs:complexType>
     </xs:element>
-    <xs:attributeGroup name="attlist.clone-value">
-        <xs:attribute type="xs:string" name="value-field" use="required">
-            <xs:annotation>
-                <xs:documentation>
-                    The name of the method environment field that contains the GenericValue object.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-        <xs:attribute type="xs:string" name="new-value-field" use="required">
-            <xs:annotation>
-                <xs:documentation>
-                    The name of the method environment field that will contain the new GenericValue object.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-    </xs:attributeGroup>
     <xs:element name="create-value" substitutionGroup="EntityValueOperations">
         <xs:annotation>
             <xs:documentation>
-                The create-value tag persists the specified GenericValue object by creating a new instance of the entity in the datasource.
-                An error will result if an instance of the entity exists in the datasource with the same primary key.
+                Creates a new entity value in the datasource.
+                An error will result if an instance of the entity value exists in the datasource with the same primary key.
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attributeGroup ref="attlist.create-value"/>
+            <xs:attribute type="xs:string" name="value-field" use="required">
+                <xs:annotation>
+                    <xs:documentation>
+                        The name of the field that contains the GenericValue object.
+                        &lt;br/&gt;&lt;br/&gt;
+                        Required. Attribute type: expression.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+            <xs:attribute name="do-cache-clear">
+                <xs:annotation>
+                    <xs:documentation>
+                        Clear the cache. Defaults to "true".
+                        &lt;br/&gt;&lt;br/&gt;
+                        Optional. Attribute type: constant.
+                    </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:attribute name="or-store">
+                <xs:annotation>
+                    <xs:documentation>
+                        Store value if it already exists. Defaults to "false".
+                        &lt;br/&gt;&lt;br/&gt;
+                        Optional. Attribute type: constant.
+                    </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:complexType>
     </xs:element>
-    <xs:attributeGroup name="attlist.create-value">
-        <xs:attribute type="xs:string" name="value-field" use="required">
-            <xs:annotation>
-                <xs:documentation>
-                    The name of the method environment field that contains the GenericValue object.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-        <xs:attribute name="do-cache-clear" default="true">
-            <xs:annotation>
-                <xs:documentation>
-                    Clear the cache, defaults to true
-                </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: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>
             <xs:documentation>
@@ -3311,39 +3314,39 @@ under the License.
     <xs:element name="clear-cache-line" substitutionGroup="EntityValueOperations">
         <xs:annotation>
             <xs:documentation>
-                Uses the delegator to clear elements from the cache;
-                intelligently looks at the map passed to see if it is a byPrimaryKey, and byAnd, or an all.
+                Clears entity values from the cache.
+                Cache clearing is controlled by an optional &quot;map&quot; attribute.
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attributeGroup ref="attlist.clear-cache-line"/>
+            <xs:attribute type="xs:string" name="entity-name" use="required">
+                <xs:annotation>
+                    <xs:documentation>
+                        The name of the entity.
+                        &lt;br/&gt;&lt;br/&gt;
+                        Required. Attribute type: constant, expression.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+            <xs:attribute type="xs:string" name="map">
+                <xs:annotation>
+                    <xs:documentation>
+                        The name of a map in the method environment that will be used for the entity fields.
+                        If the fields in the map form the full primary key the entry will be removed from the byPrimaryKey cache.
+                        If the map exists but the fields do not include a full primary key the entry will be removed from the byAnd cache.
+                        If no map name is specified the entry will be removed from the all caches.
+                        &lt;br/&gt;&lt;br/&gt;
+                        Optional. Attribute type: expression.
+                </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
         </xs:complexType>
     </xs:element>
-    <xs:attributeGroup name="attlist.clear-cache-line">
-        <xs:attribute type="xs:string" name="entity-name" use="required">
-            <xs:annotation>
-                <xs:documentation>
-                    The name of the entity to clear cache lines of.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-        <xs:attribute type="xs:string" name="map">
-            <xs:annotation>
-                <xs:documentation>
-                    The name of a map in the method environment that will be used for the entity fields.
-                    If the fields in the map form the full primary key the entry will be removed from the byPrimaryKey cache.
-                    If the map exists but the fields do not include a full primary key the entry will be removed from the byAnd cache.
-                    If no map name is specified the entry will be removed from the all cache.
-                </xs:documentation>
-            </xs:annotation>
-        </xs:attribute>
-    </xs:attributeGroup>
     <xs:element name="clear-entity-caches" substitutionGroup="EntityValueOperations">
         <xs:annotation>
             <xs:documentation>
-                This is a very simple tag that should be used sparingly because of the performance impact.
-                It clears all lines from all Entity Engine caches.
-                It has no attributes or sub-elements.
+                Clears all entity caches.
+                This element should be used sparingly because of the performance impact.
             </xs:documentation>
         </xs:annotation>
         <xs:complexType/>

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java?rev=1340408&r1=1340407&r2=1340408&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java Sat May 19 10:24:42 2012
@@ -20,59 +20,71 @@ package org.ofbiz.minilang.method.entity
 
 import java.util.Map;
 
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.w3c.dom.Element;
 
 /**
- * Uses the delegator to clear elements from the cache; intelligently looks at the map passed to see if it is a byPrimaryKey, and byAnd, or an all.
+ * Implements the &lt;clear-cache-line&gt; element.
  */
-public class ClearCacheLine extends MethodOperation {
+public final class ClearCacheLine extends MethodOperation {
 
-    public static final String module = ClearCacheLine.class.getName();
-
-    String entityName;
-    ContextAccessor<Map<String, ? extends Object>> mapAcsr;
+    private final FlexibleStringExpander entityNameFse;
+    private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma;
 
     public ClearCacheLine(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        entityName = element.getAttribute("entity-name");
-        mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map"), element.getAttribute("map-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "map");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "map");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
+        mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        String entityName = methodContext.expandString(this.entityName);
-
-        if (mapAcsr.isEmpty()) {
+        String entityName = entityNameFse.expandString(methodContext.getEnvMap());
+        Map<String, ? extends Object> fieldsMap = mapFma.get(methodContext.getEnvMap());
+        if (fieldsMap == null) {
             methodContext.getDelegator().clearCacheLine(entityName);
         } else {
-            Map<String, ? extends Object> theMap = mapAcsr.get(methodContext);
-            if (theMap == null) {
-                Debug.logWarning("In clear-cache-line could not find map with name " + mapAcsr + ", not clearing any cache lines", module);
-            } else {
-                methodContext.getDelegator().clearCacheLine(entityName, theMap);
-            }
+            methodContext.getDelegator().clearCacheLine(entityName, fieldsMap);
         }
         return true;
     }
 
     @Override
     public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
+        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
     }
 
     @Override
     public String rawString() {
-        // TODO: something more than the empty tag
-        return "<clear-cache-line/>";
+        return toString();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<clear-cache-line ");
+        sb.append("entity-name=\"").append(this.entityNameFse).append("\" ");
+        if (!this.mapFma.isEmpty()) {
+            sb.append("map=\"").append(this.mapFma).append("\" ");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;clear-cache-line&gt; element.
+     */
     public static final class ClearCacheLineFactory implements Factory<ClearCacheLine> {
         public ClearCacheLine createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new ClearCacheLine(element, simpleMethod);

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java?rev=1340408&r1=1340407&r2=1340408&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java Sat May 19 10:24:42 2012
@@ -18,19 +18,30 @@
  *******************************************************************************/
 package org.ofbiz.minilang.method.entityops;
 
+import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 
 /**
- * Clears all Entity Engine Caches
+ * Implements the &lt;clear-entity-caches&gt; element.
  */
-public class ClearEntityCaches extends MethodOperation {
+public final class ClearEntityCaches extends MethodOperation {
 
     public ClearEntityCaches(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
+        if (MiniLangValidate.validationOn()) {
+            NamedNodeMap nnm = element.getAttributes();
+            for (int i = 0; i < nnm.getLength(); i++) {
+                String attributeName = nnm.item(i).getNodeName();
+                MiniLangValidate.handleError("Attribute name \"" + attributeName + "\" is not valid.", simpleMethod, element);
+            }
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
     }
 
     @Override
@@ -41,16 +52,22 @@ public class ClearEntityCaches extends M
 
     @Override
     public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
+        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
     }
 
     @Override
     public String rawString() {
-        // TODO: something more than the empty tag
+        return toString();
+    }
+
+    @Override
+    public String toString() {
         return "<clear-entity-caches/>";
     }
 
+    /**
+     * A factory for the &lt;clear-entity-caches&gt; element.
+     */
     public static final class ClearEntityCachesFactory implements Factory<ClearEntityCaches> {
         public ClearEntityCaches createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new ClearEntityCaches(element, simpleMethod);

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CloneValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CloneValue.java?rev=1340408&r1=1340407&r2=1340408&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CloneValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CloneValue.java Sat May 19 10:24:42 2012
@@ -18,54 +18,67 @@
  *******************************************************************************/
 package org.ofbiz.minilang.method.entityops;
 
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.w3c.dom.Element;
 
 /**
- * Uses the delegator to find entity values by anding the map fields
+ * Implements the &lt;clone-value&gt; element.
  */
-public class CloneValue extends MethodOperation {
+public final class CloneValue extends MethodOperation {
 
-    public static final String module = CloneValue.class.getName();
-
-    ContextAccessor<GenericValue> newValueAcsr;
-    ContextAccessor<GenericValue> valueAcsr;
+    private final FlexibleMapAccessor<GenericValue> newValueFma;
+    private final FlexibleMapAccessor<GenericValue> valueFma;
 
     public CloneValue(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        valueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("value-field"), element.getAttribute("value-name"));
-        newValueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("new-value-field"), element.getAttribute("new-value-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "new-value-field");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field", "new-value-field");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "new-value-field");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field"));
+        newValueFma = FlexibleMapAccessor.getInstance(element.getAttribute("new-value-field"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        GenericValue value = valueAcsr.get(methodContext);
-        if (value == null) {
-            Debug.logWarning("In clone-value a value was not found with the specified valueAcsr: " + valueAcsr + ", not copying", module);
-            return true;
+        GenericValue value = valueFma.get(methodContext.getEnvMap());
+        if (value != null) {
+            newValueFma.put(methodContext.getEnvMap(), GenericValue.create(value));
         }
-        newValueAcsr.put(methodContext, GenericValue.create(value));
         return true;
     }
 
     @Override
     public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
+        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
     }
 
     @Override
     public String rawString() {
-        // TODO: something more than the empty tag
-        return "<clone-value/>";
+        return toString();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<clone-value ");
+        sb.append("value-field=\"").append(this.valueFma).append("\" ");
+        sb.append("new-value-field=\"").append(this.newValueFma).append("\" ");
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;clone-value&gt; element.
+     */
     public static final class CloneValueFactory implements Factory<CloneValue> {
         public CloneValue createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new CloneValue(element, simpleMethod);

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=1340408&r1=1340407&r2=1340408&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 Sat May 19 10:24:42 2012
@@ -19,67 +19,61 @@
 package org.ofbiz.minilang.method.entityops;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.w3c.dom.Element;
 
 /**
- * Uses the delegator to create the specified value object entity in the datasource
+ * Implements the &lt;create-value&gt; element.
  */
-public class CreateValue extends MethodOperation {
+public final class CreateValue extends MethodOperation {
 
     public static final String module = CreateValue.class.getName();
 
-    boolean createOrStore;
-    String doCacheClearStr;
-    boolean testDuplicate;
-    ContextAccessor<GenericValue> valueAcsr;
+    private final boolean createOrStore;
+    private final boolean doCacheClear;
+    private final FlexibleMapAccessor<GenericValue> valueFma;
 
     public CreateValue(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        valueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("value-field"), element.getAttribute("value-name"));
-        doCacheClearStr = element.getAttribute("do-cache-clear");
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "do-cache-clear", "or-store");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field");
+            MiniLangValidate.constantAttributes(simpleMethod, element, "do-cache-clear", "or-store");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field"));
+        doCacheClear = !"false".equals(element.getAttribute("do-cache-clear"));
         createOrStore = "true".equals(element.getAttribute("or-store"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        boolean doCacheClear = !"false".equals(methodContext.expandString(doCacheClearStr));
-        GenericValue value = valueAcsr.get(methodContext);
+        GenericValue value = valueFma.get(methodContext.getEnvMap());
         if (value == null) {
-            String errMsg = "In create-value a value was not found with the specified valueAcsr: " + valueAcsr + ", not creating";
+            String errMsg = "In <create-value> the value \"" + valueFma + "\" was not found, not creating";
             Debug.logWarning(errMsg, module);
-            if (methodContext.getMethodType() == MethodContext.EVENT) {
-                methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode());
-            } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
-                methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode());
-            }
+            simpleMethod.addErrorMessage(methodContext, errMsg);
             return false;
         }
         try {
-            if (createOrStore == true) {
+            if (createOrStore) {
                 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) {
-                methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode());
-            } else if (methodContext.getMethodType() == MethodContext.SERVICE) {
-                methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg);
-                methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode());
-            }
+            String errMsg = "Exception thrown while creating the \"" + valueFma +"\" GenericValue: " + e.getMessage();
+            Debug.logWarning(e, errMsg, module);
+            simpleMethod.addErrorMessage(methodContext, errMsg);
             return false;
         }
         return true;
@@ -87,16 +81,31 @@ public class CreateValue extends MethodO
 
     @Override
     public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
+        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
     }
 
     @Override
     public String rawString() {
-        // TODO: something more than the empty tag
-        return "<create-value/>";
+        return toString();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<create-value ");
+        sb.append("value-field=\"").append(this.valueFma).append("\" ");
+        if (!this.doCacheClear) {
+            sb.append("do-cache-clear=\"false\"");
+        }
+        if (this.createOrStore) {
+            sb.append("or-store=\"true\"");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;create-value&gt; element.
+     */
     public static final class CreateValueFactory implements Factory<CreateValue> {
         public CreateValue createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new CreateValue(element, simpleMethod);