Author: jonesde
Date: Tue Mar 4 01:28:48 2008 New Revision: 633402 URL: http://svn.apache.org/viewvc?rev=633402&view=rev Log: A bunch of fixes and refinements, completed first pass of successful full load for all entities/services, and an export of eomodeld forand service and an export for one service Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/CallSimpleMethod.java ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/MasterIf.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/ServiceDispatcher.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java ofbiz/trunk/framework/webtools/servicedef/services.xml ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.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/webtools/webapp/webtools/WEB-INF/controller.xml ofbiz/trunk/framework/webtools/webapp/webtools/service/availableservices.ftl 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=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Tue Mar 4 01:28:48 2008 @@ -428,6 +428,9 @@ public String getMethodName() { return this.methodName; } + public String getLocationAndName() { + return this.fromLocation + "#" + this.methodName; + } public SimpleMethod getSimpleMethodInSameFile(String simpleMethodName) { if (parentSimpleMethodsMap == null) return null; @@ -524,10 +527,11 @@ public Set<String> getAllServiceNamesCalled() throws MiniLangException { Set<String> allServiceNames = FastSet.newInstance(); - findServiceNamesCalled(this.methodOperations, allServiceNames); + Set<String> simpleMethodsVisited = FastSet.newInstance(); + findServiceNamesCalled(this.methodOperations, allServiceNames, simpleMethodsVisited); return allServiceNames; } - protected static void findServiceNamesCalled(List<MethodOperation> methodOperations, Set<String> allServiceNames) throws MiniLangException { + protected static void findServiceNamesCalled(List<MethodOperation> methodOperations, Set<String> allServiceNames, Set<String> simpleMethodsVisited) throws MiniLangException { for (MethodOperation methodOperation: methodOperations) { if (methodOperation instanceof CallService) { String svcName = ((CallService) methodOperation).getServiceName(); @@ -540,44 +544,57 @@ if (UtilValidate.isNotEmpty(svcName)) allServiceNames.add(svcName); } else if (methodOperation instanceof CallSimpleMethod) { - SimpleMethod calledMethod = ((CallSimpleMethod) methodOperation).getSimpleMethodToCall(null); - allServiceNames.addAll(calledMethod.getAllServiceNamesCalled()); + CallSimpleMethod csm = (CallSimpleMethod) methodOperation; + try { + SimpleMethod calledMethod = csm.getSimpleMethodToCall(methodOperations.getClass().getClassLoader()); + if (calledMethod == null) { + Debug.logWarning("Could not find simple-method [" + csm.getMethodName() + "] in [" + csm.getXmlResource() + "] from the SimpleMethod [" + csm.getSimpleMethod().getMethodName() + "] in [" + csm.getSimpleMethod().getFromLocation() + "]", module); + } else { + if (!simpleMethodsVisited.contains(calledMethod.getLocationAndName())) { + simpleMethodsVisited.add(calledMethod.getLocationAndName()); + findServiceNamesCalled(calledMethod.methodOperations, allServiceNames, simpleMethodsVisited); + } + } + } catch (MiniLangException e) { + Debug.logWarning("Error getting simple-method info in the [" + csm.getSimpleMethod().getMethodName() + "] in [" + csm.getSimpleMethod().getFromLocation() + "]: " + e.toString(), module); + } } else if (methodOperation instanceof Iterate) { - findServiceNamesCalled(((Iterate) methodOperation).getSubOps(), allServiceNames); + findServiceNamesCalled(((Iterate) methodOperation).getSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IterateMap) { - findServiceNamesCalled(((IterateMap) methodOperation).getSubOps(), allServiceNames); + findServiceNamesCalled(((IterateMap) methodOperation).getSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof Loop) { - findServiceNamesCalled(((Loop) methodOperation).getSubOps(), allServiceNames); + findServiceNamesCalled(((Loop) methodOperation).getSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof MasterIf) { - findServiceNamesCalled(((MasterIf) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((MasterIf) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof While) { - findServiceNamesCalled(((While) methodOperation).getThenSubOps(), allServiceNames); + findServiceNamesCalled(((While) methodOperation).getThenSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfValidateMethod) { - findServiceNamesCalled(((IfValidateMethod) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfValidateMethod) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfInstanceOf) { - findServiceNamesCalled(((IfInstanceOf) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfInstanceOf) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfCompare) { - findServiceNamesCalled(((IfCompare) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfCompare) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfCompareField) { - findServiceNamesCalled(((IfCompareField) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfCompareField) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfRegexp) { - findServiceNamesCalled(((IfRegexp) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfRegexp) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfEmpty) { - findServiceNamesCalled(((IfEmpty) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfEmpty) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfNotEmpty) { - findServiceNamesCalled(((IfNotEmpty) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfNotEmpty) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } else if (methodOperation instanceof IfHasPermission) { - findServiceNamesCalled(((IfHasPermission) methodOperation).getAllSubOps(), allServiceNames); + findServiceNamesCalled(((IfHasPermission) methodOperation).getAllSubOps(), allServiceNames, simpleMethodsVisited); } } } public Set<String> getAllEntityNamesUsed() throws MiniLangException { Set<String> allEntityNames = FastSet.newInstance(); - findEntityNamesUsed(this.methodOperations, allEntityNames); + Set<String> simpleMethodsVisited = FastSet.newInstance(); + findEntityNamesUsed(this.methodOperations, allEntityNames, simpleMethodsVisited); return allEntityNames; } - protected static void findEntityNamesUsed(List<MethodOperation> methodOperations, Set<String> allEntityNames) throws MiniLangException { + protected static void findEntityNamesUsed(List<MethodOperation> methodOperations, Set<String> allEntityNames, Set<String> simpleMethodsVisited) throws MiniLangException { for (MethodOperation methodOperation: methodOperations) { if (methodOperation instanceof FindByPrimaryKey) { String entName = ((FindByPrimaryKey) methodOperation).getEntityName(); @@ -602,34 +619,46 @@ if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName); } else if (methodOperation instanceof CallSimpleMethod) { - SimpleMethod calledMethod = ((CallSimpleMethod) methodOperation).getSimpleMethodToCall(null); - allEntityNames.addAll(calledMethod.getAllServiceNamesCalled()); + CallSimpleMethod csm = (CallSimpleMethod) methodOperation; + try { + SimpleMethod calledMethod = csm.getSimpleMethodToCall(methodOperations.getClass().getClassLoader()); + if (calledMethod == null) { + Debug.logWarning("Could not find simple-method [" + csm.getMethodName() + "] in [" + csm.getXmlResource() + "] from the SimpleMethod [" + csm.getSimpleMethod().getMethodName() + "] in [" + csm.getSimpleMethod().getFromLocation() + "]", module); + } else { + if (!simpleMethodsVisited.contains(calledMethod.getLocationAndName())) { + simpleMethodsVisited.add(calledMethod.getLocationAndName()); + findEntityNamesUsed(calledMethod.methodOperations, allEntityNames, simpleMethodsVisited); + } + } + } catch (MiniLangException e) { + Debug.logWarning("Error getting simple-method info in the [" + csm.getSimpleMethod().getMethodName() + "] in [" + csm.getSimpleMethod().getFromLocation() + "]: " + e.toString(), module); + } } else if (methodOperation instanceof Iterate) { - findEntityNamesUsed(((Iterate) methodOperation).getSubOps(), allEntityNames); + findEntityNamesUsed(((Iterate) methodOperation).getSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IterateMap) { - findEntityNamesUsed(((IterateMap) methodOperation).getSubOps(), allEntityNames); + findEntityNamesUsed(((IterateMap) methodOperation).getSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof Loop) { - findEntityNamesUsed(((Loop) methodOperation).getSubOps(), allEntityNames); + findEntityNamesUsed(((Loop) methodOperation).getSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof MasterIf) { - findEntityNamesUsed(((MasterIf) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((MasterIf) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof While) { - findEntityNamesUsed(((While) methodOperation).getThenSubOps(), allEntityNames); + findEntityNamesUsed(((While) methodOperation).getThenSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfValidateMethod) { - findEntityNamesUsed(((IfValidateMethod) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfValidateMethod) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfInstanceOf) { - findEntityNamesUsed(((IfInstanceOf) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfInstanceOf) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfCompare) { - findEntityNamesUsed(((IfCompare) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfCompare) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfCompareField) { - findEntityNamesUsed(((IfCompareField) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfCompareField) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfRegexp) { - findEntityNamesUsed(((IfRegexp) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfRegexp) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfEmpty) { - findEntityNamesUsed(((IfEmpty) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfEmpty) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfNotEmpty) { - findEntityNamesUsed(((IfNotEmpty) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfNotEmpty) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } else if (methodOperation instanceof IfHasPermission) { - findEntityNamesUsed(((IfHasPermission) methodOperation).getAllSubOps(), allEntityNames); + findEntityNamesUsed(((IfHasPermission) methodOperation).getAllSubOps(), allEntityNames, simpleMethodsVisited); } } } Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java (original) +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/MethodOperation.java Tue Mar 4 01:28:48 2008 @@ -32,6 +32,10 @@ public MethodOperation(Element element, SimpleMethod simpleMethod) { this.simpleMethod = simpleMethod; } + + public SimpleMethod getSimpleMethod() { + return this.simpleMethod; + } /** Execute the operation; if false is returned then no further operations will be executed */ public abstract boolean exec(MethodContext methodContext); 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -42,6 +42,14 @@ this.methodName = element.getAttribute("method-name"); this.xmlResource = element.getAttribute("xml-resource"); } + + public String getXmlResource() { + return this.xmlResource; + } + + public String getMethodName() { + return this.methodName; + } public boolean exec(MethodContext methodContext) { if (this.methodName != null && this.methodName.length() > 0) { @@ -113,8 +121,7 @@ } public String rawString() { - // TODO: something more than the empty tag - return "<call-simple-method/>"; + return "<call-simple-method xml-resource=\"" + this.xmlResource + "\" method-name=\"" + this.methodName + "\" />"; } public String expandedString(MethodContext methodContext) { // TODO: something more than a stub/dummy 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -95,9 +95,11 @@ 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()); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); + if (elseIfs != null) { + for (ElseIf elseIf: elseIfs) { + allSubOps.addAll(elseIf.getThenSubOps()); + } } return allSubOps; 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -128,7 +128,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -145,7 +145,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -91,7 +91,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -99,7 +99,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -93,7 +93,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -98,7 +98,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -115,7 +115,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -133,7 +133,7 @@ public List<MethodOperation> getAllSubOps() { List<MethodOperation> allSubOps = FastList.newInstance(); allSubOps.addAll(this.subOps); - allSubOps.addAll(this.elseSubOps); + if (this.elseSubOps != null) allSubOps.addAll(this.elseSubOps); return allSubOps; } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Tue Mar 4 01:28:48 2008 @@ -18,10 +18,22 @@ *******************************************************************************/ package org.ofbiz.service; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.transaction.Transaction; + import javolution.util.FastList; import javolution.util.FastMap; + import org.ofbiz.base.config.GenericConfigException; -import org.ofbiz.base.util.*; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralRuntimeException; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilTimer; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.LRUMap; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; @@ -43,13 +55,6 @@ import org.ofbiz.service.job.JobManagerException; import org.ofbiz.service.semaphore.ServiceSemaphore; import org.w3c.dom.Element; - -import javax.transaction.Transaction; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; /** * Global Service Dispatcher Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java Tue Mar 4 01:28:48 2008 @@ -18,13 +18,11 @@ *******************************************************************************/ package org.ofbiz.service.eca; -import java.util.Iterator; -import java.util.LinkedList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; -import java.util.Collection; import javolution.util.FastList; import javolution.util.FastMap; @@ -33,13 +31,11 @@ import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.config.MainResourceHandler; import org.ofbiz.base.config.ResourceHandler; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilXml; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.config.ServiceConfigUtil; -import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilXml; -import org.ofbiz.base.util.cache.UtilCache; - import org.w3c.dom.Element; /** @@ -115,7 +111,7 @@ } catch (GenericConfigException e) { Debug.logError(e, "Could not get resource URL", module); } - Debug.logImportant("Loaded " + numDefs + " Service ECA definitions from " + resourceLocation, module); + Debug.logImportant("Loaded [" + numDefs + "] Service ECA definitions from " + resourceLocation, module); } } Modified: ofbiz/trunk/framework/webtools/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/servicedef/services.xml?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/servicedef/services.xml (original) +++ ofbiz/trunk/framework/webtools/servicedef/services.xml Tue Mar 4 01:28:48 2008 @@ -136,4 +136,11 @@ <attribute name="filterJobsWithRunningStatus" type="String" mode="INOUT" optional="true"/> <attribute name="filterJobsWithFinishedStatus" type="String" mode="INOUT" optional="true"/> </service> + <service name="exportServiceEoModelBundle" engine="java" location="org.ofbiz.webtools.WebToolsServices" invoke="exportServiceEoModelBundle" auth="true" use-transaction="false"> + <description>Saves service and related artifacts diagram to an Apple EOModelBundle file. + </description> + <permission-service service-name="entityMaintPermCheck" main-action="VIEW"/> + <attribute name="eomodeldFullPath" type="java.lang.String" mode="IN" optional="false"/> + <attribute name="serviceName" type="java.lang.String" mode="IN" optional="false"/> + </service> </services> Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Tue Mar 4 01:28:48 2008 @@ -18,32 +18,32 @@ */ package org.ofbiz.webtools; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; -import java.io.File; -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.FileReader; -import java.io.PrintWriter; -import java.io.BufferedWriter; -import java.io.OutputStreamWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.MalformedURLException; +import java.util.Set; +import java.util.TreeSet; import javax.xml.parsers.ParserConfigurationException; @@ -52,47 +52,51 @@ import javolution.util.FastSet; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.StringUtil; +import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; -import org.ofbiz.base.util.UtilProperties.UtilResourceBundle; import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilProperties.UtilResourceBundle; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.EntityDataAssert; -import org.ofbiz.entity.util.EntityDataLoader; -import org.ofbiz.entity.util.EntityListIterator; -import org.ofbiz.entity.util.EntitySaxReader; -import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityConditionList; +import org.ofbiz.entity.condition.EntityExpr; +import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; import org.ofbiz.entity.model.ModelFieldType; import org.ofbiz.entity.model.ModelIndex; -import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.entity.model.ModelUtil; import org.ofbiz.entity.model.ModelViewEntity; -import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionList; -import org.ofbiz.entity.condition.EntityExpr; -import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityDataAssert; +import org.ofbiz.entity.util.EntityDataLoader; import org.ofbiz.entity.util.EntityFindOptions; +import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntitySaxReader; import org.ofbiz.entityext.EntityGroupUtil; import org.ofbiz.security.Security; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; - +import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory; +import org.ofbiz.webtools.artifactinfo.ServiceArtifactInfo; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import freemarker.template.*; -import freemarker.ext.dom.NodeModel; import freemarker.ext.beans.BeansWrapper; +import freemarker.ext.dom.NodeModel; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateHashModel; /** * WebTools Services @@ -1013,5 +1017,44 @@ result.put("jobs", jobList); result.put("jobListSize", new Integer(jobListSize)); return result; + } + + public static Map exportServiceEoModelBundle(DispatchContext dctx, Map context) { + String eomodeldFullPath = (String) context.get("eomodeldFullPath"); + String serviceName = (String) context.get("serviceName"); + + if (eomodeldFullPath.endsWith("/")) { + eomodeldFullPath = eomodeldFullPath + serviceName + ".eomodeld"; + } + + if (!eomodeldFullPath.endsWith(".eomodeld")) { + eomodeldFullPath = eomodeldFullPath + ".eomodeld"; + } + + File outdir = new File(eomodeldFullPath); + if (!outdir.exists()) { + outdir.mkdir(); + } + if (!outdir.isDirectory()) { + return ServiceUtil.returnError("eomodel Full Path is not a directory: " + eomodeldFullPath); + } + if (!outdir.canWrite()) { + return ServiceUtil.returnError("eomodel Full Path is not write-able: " + eomodeldFullPath); + } + + try { + ArtifactInfoFactory aif = ArtifactInfoFactory.makeArtifactInfoFactory("default"); + ServiceArtifactInfo serviceInfo = aif.getServiceArtifactInfo(serviceName); + serviceInfo.writeServiceCallGraphEoModel(eomodeldFullPath); + } catch (GeneralException e) { + Debug.logError(e, module); + return ServiceUtil.returnError("Error getting service info: " + e.toString()); + } catch (UnsupportedEncodingException e) { + return ServiceUtil.returnError("ERROR saving file: " + e.toString()); + } catch (FileNotFoundException e) { + return ServiceUtil.returnError("ERROR: file/directory not found: " + e.toString()); + } + + return ServiceUtil.returnSuccess(); } } 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=633402&r1=633401&r2=633402&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 Tue Mar 4 01:28:48 2008 @@ -154,6 +154,7 @@ if (curInfo == null) { curInfo = new ServiceArtifactInfo(serviceName, this); this.allServiceInfos.put(serviceName, curInfo); + curInfo.populateAll(); } return curInfo; } @@ -163,6 +164,7 @@ if (curInfo == null) { curInfo = new ServiceEcaArtifactInfo(ecaRule, this); this.allServiceEcaInfos.put(ecaRule, curInfo); + curInfo.populateAll(); } return curInfo; } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java Tue Mar 4 01:28:48 2008 @@ -28,10 +28,13 @@ import javolution.util.FastMap; import javolution.util.FastSet; +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.SimpleMethod; +import org.ofbiz.minilang.method.callops.CallSimpleMethod; import org.ofbiz.service.ModelParam; import org.ofbiz.service.ModelService; import org.ofbiz.service.eca.ServiceEcaRule; @@ -41,6 +44,8 @@ * */ public class ServiceArtifactInfo { + public static final String module = ServiceArtifactInfo.class.getName(); + protected ArtifactInfoFactory aif; protected ModelService modelService; protected String displayPrefix = null; @@ -52,7 +57,14 @@ public ServiceArtifactInfo(String serviceName, ArtifactInfoFactory aif) throws GeneralException { this.aif = aif; this.modelService = this.aif.getModelService(serviceName); - + } + + /** + * This must be called after creation from the ArtifactInfoFactory after this class has been put into the global Map in order to avoid recursive initialization + * + * @throws GeneralException + */ + public void populateAll() throws GeneralException { this.populateUsedEntities(); this.populateCalledServices(); this.populateTriggeredServiceEcas(); @@ -62,11 +74,28 @@ // populate entitiesUsedByThisService and for each the reverse-associate cache in the aif if ("simple".equals(this.modelService.engineName)) { // we can do something with this! - Map<String, SimpleMethod> simpleMethods = SimpleMethod.getSimpleMethods(this.modelService.location, null); - SimpleMethod simpleMethodToCall = (SimpleMethod) simpleMethods.get(this.modelService.invoke); + SimpleMethod simpleMethodToCall = null; + try { + Map<String, SimpleMethod> simpleMethods = SimpleMethod.getSimpleMethods(this.modelService.location, null); + simpleMethodToCall = (SimpleMethod) simpleMethods.get(this.modelService.invoke); + } catch (MiniLangException e) { + Debug.logWarning("Error getting Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "]: " + e.toString(), module); + } + if (simpleMethodToCall == null) { + Debug.logWarning("Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "] not found", module); + return; + } Set<String> allEntityNameSet = simpleMethodToCall.getAllEntityNamesUsed(); for (String entityName: allEntityNameSet) { + if (entityName.contains("${")) { + continue; + } + if (!aif.getEntityModelReader().getEntityNames().contains(entityName)) { + Debug.logWarning("Entity [" + entityName + "] reference in service [" + this.modelService.name + "] does not exist!", module); + continue; + } + // the forward reference this.entitiesUsedByThisService.add(aif.getEntityArtifactInfo(entityName)); // the reverse reference @@ -82,11 +111,28 @@ // populate servicesCalledByThisService and for each the reverse-associate cache in the aif if ("simple".equals(this.modelService.engineName)) { // we can do something with this! - Map<String, SimpleMethod> simpleMethods = SimpleMethod.getSimpleMethods(this.modelService.location, null); - SimpleMethod simpleMethodToCall = (SimpleMethod) simpleMethods.get(this.modelService.invoke); + SimpleMethod simpleMethodToCall = null; + try { + Map<String, SimpleMethod> simpleMethods = SimpleMethod.getSimpleMethods(this.modelService.location, null); + simpleMethodToCall = (SimpleMethod) simpleMethods.get(this.modelService.invoke); + } catch (MiniLangException e) { + Debug.logWarning("Error getting Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "]: " + e.toString(), module); + } + if (simpleMethodToCall == null) { + Debug.logWarning("Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "] not found", module); + return; + } Set<String> allServiceNameSet = simpleMethodToCall.getAllServiceNamesCalled(); for (String serviceName: allServiceNameSet) { + if (serviceName.contains("${")) { + continue; + } + if (!aif.getDispatchContext().getAllServiceNames().contains(serviceName)) { + Debug.logWarning("Service [" + serviceName + "] reference in service [" + this.modelService.name + "] does not exist!", module); + continue; + } + // the forward reference this.servicesCalledByThisService.add(aif.getServiceArtifactInfo(serviceName)); // the reverse reference @@ -100,6 +146,7 @@ protected void populateTriggeredServiceEcas() throws GeneralException { // populate serviceEcasTriggeredByThisService and for each the reverse-associate cache in the aif Map<String, List<ServiceEcaRule>> serviceEventMap = ServiceEcaUtil.getServiceEventMap(this.modelService.name); + if (serviceEventMap == null) return; for (List<ServiceEcaRule> ecaRuleList: serviceEventMap.values()) { for (ServiceEcaRule ecaRule: ecaRuleList) { this.serviceEcasTriggeredByThisService.add(aif.getServiceEcaArtifactInfo(ecaRule)); @@ -153,71 +200,74 @@ return aif.allServiceEcaInfosReferringToServiceName.get(this.modelService.name); } - public List<FormWidgetArtifactInfo> getFormsCallingService() { - List<FormWidgetArtifactInfo> formList = FastList.newInstance(); + public Set<FormWidgetArtifactInfo> getFormsCallingService() { + Set<FormWidgetArtifactInfo> formSet = FastSet.newInstance(); // TODO: implement this - return formList; + return formSet; } - public List<FormWidgetArtifactInfo> getFormsBasedOnService() { - List<FormWidgetArtifactInfo> formList = FastList.newInstance(); + public Set<FormWidgetArtifactInfo> getFormsBasedOnService() { + Set<FormWidgetArtifactInfo> formSet = FastSet.newInstance(); // TODO: implement this - return formList; + return formSet; } - public List<ScreenWidgetArtifactInfo> getScreensCallingService() { - List<ScreenWidgetArtifactInfo> screenList = FastList.newInstance(); + public Set<ScreenWidgetArtifactInfo> getScreensCallingService() { + Set<ScreenWidgetArtifactInfo> screenSet = FastSet.newInstance(); // TODO: implement this - return screenList; + return screenSet; } - public List<ScreenWidgetArtifactInfo> getRequestsWithEventCallingService() { - List<ScreenWidgetArtifactInfo> screenList = FastList.newInstance(); + public Set getRequestsWithEventCallingService() { + Set requestSet = FastSet.newInstance(); // TODO: implement this - return screenList; + return requestSet; } public void writeServiceCallGraphEoModel(String eomodeldFullPath) throws GeneralException, FileNotFoundException, UnsupportedEncodingException { - // TODO: add support for parameters with recursion: int callingHops, int calledHops, boolean useMoreDetailedNames = true; + Debug.logInfo("Writing Service Call Graph EO Model for service [" + this.modelService.name + "] to [" + eomodeldFullPath + "]", module); + Set<String> allDiagramEntitiesWithPrefixes = FastSet.newInstance(); List<ServiceArtifactInfo> allServiceList = FastList.newInstance(); List<ServiceEcaArtifactInfo> allServiceEcaList = FastList.newInstance(); // all services that call this service Set<ServiceArtifactInfo> callingServiceList = this.getServicesCallingService(); - - // set the prefix and add to the all list - for (ServiceArtifactInfo callingService: callingServiceList) { - callingService.setDisplayPrefix("Calling:"); - allDiagramEntitiesWithPrefixes.add(callingService.getDisplayPrefixedName()); - allServiceList.add(callingService); + if (callingServiceList != null) { + // set the prefix and add to the all list + for (ServiceArtifactInfo callingService: callingServiceList) { + callingService.setDisplayPrefix("Calling_"); + allDiagramEntitiesWithPrefixes.add(callingService.getDisplayPrefixedName()); + allServiceList.add(callingService); + } } // all services this service calls Set<ServiceArtifactInfo> calledServiceList = this.getServicesCalledByService(); for (ServiceArtifactInfo calledService: calledServiceList) { - calledService.setDisplayPrefix("Called:"); + calledService.setDisplayPrefix("Called_"); allDiagramEntitiesWithPrefixes.add(calledService.getDisplayPrefixedName()); allServiceList.add(calledService); } // all SECAs and triggering services that call this service as an action Set<ServiceEcaArtifactInfo> callingServiceEcaSet = this.getServiceEcaRulesCallingService(); - - for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { - callingServiceEca.setDisplayPrefix("Triggering:"); - allDiagramEntitiesWithPrefixes.add(callingServiceEca.getDisplayPrefixedName()); - allServiceEcaList.add(callingServiceEca); + if (callingServiceEcaSet != null) { + for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { + callingServiceEca.setDisplayPrefix("Triggering_"); + allDiagramEntitiesWithPrefixes.add(callingServiceEca.getDisplayPrefixedName()); + allServiceEcaList.add(callingServiceEca); + } } // all SECAs and corresponding services triggered by this service Set<ServiceEcaArtifactInfo> calledServiceEcaSet = this.getServiceEcaRulesTriggeredByService(); for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaSet) { - calledServiceEca.setDisplayPrefix("Called:"); + calledServiceEca.setDisplayPrefix("Called_"); allDiagramEntitiesWithPrefixes.add(calledServiceEca.getDisplayPrefixedName()); allServiceEcaList.add(calledServiceEca); } @@ -250,26 +300,28 @@ } // write SECA description files - for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { - // add List<ServiceArtifactInfo> for services that trigger this eca rule - List<ServiceArtifactInfo> ecaCallingServiceList = callingServiceEca.getServicesTriggeringServiceEca(); - for (ServiceArtifactInfo ecaCallingService: ecaCallingServiceList) { - ecaCallingService.setDisplayPrefix("Triggering:"); + if (callingServiceEcaSet != null) { + for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) { + // add List<ServiceArtifactInfo> for services that trigger this eca rule + Set<ServiceArtifactInfo> ecaCallingServiceSet = callingServiceEca.getServicesTriggeringServiceEca(); + for (ServiceArtifactInfo ecaCallingService: ecaCallingServiceSet) { + ecaCallingService.setDisplayPrefix("Triggering:"); + } + ecaCallingServiceSet.add(this); + + Map<String, Object> serviceEcaEoModelMap = callingServiceEca.createEoModelMap(ecaCallingServiceSet, useMoreDetailedNames); + UtilFormatOut.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, callingServiceEca.getDisplayPrefixedName() + ".plist"); } - ecaCallingServiceList.add(this); - - Map<String, Object> serviceEcaEoModelMap = callingServiceEca.createEoModelMap(ecaCallingServiceList, useMoreDetailedNames); - UtilFormatOut.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, callingServiceEca.getDisplayPrefixedName() + ".plist"); } for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaSet) { // add List<ServiceArtifactInfo> for services this eca rule calls in action - List<ServiceArtifactInfo> ecaCalledServiceList = calledServiceEca.getServicesCalledByServiceEcaActions(); - for (ServiceArtifactInfo ecaCalledService: ecaCalledServiceList) { + Set<ServiceArtifactInfo> ecaCalledServiceSet = calledServiceEca.getServicesCalledByServiceEcaActions(); + for (ServiceArtifactInfo ecaCalledService: ecaCalledServiceSet) { ecaCalledService.setDisplayPrefix("Called:"); } - ecaCalledServiceList.add(this); + ecaCalledServiceSet.add(this); - Map<String, Object> serviceEcaEoModelMap = calledServiceEca.createEoModelMap(ecaCalledServiceList, useMoreDetailedNames); + Map<String, Object> serviceEcaEoModelMap = calledServiceEca.createEoModelMap(ecaCalledServiceSet, useMoreDetailedNames); UtilFormatOut.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, calledServiceEca.getDisplayPrefixedName() + ".plist"); } } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceEcaArtifactInfo.java Tue Mar 4 01:28:48 2008 @@ -20,15 +20,16 @@ import java.util.List; import java.util.Map; +import java.util.Set; import javolution.util.FastList; import javolution.util.FastMap; +import javolution.util.FastSet; -import org.ofbiz.service.GenericServiceException; +import org.ofbiz.base.util.GeneralException; import org.ofbiz.service.eca.ServiceEcaAction; import org.ofbiz.service.eca.ServiceEcaCondition; import org.ofbiz.service.eca.ServiceEcaRule; -import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory; /** * @@ -38,11 +39,25 @@ protected ServiceEcaRule serviceEcaRule; protected String displayPrefix = null; - public ServiceEcaArtifactInfo(ServiceEcaRule serviceEcaRule, ArtifactInfoFactory aif) throws GenericServiceException { + protected Set<ServiceArtifactInfo> servicesCalledByThisServiceEca = FastSet.newInstance(); + + public ServiceEcaArtifactInfo(ServiceEcaRule serviceEcaRule, ArtifactInfoFactory aif) throws GeneralException { this.aif = aif; this.serviceEcaRule = serviceEcaRule; } + /** + * This must be called after creation from the ArtifactInfoFactory after this class has been put into the global Map in order to avoid recursive initialization + * + * @throws GeneralException + */ + public void populateAll() throws GeneralException { + // populate the services called Set + for (ServiceEcaAction ecaAction: serviceEcaRule.getEcaActionList()) { + servicesCalledByThisServiceEca.add(aif.getServiceArtifactInfo(ecaAction.getServiceName())); + } + } + public ServiceEcaRule getServiceEcaRule() { return this.serviceEcaRule; } @@ -55,20 +70,16 @@ return (this.displayPrefix != null ? this.displayPrefix : "") + this.serviceEcaRule.getShortDisplayName(); } - public List<ServiceArtifactInfo> getServicesCalledByServiceEcaActions() { - List<ServiceArtifactInfo> serviceList = FastList.newInstance(); - // TODO: *implement this - return serviceList; + public Set<ServiceArtifactInfo> getServicesCalledByServiceEcaActions() { + return this.servicesCalledByThisServiceEca; } - public List<ServiceArtifactInfo> getServicesTriggeringServiceEca() { - List<ServiceArtifactInfo> serviceList = FastList.newInstance(); - // TODO: *implement this - return serviceList; + public Set<ServiceArtifactInfo> getServicesTriggeringServiceEca() { + return aif.allServiceInfosReferringToServiceEcaRule.get(this.serviceEcaRule); } - public Map<String, Object> createEoModelMap(List<ServiceArtifactInfo> relatedServiceList, boolean useMoreDetailedNames) { - if (relatedServiceList == null) relatedServiceList = FastList.newInstance(); + public Map<String, Object> createEoModelMap(Set<ServiceArtifactInfo> relatedServiceSet, boolean useMoreDetailedNames) { + if (relatedServiceSet == null) relatedServiceSet = FastSet.newInstance(); Map<String, Object> topLevelMap = FastMap.newInstance(); topLevelMap.put("name", this.getDisplayPrefixedName()); @@ -111,7 +122,7 @@ // relationships List<Map<String, Object>> relationshipsMapList = FastList.newInstance(); - for (ServiceArtifactInfo sai: relatedServiceList) { + for (ServiceArtifactInfo sai: relatedServiceSet) { Map<String, Object> relationshipMap = FastMap.newInstance(); relationshipsMapList.add(relationshipMap); Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Tue Mar 4 01:28:48 2008 @@ -358,7 +358,13 @@ <security https="true" auth="true"/> <response name="success" type="view" value="serviceEcaDetail"/> </request-map> - + <request-map uri="exportServiceEoModelBundle"> + <security https="true" auth="true"/> + <event type="service" invoke="exportServiceEoModelBundle"/> + <response name="success" type="view" value="availableServices"/> + <response name="error" type="view" value="availableServices"/> + </request-map> + <!-- CustomTimePeriod requests --> <request-map uri="EditCustomTimePeriod"> <security https="true" auth="true"/> Modified: ofbiz/trunk/framework/webtools/webapp/webtools/service/availableservices.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/service/availableservices.ftl?rev=633402&r1=633401&r2=633402&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/webapp/webtools/service/availableservices.ftl (original) +++ ofbiz/trunk/framework/webtools/webapp/webtools/service/availableservices.ftl Tue Mar 4 01:28:48 2008 @@ -271,6 +271,16 @@ </#if> </div> </#list> + + <#-- Show a little form for exportServiceEoModelBundle --> + <div class="screenlet-body"> + <form name="exportServiceEoModelBundle" method="post" action="<@ofbizUrl>exportServiceEoModelBundle</@ofbizUrl>" class="basic-form"> + <input type="hidden" name="sel_service_name" value="${selectedServiceMap.serviceName}"/> + <input type="hidden" name="serviceName" value="${selectedServiceMap.serviceName}"/> + Save eomodeld to Local Path: <input type="text" name="eomodeldFullPath" value="${parameters.eomodeldFullPath?if_exists}" size="60"/> + <input type="submit" name="submitButton" value="Export"/> + </form> + </div> </#if> <#-- No Service selected , we list all--> <#elseif servicesList?exists && servicesList?has_content> @@ -339,4 +349,4 @@ <#else> ${uiLabelMap.WebtoolsNoServicesFound}. <a href='<@ofbizUrl>${url}</@ofbizUrl>' class="smallSubmit">${uiLabelMap.CommonListAll}</a> -</#if> \ No newline at end of file +</#if> |
Free forum by Nabble | Edit this page |