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 21:10:49 UTC
svn commit: r638993 - in /ofbiz/trunk/framework:
webtools/src/org/ofbiz/webtools/artifactinfo/
widget/src/org/ofbiz/widget/screen/
Author: jacopoc
Date: Wed Mar 19 13:10:48 2008
New Revision: 638993
URL: http://svn.apache.org/viewvc?rev=638993&view=rev
Log:
Added artifact information about entities used in screens.
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
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/ArtifactInfoFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=638993&r1=638992&r2=638993&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 Wed Mar 19 13:10:48 2008
@@ -303,6 +303,7 @@
if (curInfo == null) {
try {
curInfo = new ScreenWidgetArtifactInfo(screenName, screenLocation, this);
+ curInfo.populateAll();
} catch(GeneralException e) {
Debug.logWarning("Error loading screen [" + screenName + "] from resource [" + screenLocation + "]: " + e.toString(), module);
return null;
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=638993&r1=638992&r2=638993&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 13:10:48 2008
@@ -25,6 +25,7 @@
import javolution.util.FastSet;
+import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.widget.screen.ModelScreen;
import org.xml.sax.SAXException;
@@ -33,12 +34,15 @@
*
*/
public class ScreenWidgetArtifactInfo extends ArtifactInfoBase {
+ public static final String module = ScreenWidgetArtifactInfo.class.getName();
protected ModelScreen modelScreen;
protected String screenName;
protected String screenLocation;
+ Set<EntityArtifactInfo> entitiesUsedInThisScreen = FastSet.newInstance();
+
public ScreenWidgetArtifactInfo(String screenName, String screenLocation, ArtifactInfoFactory aif) throws GeneralException {
super(aif);
this.screenName = screenName;
@@ -56,7 +60,34 @@
}
}
-
+
+ public void populateAll() throws GeneralException {
+ this.populateUsedEntities();
+ }
+ protected void populateUsedEntities() throws GeneralException {
+ // populate entitiesUsedInThisScreen and for each the reverse-associate cache in the aif
+ Set<String> allEntityNameSet = this.modelScreen.getAllEntityNamesUsed();
+ populateEntitiesFromNameSet(allEntityNameSet);
+ }
+ protected void populateEntitiesFromNameSet(Set<String> allEntityNameSet) throws GeneralException {
+ for (String entityName: allEntityNameSet) {
+ if (entityName.contains("${")) {
+ continue;
+ }
+ if (!aif.getEntityModelReader().getEntityNames().contains(entityName)) {
+ Debug.logWarning("Entity [" + entityName + "] reference in screen [" + this.screenName + "] in resource [" + this.screenLocation + "] does not exist!", module);
+ continue;
+ }
+
+ // the forward reference
+ this.entitiesUsedInThisScreen.add(aif.getEntityArtifactInfo(entityName));
+ /* TODO
+ // the reverse reference
+ UtilMisc.addToSetInMap(this, aif.allServiceInfosReferringToEntityName, entityName);
+ */
+ }
+ }
+
public String getDisplayName() {
return this.getUniqueId();
}
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=638993&r1=638992&r2=638993&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 13:10:48 2008
@@ -21,6 +21,7 @@
import java.io.Serializable;
import java.io.Writer;
import java.util.Map;
+import java.util.Set;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
@@ -34,6 +35,8 @@
import org.ofbiz.widget.ModelWidget;
import org.w3c.dom.Element;
+import javolution.util.FastSet;
+
/**
* Widget Library - Screen model class
*/
@@ -71,6 +74,29 @@
public String getSourceLocation() {
return sourceLocation;
+ }
+
+ public Set<String> getAllEntityNamesUsed() {
+ Set<String> allEntityNamesUsed = FastSet.newInstance();
+ findEntityNamesUsedInSection(this.section, allEntityNamesUsed);
+ return allEntityNamesUsed;
+ }
+ protected static void findEntityNamesUsedInSection(ModelScreenWidget.Section currentSection, Set<String> allEntityNamesUsed) {
+ currentSection.findEntityNamesUsed(allEntityNamesUsed);
+ if (currentSection.subWidgets != null) {
+ for (ModelScreenWidget widget: currentSection.subWidgets) {
+ if (widget instanceof ModelScreenWidget.Section) {
+ findEntityNamesUsedInSection((ModelScreenWidget.Section)widget, allEntityNamesUsed);
+ }
+ }
+ }
+ if (currentSection.failWidgets != null) {
+ for (ModelScreenWidget widget: currentSection.failWidgets) {
+ if (widget instanceof ModelScreenWidget.Section) {
+ findEntityNamesUsedInSection((ModelScreenWidget.Section)widget, 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=638993&r1=638992&r2=638993&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 13:10:48 2008
@@ -27,6 +27,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -167,9 +168,9 @@
public static class Section extends ModelScreenWidget {
protected ModelScreenCondition condition;
- protected List actions;
- protected List subWidgets;
- protected List failWidgets;
+ protected List<ModelScreenAction> actions;
+ protected List<ModelScreenWidget> subWidgets;
+ protected List<ModelScreenWidget> failWidgets;
public boolean isMainSection = false;
public Section(ModelScreen modelScreen, Element sectionElement) {
@@ -200,6 +201,23 @@
}
}
+ public void findEntityNamesUsed(Set<String> allEntityNames) {
+ if (this.actions != null) {
+ for (ModelScreenAction screenOperation: this.actions) {
+ if (screenOperation instanceof ModelScreenAction.EntityOne) {
+ String entName = ((ModelScreenAction.EntityOne) screenOperation).finder.getEntityName();
+ if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
+ } else if (screenOperation instanceof ModelScreenAction.EntityAnd) {
+ String entName = ((ModelScreenAction.EntityAnd) screenOperation).finder.getEntityName();
+ if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
+ } else if (screenOperation instanceof ModelScreenAction.EntityCondition) {
+ String entName = ((ModelScreenAction.EntityCondition) screenOperation).finder.getEntityName();
+ if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
+ }
+ }
+ }
+ }
+
public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
// check the condition, if there is one
boolean condTrue = true;