You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2008/03/19 22:03:07 UTC

svn commit: r639017 - in /ofbiz/trunk/framework: webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java widget/src/org/ofbiz/widget/screen/ModelScreen.java widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java

Author: jacopoc
Date: Wed Mar 19 14:02:59 2008
New Revision: 639017

URL: http://svn.apache.org/viewvc?rev=639017&view=rev
Log:
Added artifact information about services used in screens.

Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java

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=639017&r1=639016&r2=639017&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 Wed Mar 19 14:02:59 2008
@@ -28,6 +28,7 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.service.ModelService;
 import org.ofbiz.widget.screen.ModelScreen;
 import org.xml.sax.SAXException;
 
@@ -43,6 +44,7 @@
     protected String screenLocation;
     
     Set<EntityArtifactInfo> entitiesUsedInThisScreen = FastSet.newInstance();
+    Set<ServiceArtifactInfo> servicesUsedInThisScreen = FastSet.newInstance();
     
     public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoFactory aif) throws GeneralException {
         super(aif);
@@ -64,6 +66,30 @@
 
     public void populateAll() throws GeneralException {
         this.populateUsedEntities();
+        this.populateUsedServices();
+    }
+    protected void populateUsedServices() throws GeneralException {
+        // populate servicesUsedInThisScreen and for each the reverse-associate cache in the aif
+        Set<String> allServiceNameSet = this.modelScreen.getAllServiceNamesUsed();
+        populateServicesFromNameSet(allServiceNameSet);
+    }
+    protected void populateServicesFromNameSet(Set<String> allServiceNameSet) throws GeneralException {
+        for (String serviceName: allServiceNameSet) {
+            if (serviceName.contains("${")) {
+                continue;
+            }
+            try {
+                ModelService modelService = aif.getModelService(serviceName);
+            } catch(GeneralException e) {
+                Debug.logWarning("Service [" + serviceName + "] reference in screen [" + this.screenName + "] in resource [" + this.screenLocation + "] does not exist!", module);
+                continue;
+            }
+            
+            // the forward reference
+            this.servicesUsedInThisScreen.add(aif.getServiceArtifactInfo(serviceName));
+            // the reverse reference
+            UtilMisc.addToSetInMap(this, aif.allScreenInfosReferringToServiceName, serviceName);
+        }
     }
     protected void populateUsedEntities() throws GeneralException {
         // populate entitiesUsedInThisScreen and for each the reverse-associate cache in the aif
@@ -117,13 +143,11 @@
     }
     
     public Set<EntityArtifactInfo> getEntitiesUsedInScreen() {
-        // TODO: implement this
-        return FastSet.newInstance();
+        return this.entitiesUsedInThisScreen;
     }
     
     public Set<ServiceArtifactInfo> getServicesUsedInScreen() {
-        // TODO: implement this
-        return FastSet.newInstance();
+        return this.servicesUsedInThisScreen;
     }
     
     public Set<FormWidgetArtifactInfo> getFormsIncludedInScreen() {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=639017&r1=639016&r2=639017&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Wed Mar 19 14:02:59 2008
@@ -76,6 +76,28 @@
         return sourceLocation;
     }
 
+    public Set<String> getAllServiceNamesUsed() {
+        Set<String> allServiceNamesUsed = FastSet.newInstance();
+        findServiceNamesUsedInSection(this.section, allServiceNamesUsed);
+        return allServiceNamesUsed;
+    }
+    protected static void findServiceNamesUsedInSection(ModelScreenWidget.Section currentSection, Set<String> allServiceNamesUsed) {
+        currentSection.findServiceNamesUsed(allServiceNamesUsed);
+        if (currentSection.subWidgets != null) {
+            for (ModelScreenWidget widget: currentSection.subWidgets) {
+                if (widget instanceof ModelScreenWidget.Section) {
+                    findServiceNamesUsedInSection((ModelScreenWidget.Section)widget, allServiceNamesUsed);
+                }
+            }
+        }
+        if (currentSection.failWidgets != null) {
+            for (ModelScreenWidget widget: currentSection.failWidgets) {
+                if (widget instanceof ModelScreenWidget.Section) {
+                    findServiceNamesUsedInSection((ModelScreenWidget.Section)widget, allServiceNamesUsed);
+                }
+            }
+        }
+    }
     public Set<String> getAllEntityNamesUsed() {
         Set<String> allEntityNamesUsed = FastSet.newInstance();
         findEntityNamesUsedInSection(this.section, allEntityNamesUsed);

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=639017&r1=639016&r2=639017&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Wed Mar 19 14:02:59 2008
@@ -217,6 +217,16 @@
                 }
             }
         }
+        public void findServiceNamesUsed(Set<String> allServiceNames) {
+            if (this.actions != null) {
+                for (ModelScreenAction screenOperation: this.actions) {
+                    if (screenOperation instanceof ModelScreenAction.Service) {
+                        String serviceName = ((ModelScreenAction.Service) screenOperation).serviceNameExdr.toString();
+                        if (UtilValidate.isNotEmpty(serviceName)) allServiceNames.add(serviceName);
+                    }
+                }
+            }
+        }
 
         public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
             // check the condition, if there is one