From ec22d58cacc664d81b5b00aee8453ff7f6ce4380 Mon Sep 17 00:00:00 2001 From: Andrew Zeneski Date: Wed, 21 Mar 2007 14:48:21 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@520902 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/base/component/ComponentConfig.java | 56 ++++++++++++------- .../ofbiz/entity/util/EntityDataLoader.java | 8 ++- .../data/EntityDataLoadContainer.java | 5 +- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java b/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java index d87069ad3a..e0cd0248d7 100644 --- a/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java +++ b/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java @@ -97,29 +97,41 @@ public class ComponentConfig { } 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 class ComponentConfig { } 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); + } } } } diff --git a/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java b/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java index f75c3dfea6..57747f78db 100644 --- a/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java +++ b/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java @@ -74,10 +74,14 @@ public class EntityDataLoader { 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 @@ public class EntityDataLoader { } // 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(); diff --git a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java index 9106efc3ec..5db5bd2ed1 100644 --- a/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java +++ b/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java @@ -52,6 +52,7 @@ public class EntityDataLoadContainer implements Container { 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 @@ public class EntityDataLoadContainer implements Container { } 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 @@ public class EntityDataLoadContainer implements Container { // 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); }