Author: jaz
Date: Thu Feb 15 15:38:04 2007
New Revision: 508236
URL:
http://svn.apache.org/viewvc?view=rev&rev=508236Log:
eca set operation now uses the flexible string expander to access additional data from the context
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java?view=diff&rev=508236&r1=508235&r2=508236==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java Thu Feb 15 15:38:04 2007
@@ -22,12 +22,11 @@
import org.w3c.dom.Element;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.model.ModelUtil;
import java.util.Map;
-import javolution.util.FastMap;
-
/**
* ServiceEcaSetField
*/
@@ -49,9 +48,21 @@
public void eval(Map context) {
if (fieldName != null) {
+ // try to expand the envName
+ if (UtilValidate.isEmpty(value)) {
+ if (UtilValidate.isNotEmpty(envName) && envName.startsWith("${")) {
+ FlexibleStringExpander exp = new FlexibleStringExpander(envName);
+ String s = exp.expandString(context);
+ if (UtilValidate.isNotEmpty(s)) {
+ value = s;
+ }
+ Debug.log("Expanded String: " + s, module);
+ }
+ }
+
// process the context changes
if (UtilValidate.isNotEmpty(value)) {
- context.put(fieldName, this.format(value, context));
+ context.put(fieldName, this.format(value, context));
} else if (UtilValidate.isNotEmpty(envName) && context.get(envName) != null) {
context.put(fieldName, this.format((String) context.get(envName), context));
}
@@ -59,7 +70,7 @@
}
protected Object format(String s, Map c) {
- if (UtilValidate.isEmpty(s)) {
+ if (UtilValidate.isEmpty(s) || UtilValidate.isEmpty(format)) {
return s;
}