Author: jonesde
Date: Wed Mar 5 10:25:13 2008 New Revision: 633963 URL: http://svn.apache.org/viewvc?rev=633963&view=rev Log: Changed to be able to identify pks in related entities in the export Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.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=633963&r1=633962&r2=633963&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 Wed Mar 5 10:25:13 2008 @@ -1394,15 +1394,15 @@ * @param entityPrefix * @param helperName */ - public void writeEoModelText(PrintWriter writer, String entityPrefix, String helperName, Set<String> entityNameIncludeSet) { + public void writeEoModelText(PrintWriter writer, String entityPrefix, String helperName, Set<String> entityNameIncludeSet, ModelReader entityModelReader) throws GenericEntityException { if (entityPrefix == null) entityPrefix = ""; if (helperName == null) helperName = "localderby"; - UtilFormatOut.writePlistPropertyMap(this.createEoModelMap(entityPrefix, helperName, entityNameIncludeSet), 0, writer, false); + UtilFormatOut.writePlistPropertyMap(this.createEoModelMap(entityPrefix, helperName, entityNameIncludeSet, entityModelReader), 0, writer, false); } - public Map<String, Object> createEoModelMap(String entityPrefix, String helperName, Set<String> entityNameIncludeSet) { + public Map<String, Object> createEoModelMap(String entityPrefix, String helperName, Set<String> entityNameIncludeSet, ModelReader entityModelReader) throws GenericEntityException { final boolean useRelationshipNames = false; ModelFieldTypeReader modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperName); @@ -1478,6 +1478,8 @@ List<Map<String, Object>> relationshipsMapList = FastList.newInstance(); for (ModelRelation relationship: this.relations) { if (entityNameIncludeSet.contains(relationship.getRelEntityName())) { + ModelEntity relEntity = entityModelReader.getModelEntity(relationship.getRelEntityName()); + Map<String, Object> relationshipMap = FastMap.newInstance(); relationshipsMapList.add(relationshipMap); @@ -1502,8 +1504,21 @@ for (ModelKeyMap keyMap: relationship.getKeyMapsClone()) { Map<String, Object> joinsMap = FastMap.newInstance(); joinsMapList.add(joinsMap); - joinsMap.put("sourceAttribute", keyMap.getFieldName()); - joinsMap.put("destinationAttribute", keyMap.getRelFieldName()); + + ModelField thisField = this.getField(keyMap.getFieldName()); + if (thisField != null && thisField.getIsPk()) { + joinsMap.put("sourceAttribute", keyMap.getFieldName() + "*"); + } else { + joinsMap.put("sourceAttribute", keyMap.getFieldName()); + } + + ModelField relField = null; + if (relEntity != null) relField = relEntity.getField(keyMap.getRelFieldName()); + if (relField != null && relField.getIsPk()) { + joinsMap.put("destinationAttribute", keyMap.getRelFieldName() + "*"); + } else { + joinsMap.put("destinationAttribute", keyMap.getRelFieldName()); + } } } } Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=633963&r1=633962&r2=633963&view=diff ============================================================================== --- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original) +++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Wed Mar 5 10:25:13 2008 @@ -864,7 +864,7 @@ // write each <EntityName>.plist file for (String curEntityName: entityNames) { ModelEntity modelEntity = reader.getModelEntity(curEntityName); - UtilFormatOut.writePlistFile(modelEntity.createEoModelMap(entityNamePrefix, datasourceName, entityNames), eomodeldFullPath, curEntityName +".plist", true); + UtilFormatOut.writePlistFile(modelEntity.createEoModelMap(entityNamePrefix, datasourceName, entityNames, reader), eomodeldFullPath, curEntityName +".plist", true); } return ServiceUtil.returnSuccess("Exported eomodeld file for " + entityNames.size() + " entities to: " + eomodeldFullPath); |
Free forum by Nabble | Edit this page |