You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2012/07/10 14:06:00 UTC

svn commit: r1359626 [9/12] - in /ofbiz/branches/release12.04: ./ framework/base/ framework/base/src/org/ofbiz/base/util/collections/ framework/base/src/org/ofbiz/base/util/collections/test/ framework/base/src/org/ofbiz/base/util/string/ framework/enti...

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Break.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Break.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Break.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Break.java Tue Jul 10 12:05:55 2012
@@ -25,7 +25,9 @@ import org.ofbiz.minilang.method.MethodO
 import org.w3c.dom.Element;
 
 /**
- * Causes script execution to exit the nearest loop element.
+ * Implements the <break> element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cbreak%3E}}">Mini-language Reference</a>
  */
 public class Break extends MethodOperation {
 
@@ -39,12 +41,7 @@ public class Break extends MethodOperati
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
+    public String toString() {
         return "<break/>";
     }
 
@@ -65,11 +62,16 @@ public class Break extends MethodOperati
         }
     }
 
+    /**
+     * A factory for the &lt;break&gt; element.
+     */
     public static final class BreakFactory implements Factory<Break> {
+        @Override
         public Break createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new Break(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "break";
         }

Copied: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java (from r1335018, ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java?p2=ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java&p1=ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java&r1=1335018&r2=1359626&rev=1359626&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckErrors.java Tue Jul 10 12:05:55 2012
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.minilang.MiniLangException;
-import org.ofbiz.minilang.MiniLangUtil;
 import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
 import org.ofbiz.minilang.method.MethodContext;
@@ -30,87 +29,83 @@ import org.ofbiz.minilang.method.MethodO
 import org.w3c.dom.Element;
 
 /**
- * Halts script execution if the error message list contains any messages.
+ * Implements the &lt;check-errors&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Ccheckerrors%3E}}">Mini-language Reference</a>
  */
 public final class CheckErrors extends MethodOperation {
 
-    // This method is needed only during the v1 to v2 transition
-    private static boolean autoCorrect(Element element) {
-        String errorListAttr = element.getAttribute("error-list-name");
-        if (errorListAttr.length() > 0) {
-            element.removeAttribute("error-list-name");
-            return true;
-        }
-        return false;
-    }
-    
     private final FlexibleStringExpander errorCodeFse;
+    private final FlexibleStringExpander errorListNameFse;
 
     public CheckErrors(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
         if (MiniLangValidate.validationOn()) {
-            MiniLangValidate.attributeNames(simpleMethod, element, "error-code");
-            MiniLangValidate.constantPlusExpressionAttributes(simpleMethod, element, "error-code");
+            MiniLangValidate.attributeNames(simpleMethod, element, "error-code", "error-list-name");
             MiniLangValidate.noChildElements(simpleMethod, element);
         }
-        boolean elementModified = autoCorrect(element);
-        if (elementModified && MiniLangUtil.autoCorrectOn()) {
-            MiniLangUtil.flagDocumentAsCorrected(element);
-        }
         this.errorCodeFse = FlexibleStringExpander.getInstance(element.getAttribute("error-code"));
+        this.errorListNameFse = FlexibleStringExpander.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        if (methodContext.getMethodType() == MethodContext.EVENT) {
-            List<Object> messages = methodContext.getEnv(this.simpleMethod.getEventErrorMessageListName());
-            if (messages != null && messages.size() > 0) {
+        if (methodContext.isTraceOn()) {
+            outputTraceMessage(methodContext, "Begin check-errors.");
+        }
+        List<Object> messages = methodContext.getEnv(this.errorListNameFse.expandString(methodContext.getEnvMap()));
+        if (messages != null && messages.size() > 0) {
+            if (methodContext.getMethodType() == MethodContext.EVENT) {
+                methodContext.putEnv(simpleMethod.getEventErrorMessageListName(), messages);
                 methodContext.putEnv(this.simpleMethod.getEventResponseCodeName(), getErrorCode(methodContext));
-                return false;
-            }
-        } else {
-            List<Object> messages = methodContext.getEnv(this.simpleMethod.getServiceErrorMessageListName());
-            if (messages != null && messages.size() > 0) {
+            } else {
+                methodContext.putEnv(simpleMethod.getServiceErrorMessageListName(), messages);
                 methodContext.putEnv(this.simpleMethod.getServiceResponseMessageName(), getErrorCode(methodContext));
-                return false;
             }
+            if (methodContext.isTraceOn()) {
+                outputTraceMessage(methodContext, "Found error messages. Setting error status and halting script execution.");
+                outputTraceMessage(methodContext, "End check-errors.");
+            }
+            return false;
+        }
+        if (methodContext.isTraceOn()) {
+            outputTraceMessage(methodContext, "No error messages found. Continuing script execution.");
+            outputTraceMessage(methodContext, "End check-errors.");
         }
         return true;
     }
 
-    @Override
-    public String expandedString(MethodContext methodContext) {
-        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
-    }
-
     private String getErrorCode(MethodContext methodContext) {
         String errorCode = this.errorCodeFse.expandString(methodContext.getEnvMap());
-        if (errorCode.length() == 0) {
+        if (errorCode.isEmpty()) {
             errorCode = this.simpleMethod.getDefaultErrorCode();
         }
         return errorCode;
     }
 
     @Override
-    public String rawString() {
-        return toString();
-    }
-
-    @Override
     public String toString() {
         StringBuilder sb = new StringBuilder("<check-errors ");
         if (!this.errorCodeFse.isEmpty()) {
             sb.append("error-code=\"").append(this.errorCodeFse).append("\" ");
         }
+        if (!"error_list".equals(this.errorListNameFse.getOriginal())) {
+            sb.append("error-list-name=\"").append(this.errorListNameFse).append("\" ");
+        }
         sb.append("/>");
         return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;check-errors&gt; element.
+     */
     public static final class CheckErrorsFactory implements Factory<CheckErrors> {
+        @Override
         public CheckErrors createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new CheckErrors(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "check-errors";
         }

Copied: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java (from r1334971, ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java?p2=ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java&p1=ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java&r1=1334971&r2=1359626&rev=1359626&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CheckId.java Tue Jul 10 12:05:55 2012
@@ -35,7 +35,9 @@ import org.ofbiz.minilang.method.MethodO
 import org.w3c.dom.Element;
 
 /**
- * If the given ID field is not valid the fail-message or fail-property sub-elements are used to add a message to the error-list.
+ * Implements the &lt;check-id&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Ccheckid%3E}}">Mini-language Reference</a>
  */
 public final class CheckId extends MethodOperation {
 
@@ -50,10 +52,11 @@ public final class CheckId extends Metho
     public CheckId(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
         if (MiniLangValidate.validationOn()) {
-            MiniLangValidate.attributeNames(simpleMethod, element, "error-list-name");
+            MiniLangValidate.attributeNames(simpleMethod, element, "field", "error-list-name");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
             MiniLangValidate.constantAttributes(simpleMethod, element, "error-list-name");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
             MiniLangValidate.childElements(simpleMethod, element, "fail-message", "fail-property");
-            MiniLangValidate.requireAnyChildElement(simpleMethod, element, "fail-message", "fail-property");
         }
         this.errorListFma = FlexibleMapAccessor.getInstance(MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
         this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
@@ -115,16 +118,6 @@ public final class CheckId extends Metho
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
-    }
-
-    @Override
-    public String rawString() {
-        return toString();
-    }
-
-    @Override
     public String toString() {
         StringBuilder sb = new StringBuilder("<check-id ");
         if (!this.fieldFma.isEmpty()) {
@@ -144,11 +137,16 @@ public final class CheckId extends Metho
         return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;check-id&gt; element.
+     */
     public static final class CheckIdFactory implements Factory<CheckId> {
+        @Override
         public CheckId createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new CheckId(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "check-id";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ClearField.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ClearField.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ClearField.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ClearField.java Tue Jul 10 12:05:55 2012
@@ -18,70 +18,57 @@
  *******************************************************************************/
 package org.ofbiz.minilang.method.envops;
 
-import java.util.Map;
-
-import javolution.util.FastMap;
-
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 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;
 
 /**
- * Clears the specified field
+ * Implements the &lt;clear-field&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{<clearfield>}}">Mini-language Reference</a>
  */
-public class ClearField extends MethodOperation {
+public final class ClearField extends MethodOperation {
 
-    public static final String module = ClearField.class.getName();
-
-    ContextAccessor<Object> fieldAcsr;
-    ContextAccessor<Map<String, Object>> mapAcsr;
+    private final FlexibleMapAccessor<Object> fieldFma;
 
     public ClearField(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        // the schema for this element now just has the "field" attribute, though the old "field-name" and "map-name" pair is still supported
-        fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field"), element.getAttribute("field-name"));
-        mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "field");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        if (!mapAcsr.isEmpty()) {
-            Map<String, Object> toMap = mapAcsr.get(methodContext);
-            if (toMap == null) {
-                // it seems silly to create a new map, but necessary since whenever
-                // an env field like a Map or List is referenced it should be created, even if empty
-                if (Debug.verboseOn())
-                    Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
-                toMap = FastMap.newInstance();
-                mapAcsr.put(methodContext, toMap);
-            }
-            fieldAcsr.put(toMap, null, methodContext);
-        } else {
-            fieldAcsr.put(methodContext, null);
-        }
+        fieldFma.put(methodContext.getEnvMap(), null);
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        return "<clear-field field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<set ");
+        sb.append("field=\"").append(this.fieldFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;clear-field&gt; element.
+     */
     public static final class ClearFieldFactory implements Factory<ClearField> {
+        @Override
         public ClearField createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new ClearField(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "clear-field";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Continue.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Continue.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Continue.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Continue.java Tue Jul 10 12:05:55 2012
@@ -25,7 +25,9 @@ import org.ofbiz.minilang.method.MethodO
 import org.w3c.dom.Element;
 
 /**
- * Causes script execution to return to the beginning of the nearest enclosing loop element.
+ * Implements the &lt;continue&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Ccontinue%3E}}">Mini-language Reference</a>
  */
 public class Continue extends MethodOperation {
 
@@ -39,12 +41,7 @@ public class Continue extends MethodOper
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
+    public String toString() {
         return "<continue/>";
     }
 
@@ -65,11 +62,16 @@ public class Continue extends MethodOper
         }
     }
 
+    /**
+     * A factory for the &lt;continue&gt; element.
+     */
     public static final class ContinueFactory implements Factory<Continue> {
+        @Override
         public Continue createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new Continue(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "continue";
         }

Copied: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java (from r1335018, ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java?p2=ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java&p1=ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java&r1=1335018&r2=1359626&rev=1359626&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/CreateObject.java Tue Jul 10 12:05:55 2012
@@ -19,19 +19,18 @@
 package org.ofbiz.minilang.method.envops;
 
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
-import java.util.Map;
-
-import javolution.util.FastList;
-import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilXml;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangRuntimeException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
 import org.ofbiz.minilang.method.FieldObject;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodObject;
@@ -40,57 +39,56 @@ import org.ofbiz.minilang.method.StringO
 import org.w3c.dom.Element;
 
 /**
- * Creates a Java object using the given fields as parameters
+ * Implements the &lt;create-object&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{<createobject>}}">Mini-language Reference</a>
  */
-public class CreateObject extends MethodOperation {
+public final class CreateObject extends MethodOperation {
 
     public static final String module = CreateObject.class.getName();
 
-    String className;
-    ContextAccessor<Object> fieldAcsr;
-    ContextAccessor<Map<String, Object>> mapAcsr;
-    /** A list of MethodObject objects to use as the method call parameters */
-    List<MethodObject<?>> parameters;
+    private final String className;
+    private final Class<?> targetClass;
+    private final FlexibleMapAccessor<Object> fieldFma;
+    private final List<MethodObject<?>> parameters;
 
     public CreateObject(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.handleError("<create-object> element is deprecated (use <script>)", simpleMethod, element);
+            MiniLangValidate.attributeNames(simpleMethod, element, "class-name", "field");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "class-name", "field");
+            MiniLangValidate.childElements(simpleMethod, element, "string", "field");
+        }
         className = element.getAttribute("class-name");
-        // the schema for this element now just has the "field" attribute, though the old
-        // "field-name" and "map-name" pair is still supported
-        fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field"), element.getAttribute("field-name"));
-        mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name"));
+        Class<?> targetClass = null;
+        try {
+            targetClass = ObjectType.loadClass(this.className);
+        } catch (ClassNotFoundException e) {
+            MiniLangValidate.handleError("Class not found with name " + this.className, simpleMethod, element);
+        }
+        this.targetClass = targetClass;
+        fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
         List<? extends Element> parameterElements = UtilXml.childElementList(element);
         if (parameterElements.size() > 0) {
-            parameters = FastList.newInstance();
+            ArrayList<MethodObject<?>> parameterList = new ArrayList<MethodObject<?>>(parameterElements.size());
             for (Element parameterElement : parameterElements) {
-                MethodObject<?> methodObject = null;
                 if ("string".equals(parameterElement.getNodeName())) {
-                    methodObject = new StringObject(parameterElement, simpleMethod);
+                    parameterList.add(new StringObject(parameterElement, simpleMethod));
                 } else if ("field".equals(parameterElement.getNodeName())) {
-                    methodObject = new FieldObject<Object>(parameterElement, simpleMethod);
-                } else {
-                    // whoops, invalid tag here, print warning
-                    Debug.logWarning("Found an unsupported tag under the call-object-method tag: " + parameterElement.getNodeName() + "; ignoring", module);
-                }
-                if (methodObject != null) {
-                    parameters.add(methodObject);
+                    parameterList.add(new FieldObject<Object>(parameterElement, simpleMethod));
                 }
             }
+            parameterList.trimToSize();
+            this.parameters = Collections.unmodifiableList(parameterList);
+        } else {
+            this.parameters = null;
         }
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        String className = methodContext.expandString(this.className);
-        Class<?> methodClass = null;
-        try {
-            methodClass = ObjectType.loadClass(className, methodContext.getLoader());
-        } catch (ClassNotFoundException e) {
-            Debug.logError(e, "Class to create not found with name " + className + " in create-object operation", module);
-            String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Class to create not found with name " + className + ": " + e.toString() + "]";
-            methodContext.setErrorReturn(errMsg, simpleMethod);
-            return false;
-        }
         Object[] args = null;
         Class<?>[] parameterTypes = null;
         if (parameters != null) {
@@ -104,8 +102,8 @@ public class CreateObject extends Method
                     typeClass = methodObjectDef.getTypeClass(methodContext);
                 } catch (ClassNotFoundException e) {
                     String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Parameter type not found with name " + methodObjectDef.getTypeName() + "]";
-                    Debug.logError(errMsg, module);
-                    methodContext.setErrorReturn(errMsg, simpleMethod);
+                    Debug.logWarning(e, errMsg, module);
+                    simpleMethod.addErrorMessage(methodContext, errMsg);
                     return false;
                 }
                 parameterTypes[i] = typeClass;
@@ -113,75 +111,32 @@ public class CreateObject extends Method
             }
         }
         try {
-            Constructor<?> constructor = methodClass.getConstructor(parameterTypes);
-            try {
-                Object newObject = constructor.newInstance(args);
-                // if fieldAcsr is empty, ignore return value
-                if (!fieldAcsr.isEmpty()) {
-                    if (!mapAcsr.isEmpty()) {
-                        Map<String, Object> retMap = mapAcsr.get(methodContext);
-                        if (retMap == null) {
-                            retMap = FastMap.newInstance();
-                            mapAcsr.put(methodContext, retMap);
-                        }
-                        fieldAcsr.put(retMap, newObject, methodContext);
-                    } else {
-                        // no map name, use the env
-                        fieldAcsr.put(methodContext, newObject);
-                    }
-                }
-            } catch (InstantiationException e) {
-                Debug.logError(e, "Could not instantiate object in create-object operation", module);
-                String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Could not instantiate object: " + e.toString() + "]";
-                methodContext.setErrorReturn(errMsg, simpleMethod);
-                return false;
-            } catch (IllegalAccessException e) {
-                Debug.logError(e, "Illegal access constructing object in create-object operation", module);
-                String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Illegal access constructing object: " + e.toString() + "]";
-                methodContext.setErrorReturn(errMsg, simpleMethod);
-                return false;
-            } catch (IllegalArgumentException e) {
-                Debug.logError(e, "Illegal argument calling method in create-object operation", module);
-                String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Illegal argument calling constructor: " + e.toString() + "]";
-                methodContext.setErrorReturn(errMsg, simpleMethod);
-                return false;
-            } catch (InvocationTargetException e) {
-                Debug.logError(e.getTargetException(), "Constructor in create-object operation threw an exception", module);
-                String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Constructor in create-object threw an exception: " + e.getTargetException() + "]";
-                methodContext.setErrorReturn(errMsg, simpleMethod);
-                return false;
-            }
-        } catch (NoSuchMethodException e) {
-            Debug.logError(e, "Could not find constructor to execute in simple-method create-object operation", module);
-            String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Could not find constructor to execute: " + e.toString() + "]";
-            methodContext.setErrorReturn(errMsg, simpleMethod);
-            return false;
-        } catch (SecurityException e) {
-            Debug.logError(e, "Security exception finding constructor to execute in simple-method create-object operation", module);
-            String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [Security exception finding constructor to execute: " + e.toString() + "]";
-            methodContext.setErrorReturn(errMsg, simpleMethod);
-            return false;
+            Constructor<?> constructor = targetClass.getConstructor(parameterTypes);
+            fieldFma.put(methodContext.getEnvMap(),constructor.newInstance(args));
+        } catch (Exception e) {
+            throw new MiniLangRuntimeException(e, this);
         }
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        // TODO: something more than the empty tag
-        return "<create-object/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<create-object ");
+        sb.append("class-name=\"").append(this.className).append("\" ");
+        sb.append("field=\"").append(this.fieldFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;create-object&gt; element.
+     */
     public static final class CreateObjectFactory implements Factory<CreateObject> {
+        @Override
         public CreateObject createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new CreateObject(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "create-object";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java Tue Jul 10 12:05:55 2012
@@ -19,82 +19,72 @@
 package org.ofbiz.minilang.method.envops;
 
 import java.util.List;
-import java.util.Map;
 
 import javolution.util.FastList;
 
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 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;
 
 /**
- * Copies an environment field to a list
- */
-public class FieldToList extends MethodOperation {
-
-    public static final String module = FieldToList.class.getName();
-
-    ContextAccessor<Object> fieldAcsr;
-    ContextAccessor<List<Object>> listAcsr;
-    ContextAccessor<Map<String, ? extends Object>> mapAcsr;
+ * Implements the &lt;field-to-list&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cfieldtolist%3E}}">Mini-language Reference</a>
+*/
+public final class FieldToList extends MethodOperation {
+
+    private final FlexibleMapAccessor<Object> fieldFma;
+    private final FlexibleMapAccessor<List<Object>> listFma;
 
     public FieldToList(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        // the schema for this element now just has the "field" attribute, though the old "field-name" and "map-name" pair is still supported
-        mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map-name"));
-        fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field"), element.getAttribute("field-name"));
-        listAcsr = new ContextAccessor<List<Object>>(element.getAttribute("list"), element.getAttribute("list-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.handleError("<field-to-list> element is deprecated (use <set>)", simpleMethod, element);
+            MiniLangValidate.attributeNames(simpleMethod, element, "field", "list");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "field", "list");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "field", "list");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
+        listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        Object fieldVal = null;
-        if (!mapAcsr.isEmpty()) {
-            Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext);
-            if (fromMap == null) {
-                Debug.logWarning("Map not found with name " + mapAcsr + ", Not copying to list", module);
-                return true;
+        Object fieldVal = fieldFma.get(methodContext.getEnvMap());
+        if (fieldVal != null) {
+            List<Object> toList = listFma.get(methodContext.getEnvMap());
+            if (toList == null) {
+                toList = FastList.newInstance();
+                listFma.put(methodContext.getEnvMap(), toList);
             }
-            fieldVal = fieldAcsr.get(fromMap, methodContext);
-        } else {
-            // no map name, try the env
-            fieldVal = fieldAcsr.get(methodContext);
-        }
-        if (fieldVal == null) {
-            Debug.logWarning("Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr + ", Not copying to list", module);
-            return true;
-        }
-        List<Object> toList = listAcsr.get(methodContext);
-        if (toList == null) {
-            if (Debug.verboseOn())
-                Debug.logVerbose("List not found with name " + listAcsr + ", creating new list", module);
-            toList = FastList.newInstance();
-            listAcsr.put(methodContext, toList);
+            toList.add(fieldVal);
         }
-        toList.add(fieldVal);
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        return "<field-to-list list-name=\"" + this.listAcsr + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<field-to-list ");
+        sb.append("field=\"").append(this.fieldFma).append("\" ");
+        sb.append("list=\"").append(this.listFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;field-to-list&gt; element.
+     */
     public static final class FieldToListFactory implements Factory<FieldToList> {
+        @Override
         public FieldToList createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new FieldToList(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "field-to-list";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java Tue Jul 10 12:05:55 2012
@@ -20,62 +20,67 @@ package org.ofbiz.minilang.method.envops
 
 import java.util.List;
 
-import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 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;
 
 /**
- * Get the first entry from the list
+ * Implements the &lt;first-from-list&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cfirstfromlist%3E}}">Mini-language Reference</a>
  */
-public class FirstFromList extends MethodOperation {
+public final class FirstFromList extends MethodOperation {
 
-    public static final String module = FirstFromList.class.getName();
-
-    ContextAccessor<Object> entryAcsr;
-    ContextAccessor<List<? extends Object>> listAcsr;
+    private final FlexibleMapAccessor<Object> entryFma;
+    private final FlexibleMapAccessor<List<Object>> listFma;
 
     public FirstFromList(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        this.entryAcsr = new ContextAccessor<Object>(element.getAttribute("entry"), element.getAttribute("entry-name"));
-        this.listAcsr = new ContextAccessor<List<? extends Object>>(element.getAttribute("list"), element.getAttribute("list-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.handleError("<first-from-list> element is deprecated (use <set>)", simpleMethod, element);
+            MiniLangValidate.attributeNames(simpleMethod, element, "entry", "list");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "entry", "list");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "entry", "list");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        entryFma = FlexibleMapAccessor.getInstance(element.getAttribute("entry"));
+        listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        if (listAcsr.isEmpty()) {
-            Debug.logWarning("No list-name specified in iterate tag, doing nothing", module);
-            return true;
-        }
-        List<? extends Object> theList = listAcsr.get(methodContext);
+        List<? extends Object> theList = listFma.get(methodContext.getEnvMap());
         if (UtilValidate.isEmpty(theList)) {
-            entryAcsr.put(methodContext, null);
-            return true;
+            entryFma.put(methodContext.getEnvMap(), null);
+        } else {
+            entryFma.put(methodContext.getEnvMap(), theList.get(0));
         }
-        entryAcsr.put(methodContext, theList.get(0));
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        return "<first-from-list list-name=\"" + this.listAcsr + "\" entry-name=\"" + this.entryAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<first-from-list ");
+        sb.append("entry=\"").append(this.entryFma).append("\" ");
+        sb.append("list=\"").append(this.listFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;first-from-list&gt; element.
+     */
     public static final class FirstFromListFactory implements Factory<FirstFromList> {
+        @Override
         public FirstFromList createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new FirstFromList(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "first-from-list";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Tue Jul 10 12:05:55 2012
@@ -25,12 +25,15 @@ import java.util.List;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityListIterator;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangRuntimeException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.artifact.ArtifactInfoContext;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.ofbiz.minilang.method.envops.Break.BreakElementException;
@@ -38,37 +41,45 @@ import org.ofbiz.minilang.method.envops.
 import org.w3c.dom.Element;
 
 /**
- * Process sub-operations for each entry in the list
+ * Implements the &lt;iterate&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Citerate%3E}}">Mini-language Reference</a>
  */
-public class Iterate extends MethodOperation {
+public final class Iterate extends MethodOperation {
 
     public static final String module = Iterate.class.getName();
 
-    protected ContextAccessor<Object> entryAcsr;
-    protected ContextAccessor<Object> listAcsr;
-    protected List<MethodOperation> subOps;
+    private final FlexibleMapAccessor<Object> entryFma;
+    private final FlexibleMapAccessor<Object> listFma;
+    private final List<MethodOperation> subOps;
 
     public Iterate(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        this.entryAcsr = new ContextAccessor<Object>(element.getAttribute("entry"), element.getAttribute("entry-name"));
-        this.listAcsr = new ContextAccessor<Object>(element.getAttribute("list"), element.getAttribute("list-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "entry", "list");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "entry", "list");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "entry", "list");
+        }
+        this.entryFma = FlexibleMapAccessor.getInstance(element.getAttribute("entry"));
+        this.listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
         this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        if (listAcsr.isEmpty()) {
-            Debug.logWarning("No list-name specified in iterate tag, doing nothing: " + rawString(), module);
+        if (listFma.isEmpty()) {
+            if (Debug.verboseOn())
+                Debug.logVerbose("Collection not found, doing nothing: " + this, module);
             return true;
         }
-        Object oldEntryValue = entryAcsr.get(methodContext);
-        Object objList = listAcsr.get(methodContext);
+        Object oldEntryValue = entryFma.get(methodContext.getEnvMap());
+        Object objList = listFma.get(methodContext.getEnvMap());
         if (objList instanceof EntityListIterator) {
             EntityListIterator eli = (EntityListIterator) objList;
             GenericValue theEntry;
             try {
                 while ((theEntry = eli.next()) != null) {
-                    entryAcsr.put(methodContext, theEntry);
+                    entryFma.put(methodContext.getEnvMap(), theEntry);
                     try {
                         for (MethodOperation methodOperation : subOps) {
                             if (!methodOperation.exec(methodContext)) {
@@ -86,81 +97,102 @@ public class Iterate extends MethodOpera
                     }
                 }
             } finally {
-                // close the iterator
                 try {
                     eli.close();
                 } catch (GenericEntityException e) {
-                    Debug.logError(e, module);
-                    String errMsg = "ERROR: Error closing entityListIterator in " + simpleMethod.getShortDescription() + " [" + e.getMessage() + "]: " + rawString();
-                    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());
-                    }
-                    return false;
+                    throw new MiniLangRuntimeException("Error closing entityListIterator: " + e.getMessage(), this);
                 }
             }
         } else if (objList instanceof Collection<?>) {
             Collection<Object> theCollection = UtilGenerics.checkCollection(objList);
             if (theCollection.size() == 0) {
                 if (Debug.verboseOn())
-                    Debug.logVerbose("Collection with name " + listAcsr + " has zero entries, doing nothing: " + rawString(), module);
+                    Debug.logVerbose("Collection has zero entries, doing nothing: " + this, module);
                 return true;
             }
             for (Object theEntry : theCollection) {
-                entryAcsr.put(methodContext, theEntry);
-                if (!SimpleMethod.runSubOps(subOps, methodContext)) {
-                    // only return here if it returns false, otherwise just carry on
-                    return false;
+                entryFma.put(methodContext.getEnvMap(), theEntry);
+                try {
+                    for (MethodOperation methodOperation : subOps) {
+                        if (!methodOperation.exec(methodContext)) {
+                            return false;
+                        }
+                    }
+                } catch (MiniLangException e) {
+                    if (e instanceof BreakElementException) {
+                        break;
+                    }
+                    if (e instanceof ContinueElementException) {
+                        continue;
+                    }
+                    throw e;
                 }
             }
         } else if (objList instanceof Iterator<?>) {
             Iterator<Object> theIterator = UtilGenerics.cast(objList);
             if (!theIterator.hasNext()) {
                 if (Debug.verboseOn())
-                    Debug.logVerbose("List with name " + listAcsr + " has no more entries, doing nothing: " + rawString(), module);
+                    Debug.logVerbose("Iterator has zero entries, doing nothing: " + this, module);
                 return true;
             }
             while (theIterator.hasNext()) {
                 Object theEntry = theIterator.next();
-                entryAcsr.put(methodContext, theEntry);
-                if (!SimpleMethod.runSubOps(subOps, methodContext)) {
-                    // only return here if it returns false, otherwise just carry on
-                    return false;
+                entryFma.put(methodContext.getEnvMap(), theEntry);
+                try {
+                    for (MethodOperation methodOperation : subOps) {
+                        if (!methodOperation.exec(methodContext)) {
+                            return false;
+                        }
+                    }
+                } catch (MiniLangException e) {
+                    if (e instanceof BreakElementException) {
+                        break;
+                    }
+                    if (e instanceof ContinueElementException) {
+                        continue;
+                    }
+                    throw e;
                 }
             }
         } else {
-            if (Debug.infoOn())
-                Debug.logInfo("List not found with name " + listAcsr + ", doing nothing: " + rawString(), module);
+            if (Debug.verboseOn())
+                Debug.logVerbose("Cannot iterate over a " + objList.getClass().getName() + ", doing nothing: " + this, module);
             return true;
         }
-        entryAcsr.put(methodContext, oldEntryValue);
+        entryFma.put(methodContext.getEnvMap(), oldEntryValue);
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    public List<MethodOperation> getSubOps() {
-        return this.subOps;
+    public void gatherArtifactInfo(ArtifactInfoContext aic) {
+        for (MethodOperation method : this.subOps) {
+            method.gatherArtifactInfo(aic);
+        }
     }
 
     @Override
-    public String rawString() {
-        // TODO: something more than the empty tag
-        return "<iterate list-name=\"" + this.listAcsr + "\" entry-name=\"" + this.entryAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<iterate ");
+        if (!this.entryFma.isEmpty()) {
+            sb.append("entry=\"").append(this.entryFma).append("\" ");
+        }
+        if (!this.listFma.isEmpty()) {
+            sb.append("list=\"").append(this.listFma).append("\" ");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;iterate&gt; element.
+     */
     public static final class IterateFactory implements Factory<Iterate> {
+        @Override
         public Iterate createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new Iterate(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "iterate";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java Tue Jul 10 12:05:55 2012
@@ -23,9 +23,12 @@ import java.util.List;
 import java.util.Map;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangRuntimeException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.artifact.ArtifactInfoContext;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.ofbiz.minilang.method.envops.Break.BreakElementException;
@@ -33,53 +36,61 @@ import org.ofbiz.minilang.method.envops.
 import org.w3c.dom.Element;
 
 /**
- * Process sub-operations for each entry in the map
+ * Implements the &lt;iterate-map&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Citeratemap%3E}}">Mini-language Reference</a>
  */
-public class IterateMap extends MethodOperation {
+public final class IterateMap extends MethodOperation {
 
     public static final String module = IterateMap.class.getName();
 
-    ContextAccessor<Object> keyAcsr;
-    ContextAccessor<Map<? extends Object, ? extends Object>> mapAcsr;
-    List<MethodOperation> subOps;
-    ContextAccessor<Object> valueAcsr;
+    private final FlexibleMapAccessor<Object> keyFma;
+    private final FlexibleMapAccessor<Map<? extends Object, ? extends Object>> mapFma;
+    private final List<MethodOperation> subOps;
+    private final FlexibleMapAccessor<Object> valueFma;
 
     public IterateMap(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        this.keyAcsr = new ContextAccessor<Object>(element.getAttribute("key"), element.getAttribute("key-name"));
-        this.valueAcsr = new ContextAccessor<Object>(element.getAttribute("value"), element.getAttribute("value-name"));
-        this.mapAcsr = new ContextAccessor<Map<? extends Object, ? extends Object>>(element.getAttribute("map"), element.getAttribute("map-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "key", "map", "value");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "key", "map", "value");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "key", "map", "value");
+        }
+        this.keyFma = FlexibleMapAccessor.getInstance(element.getAttribute("key"));
+        this.mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map"));
+        this.valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value"));
         this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        if (mapAcsr.isEmpty()) {
-            Debug.logWarning("No map-name specified in iterate tag, doing nothing: " + rawString(), module);
-            return true;
+        if (mapFma.isEmpty()) {
+            throw new MiniLangRuntimeException("No map specified.", this);
         }
-        Object oldKey = keyAcsr.get(methodContext);
-        Object oldValue = valueAcsr.get(methodContext);
+        Object oldKey = keyFma.get(methodContext.getEnvMap());
+        Object oldValue = valueFma.get(methodContext.getEnvMap());
         if (oldKey != null) {
-            Debug.logWarning("In iterate-map the key had a non-null value before entering the loop for the operation: " + this.rawString(), module);
+            if (Debug.verboseOn())
+                Debug.logVerbose("In iterate-map the key had a non-null value before entering the loop for the operation: " + this, module);
         }
         if (oldValue != null) {
-            Debug.logWarning("In iterate-map the value had a non-null value before entering the loop for the operation: " + this.rawString(), module);
+            if (Debug.verboseOn())
+                Debug.logVerbose("In iterate-map the value had a non-null value before entering the loop for the operation: " + this, module);
         }
-        Map<? extends Object, ? extends Object> theMap = mapAcsr.get(methodContext);
+        Map<? extends Object, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap());
         if (theMap == null) {
-            if (Debug.infoOn())
-                Debug.logInfo("Map not found with name " + mapAcsr + ", doing nothing: " + rawString(), module);
+            if (Debug.verboseOn())
+                Debug.logVerbose("Map not found with name " + mapFma + ", doing nothing: " + this, module);
             return true;
         }
         if (theMap.size() == 0) {
             if (Debug.verboseOn())
-                Debug.logVerbose("Map with name " + mapAcsr + " has zero entries, doing nothing: " + rawString(), module);
+                Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, module);
             return true;
         }
         for (Map.Entry<? extends Object, ? extends Object> theEntry : theMap.entrySet()) {
-            keyAcsr.put(methodContext, theEntry.getKey());
-            valueAcsr.put(methodContext, theEntry.getValue());
+            keyFma.put(methodContext.getEnvMap(), theEntry.getKey());
+            valueFma.put(methodContext.getEnvMap(), theEntry.getValue());
             try {
                 for (MethodOperation methodOperation : subOps) {
                     if (!methodOperation.exec(methodContext)) {
@@ -100,25 +111,38 @@ public class IterateMap extends MethodOp
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    public List<MethodOperation> getSubOps() {
-        return this.subOps;
+    public void gatherArtifactInfo(ArtifactInfoContext aic) {
+        for (MethodOperation method : this.subOps) {
+            method.gatherArtifactInfo(aic);
+        }
     }
 
     @Override
-    public String rawString() {
-        return "<iterate-map map-name=\"" + this.mapAcsr + "\" key=\"" + this.keyAcsr + "\" value=\"" + this.valueAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<iterate-map ");
+        if (!this.mapFma.isEmpty()) {
+            sb.append("map=\"").append(this.mapFma).append("\" ");
+        }
+        if (!this.keyFma.isEmpty()) {
+            sb.append("key=\"").append(this.keyFma).append("\" ");
+        }
+        if (!this.valueFma.isEmpty()) {
+            sb.append("value=\"").append(this.valueFma).append("\" ");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;iterate-map&gt; element.
+     */
     public static final class IterateMapFactory implements Factory<IterateMap> {
+        @Override
         public IterateMap createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new IterateMap(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "iterate-map";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java Tue Jul 10 12:05:55 2012
@@ -22,66 +22,68 @@ import java.util.List;
 
 import javolution.util.FastList;
 
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 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;
 
 /**
- * Copies an environment field to a list
+ * Implements the &lt;list-to-list&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Clisttolist%3E}}">Mini-language Reference</a>
  */
-public class ListToList extends MethodOperation {
+public final class ListToList extends MethodOperation {
 
-    public static final String module = ListToList.class.getName();
-
-    ContextAccessor<List<Object>> listAcsr;
-    ContextAccessor<List<Object>> toListAcsr;
+    private final FlexibleMapAccessor<List<Object>> listFma;
+    private final FlexibleMapAccessor<List<Object>> toListFma;
 
     public ListToList(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        listAcsr = new ContextAccessor<List<Object>>(element.getAttribute("list"), element.getAttribute("list-name"));
-        toListAcsr = new ContextAccessor<List<Object>>(element.getAttribute("to-list"), element.getAttribute("to-list-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "to-list", "list");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "to-list", "list");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "to-list", "list");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        toListFma = FlexibleMapAccessor.getInstance(element.getAttribute("to-list"));
+        listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        List<Object> fromList = listAcsr.get(methodContext);
-        List<Object> toList = toListAcsr.get(methodContext);
-        if (fromList == null) {
-            if (Debug.infoOn())
-                Debug.logInfo("List not found with name " + listAcsr + ", not copying list", module);
-            return true;
-        }
-        if (toList == null) {
-            if (Debug.verboseOn())
-                Debug.logVerbose("List not found with name " + toListAcsr + ", creating new list", module);
-            toList = FastList.newInstance();
-            toListAcsr.put(methodContext, toList);
+        List<Object> fromList = listFma.get(methodContext.getEnvMap());
+        if (fromList != null) {
+            List<Object> toList = toListFma.get(methodContext.getEnvMap());
+            if (toList == null) {
+                toList = FastList.newInstance();
+                toListFma.put(methodContext.getEnvMap(), toList);
+            }
+            toList.addAll(fromList);
         }
-        toList.addAll(fromList);
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        // TODO: something more than the empty tag
-        return "<list-to-list/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<list-to-list ");
+        sb.append("to-list=\"").append(this.toListFma).append("\" ");
+        sb.append("list=\"").append(this.listFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;list-to-list&gt; element.
+     */
     public static final class ListToListFactory implements Factory<ListToList> {
+        @Override
         public ListToList createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new ListToList(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "list-to-list";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java Tue Jul 10 12:05:55 2012
@@ -21,10 +21,13 @@ package org.ofbiz.minilang.method.envops
 import java.util.Collections;
 import java.util.List;
 
-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.MiniLangRuntimeException;
+import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.artifact.ArtifactInfoContext;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
 import org.ofbiz.minilang.method.envops.Break.BreakElementException;
@@ -32,42 +35,44 @@ import org.ofbiz.minilang.method.envops.
 import org.w3c.dom.Element;
 
 /**
- * Loop
+ * Implements the &lt;loop&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cloop%3E}}">Mini-language Reference</a>
  */
-public class Loop extends MethodOperation {
+public final class Loop extends MethodOperation {
 
     public static final String module = Loop.class.getName();
 
-    protected String countStr;
-    protected ContextAccessor<Integer> fieldAcsr;
-    protected List<MethodOperation> subOps;
+    private final FlexibleStringExpander countFse;
+    private final FlexibleMapAccessor<Integer> fieldFma;
+    private final List<MethodOperation> subOps;
 
     public Loop(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        this.fieldAcsr = new ContextAccessor<Integer>(element.getAttribute("field"));
-        this.countStr = element.getAttribute("count");
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "count", "field");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "count");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "count", "field");
+        }
+        this.countFse = FlexibleStringExpander.getInstance(element.getAttribute("count"));
+        this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
         this.subOps = Collections.unmodifiableList(SimpleMethod.readOperations(element, simpleMethod));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        String countStrExp = methodContext.expandString(this.countStr);
+        String countStr = this.countFse.expandString(methodContext.getEnvMap());
         int count = 0;
         try {
-            Double ctDbl = Double.valueOf(countStrExp);
-            if (ctDbl != null) {
-                count = ctDbl.intValue();
-            }
+            count = Double.valueOf(countStr).intValue();
         } catch (NumberFormatException e) {
-            Debug.logError(e, module);
-            return false;
+            throw new MiniLangRuntimeException("Error while converting \"" + countStr + "\" to a number: " + e.getMessage(), this);
         }
         if (count < 0) {
-            Debug.logWarning("Unable to execute loop operation because the count variable is negative: " + rawString(), module);
-            return false;
+            throw new MiniLangRuntimeException("Unable to execute loop operation because the count is negative: " + countStr, this);
         }
         for (int i = 0; i < count; i++) {
-            fieldAcsr.put(methodContext, i);
+            this.fieldFma.put(methodContext.getEnvMap(), i);
             try {
                 for (MethodOperation methodOperation : subOps) {
                     if (!methodOperation.exec(methodContext)) {
@@ -88,24 +93,35 @@ public class Loop extends MethodOperatio
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        return this.rawString();
-    }
-
-    public List<MethodOperation> getSubOps() {
-        return this.subOps;
+    public void gatherArtifactInfo(ArtifactInfoContext aic) {
+        for (MethodOperation method : this.subOps) {
+            method.gatherArtifactInfo(aic);
+        }
     }
 
     @Override
-    public String rawString() {
-        return "<loop field=\"" + this.fieldAcsr + "\" count=\"" + this.countStr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<loop ");
+        if (!this.countFse.isEmpty()) {
+            sb.append("count=\"").append(this.countFse).append("\" ");
+        }
+        if (!this.fieldFma.isEmpty()) {
+            sb.append("field=\"").append(this.fieldFma).append("\" ");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;loop&gt; element.
+     */
     public static final class LoopFactory implements Factory<Loop> {
+        @Override
         public Loop createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new Loop(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "loop";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java Tue Jul 10 12:05:55 2012
@@ -22,74 +22,75 @@ import java.util.Map;
 
 import javolution.util.FastMap;
 
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 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;
 
 /**
- * Copies a map field to a map field
+ * Implements the &lt;map-to-map&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cmaptomap%3E}}">Mini-language Reference</a>
  */
-public class MapToMap extends MethodOperation {
+public final class MapToMap extends MethodOperation {
 
-    public static final String module = MapToMap.class.getName();
-
-    ContextAccessor<Map<String, Object>> mapAcsr;
-    ContextAccessor<Map<String, Object>> toMapAcsr;
+    private final FlexibleMapAccessor<Map<String, Object>> mapFma;
+    private final FlexibleMapAccessor<Map<String, Object>> toMapFma;
 
     public MapToMap(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map"), element.getAttribute("map-name"));
-        toMapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("to-map"), element.getAttribute("to-map-name"));
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "to-map", "map");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "map");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "to-map", "map");
+            MiniLangValidate.noChildElements(simpleMethod, element);
+        }
+        mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map"));
+        toMapFma = FlexibleMapAccessor.getInstance(element.getAttribute("to-map"));
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        Map<String, Object> fromMap = null;
-        if (!mapAcsr.isEmpty()) {
-            fromMap = mapAcsr.get(methodContext);
-            if (fromMap == null) {
-                if (Debug.infoOn())
-                    Debug.logInfo("Map not found with name " + mapAcsr + ", not copying from this map", module);
-                fromMap = FastMap.newInstance();
-                mapAcsr.put(methodContext, fromMap);
-            }
-        }
-        if (!toMapAcsr.isEmpty()) {
-            Map<String, Object> toMap = toMapAcsr.get(methodContext);
-            if (toMap == null) {
-                if (Debug.verboseOn())
-                    Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module);
-                toMap = FastMap.newInstance();
-                toMapAcsr.put(methodContext, toMap);
+        Map<String, Object> fromMap = mapFma.get(methodContext.getEnvMap());
+        if (fromMap != null) {
+            if (!toMapFma.isEmpty()) {
+                Map<String, Object> toMap = toMapFma.get(methodContext.getEnvMap());
+                if (toMap == null) {
+                    toMap = FastMap.newInstance();
+                    toMapFma.put(methodContext.getEnvMap(), toMap);
+                    toMap.putAll(fromMap);
+                }
+            } else {
+                methodContext.putAllEnv(fromMap);
             }
-            toMap.putAll(fromMap);
-        } else {
-            methodContext.putAllEnv(fromMap);
         }
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        // TODO: something more than the empty tag
-        return "<map-to-map/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<map-to-map ");
+        sb.append("map=\"").append(this.mapFma).append("\" ");
+        if (!toMapFma.isEmpty()) {
+            sb.append("to-map=\"").append(this.toMapFma).append("\" ");
+        }
+        sb.append("/>");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;map-to-map&gt; element.
+     */
     public static final class MapToMapFactory implements Factory<MapToMap> {
+        @Override
         public MapToMap createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new MapToMap(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "map-to-map";
         }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Now.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Now.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Now.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/Now.java Tue Jul 10 12:05:55 2012
@@ -23,21 +23,41 @@ import org.ofbiz.base.conversion.Convert
 import org.ofbiz.base.conversion.Converters;
 import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
-import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.minilang.MiniLangException;
 import org.ofbiz.minilang.MiniLangRuntimeException;
+import org.ofbiz.minilang.MiniLangUtil;
 import org.ofbiz.minilang.MiniLangValidate;
 import org.ofbiz.minilang.SimpleMethod;
 import org.ofbiz.minilang.ValidationException;
 import org.ofbiz.minilang.method.MethodContext;
 import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 /**
- * Sets a field to the current system time.
+ * Implements the &lt;now&gt;, &lt;now-date-to-env&gt;, and &lt;now-timestamp&gt; elements.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cnow%3E}}">Mini-language Reference</a>
  */
 public final class Now extends MethodOperation {
 
+    // This method is needed only during the v1 to v2 transition
+    private static boolean autoCorrect(Element element) {
+        String tagName = element.getTagName();
+        if ("now-date-to-env".equals(tagName) || "now-timestamp".equals(tagName)) {
+            Document doc = element.getOwnerDocument();
+            Element newElement = doc.createElement("now");
+            newElement.setAttribute("field", element.getAttribute("field"));
+            if ("now-date-to-env".equals(tagName)) {
+                element.setAttribute("type", "java.sql.Date");
+                newElement.setAttribute("type", "java.sql.Date");
+            }
+            element.getParentNode().replaceChild(newElement, element);
+            return true;
+        }
+        return false;
+    }
+
     private final FlexibleMapAccessor<Object> fieldFma;
     private final String type;
     private final Converter<Long, ? extends Object> converter;
@@ -45,17 +65,25 @@ public final class Now extends MethodOpe
     public Now(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
         if (MiniLangValidate.validationOn()) {
+            String tagName = element.getTagName();
+            if ("now-date-to-env".equals(tagName) || "now-timestamp".equals(tagName)) {
+                MiniLangValidate.handleError("Deprecated - use <now>", simpleMethod, element);
+            }
             MiniLangValidate.attributeNames(simpleMethod, element, "field", "type");
             MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
             MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
             MiniLangValidate.constantAttributes(simpleMethod, element, "type");
             MiniLangValidate.noChildElements(simpleMethod, element);
         }
+        boolean elementModified = autoCorrect(element);
+        if (elementModified && MiniLangUtil.autoCorrectOn()) {
+            MiniLangUtil.flagDocumentAsCorrected(element);
+        }
         this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
         this.type = element.getAttribute("type");
         Class<?> targetClass = null;
         try {
-            if (this.type.length() > 0) {
+            if (!this.type.isEmpty()) {
                 targetClass = ObjectType.loadClass(this.type);
             }
             if (targetClass == null) {
@@ -78,22 +106,12 @@ public final class Now extends MethodOpe
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap());
-    }
-
-    @Override
-    public String rawString() {
-        return toString();
-    }
-
-    @Override
     public String toString() {
         StringBuilder sb = new StringBuilder("<now ");
         if (!this.fieldFma.isEmpty()) {
             sb.append("field=\"").append(this.fieldFma).append("\" ");
         }
-        if (this.type.length() > 0) {
+        if (!this.type.isEmpty()) {
             sb.append("type=\"").append(this.type).append("\" ");
         }
         sb.append("/>");
@@ -101,13 +119,48 @@ public final class Now extends MethodOpe
     }
 
 
+    /**
+     * A factory for the &lt;now&gt; element.
+     */
     public static final class NowFactory implements Factory<Now> {
+        @Override
         public Now createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new Now(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "now";
         }
     }
+
+    /**
+     * A factory for the &lt;now-date-to-env&gt; element.
+     */
+    public static final class NowDateToEnvFactory implements Factory<Now> {
+        @Override
+        public Now createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
+            return new Now(element, simpleMethod);
+        }
+
+        @Override
+        public String getName() {
+            return "now-date-to-env";
+        }
+    }
+
+    /**
+     * A factory for the &lt;now-timestamp&gt; element.
+     */
+    public static final class NowTimestampFactory implements Factory<Now> {
+        @Override
+        public Now createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
+            return new Now(element, simpleMethod);
+        }
+
+        @Override
+        public String getName() {
+            return "now-timestamp";
+        }
+    }
 }

Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java?rev=1359626&r1=1359625&r2=1359626&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java Tue Jul 10 12:05:55 2012
@@ -18,73 +18,84 @@
  *******************************************************************************/
 package org.ofbiz.minilang.method.envops;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-import javolution.util.FastList;
-
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.base.util.collections.MapComparator;
 import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.MiniLangRuntimeException;
+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;
 
 /**
- * Copies an environment field to a list
+ * Implements the &lt;order-map-list&gt; element.
+ * 
+ * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cordermaplist%3E}}">Mini-language Reference</a>
  */
-public class OrderMapList extends MethodOperation {
-
-    public static final String module = FieldToList.class.getName();
+public final class OrderMapList extends MethodOperation {
 
-    protected ContextAccessor<List<Map<Object, Object>>> listAcsr;
-    protected MapComparator mc;
-    protected List<FlexibleMapAccessor<String>> orderByAcsrList = FastList.newInstance();
+    private final FlexibleMapAccessor<List<Map<Object, Object>>> listFma;
+    private final MapComparator mc;
 
     public OrderMapList(Element element, SimpleMethod simpleMethod) throws MiniLangException {
         super(element, simpleMethod);
-        listAcsr = new ContextAccessor<List<Map<Object, Object>>>(element.getAttribute("list"), element.getAttribute("list-name"));
-        for (Element orderByElement : UtilXml.childElementList(element, "order-by")) {
-            FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(UtilValidate.isNotEmpty(orderByElement.getAttribute("field")) ? orderByElement.getAttribute("field") : orderByElement.getAttribute("field-name"));
-            this.orderByAcsrList.add(fma);
+        if (MiniLangValidate.validationOn()) {
+            MiniLangValidate.attributeNames(simpleMethod, element, "list");
+            MiniLangValidate.requiredAttributes(simpleMethod, element, "list");
+            MiniLangValidate.expressionAttributes(simpleMethod, element, "list");
+            MiniLangValidate.childElements(simpleMethod, element, "order-by");
+            MiniLangValidate.requiredChildElements(simpleMethod, element, "order-by");
+        }
+        listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
+        List<? extends Element> orderByElements = UtilXml.childElementList(element, "order-by");
+        if (orderByElements.size() > 0) {
+            ArrayList<FlexibleMapAccessor<String>> orderByList = new ArrayList<FlexibleMapAccessor<String>>(orderByElements.size());
+            for (Element orderByElement : orderByElements) {
+                FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(orderByElement.getAttribute("field"));
+                orderByList.add(fma);
+            }
+            mc = new MapComparator(orderByList);
+        } else {
+            mc = null;
         }
-        this.mc = new MapComparator(this.orderByAcsrList);
     }
 
     @Override
     public boolean exec(MethodContext methodContext) throws MiniLangException {
-        List<Map<Object, Object>> orderList = listAcsr.get(methodContext);
-        if (orderList == null) {
-            if (Debug.infoOn())
-                Debug.logInfo("List not found with name " + listAcsr + ", not ordering/sorting list.", module);
-            return true;
+        if (mc == null) {
+            throw new MiniLangRuntimeException("order-by sub-elements not found.", this);
+        }
+        List<Map<Object, Object>> orderList = listFma.get(methodContext.getEnvMap());
+        if (orderList != null) {
+            Collections.sort(orderList, mc);
         }
-        Collections.sort(orderList, mc);
         return true;
     }
 
     @Override
-    public String expandedString(MethodContext methodContext) {
-        // TODO: something more than a stub/dummy
-        return this.rawString();
-    }
-
-    @Override
-    public String rawString() {
-        return "<order-map-list list-name=\"" + this.listAcsr + "\"/>";
+    public String toString() {
+        StringBuilder sb = new StringBuilder("<order-map-list ");
+        sb.append("list=\"").append(this.listFma).append("\" />");
+        return sb.toString();
     }
 
+    /**
+     * A factory for the &lt;order-map-list&gt; element.
+     */
     public static final class OrderMapListFactory implements Factory<OrderMapList> {
+        @Override
         public OrderMapList createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
             return new OrderMapList(element, simpleMethod);
         }
 
+        @Override
         public String getName() {
             return "order-map-list";
         }