svn commit: r631078 - in /ofbiz/trunk/framework: entityext/src/org/ofbiz/entityext/EntityGroupUtil.java entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java webtools/src/org/ofbiz/webtools/WebToolsServices.java

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

svn commit: r631078 - in /ofbiz/trunk/framework: entityext/src/org/ofbiz/entityext/EntityGroupUtil.java entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java webtools/src/org/ofbiz/webtools/WebToolsServices.java

jonesde
Author: jonesde
Date: Mon Feb 25 19:32:50 2008
New Revision: 631078

URL: http://svn.apache.org/viewvc?rev=631078&view=rev
Log:
Fixed exporting entity eomodeld by entityGroupId

Modified:
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java?rev=631078&r1=631077&r2=631078&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java Mon Feb 25 19:32:50 2008
@@ -39,12 +39,12 @@
 
     public static final String module = EntityGroupUtil.class.getName();
 
-    public static Set<String> getEntityNamesByGroup(String entityGroupId, GenericDelegator delegator) throws GenericEntityException {
+    public static Set<String> getEntityNamesByGroup(String entityGroupId, GenericDelegator delegator, boolean requireStampFields) throws GenericEntityException {
         Set<String> entityNames = FastSet.newInstance();
         
-        List entitySyncGroupIncludes = delegator.findByAnd("EntitySyncInclGrpDetailView", UtilMisc.toMap("entityGroupId", entityGroupId));
+        List<GenericValue> entitySyncGroupIncludes = delegator.findByAnd("EntityGroupEntry", UtilMisc.toMap("entityGroupId", entityGroupId));
         
-        List<ModelEntity> modelEntities = getModelEntitiesFromRecords(entitySyncGroupIncludes, delegator);
+        List<ModelEntity> modelEntities = getModelEntitiesFromRecords(entitySyncGroupIncludes, delegator, requireStampFields);
         for (ModelEntity modelEntity: modelEntities) {
             entityNames.add(modelEntity.getEntityName());
         }
@@ -52,12 +52,10 @@
         return entityNames;
     }
 
-    public static List<ModelEntity> getModelEntitiesFromRecords(List<GenericValue> entityGroupEntryValues, GenericDelegator delegator) throws GenericEntityException {
+    public static List<ModelEntity> getModelEntitiesFromRecords(List<GenericValue> entityGroupEntryValues, GenericDelegator delegator, boolean requireStampFields) throws GenericEntityException {
         List<ModelEntity> entityModelToUseList = FastList.newInstance();
 
-        Iterator entityNameIter = delegator.getModelReader().getEntityNamesIterator();
-        while (entityNameIter.hasNext()) {
-            String entityName = (String) entityNameIter.next();
+        for (String entityName: delegator.getModelReader().getEntityNames()) {
             ModelEntity modelEntity = delegator.getModelEntity(entityName);
             
             // if view-entity, throw it out
@@ -66,7 +64,7 @@
             }
             
             // if it doesn't have either or both of the two update stamp fields, throw it out
-            if (!modelEntity.isField(ModelEntity.STAMP_FIELD) || !modelEntity.isField(ModelEntity.STAMP_TX_FIELD)) {
+            if (requireStampFields && (!modelEntity.isField(ModelEntity.STAMP_FIELD) || !modelEntity.isField(ModelEntity.STAMP_TX_FIELD))) {
                 continue;
             }
             

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java?rev=631078&r1=631077&r2=631078&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java Mon Feb 25 19:32:50 2008
@@ -850,7 +850,7 @@
         List<GenericValue> entitySyncGroupIncludes = entitySync.getRelated("EntitySyncInclGrpDetailView");
         entitySyncIncludes.addAll(entitySyncGroupIncludes);
 
-        List<ModelEntity> entityModelToUseList = EntityGroupUtil.getModelEntitiesFromRecords(entitySyncIncludes, delegator);
+        List<ModelEntity> entityModelToUseList = EntityGroupUtil.getModelEntitiesFromRecords(entitySyncIncludes, delegator, true);
         
         if (Debug.infoOn()) Debug.logInfo("In makeEntityModelToUseList for EntitySync with ID [" + entitySync.get("entitySyncId") + "] syncing " + entityModelToUseList.size() + " entities", module);
         return entityModelToUseList;

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=631078&r1=631077&r2=631078&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Mon Feb 25 19:32:50 2008
@@ -795,13 +795,6 @@
         String datasourceName = (String) context.get("datasourceName");
         String entityNamePrefix = (String) context.get("entityNamePrefix");
         
-        Set<String> entityPackageNameSet = FastSet.newInstance();
-        if (UtilValidate.isNotEmpty(entityPackageNameOrig)) {
-            entityPackageNameSet.addAll(StringUtil.split(entityPackageNameOrig, ","));
-        }
-        
-        Debug.logInfo("Exporting with entityPackageNameSet: " + entityPackageNameSet, module);
-
         ModelReader reader = dctx.getDelegator().getModelReader();
         
         try {
@@ -821,17 +814,23 @@
             }
             
             Set<String> entityNames = new TreeSet();
-            if (UtilValidate.isNotEmpty(entityPackageNameSet)) {
+            if (UtilValidate.isNotEmpty(entityPackageNameOrig)) {
+                Set<String> entityPackageNameSet = FastSet.newInstance();
+                entityPackageNameSet.addAll(StringUtil.split(entityPackageNameOrig, ","));
+                
+                Debug.logInfo("Exporting with entityPackageNameSet: " + entityPackageNameSet, module);
+
                 Map<String, TreeSet<String>> entitiesByPackage = reader.getEntitiesByPackage(entityPackageNameSet, null);
                 for (Map.Entry<String, TreeSet<String>> entitiesByPackageMapEntry: entitiesByPackage.entrySet()) {
                     entityNames.addAll(entitiesByPackageMapEntry.getValue());
                 }
-                Debug.logInfo("Exporting the following entities: " + entityNames, module);
             } else if (UtilValidate.isNotEmpty(entityGroupId)) {
-                entityNames.addAll(EntityGroupUtil.getEntityNamesByGroup(entityGroupId, dctx.getDelegator()));
+                Debug.logInfo("Exporting entites from the Group: " + entityGroupId, module);
+                entityNames.addAll(EntityGroupUtil.getEntityNamesByGroup(entityGroupId, dctx.getDelegator(), false));
             } else {
                 entityNames.addAll(reader.getEntityNames());
             }
+            Debug.logInfo("Exporting the following entities: " + entityNames, module);
 
             // remove all view-entity
             Iterator<String> filterEntityNameIter = entityNames.iterator();