More generics work; a bit of fallout from the recent
FlexibleMapAccessor generification. Plus a few additional changes. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@682102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -87,7 +87,7 @@ public class ModelForm extends ModelWidget {
|
||||
protected String tooltip;
|
||||
protected String listName;
|
||||
protected String listEntryName;
|
||||
protected FlexibleMapAccessor defaultMapName;
|
||||
protected FlexibleMapAccessor<Map<String, ? extends Object>> defaultMapName;
|
||||
protected String defaultEntityName;
|
||||
protected String defaultServiceName;
|
||||
protected String formTitleAreaStyle;
|
||||
@@ -1785,8 +1785,8 @@ public class ModelForm extends ModelWidget {
|
||||
return this.defaultMapName.getOriginalName();
|
||||
}
|
||||
|
||||
public Map getDefaultMap(Map<String, Object> context) {
|
||||
return (Map) this.defaultMapName.get(context);
|
||||
public Map<String, ? extends Object> getDefaultMap(Map<String, ? extends Object> context) {
|
||||
return this.defaultMapName.get(context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2040,7 +2040,7 @@ public class ModelForm extends ModelWidget {
|
||||
* @param string
|
||||
*/
|
||||
public void setDefaultMapName(String string) {
|
||||
this.defaultMapName = new FlexibleMapAccessor(string);
|
||||
this.defaultMapName = new FlexibleMapAccessor<Map<String, ? extends Object>>(string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
import org.ofbiz.base.util.GroovyUtil;
|
||||
import org.ofbiz.base.util.ObjectType;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.base.util.UtilXml;
|
||||
@@ -67,10 +68,7 @@ public abstract class ModelFormAction {
|
||||
public static List<ModelFormAction> readSubActions(ModelForm modelForm, Element parentElement) {
|
||||
List<ModelFormAction> actions = new LinkedList<ModelFormAction>();
|
||||
|
||||
List actionElementList = UtilXml.childElementList(parentElement);
|
||||
Iterator actionElementIter = actionElementList.iterator();
|
||||
while (actionElementIter.hasNext()) {
|
||||
Element actionElement = (Element) actionElementIter.next();
|
||||
for (Element actionElement: UtilXml.childElementList(parentElement)) {
|
||||
if ("set".equals(actionElement.getNodeName())) {
|
||||
actions.add(new SetField(modelForm, actionElement));
|
||||
} else if ("property-map".equals(actionElement.getNodeName())) {
|
||||
@@ -95,20 +93,18 @@ public abstract class ModelFormAction {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static void runSubActions(List actions, Map<String, Object> context) {
|
||||
public static void runSubActions(List<ModelFormAction> actions, Map<String, Object> context) {
|
||||
if (actions == null) return;
|
||||
|
||||
Iterator actionIter = actions.iterator();
|
||||
while (actionIter.hasNext()) {
|
||||
ModelFormAction action = (ModelFormAction) actionIter.next();
|
||||
for (ModelFormAction action: actions) {
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Running screen action " + action.getClass().getName(), module);
|
||||
action.runAction(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetField extends ModelFormAction {
|
||||
protected FlexibleMapAccessor field;
|
||||
protected FlexibleMapAccessor fromField;
|
||||
protected FlexibleMapAccessor<Object> field;
|
||||
protected FlexibleMapAccessor<String> fromField;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
@@ -116,8 +112,8 @@ public abstract class ModelFormAction {
|
||||
|
||||
public SetField(ModelForm modelForm, Element setElement) {
|
||||
super (modelForm, setElement);
|
||||
this.field = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor(setElement.getAttribute("from-field")) : null;
|
||||
this.field = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor<String>(setElement.getAttribute("from-field")) : null;
|
||||
this.valueExdr = UtilValidate.isNotEmpty(setElement.getAttribute("value")) ? new FlexibleStringExpander(setElement.getAttribute("value")) : null;
|
||||
this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default-value"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
@@ -159,14 +155,14 @@ public abstract class ModelFormAction {
|
||||
this.field.put(context, newValue);
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.field.put(globalCtx, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
// this is a hack for backward compatibility with the JPublish page object
|
||||
Map page = (Map) context.get("page");
|
||||
Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
|
||||
if (page != null) {
|
||||
this.field.put(page, newValue);
|
||||
}
|
||||
@@ -175,13 +171,13 @@ public abstract class ModelFormAction {
|
||||
|
||||
public static class PropertyMap extends ModelFormAction {
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleMapAccessor mapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> mapNameAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyMap(ModelForm modelForm, Element setElement) {
|
||||
super (modelForm, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor(setElement.getAttribute("map-name"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor<Map<String, Object>>(setElement.getAttribute("map-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -192,11 +188,11 @@ public abstract class ModelFormAction {
|
||||
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String resource = this.resourceExdr.expandString(context, locale);
|
||||
Map propertyMap = UtilProperties.getResourceBundleMap(resource, locale);
|
||||
Map<String, Object> propertyMap = UtilProperties.getResourceBundleMap(resource, locale);
|
||||
this.mapNameAcsr.put(context, propertyMap);
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.mapNameAcsr.put(globalCtx, propertyMap);
|
||||
}
|
||||
@@ -208,20 +204,20 @@ public abstract class ModelFormAction {
|
||||
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleStringExpander propertyExdr;
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<String> fieldAcsr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected boolean noLocale;
|
||||
protected FlexibleMapAccessor argListAcsr;
|
||||
protected FlexibleMapAccessor<List<Object>> argListAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyToField(ModelForm modelForm, Element setElement) {
|
||||
super (modelForm, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<String>(setElement.getAttribute("field"));
|
||||
this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default"));
|
||||
noLocale = "true".equals(setElement.getAttribute("no-locale"));
|
||||
this.argListAcsr = new FlexibleMapAccessor(setElement.getAttribute("arg-list-name"));
|
||||
this.argListAcsr = new FlexibleMapAccessor<List<Object>>(setElement.getAttribute("arg-list-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -250,7 +246,7 @@ public abstract class ModelFormAction {
|
||||
value = FlexibleStringExpander.expandString(value, context);
|
||||
|
||||
if (!argListAcsr.isEmpty()) {
|
||||
List argList = (List) argListAcsr.get(context);
|
||||
List<Object> argList = argListAcsr.get(context);
|
||||
if (argList != null && argList.size() > 0) {
|
||||
value = MessageFormat.format(value, argList.toArray());
|
||||
}
|
||||
@@ -293,7 +289,7 @@ public abstract class ModelFormAction {
|
||||
|
||||
public static class Service extends ModelFormAction {
|
||||
protected FlexibleStringExpander serviceNameExdr;
|
||||
protected FlexibleMapAccessor resultMapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr;
|
||||
protected FlexibleStringExpander autoFieldMapExdr;
|
||||
protected FlexibleStringExpander resultMapListNameExdr;
|
||||
protected Map<FlexibleMapAccessor, Object> fieldMap;
|
||||
@@ -301,7 +297,7 @@ public abstract class ModelFormAction {
|
||||
public Service(ModelForm modelForm, Element serviceElement) {
|
||||
super (modelForm, serviceElement);
|
||||
this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor<Map<String, Object>>(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));
|
||||
if (UtilValidate.isEmpty(serviceElement.getAttribute("result-map-list-name"))) {
|
||||
if (UtilValidate.isEmpty(serviceElement.getAttribute("result-map-list-iterator-name"))) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.StringTokenizer;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.BshUtil;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
@@ -76,10 +77,10 @@ public class ModelFormField {
|
||||
protected ModelForm modelForm;
|
||||
|
||||
protected String name;
|
||||
protected FlexibleMapAccessor mapAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, ? extends Object>> mapAcsr;
|
||||
protected String entityName;
|
||||
protected String serviceName;
|
||||
protected FlexibleMapAccessor entryAcsr;
|
||||
protected FlexibleMapAccessor<Object> entryAcsr;
|
||||
protected String parameterName;
|
||||
protected String fieldName;
|
||||
protected String attributeName;
|
||||
@@ -695,7 +696,7 @@ public class ModelFormField {
|
||||
}
|
||||
} else {
|
||||
//Debug.logInfo("Getting entry, isError false so getting from Map in context for field " + this.getName() + " of form " + this.modelForm.getName(), module);
|
||||
Map dataMap = this.getMap(context);
|
||||
Map<String, ? extends Object> dataMap = this.getMap(context);
|
||||
boolean dataMapIsContext = false;
|
||||
if (dataMap == null) {
|
||||
//Debug.logInfo("Getting entry, no Map found with name " + this.getMapName() + ", using context for field " + this.getName() + " of form " + this.modelForm.getName(), module);
|
||||
@@ -723,7 +724,7 @@ public class ModelFormField {
|
||||
|
||||
// this is a special case to fill in fields during a create by default from parameters passed in
|
||||
if (dataMapIsContext && retVal == null && !Boolean.FALSE.equals(useRequestParameters)) {
|
||||
Map parameters = (Map) context.get("parameters");
|
||||
Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters"));
|
||||
if (parameters != null) {
|
||||
if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) {
|
||||
retVal = this.entryAcsr.get(parameters);
|
||||
@@ -760,13 +761,13 @@ public class ModelFormField {
|
||||
}
|
||||
}
|
||||
|
||||
public Map getMap(Map<String, Object> context) {
|
||||
public Map<String, ? extends Object> getMap(Map<String, ? extends Object> context) {
|
||||
if (this.mapAcsr == null || this.mapAcsr.isEmpty()) {
|
||||
//Debug.logInfo("Getting Map from default of the form because of no mapAcsr for field " + this.getName(), module);
|
||||
return this.modelForm.getDefaultMap(context);
|
||||
} else {
|
||||
//Debug.logInfo("Getting Map from mapAcsr for field " + this.getName(), module);
|
||||
return (Map) mapAcsr.get(context);
|
||||
return mapAcsr.get(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,7 +1218,7 @@ public class ModelFormField {
|
||||
* @param string
|
||||
*/
|
||||
public void setEntryName(String string) {
|
||||
entryAcsr = new FlexibleMapAccessor(string);
|
||||
entryAcsr = new FlexibleMapAccessor<Object>(string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1231,7 +1232,7 @@ public class ModelFormField {
|
||||
* @param string
|
||||
*/
|
||||
public void setMapName(String string) {
|
||||
this.mapAcsr = new FlexibleMapAccessor(string);
|
||||
this.mapAcsr = new FlexibleMapAccessor<Map<String, ? extends Object>>(string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1624,35 +1625,34 @@ public class ModelFormField {
|
||||
}
|
||||
|
||||
public static class ListOptions extends OptionSource {
|
||||
protected FlexibleMapAccessor listAcsr;
|
||||
protected FlexibleMapAccessor<List<? extends Object>> listAcsr;
|
||||
protected String listEntryName;
|
||||
protected FlexibleMapAccessor keyAcsr;
|
||||
protected FlexibleMapAccessor<String> keyAcsr;
|
||||
protected FlexibleStringExpander description;
|
||||
|
||||
public ListOptions(String listName, String listEntryName, String keyName, String description, FieldInfo fieldInfo) {
|
||||
this.listAcsr = new FlexibleMapAccessor(listName);
|
||||
this.listAcsr = new FlexibleMapAccessor<List<? extends Object>>(listName);
|
||||
this.listEntryName = listEntryName;
|
||||
this.keyAcsr = new FlexibleMapAccessor(keyName);
|
||||
this.keyAcsr = new FlexibleMapAccessor<String>(keyName);
|
||||
this.description = new FlexibleStringExpander(description);
|
||||
this.fieldInfo = fieldInfo;
|
||||
}
|
||||
|
||||
public ListOptions(Element optionElement, FieldInfo fieldInfo) {
|
||||
this.listEntryName = optionElement.getAttribute("list-entry-name");
|
||||
this.keyAcsr = new FlexibleMapAccessor(optionElement.getAttribute("key-name"));
|
||||
this.listAcsr = new FlexibleMapAccessor(optionElement.getAttribute("list-name"));
|
||||
this.keyAcsr = new FlexibleMapAccessor<String>(optionElement.getAttribute("key-name"));
|
||||
this.listAcsr = new FlexibleMapAccessor<List<? extends Object>>(optionElement.getAttribute("list-name"));
|
||||
this.listEntryName = optionElement.getAttribute("list-entry-name");
|
||||
this.description = new FlexibleStringExpander(optionElement.getAttribute("description"));
|
||||
this.fieldInfo = fieldInfo;
|
||||
}
|
||||
|
||||
public void addOptionValues(List<OptionValue> optionValues, Map<String, Object> context, GenericDelegator delegator) {
|
||||
List dataList = (List) this.listAcsr.get(context);
|
||||
List<? extends Object> dataList = UtilGenerics.checkList(this.listAcsr.get(context));
|
||||
if (dataList != null && dataList.size() != 0) {
|
||||
Iterator dataIter = dataList.iterator();
|
||||
while (dataIter.hasNext()) {
|
||||
Object data = dataIter.next();
|
||||
Map<String, Object> localContext = new HashMap<String, Object>(context);
|
||||
for (Object data: dataList) {
|
||||
Map<String, Object> localContext = FastMap.newInstance();
|
||||
localContext.putAll(context);
|
||||
if (UtilValidate.isNotEmpty(this.listEntryName)) {
|
||||
localContext.put(this.listEntryName, data);
|
||||
} else {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ModelMenu extends ModelWidget {
|
||||
protected String defaultCellWidth;
|
||||
protected Boolean defaultHideIfSelected;
|
||||
protected String defaultDisabledTitleStyle;
|
||||
protected FlexibleMapAccessor selectedMenuItemContextFieldName;
|
||||
protected FlexibleMapAccessor<String> selectedMenuItemContextFieldName;
|
||||
protected FlexibleStringExpander menuContainerStyleExdr;
|
||||
protected String defaultAlign;
|
||||
protected String defaultAlignStyle;
|
||||
@@ -226,7 +226,7 @@ public class ModelMenu extends ModelWidget {
|
||||
if (this.defaultDisabledTitleStyle == null || menuElement.hasAttribute("default-disabled-title-style"))
|
||||
this.defaultDisabledTitleStyle = menuElement.getAttribute("default-disabled-title-style");
|
||||
if (this.selectedMenuItemContextFieldName == null || menuElement.hasAttribute("selected-menuitem-context-field-name"))
|
||||
this.selectedMenuItemContextFieldName = new FlexibleMapAccessor(menuElement.getAttribute("selected-menuitem-context-field-name"));
|
||||
this.selectedMenuItemContextFieldName = new FlexibleMapAccessor<String>(menuElement.getAttribute("selected-menuitem-context-field-name"));
|
||||
if (this.menuContainerStyleExdr == null || menuElement.hasAttribute("menu-container-style"))
|
||||
this.setMenuContainerStyle(menuElement.getAttribute("menu-container-style"));
|
||||
if (this.defaultAlign == null || menuElement.hasAttribute("default-align"))
|
||||
@@ -440,7 +440,7 @@ public class ModelMenu extends ModelWidget {
|
||||
* @return
|
||||
*/
|
||||
public String getSelectedMenuItemContextFieldName(Map<String, Object> context) {
|
||||
String menuItemName = (String)this.selectedMenuItemContextFieldName.get(context);
|
||||
String menuItemName = this.selectedMenuItemContextFieldName.get(context);
|
||||
if (UtilValidate.isEmpty(menuItemName)) {
|
||||
return this.defaultMenuItemName;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.ofbiz.widget.menu;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -27,10 +26,13 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.BshUtil;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
import org.ofbiz.base.util.ObjectType;
|
||||
import org.ofbiz.base.util.UtilGenerics;
|
||||
import org.ofbiz.base.util.UtilFormatOut;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
@@ -117,8 +119,8 @@ public abstract class ModelMenuAction {
|
||||
}
|
||||
|
||||
public static class SetField extends ModelMenuAction {
|
||||
protected FlexibleMapAccessor field;
|
||||
protected FlexibleMapAccessor fromField;
|
||||
protected FlexibleMapAccessor<Object> field;
|
||||
protected FlexibleMapAccessor<Object> fromField;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
@@ -128,8 +130,8 @@ public abstract class ModelMenuAction {
|
||||
|
||||
public SetField(ModelMenu modelMenu, Element setElement) {
|
||||
super (modelMenu, setElement);
|
||||
this.field = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor(setElement.getAttribute("from-field")) : null;
|
||||
this.field = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor<Object>(setElement.getAttribute("from-field")) : null;
|
||||
this.valueExdr = UtilValidate.isNotEmpty(setElement.getAttribute("value")) ? new FlexibleStringExpander(setElement.getAttribute("value")) : null;
|
||||
this.defaultExdr = UtilValidate.isNotEmpty(setElement.getAttribute("default-value")) ? new FlexibleStringExpander(setElement.getAttribute("default-value")) : null;
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
@@ -219,14 +221,14 @@ public abstract class ModelMenuAction {
|
||||
}
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.field.put(globalCtx, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
// this is a hack for backward compatibility with the JPublish page object
|
||||
Map page = (Map) context.get("page");
|
||||
Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
|
||||
if (page != null) {
|
||||
this.field.put(page, newValue);
|
||||
}
|
||||
@@ -235,13 +237,13 @@ public abstract class ModelMenuAction {
|
||||
|
||||
public static class PropertyMap extends ModelMenuAction {
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleMapAccessor mapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> mapNameAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyMap(ModelMenu modelMenu, Element setElement) {
|
||||
super (modelMenu, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor(setElement.getAttribute("map-name"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor<Map<String, Object>>(setElement.getAttribute("map-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -252,11 +254,11 @@ public abstract class ModelMenuAction {
|
||||
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String resource = this.resourceExdr.expandString(context, locale);
|
||||
Map propertyMap = UtilProperties.getResourceBundleMap(resource, locale);
|
||||
Map<String, Object> propertyMap = UtilProperties.getResourceBundleMap(resource, locale);
|
||||
this.mapNameAcsr.put(context, propertyMap);
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.mapNameAcsr.put(globalCtx, propertyMap);
|
||||
}
|
||||
@@ -268,20 +270,20 @@ public abstract class ModelMenuAction {
|
||||
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleStringExpander propertyExdr;
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected boolean noLocale;
|
||||
protected FlexibleMapAccessor argListAcsr;
|
||||
protected FlexibleMapAccessor<List<? extends Object>> argListAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyToField(ModelMenu modelMenu, Element setElement) {
|
||||
super (modelMenu, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default"));
|
||||
noLocale = "true".equals(setElement.getAttribute("no-locale"));
|
||||
this.argListAcsr = new FlexibleMapAccessor(setElement.getAttribute("arg-list-name"));
|
||||
this.argListAcsr = new FlexibleMapAccessor<List<? extends Object>>(setElement.getAttribute("arg-list-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -308,7 +310,7 @@ public abstract class ModelMenuAction {
|
||||
value = FlexibleStringExpander.expandString(value, context);
|
||||
|
||||
if (!argListAcsr.isEmpty()) {
|
||||
List argList = (List) argListAcsr.get(context);
|
||||
List<? extends Object> argList = argListAcsr.get(context);
|
||||
if (argList != null && argList.size() > 0) {
|
||||
value = MessageFormat.format(value, argList.toArray());
|
||||
}
|
||||
@@ -343,26 +345,24 @@ public abstract class ModelMenuAction {
|
||||
|
||||
public static class Service extends ModelMenuAction {
|
||||
protected FlexibleStringExpander serviceNameExdr;
|
||||
protected FlexibleMapAccessor resultMapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr;
|
||||
protected FlexibleStringExpander autoFieldMapExdr;
|
||||
protected Map<FlexibleMapAccessor, FlexibleMapAccessor> fieldMap;
|
||||
protected Map<FlexibleMapAccessor<Object>, FlexibleMapAccessor<Object>> fieldMap;
|
||||
|
||||
public Service(ModelMenu modelMenu, Element serviceElement) {
|
||||
super (modelMenu, serviceElement);
|
||||
this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor<Map<String, Object>>(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));
|
||||
|
||||
List fieldMapElementList = UtilXml.childElementList(serviceElement, "field-map");
|
||||
List<? extends Element> fieldMapElementList = UtilXml.childElementList(serviceElement, "field-map");
|
||||
if (fieldMapElementList.size() > 0) {
|
||||
this.fieldMap = new HashMap<FlexibleMapAccessor, FlexibleMapAccessor>();
|
||||
Iterator fieldMapElementIter = fieldMapElementList.iterator();
|
||||
while (fieldMapElementIter.hasNext()) {
|
||||
Element fieldMapElement = (Element) fieldMapElementIter.next();
|
||||
this.fieldMap = FastMap.newInstance();
|
||||
for (Element fieldMapElement: fieldMapElementList) {
|
||||
// set the env-name for each field-name, noting that if no field-name is specified it defaults to the env-name
|
||||
this.fieldMap.put(
|
||||
new FlexibleMapAccessor(UtilFormatOut.checkEmpty(fieldMapElement.getAttribute("field-name"), fieldMapElement.getAttribute("env-name"))),
|
||||
new FlexibleMapAccessor(fieldMapElement.getAttribute("env-name")));
|
||||
new FlexibleMapAccessor<Object>(UtilFormatOut.checkEmpty(fieldMapElement.getAttribute("field-name"), fieldMapElement.getAttribute("env-name"))),
|
||||
new FlexibleMapAccessor<Object>(fieldMapElement.getAttribute("env-name")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,15 +381,13 @@ public abstract class ModelMenuAction {
|
||||
if (autoFieldMapBool) {
|
||||
serviceContext = this.modelMenu.getDispacher().getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context);
|
||||
} else {
|
||||
serviceContext = new HashMap<String, Object>();
|
||||
serviceContext = FastMap.newInstance();
|
||||
}
|
||||
|
||||
if (this.fieldMap != null) {
|
||||
Iterator fieldMapEntryIter = this.fieldMap.entrySet().iterator();
|
||||
while (fieldMapEntryIter.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) fieldMapEntryIter.next();
|
||||
FlexibleMapAccessor serviceContextFieldAcsr = (FlexibleMapAccessor) entry.getKey();
|
||||
FlexibleMapAccessor contextEnvAcsr = (FlexibleMapAccessor) entry.getValue();
|
||||
for (Map.Entry<FlexibleMapAccessor<Object>, FlexibleMapAccessor<Object>> entry: this.fieldMap.entrySet()) {
|
||||
FlexibleMapAccessor<Object> serviceContextFieldAcsr = entry.getKey();
|
||||
FlexibleMapAccessor<Object> contextEnvAcsr = entry.getValue();
|
||||
serviceContextFieldAcsr.put(serviceContext, contextEnvAcsr.get(context));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,13 +331,13 @@ public class ModelMenuCondition {
|
||||
}
|
||||
|
||||
public static class IfValidateMethod extends MenuCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander methodExdr;
|
||||
protected FlexibleStringExpander classExdr;
|
||||
|
||||
public IfValidateMethod(ModelMenuItem modelMenuItem, Element condElement) {
|
||||
super (modelMenuItem, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.methodExdr = new FlexibleStringExpander(condElement.getAttribute("method"));
|
||||
this.classExdr = new FlexibleStringExpander(condElement.getAttribute("class"));
|
||||
}
|
||||
@@ -390,7 +390,7 @@ public class ModelMenuCondition {
|
||||
}
|
||||
|
||||
public static class IfCompare extends MenuCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
|
||||
protected String operator;
|
||||
@@ -399,7 +399,7 @@ public class ModelMenuCondition {
|
||||
|
||||
public IfCompare(ModelMenuItem modelMenuItem, Element condElement) {
|
||||
super (modelMenuItem, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.valueExdr = new FlexibleStringExpander(condElement.getAttribute("value"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
@@ -439,8 +439,8 @@ public class ModelMenuCondition {
|
||||
}
|
||||
|
||||
public static class IfCompareField extends MenuCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor toFieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> toFieldAcsr;
|
||||
|
||||
protected String operator;
|
||||
protected String type;
|
||||
@@ -448,8 +448,8 @@ public class ModelMenuCondition {
|
||||
|
||||
public IfCompareField(ModelMenuItem modelMenuItem, Element condElement) {
|
||||
super (modelMenuItem, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("to-field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("to-field-name"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
this.type = condElement.getAttribute("type");
|
||||
@@ -491,12 +491,12 @@ public class ModelMenuCondition {
|
||||
static PatternMatcher matcher = new Perl5Matcher();
|
||||
static PatternCompiler compiler = new Perl5Compiler();
|
||||
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander exprExdr;
|
||||
|
||||
public IfRegexp(ModelMenuItem modelMenuItem, Element condElement) {
|
||||
super (modelMenuItem, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.exprExdr = new FlexibleStringExpander(condElement.getAttribute("expr"));
|
||||
}
|
||||
|
||||
@@ -526,11 +526,11 @@ public class ModelMenuCondition {
|
||||
}
|
||||
|
||||
public static class IfEmpty extends MenuCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
|
||||
public IfEmpty(ModelMenuItem modelMenuItem, Element condElement) {
|
||||
super (modelMenuItem, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
}
|
||||
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
|
||||
|
||||
protected ModelScreenWidget childWidget;
|
||||
protected List<ModelScreenWidget.Section> sectionList;
|
||||
protected FlexibleMapAccessor listNameExdr;
|
||||
protected FlexibleMapAccessor<Object> listNameExdr;
|
||||
protected FlexibleStringExpander entryNameExdr;
|
||||
protected FlexibleStringExpander keyNameExdr;
|
||||
protected FlexibleStringExpander paginateTarget;
|
||||
@@ -67,7 +67,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
|
||||
|
||||
public IterateSectionWidget(ModelScreen modelScreen, Element iterateSectionElement) {
|
||||
super(modelScreen, iterateSectionElement);
|
||||
listNameExdr = new FlexibleMapAccessor(iterateSectionElement.getAttribute("list-name"));
|
||||
listNameExdr = new FlexibleMapAccessor<Object>(iterateSectionElement.getAttribute("list-name"));
|
||||
entryNameExdr = new FlexibleStringExpander(iterateSectionElement.getAttribute("entry-name"));
|
||||
keyNameExdr = new FlexibleStringExpander(iterateSectionElement.getAttribute("key-name"));
|
||||
if (this.paginateTarget == null || iterateSectionElement.hasAttribute("paginate-target"))
|
||||
@@ -133,9 +133,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
|
||||
contextMs.put("itemIndex", Integer.valueOf(itemIndex));
|
||||
|
||||
rowCount++;
|
||||
Iterator sectionIter = this.sectionList.iterator();
|
||||
while (sectionIter.hasNext()) {
|
||||
ModelScreenWidget.Section section = (ModelScreenWidget.Section)sectionIter.next();
|
||||
for (ModelScreenWidget.Section section: this.sectionList) {
|
||||
section.renderWidgetString(writer, contextMs, screenStringRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class SetField extends ModelScreenAction {
|
||||
protected FlexibleMapAccessor field;
|
||||
protected FlexibleMapAccessor fromField;
|
||||
protected FlexibleMapAccessor<Object> field;
|
||||
protected FlexibleMapAccessor<Object> fromField;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
@@ -136,8 +136,8 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
|
||||
public SetField(ModelScreen modelScreen, Element setElement) {
|
||||
super (modelScreen, setElement);
|
||||
this.field = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fromField = new FlexibleMapAccessor(setElement.getAttribute("from-field"));
|
||||
this.field = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.fromField = new FlexibleMapAccessor<Object>(setElement.getAttribute("from-field"));
|
||||
this.valueExdr = new FlexibleStringExpander(setElement.getAttribute("value"));
|
||||
this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default-value"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
@@ -232,7 +232,7 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
}
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.field.put(globalCtx, newValue);
|
||||
} else {
|
||||
@@ -241,7 +241,7 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
}
|
||||
|
||||
// this is a hack for backward compatibility with the JPublish page object
|
||||
Map page = (Map) context.get("page");
|
||||
Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
|
||||
if (page != null) {
|
||||
this.field.put(page, newValue);
|
||||
}
|
||||
@@ -280,13 +280,13 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
@SuppressWarnings("serial")
|
||||
public static class PropertyMap extends ModelScreenAction {
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleMapAccessor mapNameAcsr;
|
||||
protected FlexibleMapAccessor<ResourceBundleMapWrapper> mapNameAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyMap(ModelScreen modelScreen, Element setElement) {
|
||||
super (modelScreen, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor(setElement.getAttribute("map-name"));
|
||||
this.mapNameAcsr = new FlexibleMapAccessor<ResourceBundleMapWrapper>(setElement.getAttribute("map-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
String resource = this.resourceExdr.expandString(context, locale);
|
||||
|
||||
ResourceBundleMapWrapper existingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(context);
|
||||
ResourceBundleMapWrapper existingPropMap = this.mapNameAcsr.get(context);
|
||||
if (existingPropMap == null) {
|
||||
this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale, context));
|
||||
} else {
|
||||
@@ -306,9 +306,9 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
}
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
ResourceBundleMapWrapper globalExistingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(globalCtx);
|
||||
ResourceBundleMapWrapper globalExistingPropMap = this.mapNameAcsr.get(globalCtx);
|
||||
if (globalExistingPropMap == null) {
|
||||
this.mapNameAcsr.put(globalCtx, UtilProperties.getResourceBundleMap(resource, locale, context));
|
||||
} else {
|
||||
@@ -327,20 +327,20 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
|
||||
protected FlexibleStringExpander resourceExdr;
|
||||
protected FlexibleStringExpander propertyExdr;
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander defaultExdr;
|
||||
protected boolean noLocale;
|
||||
protected FlexibleMapAccessor argListAcsr;
|
||||
protected FlexibleMapAccessor<List<? extends Object>> argListAcsr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
|
||||
public PropertyToField(ModelScreen modelScreen, Element setElement) {
|
||||
super (modelScreen, setElement);
|
||||
this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource"));
|
||||
this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default"));
|
||||
noLocale = "true".equals(setElement.getAttribute("no-locale"));
|
||||
this.argListAcsr = new FlexibleMapAccessor(setElement.getAttribute("arg-list-name"));
|
||||
this.argListAcsr = new FlexibleMapAccessor<List<? extends Object>>(setElement.getAttribute("arg-list-name"));
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
value = FlexibleStringExpander.expandString(value, context);
|
||||
|
||||
if (!argListAcsr.isEmpty()) {
|
||||
List argList = (List) argListAcsr.get(context);
|
||||
List<? extends Object> argList = argListAcsr.get(context);
|
||||
if (argList != null && argList.size() > 0) {
|
||||
value = MessageFormat.format(value, argList.toArray());
|
||||
}
|
||||
@@ -423,14 +423,14 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
@SuppressWarnings("serial")
|
||||
public static class Service extends ModelScreenAction {
|
||||
protected FlexibleStringExpander serviceNameExdr;
|
||||
protected FlexibleMapAccessor resultMapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr;
|
||||
protected FlexibleStringExpander autoFieldMapExdr;
|
||||
protected Map<FlexibleMapAccessor, Object> fieldMap;
|
||||
|
||||
public Service(ModelScreen modelScreen, Element serviceElement) {
|
||||
super (modelScreen, serviceElement);
|
||||
this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor<Map<String, Object>>(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));
|
||||
this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement);
|
||||
}
|
||||
@@ -558,15 +558,15 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class GetRelatedOne extends ModelScreenAction {
|
||||
protected FlexibleMapAccessor valueNameAcsr;
|
||||
protected FlexibleMapAccessor toValueNameAcsr;
|
||||
protected FlexibleMapAccessor<Object> valueNameAcsr;
|
||||
protected FlexibleMapAccessor<Object> toValueNameAcsr;
|
||||
protected String relationName;
|
||||
protected boolean useCache;
|
||||
|
||||
public GetRelatedOne(ModelScreen modelScreen, Element getRelatedOneElement) {
|
||||
super (modelScreen, getRelatedOneElement);
|
||||
this.valueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("value-name"));
|
||||
this.toValueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("to-value-name"));
|
||||
this.valueNameAcsr = new FlexibleMapAccessor<Object>(getRelatedOneElement.getAttribute("value-name"));
|
||||
this.toValueNameAcsr = new FlexibleMapAccessor<Object>(getRelatedOneElement.getAttribute("to-value-name"));
|
||||
this.relationName = getRelatedOneElement.getAttribute("relation-name");
|
||||
this.useCache = "true".equals(getRelatedOneElement.getAttribute("use-cache"));
|
||||
}
|
||||
@@ -600,20 +600,20 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class GetRelated extends ModelScreenAction {
|
||||
protected FlexibleMapAccessor valueNameAcsr;
|
||||
protected FlexibleMapAccessor listNameAcsr;
|
||||
protected FlexibleMapAccessor mapAcsr;
|
||||
protected FlexibleMapAccessor orderByListAcsr;
|
||||
protected FlexibleMapAccessor<Object> valueNameAcsr;
|
||||
protected FlexibleMapAccessor<List<GenericValue>> listNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> mapAcsr;
|
||||
protected FlexibleMapAccessor<List<String>> orderByListAcsr;
|
||||
protected String relationName;
|
||||
protected boolean useCache;
|
||||
|
||||
public GetRelated(ModelScreen modelScreen, Element getRelatedElement) {
|
||||
super (modelScreen, getRelatedElement);
|
||||
this.valueNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("value-name"));
|
||||
this.listNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("list-name"));
|
||||
this.valueNameAcsr = new FlexibleMapAccessor<Object>(getRelatedElement.getAttribute("value-name"));
|
||||
this.listNameAcsr = new FlexibleMapAccessor<List<GenericValue>>(getRelatedElement.getAttribute("list-name"));
|
||||
this.relationName = getRelatedElement.getAttribute("relation-name");
|
||||
this.mapAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("map-name"));
|
||||
this.orderByListAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("order-by-list-name"));
|
||||
this.mapAcsr = new FlexibleMapAccessor<Map<String, Object>>(getRelatedElement.getAttribute("map-name"));
|
||||
this.orderByListAcsr = new FlexibleMapAccessor<List<String>>(getRelatedElement.getAttribute("order-by-list-name"));
|
||||
this.useCache = "true".equals(getRelatedElement.getAttribute("use-cache"));
|
||||
}
|
||||
|
||||
@@ -631,11 +631,11 @@ public abstract class ModelScreenAction implements Serializable {
|
||||
GenericValue value = (GenericValue) valueObject;
|
||||
List<String> orderByNames = null;
|
||||
if (!orderByListAcsr.isEmpty()) {
|
||||
orderByNames = UtilGenerics.toList(orderByListAcsr.get(context));
|
||||
orderByNames = orderByListAcsr.get(context);
|
||||
}
|
||||
Map<String, Object> constraintMap = null;
|
||||
if (!mapAcsr.isEmpty()) {
|
||||
constraintMap = UtilGenerics.toMap(mapAcsr.get(context));
|
||||
constraintMap = mapAcsr.get(context);
|
||||
}
|
||||
try {
|
||||
if (useCache) {
|
||||
|
||||
@@ -324,13 +324,13 @@ public class ModelScreenCondition implements Serializable {
|
||||
}
|
||||
|
||||
public static class IfValidateMethod extends ScreenCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander methodExdr;
|
||||
protected FlexibleStringExpander classExdr;
|
||||
|
||||
public IfValidateMethod(ModelScreen modelScreen, Element condElement) {
|
||||
super (modelScreen, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.methodExdr = new FlexibleStringExpander(condElement.getAttribute("method"));
|
||||
this.classExdr = new FlexibleStringExpander(condElement.getAttribute("class"));
|
||||
}
|
||||
@@ -383,7 +383,7 @@ public class ModelScreenCondition implements Serializable {
|
||||
}
|
||||
|
||||
public static class IfCompare extends ScreenCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
|
||||
protected String operator;
|
||||
@@ -392,7 +392,7 @@ public class ModelScreenCondition implements Serializable {
|
||||
|
||||
public IfCompare(ModelScreen modelScreen, Element condElement) {
|
||||
super (modelScreen, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.valueExdr = new FlexibleStringExpander(condElement.getAttribute("value"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
@@ -432,8 +432,8 @@ public class ModelScreenCondition implements Serializable {
|
||||
}
|
||||
|
||||
public static class IfCompareField extends ScreenCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor toFieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> toFieldAcsr;
|
||||
|
||||
protected String operator;
|
||||
protected String type;
|
||||
@@ -441,8 +441,8 @@ public class ModelScreenCondition implements Serializable {
|
||||
|
||||
public IfCompareField(ModelScreen modelScreen, Element condElement) {
|
||||
super (modelScreen, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("to-field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("to-field-name"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
this.type = condElement.getAttribute("type");
|
||||
@@ -484,12 +484,12 @@ public class ModelScreenCondition implements Serializable {
|
||||
static PatternMatcher matcher = new Perl5Matcher();
|
||||
static PatternCompiler compiler = new Perl5Compiler();
|
||||
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander exprExdr;
|
||||
|
||||
public IfRegexp(ModelScreen modelScreen, Element condElement) {
|
||||
super (modelScreen, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.exprExdr = new FlexibleStringExpander(condElement.getAttribute("expr"));
|
||||
}
|
||||
|
||||
@@ -519,11 +519,11 @@ public class ModelScreenCondition implements Serializable {
|
||||
}
|
||||
|
||||
public static class IfEmpty extends ScreenCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
|
||||
public IfEmpty(ModelScreen modelScreen, Element condElement) {
|
||||
super (modelScreen, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
}
|
||||
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
|
||||
@@ -20,8 +20,6 @@ package org.ofbiz.widget.tree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
@@ -31,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
@@ -69,8 +68,8 @@ public class ModelTree extends ModelWidget {
|
||||
protected String rootNodeName;
|
||||
protected String defaultRenderStyle;
|
||||
protected FlexibleStringExpander defaultWrapStyleExdr;
|
||||
protected List<ModelNode> nodeList = new ArrayList<ModelNode>();
|
||||
protected Map<String, ModelNode> nodeMap = new HashMap<String, ModelNode>();
|
||||
protected List<ModelNode> nodeList = FastList.newInstance();
|
||||
protected Map<String, ModelNode> nodeMap = FastMap.newInstance();
|
||||
protected GenericDelegator delegator;
|
||||
protected LocalDispatcher dispatcher;
|
||||
protected FlexibleStringExpander expandCollapseRequestExdr;
|
||||
@@ -266,8 +265,8 @@ public class ModelTree extends ModelWidget {
|
||||
protected Label label;
|
||||
protected Link link;
|
||||
protected Image image;
|
||||
protected List<ModelSubNode> subNodeList = new ArrayList<ModelSubNode>();
|
||||
protected List<ModelTreeAction> actions = new ArrayList<ModelTreeAction>();
|
||||
protected List<ModelSubNode> subNodeList = FastList.newInstance();
|
||||
protected List<ModelTreeAction> actions = FastList.newInstance();
|
||||
protected String name;
|
||||
protected ModelTree modelTree;
|
||||
protected List<Object []> subNodeValues;
|
||||
@@ -536,17 +535,15 @@ public class ModelTree extends ModelWidget {
|
||||
}
|
||||
|
||||
public void getChildren(Map<String, Object> context) {
|
||||
this.subNodeValues = new ArrayList<Object []>();
|
||||
Iterator nodeIter = subNodeList.iterator();
|
||||
while (nodeIter.hasNext()) {
|
||||
ModelSubNode subNode = (ModelSubNode)nodeIter.next();
|
||||
this.subNodeValues = FastList.newInstance();
|
||||
for (ModelSubNode subNode: subNodeList) {
|
||||
String nodeName = subNode.getNodeName(context);
|
||||
ModelNode node = (ModelNode)modelTree.nodeMap.get(nodeName);
|
||||
List subNodeActions = subNode.getActions();
|
||||
List<ModelTreeAction> subNodeActions = subNode.getActions();
|
||||
//if (Debug.infoOn()) Debug.logInfo(" context.currentValue:" + context.get("currentValue"), module);
|
||||
ModelTreeAction.runSubActions(subNodeActions, context);
|
||||
// List dataFound = (List)context.get("dataFound");
|
||||
ListIterator dataIter = subNode.getListIterator();
|
||||
Iterator<? extends Map<String, ? extends Object>> dataIter = subNode.getListIterator();
|
||||
if (dataIter instanceof EntityListIterator) {
|
||||
EntityListIterator eli = (EntityListIterator) dataIter;
|
||||
Map val = null;
|
||||
@@ -686,8 +683,8 @@ public class ModelTree extends ModelWidget {
|
||||
|
||||
protected ModelNode rootNode;
|
||||
protected FlexibleStringExpander nodeNameExdr;
|
||||
protected List<ModelTreeAction> actions = new ArrayList<ModelTreeAction>();
|
||||
protected ListIterator listIterator;
|
||||
protected List<ModelTreeAction> actions = FastList.newInstance();
|
||||
protected ListIterator<? extends Map<String, ? extends Object>> listIterator;
|
||||
|
||||
public ModelSubNode() {}
|
||||
|
||||
@@ -726,15 +723,15 @@ public class ModelTree extends ModelWidget {
|
||||
return this.nodeNameExdr.expandString(context);
|
||||
}
|
||||
|
||||
public List getActions() {
|
||||
public List<ModelTreeAction> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setListIterator(ListIterator iter) {
|
||||
public void setListIterator(ListIterator<? extends Map<String, ? extends Object>> iter) {
|
||||
listIterator = iter;
|
||||
}
|
||||
|
||||
public ListIterator getListIterator() {
|
||||
public ListIterator<? extends Map<String, ? extends Object>> getListIterator() {
|
||||
return listIterator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.widget.tree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
@@ -27,6 +26,8 @@ import java.util.Map;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
import org.ofbiz.base.util.BshUtil;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.GeneralException;
|
||||
@@ -102,26 +103,24 @@ public abstract class ModelTreeAction {
|
||||
}
|
||||
*/
|
||||
|
||||
public static void runSubActions(List actions, Map<String, Object> context) {
|
||||
Iterator actionIter = actions.iterator();
|
||||
while (actionIter.hasNext()) {
|
||||
ModelTreeAction action = (ModelTreeAction) actionIter.next();
|
||||
public static void runSubActions(List<ModelTreeAction> actions, Map<String, Object> context) {
|
||||
for (ModelTreeAction action: actions) {
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module);
|
||||
action.runAction(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetField extends ModelTreeAction {
|
||||
protected FlexibleMapAccessor field;
|
||||
protected FlexibleMapAccessor fromField;
|
||||
protected FlexibleMapAccessor<Object> field;
|
||||
protected FlexibleMapAccessor<Object> fromField;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
protected FlexibleStringExpander globalExdr;
|
||||
protected String type;
|
||||
|
||||
public SetField(ModelTree.ModelNode modelNode, Element setElement) {
|
||||
super (modelNode, setElement);
|
||||
this.field = new FlexibleMapAccessor(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor(setElement.getAttribute("from-field")) : null;
|
||||
this.field = new FlexibleMapAccessor<Object>(setElement.getAttribute("field"));
|
||||
this.fromField = UtilValidate.isNotEmpty(setElement.getAttribute("from-field")) ? new FlexibleMapAccessor<Object>(setElement.getAttribute("from-field")) : null;
|
||||
this.valueExdr = UtilValidate.isNotEmpty(setElement.getAttribute("value")) ? new FlexibleStringExpander(setElement.getAttribute("value")) : null;
|
||||
this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global"));
|
||||
this.type = setElement.getAttribute("type");
|
||||
@@ -154,14 +153,14 @@ public abstract class ModelTreeAction {
|
||||
this.field.put(context, newValue);
|
||||
|
||||
if (global) {
|
||||
Map globalCtx = (Map) context.get("globalContext");
|
||||
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
|
||||
if (globalCtx != null) {
|
||||
this.field.put(globalCtx, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
// this is a hack for backward compatibility with the JPublish page object
|
||||
Map page = (Map) context.get("page");
|
||||
Map<String, Object> page = UtilGenerics.checkMap(context.get("page"));
|
||||
if (page != null) {
|
||||
this.field.put(page, newValue);
|
||||
}
|
||||
@@ -189,10 +188,13 @@ public abstract class ModelTreeAction {
|
||||
Object obj = context.get("_LIST_ITERATOR_");
|
||||
if (this.modelSubNode != null) {
|
||||
if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator)) {
|
||||
this.modelSubNode.setListIterator((ListIterator)obj);
|
||||
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
|
||||
this.modelSubNode.setListIterator(listIt);
|
||||
} else {
|
||||
if (obj instanceof List)
|
||||
this.modelSubNode.setListIterator(((List)obj).listIterator());
|
||||
if (obj instanceof List) {
|
||||
List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
|
||||
this.modelSubNode.setListIterator(list.listIterator());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (GeneralException e) {
|
||||
@@ -208,7 +210,7 @@ public abstract class ModelTreeAction {
|
||||
|
||||
public static class Service extends ModelTreeAction {
|
||||
protected FlexibleStringExpander serviceNameExdr;
|
||||
protected FlexibleMapAccessor resultMapNameAcsr;
|
||||
protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr;
|
||||
protected FlexibleStringExpander autoFieldMapExdr;
|
||||
protected FlexibleStringExpander resultMapListNameExdr;
|
||||
protected FlexibleStringExpander resultMapListIteratorNameExdr;
|
||||
@@ -229,7 +231,7 @@ public abstract class ModelTreeAction {
|
||||
public void initService( Element serviceElement ) {
|
||||
|
||||
this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name"));
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor<Map<String, Object>>(serviceElement.getAttribute("result-map-name")) : null;
|
||||
this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map"));
|
||||
this.resultMapListNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("result-map-list-name"));
|
||||
this.resultMapListIteratorNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("result-map-list-iterator-name"));
|
||||
@@ -252,7 +254,7 @@ public abstract class ModelTreeAction {
|
||||
if (autoFieldMapBool) {
|
||||
serviceContext = this.modelTree.getDispatcher().getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context);
|
||||
} else {
|
||||
serviceContext = new HashMap<String, Object>();
|
||||
serviceContext = FastMap.newInstance();
|
||||
}
|
||||
|
||||
if (this.fieldMap != null) {
|
||||
@@ -285,9 +287,10 @@ public abstract class ModelTreeAction {
|
||||
if (this.modelSubNode != null) {
|
||||
//ListIterator iter = null;
|
||||
if (UtilValidate.isNotEmpty(resultMapListIteratorName)) {
|
||||
this.modelSubNode.setListIterator((ListIterator)result.get(resultMapListIteratorName));
|
||||
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(result.get(resultMapListIteratorName));
|
||||
this.modelSubNode.setListIterator(listIt);
|
||||
} else if (UtilValidate.isNotEmpty(resultMapListName)) {
|
||||
List lst = (List)result.get(resultMapListName);
|
||||
List<? extends Map<String, ? extends Object>> lst = UtilGenerics.checkList(result.get(resultMapListName));
|
||||
if (lst != null ) {
|
||||
this.modelSubNode.setListIterator(lst.listIterator());
|
||||
}
|
||||
@@ -353,9 +356,13 @@ public abstract class ModelTreeAction {
|
||||
finder.runFind(context, this.modelTree.getDelegator());
|
||||
Object obj = context.get(this.listName);
|
||||
if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator)) {
|
||||
this.modelSubNode.setListIterator((ListIterator)obj);
|
||||
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
|
||||
this.modelSubNode.setListIterator(listIt);
|
||||
} else {
|
||||
if (obj instanceof List) this.modelSubNode.setListIterator(((List)obj).listIterator());
|
||||
if (obj instanceof List) {
|
||||
List<? extends Map<String, ? extends Object>> list = UtilGenerics.checkList(obj);
|
||||
this.modelSubNode.setListIterator(list.listIterator());
|
||||
}
|
||||
}
|
||||
} catch (GeneralException e) {
|
||||
String errMsg = "Error doing entity query by condition: " + e.toString();
|
||||
@@ -387,9 +394,13 @@ public abstract class ModelTreeAction {
|
||||
finder.runFind(context, this.modelTree.getDelegator());
|
||||
Object obj = context.get(this.listName);
|
||||
if (obj != null && (obj instanceof EntityListIterator || obj instanceof ListIterator)) {
|
||||
this.modelSubNode.setListIterator((ListIterator)obj);
|
||||
ListIterator<? extends Map<String, ? extends Object>> listIt = UtilGenerics.cast(obj);
|
||||
this.modelSubNode.setListIterator(listIt);
|
||||
} else {
|
||||
if (obj instanceof List) this.modelSubNode.setListIterator(((List)obj).listIterator());
|
||||
if (obj instanceof List) {
|
||||
List<? extends Map<String, ? extends Object>> list = UtilGenerics.cast(obj);
|
||||
this.modelSubNode.setListIterator(list.listIterator());
|
||||
}
|
||||
}
|
||||
} catch (GeneralException e) {
|
||||
String errMsg = "Error doing entity query by condition: " + e.toString();
|
||||
|
||||
@@ -78,12 +78,9 @@ public class ModelTreeCondition {
|
||||
public abstract boolean eval(Map<String, Object> context);
|
||||
}
|
||||
|
||||
public static List readSubConditions(ModelTree modelTree, Element conditionElement) {
|
||||
public static List<TreeCondition> readSubConditions(ModelTree modelTree, Element conditionElement) {
|
||||
List<TreeCondition> condList = FastList.newInstance();
|
||||
List subElementList = UtilXml.childElementList(conditionElement);
|
||||
Iterator subElementIter = subElementList.iterator();
|
||||
while (subElementIter.hasNext()) {
|
||||
Element subElement = (Element) subElementIter.next();
|
||||
for (Element subElement: UtilXml.childElementList(conditionElement)) {
|
||||
condList.add(readCondition(modelTree, subElement));
|
||||
}
|
||||
return condList;
|
||||
@@ -121,7 +118,7 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class And extends TreeCondition {
|
||||
protected List subConditions;
|
||||
protected List<TreeCondition> subConditions;
|
||||
|
||||
public And(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
@@ -130,9 +127,7 @@ public class ModelTreeCondition {
|
||||
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
// return false for the first one in the list that is false, basic and algo
|
||||
Iterator subConditionIter = this.subConditions.iterator();
|
||||
while (subConditionIter.hasNext()) {
|
||||
TreeCondition subCondition = (TreeCondition) subConditionIter.next();
|
||||
for (TreeCondition subCondition: subConditions) {
|
||||
if (!subCondition.eval(context)) {
|
||||
return false;
|
||||
}
|
||||
@@ -142,7 +137,7 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class Xor extends TreeCondition {
|
||||
protected List subConditions;
|
||||
protected List<TreeCondition> subConditions;
|
||||
|
||||
public Xor(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
@@ -152,9 +147,7 @@ public class ModelTreeCondition {
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
// if more than one is true stop immediately and return false; if all are false return false; if only one is true return true
|
||||
boolean foundOneTrue = false;
|
||||
Iterator subConditionIter = this.subConditions.iterator();
|
||||
while (subConditionIter.hasNext()) {
|
||||
TreeCondition subCondition = (TreeCondition) subConditionIter.next();
|
||||
for (TreeCondition subCondition: subConditions) {
|
||||
if (subCondition.eval(context)) {
|
||||
if (foundOneTrue) {
|
||||
// now found two true, so return false
|
||||
@@ -169,7 +162,7 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class Or extends TreeCondition {
|
||||
protected List subConditions;
|
||||
protected List<TreeCondition> subConditions;
|
||||
|
||||
public Or(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
@@ -178,9 +171,7 @@ public class ModelTreeCondition {
|
||||
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
// return true for the first one in the list that is true, basic or algo
|
||||
Iterator subConditionIter = this.subConditions.iterator();
|
||||
while (subConditionIter.hasNext()) {
|
||||
TreeCondition subCondition = (TreeCondition) subConditionIter.next();
|
||||
for (TreeCondition subCondition: subConditions) {
|
||||
if (subCondition.eval(context)) {
|
||||
return true;
|
||||
}
|
||||
@@ -238,13 +229,13 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class IfValidateMethod extends TreeCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander methodExdr;
|
||||
protected FlexibleStringExpander classExdr;
|
||||
|
||||
public IfValidateMethod(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.methodExdr = new FlexibleStringExpander(condElement.getAttribute("method"));
|
||||
this.classExdr = new FlexibleStringExpander(condElement.getAttribute("class"));
|
||||
}
|
||||
@@ -297,7 +288,7 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class IfCompare extends TreeCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander valueExdr;
|
||||
|
||||
protected String operator;
|
||||
@@ -306,7 +297,7 @@ public class ModelTreeCondition {
|
||||
|
||||
public IfCompare(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.valueExdr = new FlexibleStringExpander(condElement.getAttribute("value"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
@@ -346,8 +337,8 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class IfCompareField extends TreeCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor toFieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> toFieldAcsr;
|
||||
|
||||
protected String operator;
|
||||
protected String type;
|
||||
@@ -355,8 +346,8 @@ public class ModelTreeCondition {
|
||||
|
||||
public IfCompareField(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("to-field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.toFieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("to-field-name"));
|
||||
|
||||
this.operator = condElement.getAttribute("operator");
|
||||
this.type = condElement.getAttribute("type");
|
||||
@@ -398,12 +389,12 @@ public class ModelTreeCondition {
|
||||
static PatternMatcher matcher = new Perl5Matcher();
|
||||
static PatternCompiler compiler = new Perl5Compiler();
|
||||
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
protected FlexibleStringExpander exprExdr;
|
||||
|
||||
public IfRegexp(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
this.exprExdr = new FlexibleStringExpander(condElement.getAttribute("expr"));
|
||||
}
|
||||
|
||||
@@ -433,11 +424,11 @@ public class ModelTreeCondition {
|
||||
}
|
||||
|
||||
public static class IfEmpty extends TreeCondition {
|
||||
protected FlexibleMapAccessor fieldAcsr;
|
||||
protected FlexibleMapAccessor<Object> fieldAcsr;
|
||||
|
||||
public IfEmpty(ModelTree modelTree, Element condElement) {
|
||||
super (modelTree, condElement);
|
||||
this.fieldAcsr = new FlexibleMapAccessor(condElement.getAttribute("field-name"));
|
||||
this.fieldAcsr = new FlexibleMapAccessor<Object>(condElement.getAttribute("field-name"));
|
||||
}
|
||||
|
||||
public boolean eval(Map<String, Object> context) {
|
||||
|
||||
Reference in New Issue
Block a user