svn commit: r639780 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ minilang/src/org/ofbiz/minilang/ minilang/src/org/ofbiz/minilang/method/entityops/ webtools/src/org/ofbiz/webtools/artifactinfo/ widget/src/org/ofbiz/widget/screen/

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

svn commit: r639780 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ minilang/src/org/ofbiz/minilang/ minilang/src/org/ofbiz/minilang/method/entityops/ webtools/src/org/ofbiz/webtools/artifactinfo/ widget/src/org/ofbiz/widget/screen/

jacopoc
Author: jacopoc
Date: Fri Mar 21 12:58:09 2008
New Revision: 639780

URL: http://svn.apache.org/viewvc?rev=639780&view=rev
Log:
Added support for get-related* operations in entity related information for artifact infos.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/FormWidgetArtifactInfo.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/widget/src/org/ofbiz/widget/screen/ModelScreen.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=639780&r1=639779&r2=639780&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Fri Mar 21 12:58:09 2008
@@ -527,6 +527,22 @@
         return entitiesByPackage;
     }
 
+    /** Util method to validate an entity name; if no entity is found with the name,
+     *  characters are stripped from the beginning of the name until a valid entity name is found.
+     *  It is intended to be used to determine the entity name from a relation name.
+     * @return A valid entityName or null
+     */
+    public String validateEntityName(String entityName) throws GenericEntityException {
+        if (entityName == null) {
+            return null;
+        }
+        Set allEntities = this.getEntityNames();
+        while (!allEntities.contains(entityName) && entityName.length() > 0) {
+            entityName = entityName.substring(1);
+        }
+        return (entityName.length() > 0? entityName: null);
+    }
+
     ModelEntity createModelEntity(Element entityElement, UtilTimer utilTimer, ModelInfo def) {
         if (entityElement == null) return null;
         this.numEntities++;

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java?rev=639780&r1=639779&r2=639780&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/SimpleMethod.java Fri Mar 21 12:58:09 2008
@@ -52,6 +52,8 @@
 import org.ofbiz.minilang.method.callops.SetServiceFields;
 import org.ofbiz.minilang.method.conditional.MasterIf;
 import org.ofbiz.minilang.method.conditional.While;
+import org.ofbiz.minilang.method.entityops.GetRelated;
+import org.ofbiz.minilang.method.entityops.GetRelatedOne;
 import org.ofbiz.minilang.method.entityops.EntityAnd;
 import org.ofbiz.minilang.method.entityops.EntityCondition;
 import org.ofbiz.minilang.method.entityops.EntityCount;
@@ -617,6 +619,12 @@
             } else if (methodOperation instanceof MakeValue) {
                 String entName = ((MakeValue) methodOperation).getEntityName();
                 if (UtilValidate.isNotEmpty(entName)) allEntityNames.add(entName);
+            } else if (methodOperation instanceof GetRelated) {
+                String relationName = ((GetRelated) methodOperation).getRelationName();
+                if (UtilValidate.isNotEmpty(relationName)) allEntityNames.add(relationName);
+            } else if (methodOperation instanceof GetRelatedOne) {
+                String relationName = ((GetRelatedOne) methodOperation).getRelationName();
+                if (UtilValidate.isNotEmpty(relationName)) allEntityNames.add(relationName);
                 
             } else if (methodOperation instanceof CallSimpleMethod) {
                 CallSimpleMethod csm = (CallSimpleMethod) methodOperation;

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java?rev=639780&r1=639779&r2=639780&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java Fri Mar 21 12:58:09 2008
@@ -89,6 +89,9 @@
         return true;
     }
 
+    public String getRelationName() {
+        return this.relationName;
+    }
     public String rawString() {
         // TODO: something more than the empty tag
         return "<get-related/>";

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java?rev=639780&r1=639779&r2=639780&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java Fri Mar 21 12:58:09 2008
@@ -79,6 +79,9 @@
         return true;
     }
 
+    public String getRelationName() {
+        return this.relationName;
+    }
     public String rawString() {
         // TODO: something more than the empty tag
         return "<get-related-one/>";

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=639780&r1=639779&r2=639780&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 Fri Mar 21 12:58:09 2008
@@ -71,7 +71,7 @@
     }
     protected void populateFormExtended() throws GeneralException {
         // populate formThisFormExtends and the reverse-associate cache in the aif
-        if (this.modelForm.getParentFormName() != null && this.modelForm.getParentFormLocation() != null) {
+        if (this.modelForm.getParentFormName() != null) {
             String formName = this.modelForm.getParentFormLocation() + "#" + this.modelForm.getParentFormName();
             if (formName.contains("${")) {
                 return;

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=639780&r1=639779&r2=639780&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 Fri Mar 21 12:58:09 2008
@@ -104,7 +104,9 @@
             if (entityName.contains("${")) {
                 continue;
             }
-            if (!aif.getEntityModelReader().getEntityNames().contains(entityName)) {
+            // attempt to convert relation names to entity names
+            entityName = aif.getEntityModelReader().validateEntityName(entityName);
+            if (entityName == null) {
                 Debug.logWarning("Entity [" + entityName + "] reference in screen [" + this.screenName + "] in resource [" + this.screenLocation + "] does not exist!", module);
                 continue;
             }

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=639780&r1=639779&r2=639780&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 Fri Mar 21 12:58:09 2008
@@ -120,7 +120,9 @@
             if (entityName.contains("${")) {
                 continue;
             }
-            if (!aif.getEntityModelReader().getEntityNames().contains(entityName)) {
+            // attempt to convert relation names to entity names
+            entityName = aif.getEntityModelReader().validateEntityName(entityName);
+            if (entityName == null) {
                 Debug.logWarning("Entity [" + entityName + "] reference in service [" + this.modelService.name + "] does not exist!", module);
                 continue;
             }

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=639780&r1=639779&r2=639780&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 Fri Mar 21 12:58:09 2008
@@ -159,6 +159,12 @@
                     } else if (screenOperation instanceof ModelScreenAction.EntityCondition) {
                         String entName = ((ModelScreenAction.EntityCondition) screenOperation).finder.getEntityName();
                         if (UtilValidate.isNotEmpty(entName)) allEntityNamesUsed.add(entName);
+                    } else if (screenOperation instanceof ModelScreenAction.GetRelated) {
+                        String relationName = ((ModelScreenAction.GetRelated) screenOperation).relationName;
+                        if (UtilValidate.isNotEmpty(relationName)) allEntityNamesUsed.add(relationName);
+                    } else if (screenOperation instanceof ModelScreenAction.GetRelatedOne) {
+                        String relationName = ((ModelScreenAction.GetRelatedOne) screenOperation).relationName;
+                        if (UtilValidate.isNotEmpty(relationName)) allEntityNamesUsed.add(relationName);
                     }
                 }
             }