svn commit: r638707 - in /ofbiz/trunk/framework/webtools: src/org/ofbiz/webtools/artifactinfo/ webapp/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: r638707 - in /ofbiz/trunk/framework/webtools: src/org/ofbiz/webtools/artifactinfo/ webapp/webtools/artifactinfo/

jonesde
Author: jonesde
Date: Tue Mar 18 21:49:49 2008
New Revision: 638707

URL: http://svn.apache.org/viewvc?rev=638707&view=rev
Log:
A few cleanups, fixed NPE and circular reference problems; filled in a little bit of info gathering; had added messages like Jacopo's,info gathering; merged my warnings with Jacopos

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/ScreenWidgetArtifactInfo.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ServiceArtifactInfo.java
    ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl

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=638707&r1=638706&r2=638707&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 Tue Mar 18 21:49:49 2008
@@ -19,10 +19,11 @@
 package org.ofbiz.webtools.artifactinfo;
 
 
+
 /**
  *
  */
-public abstract class ArtifactInfoBase {
+public abstract class ArtifactInfoBase implements Comparable<ArtifactInfoBase> {
     protected ArtifactInfoFactory aif;
     
     public ArtifactInfoBase(ArtifactInfoFactory aif) {
@@ -37,8 +38,17 @@
         }
     }
     
+    public int compareTo(ArtifactInfoBase aib) {
+        if (aib == null) return -1;
+        return this.getDisplayName().compareTo(aib.getDisplayName());
+    }
+    
     abstract public String getDisplayName();
     abstract public String getDisplayType();
     abstract public String getType();
     abstract public String getUniqueId();
+    
+    //public static List<ArtifactInfoBase> sortArtifactInfoSetByDisplayName(Set<ArtifactInfoBase> artifactInfoSet) {
+        //SortedMap<String, ArtifactInfoBase> sortedMap = FastMap.newInstance();
+    //}
 }

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=638707&r1=638706&r2=638707&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 18 21:49:49 2008
@@ -96,6 +96,7 @@
     public Map<String, Set<ServiceArtifactInfo>> allServiceInfosReferringToServiceName = FastMap.newInstance();
     public Map<String, Set<FormWidgetArtifactInfo>> allFormInfosReferringToServiceName = FastMap.newInstance();
     public Map<String, Set<ScreenWidgetArtifactInfo>> allScreenInfosReferringToServiceName = FastMap.newInstance();
+    public Map<String, Set<ControllerRequestArtifactInfo>> allRequestInfosReferringToServiceName = FastMap.newInstance();
     
     public Map<String, Set<ServiceArtifactInfo>> allServiceInfosReferringToEntityName = FastMap.newInstance();
     public Map<String, Set<FormWidgetArtifactInfo>> allFormInfosReferringToEntityName = FastMap.newInstance();
@@ -103,8 +104,11 @@
 
     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<ScreenWidgetArtifactInfo>> allScreenInfosReferringToScreen = 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();
     
     public static ArtifactInfoFactory getArtifactInfoFactory(String delegatorName) throws GeneralException {
@@ -313,6 +317,7 @@
         if (curInfo == null) {
             curInfo = new ControllerRequestArtifactInfo(controllerXmlUrl, requestUri, this);
             this.allControllerRequestInfos.put(curInfo.getUniqueId(), curInfo);
+            curInfo.populateAll();
         }
         return curInfo;
     }
