svn commit: r633325 [2/2] - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/util/ entity/src/org/ofbiz/entity/finder/ entity/src/org/ofbiz/entity/model/ minilang/src/org/ofbiz/minilang/ minilang/src/org/ofbiz/minilang/method/callops/ minilang/s...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r633325 [2/2] - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/util/ entity/src/org/ofbiz/entity/finder/ entity/src/org/ofbiz/entity/model/ minilang/src/org/ofbiz/minilang/ minilang/src/org/ofbiz/minilang/method/callops/ minilang/s...

jonesde
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=633325&r1=633324&r2=633325&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 Mon Mar  3 15:37:14 2008
@@ -31,22 +31,74 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.minilang.SimpleMethod;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelParam;
 import org.ofbiz.service.ModelService;
-import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory.ArtifactInfoContext;
 
 /**
  *
  */
 public class ServiceArtifactInfo {
-    protected ArtifactInfoContext aic;
+    protected ArtifactInfoFactory aif;
     protected ModelService modelService;
     protected String displayPrefix = null;
     
-    public ServiceArtifactInfo(String serviceName, ArtifactInfoContext aic) throws GenericServiceException {
-        this.aic = aic;
-        this.modelService = this.aic.getModelService(serviceName);
+    Set<EntityArtifactInfo> entitiesUsedByThisService = FastSet.newInstance();
+    Set<ServiceArtifactInfo> servicesCalledByThisService = FastSet.newInstance();
+    Set<ServiceEcaArtifactInfo> serviceEcasTriggeredByThisService = FastSet.newInstance();
+    
+    public ServiceArtifactInfo(String serviceName, ArtifactInfoFactory aif) throws GeneralException {
+        this.aif = aif;
+        this.modelService = this.aif.getModelService(serviceName);
+        
+        this.populateUsedEntities();
+        this.populateCalledServices();
+        this.populateTriggeredServiceEcas();
+    }
+    
+    protected void populateUsedEntities() throws GeneralException {
+        // 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);
+            
+            Set<String> allEntityNameSet = simpleMethodToCall.getAllEntityNamesUsed();
+            for (String entityName: allEntityNameSet) {
+                // the forward reference
+                this.entitiesUsedByThisService.add(aif.getEntityArtifactInfo(entityName));
+                // the reverse reference
+                UtilMisc.addToSetInMap(this, aif.allServiceInfosReferringToEntityName, entityName);
+                
+            }
+        } else if ("java".equals(this.modelService.engineName)) {
+            // TODO: can't do anything about this :( ...YET! :)
+        }
+    }
+    
+    protected void populateCalledServices() throws GeneralException {
+        // 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);
+            
+            Set<String> allServiceNameSet = simpleMethodToCall.getAllServiceNamesCalled();
+            for (String serviceName: allServiceNameSet) {
+                // the forward reference
+                this.servicesCalledByThisService.add(aif.getServiceArtifactInfo(serviceName));
+                // the reverse reference
+                UtilMisc.addToSetInMap(this, aif.allServiceInfosReferringToServiceName, serviceName);
+            }
+        } else if ("java".equals(this.modelService.engineName)) {
+            // TODO: can't do anything about this :( ...YET! :)
+        }
+    }
+    
+    protected void populateTriggeredServiceEcas() {
+        // TODO populate serviceEcasTriggeredByThisService and for each the reverse-associate cache in the aif
+        
     }
     
     public ModelService getModelService() {
@@ -61,46 +113,36 @@
         return (this.displayPrefix != null ? this.displayPrefix : "") + this.modelService.name;
     }
     
