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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user