svn commit: r630544 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ModelReader.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: r630544 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/model/ModelReader.java webtools/src/org/ofbiz/webtools/WebToolsServices.java

jonesde
Author: jonesde
Date: Sat Feb 23 15:11:04 2008
New Revision: 630544

URL: http://svn.apache.org/viewvc?rev=630544&view=rev
Log:
Changed to support comma separated package name list

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.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=630544&r1=630543&r2=630544&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 Sat Feb 23 15:11:04 2008
@@ -499,19 +499,17 @@
             String packageName = entity.getPackageName();
             
             if (UtilValidate.isNotEmpty(packageFilterSet)) {
-                boolean skipThis = false;
                 // does it match any of these?
+                boolean foundMatch = false;
                 for (String packageFilter: packageFilterSet) {
-                    boolean foundMatch = false;
                     if (packageName.contains(packageFilter)) {
                         foundMatch = true;
                     }
-                    if (!foundMatch) {
-                        //Debug.logInfo("Not including entity " + entityName + " becuase it is not in the package set: " + packageFilterSet, module);
-                        skipThis = true;
-                    }
                 }
-                if (skipThis) continue;
+                if (!foundMatch) {
+                    //Debug.logInfo("Not including entity " + entityName + " becuase it is not in the package set: " + packageFilterSet, module);
+                    continue;
+                }
             }
             if (UtilValidate.isNotEmpty(entityFilterSet) && !entityFilterSet.contains(entityName)) {
                 //Debug.logInfo("Not including entity " + entityName + " becuase it is not in the entity set: " + entityFilterSet, module);

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=630544&r1=630543&r2=630544&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Sat Feb 23 15:11:04 2008
@@ -49,6 +49,7 @@
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
@@ -789,10 +790,17 @@
     
     public static Map exportEntityEoModelBundle(DispatchContext dctx, Map context) {
         String eomodeldFullPath = (String) context.get("eomodeldFullPath");
-        String entityPackageName = (String) context.get("entityPackageName");
+        String entityPackageNameOrig = (String) context.get("entityPackageName");
         String entityGroupId = (String) context.get("entityGroupId");
         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();
         
@@ -813,12 +821,10 @@
             }
             
             Set<String> entityNames = new TreeSet();
-            if (UtilValidate.isNotEmpty(entityPackageName)) {
-                Map<String, TreeSet<String>> entitiesByPackage = reader.getEntitiesByPackage(UtilMisc.toSet(entityPackageName), null);
+            if (UtilValidate.isNotEmpty(entityPackageNameSet)) {
+                Map<String, TreeSet<String>> entitiesByPackage = reader.getEntitiesByPackage(entityPackageNameSet, null);
                 for (Map.Entry<String, TreeSet<String>> entitiesByPackageMapEntry: entitiesByPackage.entrySet()) {
-                    if (entitiesByPackageMapEntry.getKey().contains(entityPackageName)) {
-                        entityNames.addAll(entitiesByPackageMapEntry.getValue());
-                    }
+                    entityNames.addAll(entitiesByPackageMapEntry.getValue());
                 }
                 Debug.logInfo("Exporting the following entities: " + entityNames, module);
             } else if (UtilValidate.isNotEmpty(entityGroupId)) {
@@ -859,6 +865,8 @@
                 modelEntity.writeEoModelText(entityWriter, entityNamePrefix, datasourceName, entityNames);
                 entityWriter.close();
             }
+            
+            return ServiceUtil.returnSuccess("Exported eomodeld file for " + entityNames.size() + " entities to: " + eomodeldFullPath);
         } catch (UnsupportedEncodingException e) {
             return ServiceUtil.returnError("ERROR saving file: " + e.toString());
         } catch (FileNotFoundException e) {
@@ -866,8 +874,6 @@
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError("ERROR: getting entity names: " + e.toString());
         }
-        
-        return ServiceUtil.returnSuccess();
     }
 
     /** Performs an entity maintenance security check. Returns hasPermission=true