Author: jonesde
Date: Mon Mar 3 15:37:14 2008 New Revision: 633325 URL: http://svn.apache.org/viewvc?rev=633325&view=rev Log: No real functional changes to operational code, just new stuff for getting meta data about entities, services, etc from the system Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallServiceAsynch.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ElseIf.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/While.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompare.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompareField.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfEmpty.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfInstanceOf.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfNotEmpty.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/EntityArtifactInfo.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilMisc.java Mon Mar 3 15:37:14 2008 @@ -489,6 +489,15 @@ theList.add(element); } + public static <K, V> void addToSetInMap(V element, Map<K, Set<V>> theMap, K setKey) { + Set<V> theSet = UtilGenerics.checkSet(theMap.get(setKey)); + if (theSet == null) { + theSet = FastSet.newInstance(); + theMap.put(setKey, theSet); + } + theSet.add(element); + } + public static long toLong(Object value) { if (value != null) { // FIXME: Handle java.lang.Number? Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/Finder.java Mon Mar 3 15:37:14 2008 @@ -34,6 +34,13 @@ this.entityNameExdr = new FlexibleStringExpander(element.getAttribute("entity-name")); this.useCacheStrExdr = new FlexibleStringExpander(element.getAttribute("use-cache")); } + + public String getEntityName() { + String entName = this.entityNameExdr.getOriginal(); + // if there is expansion syntax + if (entName.indexOf("${") >= 0) return null; + return entName; + } public abstract void runFind(Map<String, Object> context, GenericDelegator delegator) throws GeneralException; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Mon Mar 3 15:37:14 2008 @@ -479,7 +479,7 @@ /** Creates a Collection with the entityName of each Entity defined in the specified XML Entity Descriptor file. * @return A Collection of entityName Strings */ - public Collection<String> getEntityNames() throws GenericEntityException { + public Set<String> getEntityNames() throws GenericEntityException { Map<String, ModelEntity> ec = getEntityCache(); if (ec == null) { throw new GenericEntityConfException("ERROR: Unable to load Entity Cache"); Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Mon Mar 3 15:37:14 2008 @@ -24,13 +24,14 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javolution.util.FastList; import javolution.util.FastMap; -import org.w3c.dom.Document; -import org.w3c.dom.Element; +import javolution.util.FastSet; import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; @@ -45,8 +46,34 @@ import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.minilang.method.MethodContext; import org.ofbiz.minilang.method.MethodOperation; +import org.ofbiz.minilang.method.callops.CallService; +import org.ofbiz.minilang.method.callops.CallServiceAsynch; +import org.ofbiz.minilang.method.callops.CallSimpleMethod; +import org.ofbiz.minilang.method.callops.SetServiceFields; +import org.ofbiz.minilang.method.conditional.MasterIf; +import org.ofbiz.minilang.method.conditional.While; +import org.ofbiz.minilang.method.entityops.EntityAnd; +import org.ofbiz.minilang.method.entityops.EntityCondition; +import org.ofbiz.minilang.method.entityops.EntityCount; +import org.ofbiz.minilang.method.entityops.EntityOne; +import org.ofbiz.minilang.method.entityops.FindByAnd; +import org.ofbiz.minilang.method.entityops.FindByPrimaryKey; +import org.ofbiz.minilang.method.entityops.MakeValue; +import org.ofbiz.minilang.method.envops.Iterate; +import org.ofbiz.minilang.method.envops.IterateMap; +import org.ofbiz.minilang.method.envops.Loop; +import org.ofbiz.minilang.method.ifops.IfCompare; +import org.ofbiz.minilang.method.ifops.IfCompareField; +import org.ofbiz.minilang.method.ifops.IfEmpty; +import org.ofbiz.minilang.method.ifops.IfHasPermission; +import org.ofbiz.minilang.method.ifops.IfInstanceOf; +import org.ofbiz.minilang.method.ifops.IfNotEmpty; +import org.ofbiz.minilang.method.ifops.IfRegexp; +import org.ofbiz.minilang.method.ifops.IfValidateMethod; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.ModelService; +import org.w3c.dom.Document; +import org.w3c.dom.Element; /** * SimpleMethod Mini Language Core Object @@ -56,9 +83,9 @@ public static final String module = SimpleMethod.class.getName(); public static final String err_resource = "MiniLangErrorUiLabels"; - protected static UtilCache simpleMethodsDirectCache = new UtilCache("minilang.SimpleMethodsDirect", 0, 0); - protected static UtilCache simpleMethodsResourceCache = new UtilCache("minilang.SimpleMethodsResource", 0, 0); - protected static UtilCache simpleMethodsURLCache = new UtilCache("minilang.SimpleMethodsURL", 0, 0); + protected static UtilCache<String, Map<String, SimpleMethod>> simpleMethodsDirectCache = new UtilCache("minilang.SimpleMethodsDirect", 0, 0); + protected static UtilCache<String, Map<String, SimpleMethod>> simpleMethodsResourceCache = new UtilCache("minilang.SimpleMethodsResource", 0, 0); + protected static UtilCache<URL, Map<String, SimpleMethod>> simpleMethodsURLCache = new UtilCache("minilang.SimpleMethodsURL", 0, 0); // ----- Event Context Invokers ----- @@ -97,7 +124,7 @@ // ----- General Method Invokers ----- public static String runSimpleMethod(String xmlResource, String methodName, MethodContext methodContext) throws MiniLangException { - Map simpleMethods = getSimpleMethods(xmlResource, methodName, methodContext.getLoader()); + Map simpleMethods = getSimpleMethods(xmlResource, methodContext.getLoader()); SimpleMethod simpleMethod = (SimpleMethod) simpleMethods.get(methodName); if (simpleMethod == null) { throw new MiniLangException("Could not find SimpleMethod " + methodName + " in XML document in resource: " + xmlResource); @@ -106,7 +133,7 @@ } public static String runSimpleMethod(URL xmlURL, String methodName, MethodContext methodContext) throws MiniLangException { - Map simpleMethods = getSimpleMethods(xmlURL, methodName); + Map simpleMethods = getSimpleMethods(xmlURL); SimpleMethod simpleMethod = (SimpleMethod) simpleMethods.get(methodName); if (simpleMethod == null) { throw new MiniLangException("Could not find SimpleMethod " + methodName + " in XML document from URL: " + xmlURL.toString()); @@ -114,8 +141,8 @@ return simpleMethod.exec(methodContext); } - public static Map getSimpleMethods(String xmlResource, String methodName, ClassLoader loader) throws MiniLangException { - Map simpleMethods = (Map) simpleMethodsResourceCache.get(xmlResource); + public static Map<String, SimpleMethod> getSimpleMethods(String xmlResource, ClassLoader loader) throws MiniLangException { + Map<String, SimpleMethod> simpleMethods = (Map) simpleMethodsResourceCache.get(xmlResource); if (simpleMethods == null) { synchronized (SimpleMethod.class) { simpleMethods = (Map) simpleMethodsResourceCache.get(xmlResource); @@ -142,8 +169,8 @@ return simpleMethods; } - public static Map getSimpleMethods(URL xmlURL, String methodName) throws MiniLangException { - Map simpleMethods = (Map) simpleMethodsURLCache.get(xmlURL); + public static Map<String, SimpleMethod> getSimpleMethods(URL xmlURL) throws MiniLangException { + Map<String, SimpleMethod> simpleMethods = (Map) simpleMethodsURLCache.get(xmlURL); if (simpleMethods == null) { synchronized (SimpleMethod.class) { @@ -160,8 +187,8 @@ return simpleMethods; } - protected static Map getAllSimpleMethods(URL xmlURL) throws MiniLangException { - Map simpleMethods = FastMap.newInstance(); + protected static Map<String, SimpleMethod> getAllSimpleMethods(URL xmlURL) throws MiniLangException { + Map<String, SimpleMethod> simpleMethods = FastMap.newInstance(); // read in the file Document document = null; @@ -252,7 +279,7 @@ } // Member fields begin here... - protected List methodOperations = FastList.newInstance(); + protected List<MethodOperation> methodOperations = FastList.newInstance(); protected Map parentSimpleMethodsMap; protected String fromLocation; protected String methodName; @@ -494,6 +521,118 @@ public String getUserLoginEnvName() { return this.userLoginName; } + + public Set<String> getAllServiceNamesCalled() throws MiniLangException { + Set<String> allServiceNames = FastSet.newInstance(); + findServiceNamesCalled(this.methodOperations, allServiceNames); + return allServiceNames; + } + protected static void findServiceNamesCalled(List<MethodOperation> methodOperations, Set<String> allServiceNames) throws MiniLangException { + for (MethodOperation methodOperation: methodOperations) { + if (methodOperation instanceof CallService) { + String svcName = ((CallService) methodOperation).getServiceName(); + if (UtilValidate.isNotEmpty(svcName)) allServiceNames.add(svcName); + } else if (methodOperation instanceof CallServiceAsynch) { + String svcName = ((CallServiceAsynch) methodOperation).getServiceName(); + if (UtilValidate.isNotEmpty(svcName)) allServiceNames.add(svcName); + } else if (methodOperation instanceof SetServiceFields) { + String svcName = ((SetServiceFields) methodOperation).getServiceName(); + if (UtilValidate.isNotEmpty(svcName)) allServiceNames.add(svcName); + + } else if (methodOperation instanceof CallSimpleMethod) { + SimpleMethod calledMethod = ((CallSimpleMethod) methodOperation).getSimpleMethodToCall(null); + allServiceNames.addAll(calledMethod.getAllServiceNamesCalled()); + } else if (methodOperation instanceof Iterate) { + findServiceNamesCalled(((Iterate) methodOperation).getSubOps(), allServiceNames); + } else if (methodOperation instanceof IterateMap) { + findServiceNamesCalled(((IterateMap) methodOperation).getSubOps(), allServiceNames); + } else if (methodOperation instanceof Loop) { + findServiceNamesCalled(((Loop) methodOperation).getSubOps(), allServiceNames); + } else if (methodOperation instanceof MasterIf) { + findServiceNamesCalled(((MasterIf) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof While) { + findServiceNamesCalled(((While) methodOperation).getThenSubOps(), allServiceNames); + } else if (methodOperation instanceof IfValidateMethod) { + findServiceNamesCalled(((IfValidateMethod) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfInstanceOf) { + findServiceNamesCalled(((IfInstanceOf) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfCompare) { + findServiceNamesCalled(((IfCompare) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfCompareField) { + findServiceNamesCalled(((IfCompareField) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfRegexp) { + findServiceNamesCalled(((IfRegexp) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfEmpty) { + findServiceNamesCalled(((IfEmpty) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfNotEmpty) { + findServiceNamesCalled(((IfNotEmpty) methodOperation).getAllSubOps(), allServiceNames); + } else if (methodOperation instanceof IfHasPermission) { + findServiceNamesCalled(((IfHasPermission) methodOperation).getAllSubOps(), allServiceNames); + } + } + } + + public Set<String> getAllEntityNamesUsed() throws MiniLangException { + Set<String> allEntityNames = FastSet.newInstance(); + findEntityNamesUsed(this.methodOperations, allEntityNames); + return allEntityNames; + } + protected static void findEntityNamesUsed(List<MethodOperation> methodOperations, Set<String> allEntityNames) throws MiniLangException { + for (MethodOperation methodOperation: methodOperations) { + if (methodOperation instanceof FindByPrimaryKey) { + String entName = ((FindByPrimaryKey) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof FindByAnd) { + String entName = ((FindByAnd) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof EntityOne) { + String entName = ((EntityOne) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof EntityAnd) { + String entName = ((EntityAnd) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof EntityCondition) { + String entName = ((EntityCondition) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof EntityCount) { + String entName = ((EntityCount) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + } else if (methodOperation instanceof MakeValue) { + String entName = ((MakeValue) methodOperation).getEntityName(); + if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); + + } else if (methodOperation instanceof CallSimpleMethod) { + SimpleMethod calledMethod = ((CallSimpleMethod) methodOperation).getSimpleMethodToCall(null); + allEntityNames.addAll(calledMethod.getAllServiceNamesCalled()); + } else if (methodOperation instanceof Iterate) { + findEntityNamesUsed(((Iterate) methodOperation).getSubOps(), allEntityNames); + } else if (methodOperation instanceof IterateMap) { + findEntityNamesUsed(((IterateMap) methodOperation).getSubOps(), allEntityNames); + } else if (methodOperation instanceof Loop) { + findEntityNamesUsed(((Loop) methodOperation).getSubOps(), allEntityNames); + } else if (methodOperation instanceof MasterIf) { + findEntityNamesUsed(((MasterIf) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof While) { + findEntityNamesUsed(((While) methodOperation).getThenSubOps(), allEntityNames); + } else if (methodOperation instanceof IfValidateMethod) { + findEntityNamesUsed(((IfValidateMethod) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfInstanceOf) { + findEntityNamesUsed(((IfInstanceOf) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfCompare) { + findEntityNamesUsed(((IfCompare) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfCompareField) { + findEntityNamesUsed(((IfCompareField) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfRegexp) { + findEntityNamesUsed(((IfRegexp) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfEmpty) { + findEntityNamesUsed(((IfEmpty) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfNotEmpty) { + findEntityNamesUsed(((IfNotEmpty) methodOperation).getAllSubOps(), allEntityNames); + } else if (methodOperation instanceof IfHasPermission) { + findEntityNamesUsed(((IfHasPermission) methodOperation).getAllSubOps(), allEntityNames); + } + } + } /** Execute the Simple Method operations */ public String exec(MethodContext methodContext) { @@ -707,14 +846,11 @@ return returnValue; } - public static void readOperations(Element simpleMethodElement, List methodOperations, SimpleMethod simpleMethod) { - List operationElements = UtilXml.childElementList(simpleMethodElement); + public static void readOperations(Element simpleMethodElement, List<MethodOperation> methodOperations, SimpleMethod simpleMethod) { + List<? extends Element> operationElements = UtilXml.childElementList(simpleMethodElement); if (operationElements != null && operationElements.size() > 0) { - Iterator operElemIter = operationElements.iterator(); - - while (operElemIter.hasNext()) { - Element curOperElem = (Element) operElemIter.next(); + for (Element curOperElem: operationElements) { String nodeName = curOperElem.getNodeName(); if ("call-map-processor".equals(nodeName)) { @@ -925,10 +1061,8 @@ /** Execs the given operations returning true if all return true, or returning * false and stopping if any return false. */ - public static boolean runSubOps(List methodOperations, MethodContext methodContext) { - Iterator methodOpsIter = methodOperations.iterator(); - while (methodOpsIter.hasNext()) { - MethodOperation methodOperation = (MethodOperation) methodOpsIter.next(); + public static boolean runSubOps(List<MethodOperation> methodOperations, MethodContext methodContext) { + for (MethodOperation methodOperation: methodOperations) { try { if (!methodOperation.exec(methodContext)) { return false; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java Mon Mar 3 15:37:14 2008 @@ -25,6 +25,9 @@ import java.util.Locale; import java.util.Map; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -46,40 +49,40 @@ public static final String module = CallService.class.getName(); - String serviceName; - ContextAccessor inMapAcsr; - String includeUserLoginStr; - String breakOnErrorStr; - String errorCode; - String successCode; + protected String serviceName; + protected ContextAccessor inMapAcsr; + protected String includeUserLoginStr; + protected String breakOnErrorStr; + protected String errorCode; + protected String successCode; /** Require a new transaction for this service */ - public String requireNewTransactionStr; + protected String requireNewTransactionStr; /** Override the default transaction timeout, only works if we start the transaction */ - public int transactionTimeout; + protected int transactionTimeout; - FlexibleMessage errorPrefix; - FlexibleMessage errorSuffix; - FlexibleMessage successPrefix; - FlexibleMessage successSuffix; - FlexibleMessage messagePrefix; - FlexibleMessage messageSuffix; - FlexibleMessage defaultMessage; + protected FlexibleMessage errorPrefix; + protected FlexibleMessage errorSuffix; + protected FlexibleMessage successPrefix; + protected FlexibleMessage successSuffix; + protected FlexibleMessage messagePrefix; + protected FlexibleMessage messageSuffix; + protected FlexibleMessage defaultMessage; /** A list of strings with names of new maps to create */ - List resultsToMap = new LinkedList(); + protected List<String> resultsToMap = FastList.newInstance(); /** A list of ResultToFieldDef objects */ - List resultToField = new LinkedList(); + protected List<ResultToFieldDef> resultToField = FastList.newInstance(); /** the key is the request attribute name, the value is the result name to get */ - Map resultToRequest = new HashMap(); + protected Map<FlexibleServletAccessor, ContextAccessor> resultToRequest = FastMap.newInstance(); /** the key is the session attribute name, the value is the result name to get */ - Map resultToSession = new HashMap(); + protected Map<FlexibleServletAccessor, ContextAccessor> resultToSession = FastMap.newInstance(); /** the key is the result entry name, the value is the result name to get */ - Map resultToResult = new HashMap(); + protected Map<ContextAccessor, ContextAccessor> resultToResult = FastMap.newInstance(); public CallService(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); @@ -172,6 +175,10 @@ resultToResult.put(serResAcsr, resultAcsr); } } + } + + public String getServiceName() { + return this.serviceName; } public boolean exec(MethodContext methodContext) { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallServiceAsynch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallServiceAsynch.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallServiceAsynch.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallServiceAsynch.java Mon Mar 3 15:37:14 2008 @@ -38,9 +38,9 @@ public static final String module = CallServiceAsynch.class.getName(); - String serviceName; - ContextAccessor inMapAcsr; - String includeUserLoginStr; + protected String serviceName; + protected ContextAccessor inMapAcsr; + protected String includeUserLoginStr; public CallServiceAsynch(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); @@ -97,6 +97,10 @@ } return true; + } + + public String getServiceName() { + return this.serviceName; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java Mon Mar 3 15:37:14 2008 @@ -18,12 +18,14 @@ *******************************************************************************/ package org.ofbiz.minilang.method.callops; -import java.util.*; +import java.util.Map; -import org.w3c.dom.*; -import org.ofbiz.base.util.*; -import org.ofbiz.minilang.*; -import org.ofbiz.minilang.method.*; +import org.ofbiz.base.util.Debug; +import org.ofbiz.minilang.MiniLangException; +import org.ofbiz.minilang.SimpleMethod; +import org.ofbiz.minilang.method.MethodContext; +import org.ofbiz.minilang.method.MethodOperation; +import org.w3c.dom.Element; /** * An operation that calls a simple method in the same, or from another, file @@ -47,20 +49,13 @@ String xmlResource = methodContext.expandString(this.xmlResource); SimpleMethod simpleMethodToCall = null; - if (xmlResource == null || xmlResource.length() == 0) { - simpleMethodToCall = this.simpleMethod.getSimpleMethodInSameFile(methodName); - } else { - Map simpleMethods = null; - try { - simpleMethods = SimpleMethod.getSimpleMethods(xmlResource, methodName, methodContext.getLoader()); - } catch (MiniLangException e) { - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [error getting methods from resource: " + e.getMessage() + "]"; - Debug.logError(e, errMsg, module); - methodContext.setErrorReturn(errMsg, simpleMethod); - return false; - } - - simpleMethodToCall = (SimpleMethod) simpleMethods.get(methodName); + try { + simpleMethodToCall = getSimpleMethodToCall(methodContext.getLoader()); + } catch (MiniLangException e) { + String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [error getting methods from resource: " + e.getMessage() + "]"; + Debug.logError(e, errMsg, module); + methodContext.setErrorReturn(errMsg, simpleMethod); + return false; } if (simpleMethodToCall == null) { @@ -82,7 +77,7 @@ return false; } - // if the response code/meassge is error, if so show the error and return false + // if the response code/message is error, if so show the error and return false if (methodContext.getMethodType() == MethodContext.EVENT) { String responseCode = (String) methodContext.getEnv(simpleMethod.getEventResponseCodeName()); if (responseCode != null && responseCode.equals(simpleMethod.getDefaultErrorCode())) { @@ -104,6 +99,17 @@ } return true; + } + + public SimpleMethod getSimpleMethodToCall(ClassLoader loader) throws MiniLangException { + SimpleMethod simpleMethodToCall = null; + if (xmlResource == null || xmlResource.length() == 0) { + simpleMethodToCall = this.simpleMethod.getSimpleMethodInSameFile(methodName); + } else { + Map simpleMethods = SimpleMethod.getSimpleMethods(xmlResource, loader); + simpleMethodToCall = (SimpleMethod) simpleMethods.get(methodName); + } + return simpleMethodToCall; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java Mon Mar 3 15:37:14 2008 @@ -24,6 +24,8 @@ import java.util.List; import java.util.Map; +import javolution.util.FastList; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; @@ -61,7 +63,7 @@ public boolean exec(MethodContext methodContext) { List messages = (List) errorListAcsr.get(methodContext); if (messages == null) { - messages = new LinkedList(); + messages = FastList.newInstance(); errorListAcsr.put(methodContext, messages); } @@ -115,6 +117,10 @@ return true; } + public String getServiceName() { + return this.serviceName; + } + public String rawString() { // TODO: something more than the empty tag return "<set-service-fields/>"; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ElseIf.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ElseIf.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ElseIf.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ElseIf.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -30,8 +32,8 @@ */ public class ElseIf { - Conditional condition; - List thenSubOps = new LinkedList(); + protected Conditional condition; + protected List<MethodOperation> thenSubOps = FastList.newInstance(); public ElseIf(Element element, SimpleMethod simpleMethod) { Element conditionElement = UtilXml.firstChildElement(element, "condition"); @@ -40,6 +42,10 @@ Element thenElement = UtilXml.firstChildElement(element, "then"); SimpleMethod.readOperations(thenElement, thenSubOps, simpleMethod); + } + + public List<MethodOperation> getThenSubOps() { + return this.thenSubOps; } public boolean checkCondition(MethodContext methodContext) { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -32,10 +34,10 @@ Conditional condition; - List thenSubOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> thenSubOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; - List elseIfs = null; + List<ElseIf> elseIfs = null; public MasterIf(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); @@ -47,19 +49,17 @@ Element thenElement = UtilXml.firstChildElement(element, "then"); SimpleMethod.readOperations(thenElement, thenSubOps, simpleMethod); - List elseIfElements = UtilXml.childElementList(element, "else-if"); + List<? extends Element> elseIfElements = UtilXml.childElementList(element, "else-if"); if (elseIfElements != null && elseIfElements.size() > 0) { - elseIfs = new LinkedList(); - Iterator eieIter = elseIfElements.iterator(); - while (eieIter.hasNext()) { - Element elseIfElement = (Element) eieIter.next(); + elseIfs = FastList.newInstance(); + for (Element elseIfElement: elseIfElements) { elseIfs.add(new ElseIf(elseIfElement, simpleMethod)); } } Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -75,12 +75,9 @@ if (runSubOps) { return SimpleMethod.runSubOps(thenSubOps, methodContext); } else { - // try the else-ifs if (elseIfs != null && elseIfs.size() > 0) { - Iterator elseIfIter = elseIfs.iterator(); - while (elseIfIter.hasNext()) { - ElseIf elseIf = (ElseIf) elseIfIter.next(); + for (ElseIf elseIf: elseIfs) { if (elseIf.checkCondition(methodContext)) { return elseIf.runSubOps(methodContext); } @@ -93,6 +90,17 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.thenSubOps); + allSubOps.addAll(this.elseSubOps); + for (ElseIf elseIf: elseIfs) { + allSubOps.addAll(elseIf.getThenSubOps()); + } + + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/While.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/While.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/While.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/While.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -34,7 +36,7 @@ Conditional condition; - List thenSubOps = new LinkedList(); + List<MethodOperation> thenSubOps = FastList.newInstance(); public While(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); @@ -57,6 +59,10 @@ } } return true; + } + + public List<MethodOperation> getThenSubOps() { + return this.thenSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java Mon Mar 3 15:37:14 2008 @@ -61,6 +61,10 @@ return true; } + public String getEntityName() { + return this.finder.getEntityName(); + } + public String rawString() { // TODO: something more than the empty tag return "<entity-and/>"; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java Mon Mar 3 15:37:14 2008 @@ -61,6 +61,10 @@ return true; } + public String getEntityName() { + return this.finder.getEntityName(); + } + public String rawString() { // TODO: something more than the empty tag return "<entity-condition/>"; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java Mon Mar 3 15:37:14 2008 @@ -119,6 +119,13 @@ return true; } + public String getEntityName() { + String entName = this.entityNameExdr.getOriginal(); + // if there is expansion syntax + if (entName.indexOf("${") >= 0) return null; + return entName; + } + public String rawString() { // TODO: something more than the empty tag return "<entity-count/>"; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java Mon Mar 3 15:37:14 2008 @@ -60,6 +60,10 @@ } return true; } + + public String getEntityName() { + return this.finder.getEntityName(); + } public String rawString() { // TODO: something more than the empty tag Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java Mon Mar 3 15:37:14 2008 @@ -109,6 +109,10 @@ return true; } + public String getEntityName() { + return this.entityName; + } + public String rawString() { // TODO: something more than the empty tag return "<find-by-and/>"; Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java Mon Mar 3 15:37:14 2008 @@ -98,6 +98,10 @@ } return true; } + + public String getEntityName() { + return this.entityName; + } public String rawString() { // TODO: something more than the empty tag Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java Mon Mar 3 15:37:14 2008 @@ -46,6 +46,10 @@ valueAcsr.put(methodContext, methodContext.getDelegator().makeValidValue(entityName, ctxMap)); return true; } + + public String getEntityName() { + return this.entityName; + } public String rawString() { // TODO: something more than the empty tag Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Mon Mar 3 15:37:14 2008 @@ -40,10 +40,10 @@ public static final String module = Iterate.class.getName(); - List subOps = new LinkedList(); + protected List<MethodOperation> subOps = new LinkedList(); - ContextAccessor entryAcsr; - ContextAccessor listAcsr; + protected ContextAccessor entryAcsr; + protected ContextAccessor listAcsr; public Iterate(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); @@ -116,6 +116,10 @@ } entryAcsr.put(methodContext, oldEntryValue); return true; + } + + public List<MethodOperation> getSubOps() { + return this.subOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java Mon Mar 3 15:37:14 2008 @@ -23,6 +23,8 @@ import java.util.List; import java.util.Map; +import javolution.util.FastList; + import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.method.ContextAccessor; import org.ofbiz.minilang.method.MethodContext; @@ -37,7 +39,7 @@ public static final String module = IterateMap.class.getName(); - List subOps = new LinkedList(); + List<MethodOperation> subOps = FastList.newInstance(); ContextAccessor keyAcsr; ContextAccessor valueAcsr; @@ -92,6 +94,10 @@ } return true; + } + + public List<MethodOperation> getSubOps() { + return this.subOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java Mon Mar 3 15:37:14 2008 @@ -21,6 +21,8 @@ import java.util.List; import java.util.LinkedList; +import javolution.util.FastList; + import org.w3c.dom.Element; import org.ofbiz.minilang.method.MethodOperation; @@ -35,7 +37,7 @@ public class Loop extends MethodOperation { public static final String module = Loop.class.getName(); - protected List subOps = new LinkedList(); + protected List<MethodOperation> subOps = FastList.newInstance(); protected ContextAccessor fieldAcsr; protected String countStr; @@ -75,6 +77,10 @@ } return true; + } + + public List<MethodOperation> getSubOps() { + return this.subOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompare.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompare.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompare.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompare.java Mon Mar 3 15:37:14 2008 @@ -36,8 +36,8 @@ public static final String module = IfCompare.class.getName(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -60,7 +60,7 @@ SimpleMethod.readOperations(element, subOps, simpleMethod); Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -123,6 +123,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompareField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompareField.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompareField.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfCompareField.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -34,8 +36,8 @@ public static final String module = IfCompareField.class.getName(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -66,7 +68,7 @@ SimpleMethod.readOperations(element, subOps, simpleMethod); Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -106,7 +108,7 @@ fieldVal2 = toFieldAcsr.get(methodContext); } - List messages = new LinkedList(); + List messages = FastList.newInstance(); Boolean resultBool = BaseCompare.doRealCompare(fieldVal1, fieldVal2, operator, type, format, messages, null, methodContext.getLoader(), false); if (messages.size() > 0) { @@ -138,6 +140,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfEmpty.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfEmpty.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfEmpty.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfEmpty.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -32,8 +34,8 @@ public static final String module = IfEmpty.class.getName(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -47,7 +49,7 @@ Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -84,6 +86,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfHasPermission.java Mon Mar 3 15:37:14 2008 @@ -18,9 +18,10 @@ *******************************************************************************/ package org.ofbiz.minilang.method.ifops; -import java.util.LinkedList; import java.util.List; +import javolution.util.FastList; + import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.GenericValue; @@ -36,8 +37,8 @@ */ public class IfHasPermission extends MethodOperation { - protected List subOps = new LinkedList(); - protected List elseSubOps = null; + protected List<MethodOperation> subOps = FastList.newInstance(); + protected List<MethodOperation> elseSubOps = null; protected FlexibleStringExpander permissionExdr; protected FlexibleStringExpander actionExdr; @@ -51,7 +52,7 @@ Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -93,6 +94,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfInstanceOf.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfInstanceOf.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfInstanceOf.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfInstanceOf.java Mon Mar 3 15:37:14 2008 @@ -22,6 +22,8 @@ import java.util.LinkedList; import java.util.Map; +import javolution.util.FastList; + import org.ofbiz.minilang.method.MethodOperation; import org.ofbiz.minilang.method.MethodContext; import org.ofbiz.minilang.method.ContextAccessor; @@ -86,6 +88,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfNotEmpty.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfNotEmpty.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfNotEmpty.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfNotEmpty.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; @@ -32,8 +34,8 @@ public static final String module = IfNotEmpty.class.getName(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -48,7 +50,7 @@ Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -91,6 +93,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java Mon Mar 3 15:37:14 2008 @@ -20,6 +20,8 @@ import java.util.*; +import javolution.util.FastList; + import org.apache.oro.text.regex.*; import org.w3c.dom.*; @@ -38,8 +40,8 @@ static PatternMatcher matcher = new Perl5Matcher(); static PatternCompiler compiler = new Perl5Compiler(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -58,7 +60,7 @@ Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -108,6 +110,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java Mon Mar 3 15:37:14 2008 @@ -21,10 +21,13 @@ import java.util.*; import java.lang.reflect.*; +import javolution.util.FastList; + import org.w3c.dom.*; import org.ofbiz.base.util.*; import org.ofbiz.minilang.*; import org.ofbiz.minilang.method.*; +import org.ofbiz.minilang.method.conditional.ElseIf; /** * Iff the validate method returns true with the specified field process sub-operations @@ -33,8 +36,8 @@ public static final String module = IfValidateMethod.class.getName(); - List subOps = new LinkedList(); - List elseSubOps = null; + List<MethodOperation> subOps = FastList.newInstance(); + List<MethodOperation> elseSubOps = null; ContextAccessor mapAcsr; ContextAccessor fieldAcsr; @@ -52,7 +55,7 @@ Element elseElement = UtilXml.firstChildElement(element, "else"); if (elseElement != null) { - elseSubOps = new LinkedList(); + elseSubOps = FastList.newInstance(); SimpleMethod.readOperations(elseElement, elseSubOps, simpleMethod); } } @@ -125,6 +128,13 @@ return true; } } + } + + public List<MethodOperation> getAllSubOps() { + List<MethodOperation> allSubOps = FastList.newInstance(); + allSubOps.addAll(this.subOps); + allSubOps.addAll(this.elseSubOps); + return allSubOps; } public String rawString() { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java Mon Mar 3 15:37:14 2008 @@ -230,4 +230,27 @@ return success; } + + public boolean equals(Object obj) { + if (obj instanceof ServiceEcaAction) { + ServiceEcaAction other = (ServiceEcaAction) obj; + + if (!UtilValidate.areEqual(this.eventName, other.eventName)) return false; + if (!UtilValidate.areEqual(this.serviceName, other.serviceName)) return false; + if (!UtilValidate.areEqual(this.serviceMode, other.serviceMode)) return false; + if (!UtilValidate.areEqual(this.resultMapName, other.resultMapName)) return false; + if (!UtilValidate.areEqual(this.runAsUser, other.runAsUser)) return false; + + if (this.newTransaction != other.newTransaction) return false; + if (this.resultToContext != other.resultToContext) return false; + if (this.resultToResult != other.resultToResult) return false; + if (this.ignoreFailure != other.ignoreFailure) return false; + if (this.ignoreError != other.ignoreError) return false; + if (this.persist != other.persist) return false; + + return true; + } else { + return false; + } + } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaCondition.java Mon Mar 3 15:37:14 2008 @@ -105,7 +105,7 @@ return buf.toString(); } - public boolean eval(String serviceName, DispatchContext dctx, Map context) throws GenericServiceException { + public boolean eval(String serviceName, DispatchContext dctx, Map<String, Object> context) throws GenericServiceException { if (serviceName == null || dctx == null || context == null || dctx.getClassLoader() == null) { throw new GenericServiceException("Cannot have null Service, Context or DispatchContext!"); } @@ -204,5 +204,27 @@ if (UtilValidate.isNotEmpty(compareType)) buf.append("[").append(compareType).append("]"); if (UtilValidate.isNotEmpty(format)) buf.append("[").append(format).append("]"); return buf.toString(); + } + + public boolean equals(Object obj) { + if (obj instanceof ServiceEcaCondition) { + ServiceEcaCondition other = (ServiceEcaCondition) obj; + + if (!UtilValidate.areEqual(this.conditionService, other.conditionService)) return false; + if (!UtilValidate.areEqual(this.lhsValueName, other.lhsValueName)) return false; + if (!UtilValidate.areEqual(this.rhsValueName, other.rhsValueName)) return false; + if (!UtilValidate.areEqual(this.lhsMapName, other.lhsMapName)) return false; + if (!UtilValidate.areEqual(this.rhsMapName, other.rhsMapName)) return false; + if (!UtilValidate.areEqual(this.operator, other.operator)) return false; + if (!UtilValidate.areEqual(this.compareType, other.compareType)) return false; + if (!UtilValidate.areEqual(this.format, other.format)) return false; + + if (this.isConstant != other.isConstant) return false; + if (this.isService != other.isService) return false; + + return true; + } else { + return false; + } } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java Mon Mar 3 15:37:14 2008 @@ -26,6 +26,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -153,5 +154,23 @@ public boolean isEnabled() { return this.enabled; + } + + public boolean equals(Object obj) { + if (obj instanceof ServiceEcaRule) { + ServiceEcaRule other = (ServiceEcaRule) obj; + if (!UtilValidate.areEqual(this.serviceName, other.serviceName)) return false; + if (!UtilValidate.areEqual(this.eventName, other.eventName)) return false; + if (!this.conditions.equals(other.conditions)) return false; + if (!this.actionsAndSets.equals(other.actionsAndSets)) return false; + + if (this.runOnFailure != other.runOnFailure) return false; + if (this.runOnError != other.runOnError) return false; + if (this.enabled != other.enabled) return false; + + return true; + } else { + return false; + } } } 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?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaSetField.java Mon Mar 3 15:37:14 2008 @@ -116,4 +116,19 @@ Debug.logWarning("Format function not found [" + format + "] return string unchanged - " + s, module); return s; } + + public boolean equals(Object obj) { + if (obj instanceof ServiceEcaSetField) { + ServiceEcaSetField other = (ServiceEcaSetField) obj; + + if (!UtilValidate.areEqual(this.fieldName, other.fieldName)) return false; + if (!UtilValidate.areEqual(this.envName, other.envName)) return false; + if (!UtilValidate.areEqual(this.value, other.value)) return false; + if (!UtilValidate.areEqual(this.format, other.format)) return false; + + return true; + } else { + return false; + } + } } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Mon Mar 3 15:37:14 2008 @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Set; import javax.xml.parsers.ParserConfigurationException; @@ -48,74 +49,124 @@ * */ public class ArtifactInfoFactory { - - public static EntityArtifactInfo makeEntityArtifactInfo(String entityName, String delegatorName) throws GeneralException { - return new EntityArtifactInfo(entityName, ArtifactInfoContext.makeArtifactInfoContext(delegatorName)); - } - public static ServiceArtifactInfo makeServiceArtifactInfo(String serviceName, String delegatorName) throws GeneralException { - return new ServiceArtifactInfo(serviceName, ArtifactInfoContext.makeArtifactInfoContext(delegatorName)); - } + protected static Map<String, ArtifactInfoFactory> artifactInfoFactoryCache = FastMap.newInstance(); - public static FormWidgetArtifactInfo makeFormWidgetArtifactInfo(String formName, String formLocation, String delegatorName) throws GeneralException, IOException, SAXException, ParserConfigurationException { - return new FormWidgetArtifactInfo(formName, formLocation, ArtifactInfoContext.makeArtifactInfoContext(delegatorName)); + protected String delegatorName; + protected ModelReader entityModelReader; + protected DispatchContext dispatchContext; + protected Map<String, Map<String, List<EntityEcaRule>>> entityEcaCache; + protected Map<String, Map<String, List<ServiceEcaRule>>> serviceEcaCache; + + public Map<String, EntityArtifactInfo> allEntityInfos = FastMap.newInstance(); + public Map<String, ServiceArtifactInfo> allServiceInfos = FastMap.newInstance(); + public Map<String, FormWidgetArtifactInfo> allFormInfos = FastMap.newInstance(); + public Map<String, ScreenWidgetArtifactInfo> allScreenInfos = FastMap.newInstance(); + + // reverse-associative caches for walking backward in the diagram + public Map<String, Set<ServiceEcaArtifactInfo>> allServiceEcaInfosReferringToServiceName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allServiceInfosReferringToServiceName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allServiceInfosReferringToEntityName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allFormInfosReferringToServiceName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allFormInfosReferringToEntityName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allScreenInfosReferringToServiceName = FastMap.newInstance(); + public Map<String, Set<ServiceArtifactInfo>> allScreenInfosReferringToEntityName = FastMap.newInstance(); + + public static ArtifactInfoFactory makeArtifactInfoFactory(String delegatorName) throws GenericEntityException { + if (UtilValidate.isEmpty(delegatorName)) { + delegatorName = "default"; + } + + ArtifactInfoFactory aic = artifactInfoFactoryCache.get(delegatorName); + if (aic == null) { + aic = new ArtifactInfoFactory(delegatorName); + } + return aic; } - public static ScreenWidgetArtifactInfo makeScreenWidgetArtifactInfo(String screenName, String screenLocation, String delegatorName) throws GeneralException, IOException, SAXException, ParserConfigurationException { - return new ScreenWidgetArtifactInfo(screenName, screenLocation, ArtifactInfoContext.makeArtifactInfoContext(delegatorName)); + protected ArtifactInfoFactory(String delegatorName) throws GenericEntityException { + this.delegatorName = delegatorName; + this.entityModelReader = ModelReader.getModelReader(delegatorName); + this.dispatchContext = new DispatchContext("ArtifactInfoDispCtx", null, this.getClass().getClassLoader(), null); + this.entityEcaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegatorName)); + this.serviceEcaCache = ServiceEcaUtil.ecaCache; } - static public class ArtifactInfoContext { - protected static Map<String, ArtifactInfoContext> artifactInfoContextCache = FastMap.newInstance(); - - protected String delegatorName; - protected ModelReader entityModelReader; - protected DispatchContext dispatchContext; - protected Map<String, Map<String, List<EntityEcaRule>>> entityEcaCache; - protected Map<String, Map<String, List<ServiceEcaRule>>> serviceEcaCache; - - public static ArtifactInfoContext makeArtifactInfoContext(String delegatorName) throws GenericEntityException { - if (UtilValidate.isEmpty(delegatorName)) { - delegatorName = "default"; - } - - ArtifactInfoContext aic = artifactInfoContextCache.get(delegatorName); - if (aic == null) { - aic = new ArtifactInfoContext(delegatorName); - } - return aic; + public void prepareAll() throws GeneralException { + Set<String> entityNames = this.getEntityModelReader().getEntityNames(); + for (String entityName: entityNames) { + this.getEntityArtifactInfo(entityName); } - protected ArtifactInfoContext(String delegatorName) throws GenericEntityException { - this.delegatorName = delegatorName; - this.entityModelReader = ModelReader.getModelReader(delegatorName); - this.dispatchContext = new DispatchContext("ArtifactInfoDispCtx", null, this.getClass().getClassLoader(), null); - this.entityEcaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegatorName)); - this.serviceEcaCache = ServiceEcaUtil.ecaCache; + Set<String> serviceNames = this.getDispatchContext().getAllServiceNames(); + for (String serviceName: serviceNames) { + this.getServiceArtifactInfo(serviceName); } - public ModelReader getEntityModelReader() { - return this.entityModelReader; - } + // TODO: how to get all Service ECAs to prepare? - public DispatchContext getDispatchContext() { - return this.dispatchContext; - } + // TODO: how to get all forms to prepare? - public ModelEntity getModelEntity(String entityName) throws GenericEntityException { - return this.getEntityModelReader().getModelEntity(entityName); + // TODO: how to get all screens to prepare? + } + + public ModelReader getEntityModelReader() { + return this.entityModelReader; + } + + public DispatchContext getDispatchContext() { + return this.dispatchContext; + } + + public ModelEntity getModelEntity(String entityName) throws GenericEntityException { + return this.getEntityModelReader().getModelEntity(entityName); + } + + public ModelService getModelService(String serviceName) throws GenericServiceException { + return this.getDispatchContext().getModelService(serviceName); + } + + public ModelForm getModelForm(String formName, String formLocation) throws ParserConfigurationException, SAXException, IOException { + return FormFactory.getFormFromLocation(formLocation, formName, this.entityModelReader, this.dispatchContext); + } + + public ModelScreen getModelScreen(String screenName, String screenLocation) throws ParserConfigurationException, SAXException, IOException { + return ScreenFactory.getScreenFromLocation(screenLocation, screenName); + } + + public EntityArtifactInfo getEntityArtifactInfo(String entityName) throws GeneralException { + EntityArtifactInfo curInfo = this.allEntityInfos.get(entityName); + if (curInfo == null) { + curInfo = new EntityArtifactInfo(entityName, this); + this.allEntityInfos.put(entityName, curInfo); } - - public ModelService getModelService(String serviceName) throws GenericServiceException { - return this.getDispatchContext().getModelService(serviceName); + return curInfo; + } + + public ServiceArtifactInfo getServiceArtifactInfo(String serviceName) throws GeneralException { + ServiceArtifactInfo curInfo = this.allServiceInfos.get(serviceName); + if (curInfo == null) { + curInfo = new ServiceArtifactInfo(serviceName, this); + this.allServiceInfos.put(serviceName, curInfo); } - - public ModelForm getModelForm(String formName, String formLocation) throws ParserConfigurationException, SAXException, IOException { - return FormFactory.getFormFromLocation(formLocation, formName, this.entityModelReader, this.dispatchContext); + return curInfo; + } + + public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formName, String formLocation) throws GeneralException, IOException, SAXException, ParserConfigurationException { + FormWidgetArtifactInfo curInfo = this.allFormInfos.get(formName + formLocation); + if (curInfo == null) { + curInfo = new FormWidgetArtifactInfo(formName, formLocation, this); + this.allFormInfos.put(formName + formLocation, curInfo); } - - public ModelScreen getModelScreen(String screenName, String screenLocation) throws ParserConfigurationException, SAXException, IOException { - return ScreenFactory.getScreenFromLocation(screenLocation, screenName); + return curInfo; + } + + public ScreenWidgetArtifactInfo getScreenWidgetArtifactInfo(String screenName, String screenLocation) throws GeneralException, IOException, SAXException, ParserConfigurationException { + ScreenWidgetArtifactInfo curInfo = this.allScreenInfos.get(screenName + screenLocation); + if (curInfo == null) { + curInfo = new ScreenWidgetArtifactInfo(screenName, screenLocation, this); + this.allScreenInfos.put(screenName + screenLocation, curInfo); } + return curInfo; } } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/EntityArtifactInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/EntityArtifactInfo.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/EntityArtifactInfo.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/EntityArtifactInfo.java Mon Mar 3 15:37:14 2008 @@ -25,22 +25,30 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entityext.eca.EntityEcaRule; -import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory.ArtifactInfoContext; +import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory; /** * */ public class EntityArtifactInfo { - protected ArtifactInfoContext aic; + protected ArtifactInfoFactory aif; protected ModelEntity modelEntity; - public EntityArtifactInfo(String entityName, ArtifactInfoContext aic) throws GenericEntityException { - this.aic = aic; - this.modelEntity = this.aic.getModelEntity(entityName); + public EntityArtifactInfo(String entityName, ArtifactInfoFactory aif) throws GenericEntityException { + this.aif = aif; + this.modelEntity = this.aif.getModelEntity(entityName); } public ModelEntity getModelEntity() { return this.modelEntity; + } + + public boolean equals(Object obj) { + if (obj instanceof EntityArtifactInfo) { + return this.modelEntity.getEntityName().equals(((EntityArtifactInfo) obj).modelEntity.getEntityName()); + } else { + return false; + } } public List<EntityArtifactInfo> getEntitiesRelatedOne() { Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java Mon Mar 3 15:37:14 2008 @@ -22,7 +22,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory.ArtifactInfoContext; +import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory; import org.ofbiz.widget.form.ModelForm; import org.xml.sax.SAXException; @@ -30,11 +30,20 @@ * */ public class FormWidgetArtifactInfo { - protected ArtifactInfoContext aic; + protected ArtifactInfoFactory aif; protected ModelForm modelForm; - public FormWidgetArtifactInfo(String formName, String formLocation, ArtifactInfoContext aic) throws ParserConfigurationException, SAXException, IOException { - this.aic = aic; - this.modelForm = aic.getModelForm(formName, formLocation); + public FormWidgetArtifactInfo(String formName, String formLocation, ArtifactInfoFactory aif) throws ParserConfigurationException, SAXException, IOException { + this.aif = aif; + this.modelForm = aif.getModelForm(formName, formLocation); } -} + + public boolean equals(Object obj) { + if (obj instanceof FormWidgetArtifactInfo) { + return (this.modelForm.getName().equals(((FormWidgetArtifactInfo) obj).modelForm.getName()) && + this.modelForm.getFormLocation().equals(((FormWidgetArtifactInfo) obj).modelForm.getFormLocation())); + } else { + return false; + } + } +} Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java?rev=633325&r1=633324&r2=633325&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java Mon Mar 3 15:37:14 2008 @@ -22,7 +22,7 @@ import javax.xml.parsers.ParserConfigurationException; -import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory.ArtifactInfoContext; +import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory; import org.ofbiz.widget.screen.ModelScreen; import org.xml.sax.SAXException; @@ -30,11 +30,20 @@ * */ public class ScreenWidgetArtifactInfo { - protected ArtifactInfoContext aic; + protected ArtifactInfoFactory aif; protected ModelScreen modelScreen; - public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoContext aic) throws ParserConfigurationException, SAXException, IOException { - this.aic = aic; - this.modelScreen = aic.getModelScreen(screenName, screenLocation); + public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoFactory aif) throws ParserConfigurationException, SAXException, IOException { + this.aif = aif; + this.modelScreen = aif.getModelScreen(screenName, screenLocation); + } + + public boolean equals(Object obj) { + if (obj instanceof ScreenWidgetArtifactInfo) { + return (this.modelScreen.getName().equals(((ScreenWidgetArtifactInfo) obj).modelScreen.getName()) && + this.modelScreen.getSourceLocation().equals(((ScreenWidgetArtifactInfo) obj).modelScreen.getSourceLocation())); + } else { + return false; + } } } |
Free forum by Nabble | Edit this page |