You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/21 15:48:24 UTC

svn commit: r520902 - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/component/ComponentConfig.java entity/src/org/ofbiz/entity/util/EntityDataLoader.java entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java

Author: jaz
Date: Wed Mar 21 07:48:21 2007
New Revision: 520902

URL: http://svn.apache.org/viewvc?view=rev&rev=520902
Log:
implemented new data loading arguement -component to limit data loading to a single component (by name)

example:
java -jar ofbiz.jar -install -component=mycomponent -readers=seed,ext,demo


Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java?view=diff&rev=520902&r1=520901&r2=520902
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java Wed Mar 21 07:48:21 2007
@@ -97,29 +97,41 @@
     }
 
     public static List getAllClasspathInfos() {
+        return getAllClasspathInfos(null);
+    }
+
+    public static List getAllClasspathInfos(String componentName) {
         List classpaths = FastList.newInstance();
         Iterator i = getAllComponents().iterator();
         while (i.hasNext()) {
             ComponentConfig cc = (ComponentConfig) i.next();
-            classpaths.addAll(cc.getClasspathInfos());
+            if (componentName == null || componentName.equals(cc.getComponentName())) {
+                classpaths.addAll(cc.getClasspathInfos());
+            }
         }
         return classpaths;
     }
 
     public static List getAllEntityResourceInfos(String type) {
+        return getAllEntityResourceInfos(type, null);
+    }
+
+    public static List getAllEntityResourceInfos(String type, String componentName) {
         List entityInfos = FastList.newInstance();
         Iterator i = getAllComponents().iterator();
         while (i.hasNext()) {
             ComponentConfig cc = (ComponentConfig) i.next();
-            List ccEntityInfoList = cc.getEntityResourceInfos();
-            if (UtilValidate.isEmpty(type)) {
-                entityInfos.addAll(ccEntityInfoList);
-            } else {
-                Iterator ccEntityInfoIter = ccEntityInfoList.iterator();
-                while (ccEntityInfoIter.hasNext()) {
-                    EntityResourceInfo entityResourceInfo = (EntityResourceInfo) ccEntityInfoIter.next();
-                    if (type.equals(entityResourceInfo.type)) {
-                        entityInfos.add(entityResourceInfo);
+            if (componentName == null || componentName.equals(cc.getComponentName())) {
+                List ccEntityInfoList = cc.getEntityResourceInfos();
+                if (UtilValidate.isEmpty(type)) {
+                    entityInfos.addAll(ccEntityInfoList);
+                } else {
+                    Iterator ccEntityInfoIter = ccEntityInfoList.iterator();
+                    while (ccEntityInfoIter.hasNext()) {
+                        EntityResourceInfo entityResourceInfo = (EntityResourceInfo) ccEntityInfoIter.next();
+                        if (type.equals(entityResourceInfo.type)) {
+                            entityInfos.add(entityResourceInfo);
+                        }
                     }
                 }
             }
@@ -128,19 +140,25 @@
     }
 
     public static List getAllServiceResourceInfos(String type) {
+        return getAllServiceResourceInfos(type, null);
+    }
+
+    public static List getAllServiceResourceInfos(String type, String componentName) {
         List serviceInfos = FastList.newInstance();
         Iterator i = getAllComponents().iterator();
         while (i.hasNext()) {
             ComponentConfig cc = (ComponentConfig) i.next();
-            List ccServiceInfoList = cc.getServiceResourceInfos();
-            if (UtilValidate.isEmpty(type)) {
-                serviceInfos.addAll(ccServiceInfoList);
-            } else {
-                Iterator ccServiceInfoIter = ccServiceInfoList.iterator();
-                while (ccServiceInfoIter.hasNext()) {
-                    ServiceResourceInfo serviceResourceInfo = (ServiceResourceInfo) ccServiceInfoIter.next();
-                    if (type.equals(serviceResourceInfo.type)) {
-                        serviceInfos.add(serviceResourceInfo);
+            if (componentName == null || componentName.equals(cc.getComponentName())) {
+                List ccServiceInfoList = cc.getServiceResourceInfos();
+                if (UtilValidate.isEmpty(type)) {
+                    serviceInfos.addAll(ccServiceInfoList);
+                } else {
+                    Iterator ccServiceInfoIter = ccServiceInfoList.iterator();
+                    while (ccServiceInfoIter.hasNext()) {
+                        ServiceResourceInfo serviceResourceInfo = (ServiceResourceInfo) ccServiceInfoIter.next();
+                        if (type.equals(serviceResourceInfo.type)) {
+                            serviceInfos.add(serviceResourceInfo);
+                        }
                     }
                 }
             }

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java?view=diff&rev=520902&r1=520901&r2=520902
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java Wed Mar 21 07:48:21 2007
@@ -74,10 +74,14 @@
 
     public static List getUrlList(String helperName) {
         DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperName);
-        return getUrlList(helperName, datasourceInfo.readDatas);
+        return getUrlList(helperName, null, datasourceInfo.readDatas);
     }
 
     public static List getUrlList(String helperName, List readerNames) {
+        return getUrlList(helperName, null, readerNames);
+    }
+
+    public static List getUrlList(String helperName, String componentName, List readerNames) {
         String paths = getPathsString(helperName);
         List urlList = new LinkedList();
         
@@ -113,7 +117,7 @@
                     }
         
                     // get all of the component resource model stuff, ie specified in each ofbiz-component.xml file
-                    List componentResourceInfos = ComponentConfig.getAllEntityResourceInfos("data");
+                    List componentResourceInfos = ComponentConfig.getAllEntityResourceInfos("data", componentName);
                     Iterator componentResourceInfoIter = componentResourceInfos.iterator();
                     while (componentResourceInfoIter.hasNext()) {
                         ComponentConfig.EntityResourceInfo componentResourceInfo = (ComponentConfig.EntityResourceInfo) componentResourceInfoIter.next();

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?view=diff&rev=520902&r1=520901&r2=520902
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Wed Mar 21 07:48:21 2007
@@ -52,6 +52,7 @@
     protected String readers = null;
     protected String directory = null;
     protected String file = null;
+    protected String component = null;
     protected boolean useDummyFks = false;
     protected boolean maintainTxs = false;
     protected boolean tryInserts = false;
@@ -109,6 +110,8 @@
                         } catch (Exception e) {
                             this.txTimeout = -1;
                         }
+                    } else if ("component".equalsIgnoreCase(argumentName)) {
+                        this.component = argumentVal;
                     } else if ("delegator".equalsIgnoreCase(argumentName)) {
                         this.overrideDelegator = argumentVal;
                     } else if ("group".equalsIgnoreCase(argumentName)) {
@@ -183,7 +186,7 @@
         // get the reader name URLs first
         List urlList = null;
         if (readerNames != null) {
-            urlList = EntityDataLoader.getUrlList(helperName, readerNames);
+            urlList = EntityDataLoader.getUrlList(helperName, component, readerNames);
         } else if (!"none".equalsIgnoreCase(this.readers)) {
             urlList = EntityDataLoader.getUrlList(helperName);
         }