-    public List<EntityArtifactInfo> getEntitiesUsedByService() {
-        List<EntityArtifactInfo> entityList = FastList.newInstance();
-        // TODO: implement this
-        return entityList;
+    public Set<EntityArtifactInfo> getEntitiesUsedByService() {
+        return this.entitiesUsedByThisService;
     }
     
-    public List<ServiceArtifactInfo> getServicesCallingService() {
-        List<ServiceArtifactInfo> serviceList = FastList.newInstance();
-        // TODO: *implement this
-        return serviceList;
+    public Set<ServiceArtifactInfo> getServicesCallingService() {
+        return aif.allServiceInfosReferringToServiceName.get(this.modelService.name);
     }
     
-    public List<ServiceArtifactInfo> getServicesCalledByService() {
-        List<ServiceArtifactInfo> serviceList = FastList.newInstance();
-        // TODO: *implement this
-        return serviceList;
+    public Set<ServiceArtifactInfo> getServicesCalledByService() {
+        return this.servicesCalledByThisService;
     }
     
-    public List<ServiceArtifactInfo> getServicesCalledByServiceEcas() {
-        List<ServiceArtifactInfo> serviceList = FastList.newInstance();
+    public Set<ServiceArtifactInfo> getServicesCalledByServiceEcas() {
+        Set<ServiceArtifactInfo> serviceList = FastSet.newInstance();
         // TODO: implement this
         return serviceList;
     }
     
-    public List<ServiceEcaArtifactInfo> getServiceEcaRulesTriggeredByService() {
-        List<ServiceEcaArtifactInfo> secaList = FastList.newInstance();
-        // TODO: *implement this
-        return secaList;
+    public Set<ServiceEcaArtifactInfo> getServiceEcaRulesTriggeredByService() {
+        return this.serviceEcasTriggeredByThisService;
     }
     
-    public List<ServiceArtifactInfo> getServicesCallingServiceByEcas() {
-        List<ServiceArtifactInfo> serviceList = FastList.newInstance();
+    public Set<ServiceArtifactInfo> getServicesCallingServiceByEcas() {
+        Set<ServiceArtifactInfo> serviceList = FastSet.newInstance();
         // TODO: implement this
         return serviceList;
     }
     
-    public List<ServiceEcaArtifactInfo> getServiceEcaRulesCallingService() {
-        List<ServiceEcaArtifactInfo> secaList = FastList.newInstance();
-        // TODO: *implement this
-        return secaList;
+    public Set<ServiceEcaArtifactInfo> getServiceEcaRulesCallingService() {
+        return aif.allServiceEcaInfosReferringToServiceName.get(this.modelService.name);
     }
     
     public List<FormWidgetArtifactInfo> getFormsCallingService() {
@@ -136,7 +178,7 @@
         List<ServiceEcaArtifactInfo> allServiceEcaList = FastList.newInstance();
         
         // all services that call this service
-        List<ServiceArtifactInfo> callingServiceList = this.getServicesCallingService();
+        Set<ServiceArtifactInfo> callingServiceList = this.getServicesCallingService();
         
         // set the prefix and add to the all list
         for (ServiceArtifactInfo callingService: callingServiceList) {
@@ -146,7 +188,7 @@
         }
         
         // all services this service calls
-        List<ServiceArtifactInfo> calledServiceList = this.getServicesCalledByService();
+        Set<ServiceArtifactInfo> calledServiceList = this.getServicesCalledByService();
         
         for (ServiceArtifactInfo calledService: calledServiceList) {
             calledService.setDisplayPrefix("Called:");
@@ -155,18 +197,18 @@
         }
         
         // all SECAs and triggering services that call this service as an action
-        List<ServiceEcaArtifactInfo> callingServiceEcaList = this.getServiceEcaRulesCallingService();
+        Set<ServiceEcaArtifactInfo> callingServiceEcaSet = this.getServiceEcaRulesCallingService();
         
-        for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaList) {
+        for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) {
             callingServiceEca.setDisplayPrefix("Triggering:");
             allDiagramEntitiesWithPrefixes.add(callingServiceEca.getDisplayPrefixedName());
             allServiceEcaList.add(callingServiceEca);
         }
 
         // all SECAs and corresponding services triggered by this service
-        List<ServiceEcaArtifactInfo> calledServiceEcaList = this.getServiceEcaRulesTriggeredByService();
+        Set<ServiceEcaArtifactInfo> calledServiceEcaSet = this.getServiceEcaRulesTriggeredByService();
         
-        for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaList) {
+        for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaSet) {
             calledServiceEca.setDisplayPrefix("Called:");
             allDiagramEntitiesWithPrefixes.add(calledServiceEca.getDisplayPrefixedName());
             allServiceEcaList.add(calledServiceEca);
@@ -200,7 +242,7 @@
         }
         
         // write SECA description files
-        for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaList) {
+        for (ServiceEcaArtifactInfo callingServiceEca: callingServiceEcaSet) {
             // add List<ServiceArtifactInfo> for services that trigger this eca rule
             List<ServiceArtifactInfo> ecaCallingServiceList = callingServiceEca.getServicesTriggeringServiceEca();
             for (ServiceArtifactInfo ecaCallingService: ecaCallingServiceList) {
@@ -211,7 +253,7 @@
             Map<String, Object> serviceEcaEoModelMap = callingServiceEca.createEoModelMap(ecaCallingServiceList, useMoreDetailedNames);
             UtilFormatOut.writePlistFile(serviceEcaEoModelMap, eomodeldFullPath, callingServiceEca.getDisplayPrefixedName() + ".plist");
         }
-        for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaList) {
+        for (ServiceEcaArtifactInfo calledServiceEca: calledServiceEcaSet) {
             // add List<ServiceArtifactInfo> for services this eca rule calls in action
             List<ServiceArtifactInfo> ecaCalledServiceList = calledServiceEca.getServicesCalledByServiceEcaActions();
             for (ServiceArtifactInfo ecaCalledService: ecaCalledServiceList) {
@@ -295,5 +337,13 @@
         }
         
         return topLevelMap;
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof ServiceArtifactInfo) {
+            return this.modelService.name.equals(((ServiceArtifactInfo) obj).modelService.name);
+        } else {
+            return false;
+        }
     }
 }

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=633325&r1=633324&r2=633325&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 Mon Mar  3 15:37:14 2008
@@ -28,18 +28,18 @@
 import org.ofbiz.service.eca.ServiceEcaAction;
 import org.ofbiz.service.eca.ServiceEcaCondition;
 import org.ofbiz.service.eca.ServiceEcaRule;
-import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory.ArtifactInfoContext;
+import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory;
 
 /**
  *
  */
 public class ServiceEcaArtifactInfo {
-    protected ArtifactInfoContext aic;
+    protected ArtifactInfoFactory aif;
     protected ServiceEcaRule serviceEcaRule;
     protected String displayPrefix = null;
     
-    public ServiceEcaArtifactInfo(ServiceEcaRule serviceEcaRule, ArtifactInfoContext aic) throws GenericServiceException {
-        this.aic = aic;
+    public ServiceEcaArtifactInfo(ServiceEcaRule serviceEcaRule, ArtifactInfoFactory aif) throws GenericServiceException {
+        this.aif = aif;
         this.serviceEcaRule = serviceEcaRule;
     }
     
@@ -131,5 +131,14 @@
         }
         
         return topLevelMap;
+    }
+    
+    public boolean equals(Object obj) {
+        if (obj instanceof ServiceEcaArtifactInfo) {
+            ServiceEcaArtifactInfo that = (ServiceEcaArtifactInfo) obj;
+            return this.serviceEcaRule.equals(that.serviceEcaRule);
+        } else {
+            return false;
+        }
     }
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=633325&r1=633324&r2=633325&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Mon Mar  3 15:37:14 2008
@@ -2070,6 +2070,10 @@
         this.formLocation = formLocation;
     }
 
+    public String getFormLocation() {
+        return this.formLocation;
+    }
+    
     /**
      * @param string
      */