@@ -366,34 +371,34 @@
         }
         
         for (Map.Entry<String, EntityArtifactInfo> curEntry: allEntityInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }
         for (Map.Entry<String, ServiceArtifactInfo> curEntry: allServiceInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }
         
         for (Map.Entry<String, FormWidgetArtifactInfo> curEntry: allFormInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }
         for (Map.Entry<String, ScreenWidgetArtifactInfo> curEntry: allScreenInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }
         
         for (Map.Entry<String, ControllerRequestArtifactInfo> curEntry: allControllerRequestInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }
         for (Map.Entry<String, ControllerViewArtifactInfo> curEntry: allControllerViewInfos.entrySet()) {
-            if (curEntry.getKey().contains(artifactNamePartial)) {
+            if (curEntry.getKey().toUpperCase().contains(artifactNamePartial.toUpperCase())) {
                 aiBaseSet.add(curEntry.getValue());
             }
         }

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=638707&r1=638706&r2=638707&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 Tue Mar 18 21:49:49 2008
@@ -34,7 +34,6 @@
  *
  */
 public class ControllerRequestArtifactInfo extends ArtifactInfoBase {
-    
     public static final String module = ControllerRequestArtifactInfo.class.getName();
 
     protected URL controllerXmlUrl;
@@ -57,26 +56,55 @@
             throw new GeneralException("Controller request with name [" + requestUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
         }
 
+        if (this.requestInfoMap == null) {
+            throw new GeneralException("Could not find Controller Request [" + requestUri + "] at URL [" + controllerXmlUrl.toExternalForm() + "]");
+        }
+    }
+    
+    /** note this is mean to be called after the object is created and added to the ArtifactInfoFactory.allControllerRequestInfos in ArtifactInfoFactory.getControllerRequestArtifactInfo */
+    public void populateAll() throws GeneralException {
         // populate serviceCalledByRequestEvent, requestsThatAreResponsesToThisRequest, viewsThatAreResponsesToThisRequest and related reverse maps
         
         if ("service".equals(this.requestInfoMap.get(ConfigXMLReader.EVENT_TYPE))) {
             String serviceName = (String) this.requestInfoMap.get(ConfigXMLReader.EVENT_METHOD);
-            this.serviceCalledByRequestEvent = this.aif.getServiceArtifactInfo(serviceName);
+            try {
+                this.serviceCalledByRequestEvent = this.aif.getServiceArtifactInfo(serviceName);
+                if (this.serviceCalledByRequestEvent != null) {
+                    // add the reverse association
+                    UtilMisc.addToSetInMap(this, aif.allRequestInfosReferringToServiceName, this.serviceCalledByRequestEvent.getUniqueId());
+                }
+            } catch (GeneralException e) {
+                Debug.logWarning(e.toString(), module);
+            }
         }
         
         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());
+                if (viewUri.startsWith("/")) {
+                    viewUri = viewUri.substring(1);
+                }
+                try {
+                    ControllerViewArtifactInfo artInfo = this.aif.getControllerViewArtifactInfo(controllerXmlUrl, viewUri);
+                    this.viewsThatAreResponsesToThisRequest.add(artInfo);
+                    // add the reverse association
+                    UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToView, artInfo.getUniqueId());
+                } catch (GeneralException e) {
+                    Debug.logWarning(e.toString(), module);
+                }
             } 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());
+                if (otherRequestUri.startsWith("/")) {
+                    otherRequestUri = otherRequestUri.substring(1);
+                }
+                try {
+                    ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);
+                    this.requestsThatAreResponsesToThisRequest.add(artInfo);
+                    UtilMisc.addToSetInMap(this, this.aif.allRequestInfosReferringToRequest, artInfo.getUniqueId());
+                } catch (GeneralException e) {
+                    Debug.logWarning(e.toString(), module);
+                }
             } else if (responseValue.startsWith("request-redirect:")) {
                 String otherRequestUri = responseValue.substring(17);
                 ControllerRequestArtifactInfo artInfo = this.aif.getControllerRequestArtifactInfo(controllerXmlUrl, otherRequestUri);

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=638707&r1=638706&r2=638707&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 Tue Mar 18 21:49:49 2008
@@ -33,7 +33,6 @@
  *
  */
 public class ControllerViewArtifactInfo extends ArtifactInfoBase {
-
     public static final String module = ControllerViewArtifactInfo.class.getName();
 
     protected URL controllerXmlUrl;
@@ -49,6 +48,10 @@
         this.viewUri = viewUri;
         
         this.viewInfoMap = aif.getControllerViewInfoMap(controllerXmlUrl, viewUri);
+        
+        if (this.viewInfoMap == null) {
+            throw new GeneralException("Could not find Controller View [" + viewUri + "] at URL [" + controllerXmlUrl.toExternalForm() + "]");
+        }
 
         if (this.viewInfoMap == null) {
             throw new GeneralException("Controller view with name [" + viewUri + "] is not defined in controller file [" + controllerXmlUrl + "].");
@@ -58,12 +61,14 @@
             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
-                if (this.screenCalledByThisView != null) {
-                    UtilMisc.addToSetInMap(this, aif.allViewInfosReferringToScreen, this.screenCalledByThisView.getUniqueId());
-                } else {
-                    Debug.logWarning("The controller view [" + this.viewUri + "] in resource [" + controllerXmlUrl + "] is pointing to a screen [" + fullScreenName.substring(poundIndex+1) + "] in resource [" + fullScreenName.substring(0, poundIndex) + "] that doesn't exists", module);
+                try {
+                    this.screenCalledByThisView = this.aif.getScreenWidgetArtifactInfo(fullScreenName.substring(poundIndex+1), fullScreenName.substring(0, poundIndex));
+                    if (this.screenCalledByThisView != null) {
+                        // add the reverse association
+                        UtilMisc.addToSetInMap(this, aif.allViewInfosReferringToScreen, this.screenCalledByThisView.getUniqueId());
+                    }
+                } catch (GeneralException e) {
+                    Debug.logWarning(e.toString(), module);
                 }
             }
         }

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=638707&r1=638706&r2=638707&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 Tue Mar 18 21:49:49 2008
@@ -19,9 +19,12 @@
 package org.ofbiz.webtools.artifactinfo;
 
 import java.io.IOException;
+import java.util.Set;
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import javolution.util.FastSet;
+
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.widget.screen.ModelScreen;
 import org.xml.sax.SAXException;
@@ -42,14 +45,14 @@
         this.screenLocation = screenLocation;
         try {
             this.modelScreen = aif.getModelScreen(screenName, screenLocation);
+        } catch (IllegalArgumentException e) {
+            throw new GeneralException(e);
         } catch (ParserConfigurationException e) {
             throw new GeneralException(e);
         } catch (SAXException e) {
             throw new GeneralException(e);
         } catch (IOException e) {
             throw new GeneralException(e);
-        } catch (IllegalArgumentException e) {
-            throw new GeneralException(e);
         }
         
     }
@@ -77,5 +80,33 @@
         } else {
             return false;
         }
