svn commit: r638243 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/

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

svn commit: r638243 - /ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/

jonesde
Author: jonesde
Date: Mon Mar 17 23:56:17 2008
New Revision: 638243

URL: http://svn.apache.org/viewvc?rev=638243&view=rev
Log:
Finished initial work on the controller request and view artifact info classes; a few other cleanups and enhancements in others too

Modified:
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java?rev=638243&r1=638242&r2=638243&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoBase.java Mon Mar 17 23:56:17 2008
@@ -18,14 +18,6 @@
  */
 package org.ofbiz.webtools.artifactinfo;
 
-import java.util.List;
-
-import javolution.util.FastList;
-
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.model.ModelEntity;
-import org.ofbiz.entityext.eca.EntityEcaRule;
-import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory;
 
 /**
  *

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=638243&r1=638242&r2=638243&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 17 23:56:17 2008
@@ -83,6 +83,7 @@
 
     public Map<ServiceEcaRule, Set<ServiceArtifactInfo>> allServiceInfosReferringToServiceEcaRule = FastMap.newInstance();
     
+    public Map<String, Set<ControllerViewArtifactInfo>> allViewInfosReferringToScreen = FastMap.newInstance();
     public Map<String, Set<ControllerRequestArtifactInfo>> allRequestInfosReferringToView = FastMap.newInstance();
     public Map<String, Set<ControllerRequestArtifactInfo>> allRequestInfosReferringToRequest = FastMap.newInstance();
     
@@ -163,7 +164,7 @@
         return ScreenFactory.getScreenFromLocation(screenLocation, screenName);
     }
     
-    public Map<String, String> getControllerRequestInfoMap(URL controllerXmlUrl, String requestUri) {
+    public Map<String, Object> getControllerRequestInfoMap(URL controllerXmlUrl, String requestUri) {
         return ConfigXMLReader.getControllerConfig(controllerXmlUrl).requestMap.get(requestUri);
     }
 
@@ -200,7 +201,7 @@
         return curInfo;
     }
     
-    public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formName, String formLocation) throws GeneralException, IOException, SAXException, ParserConfigurationException {
+    public FormWidgetArtifactInfo getFormWidgetArtifactInfo(String formName, String formLocation) throws GeneralException {
         FormWidgetArtifactInfo curInfo = this.allFormInfos.get(formLocation + "#" + formName);
         if (curInfo == null) {
             curInfo = new FormWidgetArtifactInfo(formName, formLocation, this);
@@ -209,7 +210,7 @@
         return curInfo;
     }
     
-    public ScreenWidgetArtifactInfo getScreenWidgetArtifactInfo(String screenName, String screenLocation) throws GeneralException, IOException, SAXException, ParserConfigurationException {
+    public ScreenWidgetArtifactInfo getScreenWidgetArtifactInfo(String screenName, String screenLocation) throws GeneralException {
         ScreenWidgetArtifactInfo curInfo = this.allScreenInfos.get(screenLocation + "#" + screenName);
         if (curInfo == null) {
             curInfo = new ScreenWidgetArtifactInfo(screenName, screenLocation, this);
@@ -218,7 +219,7 @@
         return curInfo;
     }
     
-    public ControllerRequestArtifactInfo getControllerRequestArtifactInfo(URL controllerXmlUrl, String requestUri) {
+    public ControllerRequestArtifactInfo getControllerRequestArtifactInfo(URL controllerXmlUrl, String requestUri) throws GeneralException {
         ControllerRequestArtifactInfo curInfo = this.allControllerRequestInfos.get(controllerXmlUrl.toExternalForm() + "#" + requestUri);
         if (curInfo == null) {
             curInfo = new ControllerRequestArtifactInfo(controllerXmlUrl, requestUri, this);
@@ -227,7 +228,7 @@
         return curInfo;
     }
     
-    public ControllerViewArtifactInfo getControllerViewArtifactInfo(URL controllerXmlUrl, String viewUri) {
+    public ControllerViewArtifactInfo getControllerViewArtifactInfo(URL controllerXmlUrl, String viewUri) throws GeneralException {
         ControllerViewArtifactInfo curInfo = this.allControllerViewInfos.get(controllerXmlUrl.toExternalForm() + "#" + viewUri);
         if (curInfo == null) {
             curInfo = new ControllerViewArtifactInfo(controllerXmlUrl, viewUri, this);

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java?rev=638243&r1=638242&r2=638243&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerRequestArtifactInfo.java Mon Mar 17 23:56:17 2008
@@ -24,7 +24,10 @@
 
 import javolution.util.FastSet;
 
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilObject;
+import org.ofbiz.webapp.control.ConfigXMLReader;
 
 /**
  *
@@ -34,22 +37,51 @@
     protected URL controllerXmlUrl;
     protected String requestUri;
     
-    protected Map<String, String> requestInfoMap;
+    protected Map<String, Object> requestInfoMap;
     
-    protected Set<ServiceArtifactInfo> servicesCalledByRequest = FastSet.newInstance();
+    protected ServiceArtifactInfo serviceCalledByRequestEvent = null;
     protected Set<ControllerRequestArtifactInfo> requestsThatAreResponsesToThisRequest = FastSet.newInstance();
     protected Set<ControllerViewArtifactInfo> viewsThatAreResponsesToThisRequest = FastSet.newInstance();
     
-    public ControllerRequestArtifactInfo(URL controllerXmlUrl, String requestUri, ArtifactInfoFactory aif) {
+    public ControllerRequestArtifactInfo(URL controllerXmlUrl, String requestUri, ArtifactInfoFactory aif) throws GeneralException {
         super(aif);
         this.controllerXmlUrl = controllerXmlUrl;
         this.requestUri = requestUri;
         
         this.requestInfoMap = aif.getControllerRequestInfoMap(controllerXmlUrl, requestUri);
         
-        // TODO populate servicesCalledByRequest, requestsThatAreResponsesToThisRequest, viewsThatAreResponsesToThisRequest
+        // populate serviceCalledByRequestEvent, requestsThatAreResponsesToThisRequest, viewsThatAreResponsesToThisRequest and related reverse maps
         
-        // TODO populate reverse Set for getRequestsThatThisRequestIsResponsTo, View.getRequestsThatThisViewIsResponseTo
+        if ("service".equals(this.requestInfoMap.get(ConfigXMLReader.EVENT_TYPE))) {
+            String serviceName = (String) this.requestInfoMap.get(ConfigXMLReader.EVENT_METHOD);
+            this.serviceCalledByRequestEvent = this.aif.getServiceArtifactInfo(serviceName);
+        }
+        
+        Map<String, String> responseMap = (Map<String, String>) this.requestInfoMap.get(ConfigXMLReader.RESPONSE_MAP);
+        for (String responseValue: responseMap.values()) {
+            if (responseValue.startsWith("view:")) {
+                String viewUri = responseValue.substring(5);
+                ControllerViewArtifactInfo artInfo = this.aif.getControllerViewArtifactInfo(controllerXmlUrl, viewUri);
+                this.viewsThatAreResponsesToThisRequest.add(artInfo);
+                // add the reverse association
+                UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToView, artInfo.getUniqueId());
+            } else if (responseValue.startsWith("request:")) {
+                String otherRequestUri = responseValue.substring(8);
+                ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
+                this.requestsThatAreResponsesToThisRequest.add(artInfo);
+                UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
+            } else if (responseValue.startsWith("request-redirect:")) {
+                String otherRequestUri = responseValue.substring(17);
+                ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
+                this.requestsThatAreResponsesToThisRequest.add(artInfo);
+                UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
+            } else if (responseValue.startsWith("request-redirect-noparam:")) {
+                String otherRequestUri = responseValue.substring(25);
+                ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
+                this.requestsThatAreResponsesToThisRequest.add(artInfo);
+                UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
+            }
+        }
     }
     
     public URL getControllerXmlUrl() {
@@ -67,16 +99,15 @@
     public boolean equals(Object obj) {
         if (obj instanceof ControllerRequestArtifactInfo) {
             ControllerRequestArtifactInfo that = (ControllerRequestArtifactInfo) obj;
-            return UtilObject.equalsHelper(this.controllerXmlUrl, that.controllerXmlUrl) &&
-                UtilObject.equalsHelper(this.requestUri, that.requestUri);
+            return UtilObject.equalsHelper(this.controllerXmlUrl, that.controllerXmlUrl) && UtilObject.equalsHelper(this.requestUri, that.requestUri);
         } else {
             return false;
         }
     }
     
     /** Get the Services that are called by this Request */
