svn commit: r630553 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

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

svn commit: r630553 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

jonesde
Author: jonesde
Date: Sat Feb 23 16:24:19 2008
New Revision: 630553

URL: http://svn.apache.org/viewvc?rev=630553&view=rev
Log:
Some refinements to use relationship attributes for incoming rels and fields for outgoing

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=630553&r1=630552&r2=630553&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Sat Feb 23 16:24:19 2008
@@ -1395,6 +1395,8 @@
      * @param helperName
      */
     public void writeEoModelText(PrintWriter writer, String entityPrefix, String helperName, Set<String> entityNameIncludeSet) {
+        final boolean useRelationshipNames = false;
+        
         if (entityPrefix == null) entityPrefix = "";
         if (helperName == null) helperName = "localderby";
         ModelFieldTypeReader modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperName);
@@ -1409,16 +1411,23 @@
         List<String> classPropertiesList = FastList.newInstance();
         topLevelMap.put("classProperties", classPropertiesList);
         for (ModelField field: this.fields) {
+            if (field.getIsAutoCreatedInternal()) continue;
+            
             classPropertiesList.add(field.getName());
         }
         for (ModelRelation relationship: this.relations) {
-            classPropertiesList.add(relationship.getCombinedName());
+            if (!entityNameIncludeSet.contains(relationship.getRelEntityName())) continue;
+            if (useRelationshipNames || relationship.isAutoRelation()) {
+                classPropertiesList.add(relationship.getCombinedName());
+            }
         }
         
         // attributes
         List<Map<String, Object>> attributesList = FastList.newInstance();
         topLevelMap.put("attributes", attributesList);
         for (ModelField field: this.fields) {
+            if (field.getIsAutoCreatedInternal()) continue;
+            
             ModelFieldType fieldType = modelFieldTypeReader.getModelFieldType(field.getType());
             
             Map<String, Object> attributeMap = FastMap.newInstance();
@@ -1461,7 +1470,11 @@
                 Map<String, Object> relationshipMap = FastMap.newInstance();
                 relationshipsMapList.add(relationshipMap);
                 
-                relationshipMap.put("name", relationship.getCombinedName());
+                if (useRelationshipNames || relationship.isAutoRelation()) {
+                    relationshipMap.put("name", relationship.getCombinedName());
+                } else {
+                    relationshipMap.put("name", relationship.getKeyMapsIterator().next().getFieldName());
+                }
                 relationshipMap.put("destination", relationship.getRelEntityName());
                 if ("many".equals(relationship.getType())) {
                     relationshipMap.put("isToMany", "Y");