You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2014/11/01 21:15:27 UTC
svn commit: r1636031 - in /ofbiz/trunk/framework:
webtools/src/org/ofbiz/webtools/artifactinfo/
widget/src/org/ofbiz/widget/artifact/ widget/src/org/ofbiz/widget/screen/
Author: adrianc
Date: Sat Nov 1 20:15:27 2014
New Revision: 1636031
URL: http://svn.apache.org/r1636031
Log:
Move screen widget artifact info code to a separate class. This eliminates a lot of duplicate code and it should speed up artifact info gathering.
Added:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoContext.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ScreenWidgetArtifactInfo.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.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=1636031&r1=1636030&r2=1636031&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 Sat Nov 1 20:15:27 2014
@@ -33,6 +33,8 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilURL;
+import org.ofbiz.widget.artifact.ArtifactInfoContext;
+import org.ofbiz.widget.artifact.ArtifactInfoGatherer;
import org.ofbiz.widget.screen.ModelScreen;
import org.xml.sax.SAXException;
@@ -71,16 +73,15 @@ public class ScreenWidgetArtifactInfo ex
}
public void populateAll() throws GeneralException {
- this.populateUsedEntities();
- this.populateUsedServices();
- this.populateIncludedForms();
- this.populateLinkedRequests();
- }
- 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);
+ ArtifactInfoContext infoContext = new ArtifactInfoContext();
+ ArtifactInfoGatherer infoGatherer = new ArtifactInfoGatherer(infoContext);
+ infoGatherer.visit(this.modelScreen);
+ populateServicesFromNameSet(infoContext.getServiceNames());
+ populateEntitiesFromNameSet(infoContext.getEntityNames());
+ populateFormsFromNameSet(infoContext.getFormLocations());
+ populateLinkedRequests(infoContext.getRequestLocations());
}
+
protected void populateServicesFromNameSet(Set<String> allServiceNameSet) throws GeneralException {
for (String serviceName: allServiceNameSet) {
if (serviceName.contains("${")) {
@@ -99,11 +100,7 @@ public class ScreenWidgetArtifactInfo ex
UtilMisc.addToSortedSetInMap(this, aif.allScreenInfosReferringToServiceName, serviceName);
}
}
- 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("${")) {
@@ -122,11 +119,7 @@ public class ScreenWidgetArtifactInfo ex
UtilMisc.addToSortedSetInMap(this, aif.allScreenInfosReferringToEntityName, entityName);
}
}
- protected void populateIncludedForms() throws GeneralException {
- // populate servicesUsedInThisScreen and for each the reverse-associate cache in the aif
- Set<String> allFormNameSet = this.modelScreen.getAllFormNamesIncluded();
- populateFormsFromNameSet(allFormNameSet);
- }
+
protected void populateFormsFromNameSet(Set<String> allFormNameSet) throws GeneralException {
for (String formName: allFormNameSet) {
if (formName.contains("${")) {
@@ -147,8 +140,7 @@ public class ScreenWidgetArtifactInfo ex
}
}
- protected void populateLinkedRequests() throws GeneralException{
- Set<String> allRequestUniqueId = this.modelScreen.getAllRequestsLocationAndUri();
+ protected void populateLinkedRequests(Set<String> allRequestUniqueId) throws GeneralException{
for (String requestUniqueId: allRequestUniqueId) {
if (requestUniqueId.contains("${")) {
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoContext.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoContext.java?rev=1636031&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoContext.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoContext.java Sat Nov 1 20:15:27 2014
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget.artifact;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An object used for gathering artifact information.
+ */
+public final class ArtifactInfoContext {
+
+ private final Set<String> entityNameSet = new HashSet<String>();
+ private final Set<String> serviceNameSet = new HashSet<String>();
+ private final Set<String> screenLocationSet = new HashSet<String>();
+ private final Set<String> formLocationSet = new HashSet<String>();
+ private final Set<String> requestLocationSet = new HashSet<String>();
+
+ /**
+ * Adds an entity name to this context.
+ * @param name The entity name to add to this context
+ */
+ public void addEntityName(String name) {
+ if (name != null) {
+ this.entityNameSet.add(name);
+ }
+ }
+
+ /**
+ * Adds a form location to this context.
+ * @param name The form location to add to this context
+ */
+ public void addFormLocation(String name) {
+ if (name != null) {
+ this.formLocationSet.add(name);
+ }
+ }
+
+ /**
+ * Adds a request location to this context.
+ * @param name The request location to add to this context
+ */
+ public void addRequestLocation(String name) {
+ if (name != null) {
+ this.requestLocationSet.add(name);
+ }
+ }
+
+ /**
+ * Adds a screen location to this context.
+ * @param name The screen location to add to this context
+ */
+ public void addScreenLocation(String name) {
+ if (name != null) {
+ this.screenLocationSet.add(name);
+ }
+ }
+
+ /**
+ * Adds a service name to this context.
+ * @param name The service name to add to this context
+ */
+ public void addServiceName(String name) {
+ if (name != null) {
+ this.serviceNameSet.add(name);
+ }
+ }
+
+ /**
+ * Returns the entity names in this context.
+ * @return The entity names in this context
+ */
+ public Set<String> getEntityNames() {
+ return this.entityNameSet;
+ }
+
+ /**
+ * Returns the form locations in this context.
+ * @return The form locations in this context
+ */
+ public Set<String> getFormLocations() {
+ return this.formLocationSet;
+ }
+
+ /**
+ * Returns the request locations in this context.
+ * @return The request locations in this context
+ */
+ public Set<String> getRequestLocations() {
+ return this.requestLocationSet;
+ }
+
+ /**
+ * Returns the screen locations in this context.
+ * @return The screen locations in this context
+ */
+ public Set<String> getScreenLocations() {
+ return this.screenLocationSet;
+ }
+
+ /**
+ * Returns the service names in this context.
+ * @return The service names in this context
+ */
+ public Set<String> getServiceNames() {
+ return this.serviceNameSet;
+ }
+}
Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java?rev=1636031&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java Sat Nov 1 20:15:27 2014
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget.artifact;
+
+import java.util.Set;
+
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.webapp.control.ConfigXMLReader;
+import org.ofbiz.widget.ModelActionVisitor;
+import org.ofbiz.widget.ModelWidgetAction;
+import org.ofbiz.widget.ModelWidgetAction.EntityAnd;
+import org.ofbiz.widget.ModelWidgetAction.EntityCondition;
+import org.ofbiz.widget.ModelWidgetAction.EntityOne;
+import org.ofbiz.widget.ModelWidgetAction.GetRelated;
+import org.ofbiz.widget.ModelWidgetAction.GetRelatedOne;
+import org.ofbiz.widget.ModelWidgetAction.PropertyMap;
+import org.ofbiz.widget.ModelWidgetAction.PropertyToField;
+import org.ofbiz.widget.ModelWidgetAction.Script;
+import org.ofbiz.widget.ModelWidgetAction.Service;
+import org.ofbiz.widget.ModelWidgetAction.SetField;
+import org.ofbiz.widget.ModelWidgetVisitor;
+import org.ofbiz.widget.form.ModelForm;
+import org.ofbiz.widget.menu.ModelMenu;
+import org.ofbiz.widget.screen.HtmlWidget;
+import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplate;
+import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplateDecorator;
+import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplateDecoratorSection;
+import org.ofbiz.widget.screen.IterateSectionWidget;
+import org.ofbiz.widget.screen.ModelScreen;
+import org.ofbiz.widget.screen.ModelScreenWidget;
+import org.ofbiz.widget.screen.ModelScreenWidget.Column;
+import org.ofbiz.widget.screen.ModelScreenWidget.ColumnContainer;
+import org.ofbiz.widget.screen.ModelScreenWidget.Container;
+import org.ofbiz.widget.screen.ModelScreenWidget.Content;
+import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorScreen;
+import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorSection;
+import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorSectionInclude;
+import org.ofbiz.widget.screen.ModelScreenWidget.Form;
+import org.ofbiz.widget.screen.ModelScreenWidget.HorizontalSeparator;
+import org.ofbiz.widget.screen.ModelScreenWidget.Image;
+import org.ofbiz.widget.screen.ModelScreenWidget.IncludeScreen;
+import org.ofbiz.widget.screen.ModelScreenWidget.Label;
+import org.ofbiz.widget.screen.ModelScreenWidget.Link;
+import org.ofbiz.widget.screen.ModelScreenWidget.Menu;
+import org.ofbiz.widget.screen.ModelScreenWidget.PlatformSpecific;
+import org.ofbiz.widget.screen.ModelScreenWidget.PortalPage;
+import org.ofbiz.widget.screen.ModelScreenWidget.Screenlet;
+import org.ofbiz.widget.screen.ModelScreenWidget.Section;
+import org.ofbiz.widget.screen.ModelScreenWidget.Tree;
+import org.ofbiz.widget.tree.ModelTree;
+
+/**
+ * An object that gathers artifact information from screen widgets.
+ */
+public final class ArtifactInfoGatherer implements ModelWidgetVisitor, ModelActionVisitor {
+
+ private final ArtifactInfoContext infoContext;
+
+ public ArtifactInfoGatherer(ArtifactInfoContext infoContext) {
+ this.infoContext = infoContext;
+ }
+
+ @Override
+ public void visit(EntityAnd entityAnd) {
+ infoContext.addEntityName(entityAnd.getFinder().getEntityName());
+ }
+
+ @Override
+ public void visit(EntityCondition entityCondition) {
+ infoContext.addEntityName(entityCondition.getFinder().getEntityName());
+ }
+
+ @Override
+ public void visit(EntityOne entityOne) {
+ infoContext.addEntityName(entityOne.getFinder().getEntityName());
+ }
+
+ @Override
+ public void visit(GetRelated getRelated) {
+ infoContext.addEntityName(getRelated.getRelationName());
+ }
+
+ @Override
+ public void visit(GetRelatedOne getRelatedOne) {
+ infoContext.addEntityName(getRelatedOne.getRelationName());
+ }
+
+ @Override
+ public void visit(PropertyMap propertyMap) {
+ }
+
+ @Override
+ public void visit(PropertyToField propertyToField) {
+ }
+
+ @Override
+ public void visit(Script script) {
+ }
+
+ @Override
+ public void visit(Service service) {
+ infoContext.addServiceName(service.getServiceNameExdr().getOriginal());
+ }
+
+ @Override
+ public void visit(SetField setField) {
+ }
+
+ @Override
+ public void visit(HtmlWidget htmlWidget) {
+ }
+
+ @Override
+ public void visit(HtmlTemplate htmlTemplate) {
+ }
+
+ @Override
+ public void visit(HtmlTemplateDecorator htmlTemplateDecorator) {
+ }
+
+ @Override
+ public void visit(HtmlTemplateDecoratorSection htmlTemplateDecoratorSection) {
+ }
+
+ @Override
+ public void visit(IterateSectionWidget iterateSectionWidget) {
+ for (Section section : iterateSectionWidget.getSectionList()) {
+ section.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(ModelForm modelForm) {
+ }
+
+ @Override
+ public void visit(ModelMenu modelMenu) {
+ }
+
+ @Override
+ public void visit(ModelScreen modelScreen) {
+ String screenLocation = modelScreen.getSourceLocation().concat("#").concat(modelScreen.getName());
+ infoContext.addScreenLocation(screenLocation);
+ modelScreen.getSection().accept(this);;
+ }
+
+ @Override
+ public void visit(ColumnContainer columnContainer) {
+ for (Column column : columnContainer.getColumns()) {
+ for (ModelScreenWidget widget : column.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
+ }
+
+ @Override
+ public void visit(Container container) {
+ for (ModelScreenWidget widget : container.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(Content content) {
+ infoContext.addEntityName("Content");
+ if (!content.getDataResourceId().isEmpty()) {
+ infoContext.addEntityName("DataResource");
+ }
+ }
+
+ @Override
+ public void visit(DecoratorScreen decoratorScreen) {
+ for (DecoratorSection section : decoratorScreen.getSectionMap().values()) {
+ section.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(DecoratorSection decoratorSection) {
+ for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(DecoratorSectionInclude decoratorSectionInclude) {
+ }
+
+ @Override
+ public void visit(Form form) {
+ String formLocation = form.getLocation().concat("#").concat(form.getName());
+ infoContext.addFormLocation(formLocation);
+ }
+
+ @Override
+ public void visit(HorizontalSeparator horizontalSeparator) {
+ }
+
+ @Override
+ public void visit(Image image) {
+ }
+
+ @Override
+ public void visit(IncludeScreen includeScreen) {
+ }
+
+ @Override
+ public void visit(Label label) {
+ }
+
+ @Override
+ public void visit(Link link) {
+ String target = link.getTarget(null);
+ String urlMode = link.getUrlMode();
+ try {
+ Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
+ if (controllerLocAndRequestSet != null) {
+ for (String requestLocation : controllerLocAndRequestSet) {
+ infoContext.addRequestLocation(requestLocation);
+ }
+ }
+ } catch (GeneralException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void visit(Menu menu) {
+ }
+
+ @Override
+ public void visit(PlatformSpecific platformSpecific) {
+ }
+
+ @Override
+ public void visit(PortalPage portalPage) {
+ }
+
+ @Override
+ public void visit(Screenlet screenlet) {
+ for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
+ widget.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(Section section) {
+ for (ModelWidgetAction action : section.getActions()) {
+ action.accept(this);
+ }
+ for (ModelScreenWidget subWidget : section.getSubWidgets()) {
+ subWidget.accept(this);
+ }
+ for (ModelScreenWidget subWidget : section.getFailWidgets()) {
+ subWidget.accept(this);
+ }
+ }
+
+ @Override
+ public void visit(Tree tree) {
+ }
+
+ @Override
+ public void visit(ModelTree modelTree) {
+ }
+}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=1636031&r1=1636030&r2=1636031&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Sat Nov 1 20:15:27 2014
@@ -105,6 +105,10 @@ public class IterateSectionWidget extend
}
}
+ public List<ModelScreenWidget.Section> getSectionList() {
+ return sectionList;
+ }
+
@Override
public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException {
int viewIndex = 0;
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=1636031&r1=1636030&r2=1636031&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 Sat Nov 1 20:15:27 2014
@@ -18,14 +18,9 @@
*******************************************************************************/
package org.ofbiz.widget.screen;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
@@ -35,9 +30,7 @@ import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.transaction.TransactionUtil;
import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.webapp.control.ConfigXMLReader;
import org.ofbiz.widget.ModelWidget;
-import org.ofbiz.widget.ModelWidgetAction;
import org.ofbiz.widget.ModelWidgetVisitor;
import org.w3c.dom.Element;
@@ -54,11 +47,8 @@ public class ModelScreen extends ModelWi
private final Map<String, ModelScreen> modelScreenMap;
private final boolean useTransaction;
private final boolean useCache;
-
private final ModelScreenWidget.Section section;
- // ===== CONSTRUCTORS =====
-
/** XML Constructor */
public ModelScreen(Element screenElement, Map<String, ModelScreen> modelScreenMap, String sourceLocation) {
super(screenElement);
@@ -105,212 +95,6 @@ public class ModelScreen extends ModelWi
return sourceLocation;
}
- public Set<String> getAllServiceNamesUsed() {
- Set<String> allServiceNamesUsed = new HashSet<String>();
- findServiceNamesUsedInWidget(this.section, allServiceNamesUsed);
- return allServiceNamesUsed;
- }
-
- protected static void findServiceNamesUsedInWidget(ModelScreenWidget currentWidget, Set<String> allServiceNamesUsed) {
- if (currentWidget instanceof ModelScreenWidget.Section) {
- List<ModelWidgetAction> actions = ((ModelScreenWidget.Section)currentWidget).getActions();
- List<ModelScreenWidget> subWidgets = ((ModelScreenWidget.Section)currentWidget).getSubWidgets();
- List<ModelScreenWidget> failWidgets = ((ModelScreenWidget.Section)currentWidget).getFailWidgets();
- if (actions != null) {
- for (ModelWidgetAction screenOperation: actions) {
- if (screenOperation instanceof ModelWidgetAction.Service) {
- String serviceName = ((ModelWidgetAction.Service) screenOperation).getServiceNameExdr().getOriginal();
- if (UtilValidate.isNotEmpty(serviceName)) allServiceNamesUsed.add(serviceName);
- }
- }
- }
- if (subWidgets != null) {
- for (ModelScreenWidget widget: subWidgets) {
- findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
- }
- }
- if (failWidgets != null) {
- for (ModelScreenWidget widget: failWidgets) {
- findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
- }
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
- ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection) currentWidget;
- for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
- findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorScreen) {
- ModelScreenWidget.DecoratorScreen decoratorScreen = (ModelScreenWidget.DecoratorScreen) currentWidget;
- Collection<ModelScreenWidget.DecoratorSection> sections = decoratorScreen.getSectionMap().values();
- for (ModelScreenWidget section : sections) {
- findServiceNamesUsedInWidget(section, allServiceNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Container) {
- ModelScreenWidget.Container container = (ModelScreenWidget.Container) currentWidget;
- for (ModelScreenWidget widget : container.getSubWidgets()) {
- findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
- ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet) currentWidget;
- for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
- findServiceNamesUsedInWidget(widget, allServiceNamesUsed);
- }
- }
- }
- public Set<String> getAllEntityNamesUsed() {
- Set<String> allEntityNamesUsed = new HashSet<String>();
- findEntityNamesUsedInWidget(this.section, allEntityNamesUsed);
- return allEntityNamesUsed;
- }
- protected static void findEntityNamesUsedInWidget(ModelScreenWidget currentWidget, Set<String> allEntityNamesUsed) {
- if (currentWidget instanceof ModelScreenWidget.Section) {
- List<ModelWidgetAction> actions = ((ModelScreenWidget.Section)currentWidget).getActions();
- List<ModelScreenWidget> subWidgets = ((ModelScreenWidget.Section)currentWidget).getSubWidgets();
- List<ModelScreenWidget> failWidgets = ((ModelScreenWidget.Section)currentWidget).getFailWidgets();
- if (actions != null) {
- for (ModelWidgetAction screenOperation: actions) {
- if (screenOperation instanceof ModelWidgetAction.EntityOne) {
- String entName = ((ModelWidgetAction.EntityOne) screenOperation).getFinder().getEntityName();
- if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
- } else if (screenOperation instanceof ModelWidgetAction.EntityAnd) {
- String entName = ((ModelWidgetAction.EntityAnd) screenOperation).getFinder().getEntityName();
- if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
- } else if (screenOperation instanceof ModelWidgetAction.EntityCondition) {
- String entName = ((ModelWidgetAction.EntityCondition) screenOperation).getFinder().getEntityName();
- if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
- } else if (screenOperation instanceof ModelWidgetAction.GetRelated) {
- String relationName = ((ModelWidgetAction.GetRelated) screenOperation).getRelationName();
- if (UtilValidate.isNotEmpty(relationName)) allEntityNamesUsed.add(relationName);
- } else if (screenOperation instanceof ModelWidgetAction.GetRelatedOne) {
- String relationName = ((ModelWidgetAction.GetRelatedOne) screenOperation).getRelationName();
- if (UtilValidate.isNotEmpty(relationName)) allEntityNamesUsed.add(relationName);
- }
- }
- }
- if (subWidgets != null) {
- for (ModelScreenWidget widget: subWidgets) {
- findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
- }
- }
- if (failWidgets != null) {
- for (ModelScreenWidget widget: failWidgets) {
- findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
- }
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
- ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection) currentWidget;
- for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
- findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorScreen) {
- ModelScreenWidget.DecoratorScreen decoratorScreen = (ModelScreenWidget.DecoratorScreen) currentWidget;
- Collection<ModelScreenWidget.DecoratorSection> sections = decoratorScreen.getSectionMap().values();
- for (ModelScreenWidget section : sections) {
- findEntityNamesUsedInWidget(section, allEntityNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Container) {
- ModelScreenWidget.Container container = (ModelScreenWidget.Container) currentWidget;
- for (ModelScreenWidget widget : container.getSubWidgets()) {
- findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
- ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet) currentWidget;
- for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
- findEntityNamesUsedInWidget(widget, allEntityNamesUsed);
- }
- }
- }
-
- public Set<String> getAllFormNamesIncluded() {
- Set<String> allFormNamesIncluded = new HashSet<String>();
- findFormNamesIncludedInWidget(this.section, allFormNamesIncluded);
- return allFormNamesIncluded;
- }
-
- protected static void findFormNamesIncludedInWidget(ModelScreenWidget currentWidget, Set<String> allFormNamesIncluded) {
- if (currentWidget instanceof ModelScreenWidget.Form) {
- ModelScreenWidget.Form form = (ModelScreenWidget.Form) currentWidget;
- allFormNamesIncluded.add(form.getLocation() + "#" + form.getName());
- } else if (currentWidget instanceof ModelScreenWidget.Section) {
- ModelScreenWidget.Section section = (ModelScreenWidget.Section) currentWidget;
- for (ModelScreenWidget widget : section.getSubWidgets()) {
- findFormNamesIncludedInWidget(widget, allFormNamesIncluded);
- }
- for (ModelScreenWidget widget : section.getFailWidgets()) {
- findFormNamesIncludedInWidget(widget, allFormNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
- ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection) currentWidget;
- for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
- findFormNamesIncludedInWidget(widget, allFormNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorScreen) {
- ModelScreenWidget.DecoratorScreen decoratorScreen = (ModelScreenWidget.DecoratorScreen) currentWidget;
- Collection<ModelScreenWidget.DecoratorSection> sections = decoratorScreen.getSectionMap().values();
- for (ModelScreenWidget section : sections) {
- findFormNamesIncludedInWidget(section, allFormNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Container) {
- ModelScreenWidget.Container container = (ModelScreenWidget.Container) currentWidget;
- for (ModelScreenWidget widget : container.getSubWidgets()) {
- findFormNamesIncludedInWidget(widget, allFormNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
- ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet) currentWidget;
- for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
- findFormNamesIncludedInWidget(widget, allFormNamesIncluded);
- }
- }
- }
-
- public Set<String> getAllRequestsLocationAndUri() throws GeneralException {
- Set<String> allRequestNamesIncluded = new HashSet<String>();
- findRequestNamesLinkedtoInWidget(this.section, allRequestNamesIncluded);
- return allRequestNamesIncluded;
- }
- protected static void findRequestNamesLinkedtoInWidget(ModelScreenWidget currentWidget, Set<String> allRequestNamesIncluded) throws GeneralException {
- if (currentWidget instanceof ModelScreenWidget.Link) {
- ModelScreenWidget.Link link = (ModelScreenWidget.Link) currentWidget;
- String target = link.getTarget(null);
- String urlMode = link.getUrlMode();
- // Debug.logInfo("In findRequestNamesLinkedtoInWidget found link [" + link.rawString() + "] with target [" + target + "]", module);
-
- Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
- if (controllerLocAndRequestSet == null) return;
- allRequestNamesIncluded.addAll(controllerLocAndRequestSet);
- } else if (currentWidget instanceof ModelScreenWidget.Section) {
- ModelScreenWidget.Section section = (ModelScreenWidget.Section) currentWidget;
- for (ModelScreenWidget widget : section.getSubWidgets()) {
- findRequestNamesLinkedtoInWidget(widget, allRequestNamesIncluded);
- }
- for (ModelScreenWidget widget : section.getFailWidgets()) {
- findRequestNamesLinkedtoInWidget(widget, allRequestNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorSection) {
- ModelScreenWidget.DecoratorSection decoratorSection = (ModelScreenWidget.DecoratorSection) currentWidget;
- for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) {
- findRequestNamesLinkedtoInWidget(widget, allRequestNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.DecoratorScreen) {
- ModelScreenWidget.DecoratorScreen decoratorScreen = (ModelScreenWidget.DecoratorScreen) currentWidget;
- Collection<ModelScreenWidget.DecoratorSection> sections = decoratorScreen.getSectionMap().values();
- for (ModelScreenWidget section : sections) {
- findRequestNamesLinkedtoInWidget(section, allRequestNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Container) {
- ModelScreenWidget.Container container = (ModelScreenWidget.Container) currentWidget;
- for (ModelScreenWidget widget : container.getSubWidgets()) {
- findRequestNamesLinkedtoInWidget(widget, allRequestNamesIncluded);
- }
- } else if (currentWidget instanceof ModelScreenWidget.Screenlet) {
- ModelScreenWidget.Screenlet screenlet = (ModelScreenWidget.Screenlet) currentWidget;
- for (ModelScreenWidget widget : screenlet.getSubWidgets()) {
- findRequestNamesLinkedtoInWidget(widget, allRequestNamesIncluded);
- }
- }
- }
-
-
/**
* Renders this screen to a String, i.e. in a text format, as defined with the
* ScreenStringRenderer implementation.
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=1636031&r1=1636030&r2=1636031&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 Sat Nov 1 20:15:27 2014
@@ -1210,6 +1210,10 @@ public abstract class ModelScreenWidget
return this.contentId.expandString(context);
}
+ public String getDataResourceId() {
+ return this.dataResourceId.getOriginal();
+ }
+
public String getDataResourceId(Map<String, Object> context) {
return this.dataResourceId.expandString(context);
}