-    public Set<ServiceArtifactInfo> getServicesCalledByRequest() {
-        return servicesCalledByRequest;
+    public ServiceArtifactInfo getServiceCalledByRequestEvent() {
+        return serviceCalledByRequestEvent;
     }
     
     public Set<ControllerRequestArtifactInfo> getRequestsThatAreResponsesToThisRequest() {

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java?rev=638243&r1=638242&r2=638243&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ControllerViewArtifactInfo.java Mon Mar 17 23:56:17 2008
@@ -22,9 +22,11 @@
 import java.util.Map;
 import java.util.Set;
 
-import javolution.util.FastSet;
-
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilObject;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.webapp.control.ConfigXMLReader;
 
 /**
  *
@@ -36,16 +38,25 @@
     
     protected Map<String, String> viewInfoMap;
     
-    protected Set<ScreenWidgetArtifactInfo> screensCalledByThisView = FastSet.newInstance();
+    protected ScreenWidgetArtifactInfo screenCalledByThisView = null;
     
-    public ControllerViewArtifactInfo(URL controllerXmlUrl, String viewUri, ArtifactInfoFactory aif) {
+    public ControllerViewArtifactInfo(URL controllerXmlUrl, String viewUri, ArtifactInfoFactory aif) throws GeneralException {
         super(aif);
         this.controllerXmlUrl = controllerXmlUrl;
         this.viewUri = viewUri;
         
         this.viewInfoMap = aif.getControllerViewInfoMap(controllerXmlUrl, viewUri);
         
-        // TODO populate screensCalledByThisView
+        // populate screenCalledByThisView and reverse in aif.allViewInfosReferringToScreen
+        if ("screen".equals(this.viewInfoMap.get(ConfigXMLReader.VIEW_TYPE))) {
+            String fullScreenName = this.viewInfoMap.get(ConfigXMLReader.VIEW_PAGE);
+            if (UtilValidate.isNotEmpty(fullScreenName)) {
+                int poundIndex = fullScreenName.indexOf('#');
+                this.screenCalledByThisView = this.aif.getScreenWidgetArtifactInfo(fullScreenName.substring(poundIndex+1), fullScreenName.substring(0, poundIndex));
+                // add the reverse association
+                UtilMisc.addToSetInMap(this, aif.allViewInfosReferringToScreen, this.screenCalledByThisView.getUniqueId());
+            }
+        }
     }
     
     public URL getControllerXmlUrl() {
@@ -74,7 +85,7 @@
         return this.aif.allRequestInfosReferringToView.get(this.getUniqueId());
     }
     
-    public Set<ScreenWidgetArtifactInfo> getScreensCalledByThisView() {
-        return screensCalledByThisView;
+    public ScreenWidgetArtifactInfo getScreenCalledByThisView() {
+        return screenCalledByThisView;
     }
 }

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=638243&r1=638242&r2=638243&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 17 23:56:17 2008
@@ -22,7 +22,7 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory;
+import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.widget.form.ModelForm;
 import org.xml.sax.SAXException;
 
@@ -36,11 +36,19 @@
     protected String formName;
     protected String formLocation;
     
-    public FormWidgetArtifactInfo(String formName, String formLocation, ArtifactInfoFactory aif) throws ParserConfigurationException, SAXException, IOException {
+    public FormWidgetArtifactInfo(String formName, String formLocation, ArtifactInfoFactory aif) throws GeneralException {
         super(aif);
         this.formName = formName;
         this.formLocation = formLocation;
-        this.modelForm = aif.getModelForm(formName, formLocation);
+        try {
+            this.modelForm = aif.getModelForm(formName, formLocation);
+        } catch (ParserConfigurationException e) {
+            throw new GeneralException(e);
+        } catch (SAXException e) {
+            throw new GeneralException(e);
+        } catch (IOException e) {
+            throw new GeneralException(e);
+        }
     }
     
     public String getUniqueId() {

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=638243&r1=638242&r2=638243&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 17 23:56:17 2008
@@ -22,7 +22,7 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.ofbiz.webtools.artifactinfo.ArtifactInfoFactory;
+import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.widget.screen.ModelScreen;
 import org.xml.sax.SAXException;
 
@@ -36,11 +36,20 @@
     protected String screenName;
     protected String screenLocation;
     
-    public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoFactory aif) throws ParserConfigurationException, SAXException, IOException {
+    public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoFactory aif) throws GeneralException {
         super(aif);
         this.screenName = screenName;
         this.screenLocation = screenLocation;
-        this.modelScreen = aif.getModelScreen(screenName, screenLocation);
+        try {
+            this.modelScreen = aif.getModelScreen(screenName, screenLocation);
+        } catch (ParserConfigurationException e) {
+            throw new GeneralException(e);
+        } catch (SAXException e) {
+            throw new GeneralException(e);
+        } catch (IOException e) {
+            throw new GeneralException(e);
+        }
+        
     }
     
     public String getUniqueId() {