+    }
+    
+    public Set<ControllerViewArtifactInfo> getViewsReferringToScreen() {
+        return this.aif.allViewInfosReferringToScreen.get(this.getUniqueId());
+    }
+    
+    public Set<EntityArtifactInfo> getEntitiesUsedInScreen() {
+        // TODO: implement this
+        return FastSet.newInstance();
+    }
+    
+    public Set<ServiceArtifactInfo> getServicesUsedInScreen() {
+        // TODO: implement this
+        return FastSet.newInstance();
+    }
+    
+    public Set<FormWidgetArtifactInfo> getFormsIncludedInScreen() {
+        // TODO: implement this
+        return FastSet.newInstance();
+    }
+    
+    public Set<ScreenWidgetArtifactInfo> getScreensIncludedInScreen() {
+        // TODO: implement this
+        return FastSet.newInstance();
+    }
+    
+    public Set<ScreenWidgetArtifactInfo> getScreensIncludingThisScreen() {
+        return this.aif.allScreenInfosReferringToScreen.get(this.getUniqueId());
     }
 }

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=638707&r1=638706&r2=638707&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 18 21:49:49 2008
@@ -295,10 +295,8 @@
         return screenSet;
     }
     
-    public Set getRequestsWithEventCallingService() {
-        Set requestSet = FastSet.newInstance();
-        // TODO: implement this
-        return requestSet;
+    public Set<ControllerRequestArtifactInfo> getRequestsWithEventCallingService() {
+        return this.aif.allRequestInfosReferringToServiceName.get(this.modelService.name);
     }
     
     public void writeServiceCallGraphEoModel(String eomodeldFullPath) throws GeneralException, FileNotFoundException, UnsupportedEncodingException {

Modified: ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl?rev=638707&r1=638706&r2=638707&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/artifactinfo/ArtifactInfo.ftl Tue Mar 18 21:49:49 2008
@@ -82,17 +82,25 @@
     <#-- add form here to specify artifact info name. -->
     <div class="screenlet-body">
       <form name="ArtifactInfoByName" method="post" action="<@ofbizUrl>ArtifactInfo</@ofbizUrl>" class="basic-form">
-        Artifact Name: <input type="text" name="name" value="${parameters.name?if_exists}" size="60"/>
-        <select name="type">
-            <option value="">Any Type</option>
+        Search Names/Locations: <input type="text" name="name" value="${parameters.name?if_exists}" size="40"/>
+        <input type="submit" name="submitButton" value="Find"/>
+      </form>
+    </div>
+    <div class="screenlet-body">
+      <form name="ArtifactInfoByNameAndType" method="post" action="<@ofbizUrl>ArtifactInfo</@ofbizUrl>" class="basic-form">
+        <div>Name: <input type="text" name="name" value="${parameters.name?if_exists}" size="40"/></div>
+        <div>Location: <input type="text" name="location" value="${parameters.location?if_exists}" size="60"/></div>
+        <div>
+          <select name="type">
             <option>entity</option>
             <option>service</option>
             <option>form</option>
             <option>screen</option>
             <option>request</option>
             <option>view</option>
-        </select>
-        <input type="submit" name="submitButton" value="Lookup"/>
+          </select>
+          <input type="submit" name="submitButton" value="Lookup"/>
+        </div>
       </form>
     </div>
     
@@ -148,5 +156,5 @@
 </#macro>
 
 <#macro displayArtifactInfoLink artifactInfo>
-<a href="<@ofbizUrl>ArtifactInfo?type=${artifactInfo.getType()}&amp;uniqueId=${artifactInfo.getUniqueId()?html}</@ofbizUrl>">${artifactInfo.getDisplayName()}</a>
+<a href="<@ofbizUrl>ArtifactInfo?type=${artifactInfo.getType()}&amp;uniqueId=${artifactInfo.getUniqueId()?url('ISO-8859-1')}</@ofbizUrl>">${artifactInfo.getDisplayName()}</a>
 </#macro>