Improved: Add static modifiers in ‘EntityDataLoadContainer’
(OFBIZ-11070) When no reference to ‘this’ is made, it is better to declare methods as static. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+29
-28
@@ -131,7 +131,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
return name;
|
||||
}
|
||||
|
||||
private List<GenericValue> getTenantList(Property delegatorNameProp) throws ContainerException {
|
||||
private static List<GenericValue> getTenantList(Property delegatorNameProp) throws ContainerException {
|
||||
if (!EntityUtil.isMultiTenantEnabled()) {
|
||||
throw new ContainerException("Multitenant is disabled, must be enabled in general.properties -> multitenant=Y");
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadDataForDelegator(Map<String, String> loadDataProps, Configuration configuration,
|
||||
private static void loadDataForDelegator(Map<String, String> loadDataProps, Configuration configuration,
|
||||
Property delegatorNameProp, String overrideDelegator) throws ContainerException{
|
||||
|
||||
// prepare command line properties passed by user
|
||||
@@ -207,7 +207,8 @@ public class EntityDataLoadContainer implements Container {
|
||||
* Gets the default entity-group-name defined in the container definition
|
||||
* unless overridden by the user
|
||||
*/
|
||||
private String getEntityGroupNameFromConfig(Configuration cfg, String overrideGroup) throws ContainerException {
|
||||
private static String getEntityGroupNameFromConfig(Configuration cfg, String overrideGroup)
|
||||
throws ContainerException {
|
||||
if (overrideGroup != null) {
|
||||
return overrideGroup;
|
||||
} else {
|
||||
@@ -225,7 +226,8 @@ public class EntityDataLoadContainer implements Container {
|
||||
* overridden by the user. This method will create all the tables, keys and
|
||||
* indices if missing and hence might take a long time.
|
||||
*/
|
||||
private Delegator getDelegator(Property delegatorNameProp, String overrideDelegator) throws ContainerException {
|
||||
private static Delegator getDelegator(Property delegatorNameProp, String overrideDelegator)
|
||||
throws ContainerException {
|
||||
if (overrideDelegator != null) {
|
||||
return DelegatorFactory.getDelegator(overrideDelegator);
|
||||
} else {
|
||||
@@ -233,7 +235,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private Delegator getDelegatorFromProp(Property delegatorNameProp) throws ContainerException {
|
||||
private static Delegator getDelegatorFromProp(Property delegatorNameProp) throws ContainerException {
|
||||
if (delegatorNameProp != null && UtilValidate.isNotEmpty(delegatorNameProp.value)) {
|
||||
Delegator delegator = DelegatorFactory.getDelegator(delegatorNameProp.value);
|
||||
if (delegator != null) {
|
||||
@@ -246,7 +248,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private Delegator getBaseDelegator(Delegator delegator) {
|
||||
private static Delegator getBaseDelegator(Delegator delegator) {
|
||||
if (delegator.getDelegatorTenantId() != null) {
|
||||
return DelegatorFactory.getDelegator(delegator.getDelegatorBaseName());
|
||||
} else {
|
||||
@@ -254,7 +256,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private GenericHelperInfo getHelperInfo(Delegator delegator, String entityGroup) throws ContainerException {
|
||||
private static GenericHelperInfo getHelperInfo(Delegator delegator, String entityGroup) throws ContainerException {
|
||||
GenericHelperInfo helperInfo = delegator.getGroupHelperInfo(entityGroup);
|
||||
if (helperInfo == null) {
|
||||
throw new ContainerException("Unable to locate the datasource helper for the group: " + entityGroup);
|
||||
@@ -262,8 +264,8 @@ public class EntityDataLoadContainer implements Container {
|
||||
return helperInfo;
|
||||
}
|
||||
|
||||
private Map<String, ModelEntity> getModelEntities(Delegator delegator,
|
||||
String entityGroup) throws ContainerException {
|
||||
private static Map<String, ModelEntity> getModelEntities(Delegator delegator, String entityGroup)
|
||||
throws ContainerException {
|
||||
try {
|
||||
return delegator.getModelEntityMapByGroup(entityGroup);
|
||||
} catch (GenericEntityException e) {
|
||||
@@ -271,7 +273,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private void createOrUpdateComponentEntities(Delegator baseDelegator,
|
||||
private static void createOrUpdateComponentEntities(Delegator baseDelegator,
|
||||
Collection<ComponentConfig> allComponents) {
|
||||
|
||||
for (ComponentConfig config : allComponents) {
|
||||
@@ -294,7 +296,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private void dropDbConstraints(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
private static void dropDbConstraints(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
TreeSet<String> modelEntityNames) {
|
||||
|
||||
List<String> messages = new ArrayList<>();
|
||||
@@ -326,7 +328,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
logMessageList(messages);
|
||||
}
|
||||
|
||||
private void createDbConstraints(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
private static void createDbConstraints(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
TreeSet<String> modelEntityNames) {
|
||||
|
||||
List<String> messages = new ArrayList<>();
|
||||
@@ -358,7 +360,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
logMessageList(messages);
|
||||
}
|
||||
|
||||
private void dropPrimaryKeys(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
private static void dropPrimaryKeys(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
TreeSet<String> modelEntityNames) {
|
||||
|
||||
List<String> messages = new ArrayList<>();
|
||||
@@ -374,7 +376,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
logMessageList(messages);
|
||||
}
|
||||
|
||||
private void createPrimaryKeys(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
private static void createPrimaryKeys(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities,
|
||||
TreeSet<String> modelEntityNames) {
|
||||
|
||||
List<String> messages = new ArrayList<>();
|
||||
@@ -390,7 +392,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
logMessageList(messages);
|
||||
}
|
||||
|
||||
private void repairDbColumns(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities) {
|
||||
private static void repairDbColumns(DatabaseUtil dbUtil, Map<String, ModelEntity> modelEntities) {
|
||||
List<String> fieldsToRepair = new ArrayList<>();
|
||||
List<String> messages = new ArrayList<>();
|
||||
dbUtil.checkDb(modelEntities, fieldsToRepair, messages, false, false, false, false);
|
||||
@@ -401,15 +403,14 @@ public class EntityDataLoadContainer implements Container {
|
||||
logMessageList(messages);
|
||||
}
|
||||
|
||||
private void logMessageList(List<String> messages) {
|
||||
private static void logMessageList(List<String> messages) {
|
||||
if (Debug.infoOn()) {
|
||||
messages.forEach(message -> Debug.logInfo(message, module));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadData(Delegator delegator, Delegator baseDelegator,
|
||||
Collection<ComponentConfig> allComponents,
|
||||
GenericHelperInfo helperInfo,
|
||||
private static void loadData(Delegator delegator, Delegator baseDelegator,
|
||||
Collection<ComponentConfig> allComponents, GenericHelperInfo helperInfo,
|
||||
Map<String, String> loadDataProps) throws ContainerException {
|
||||
|
||||
// prepare command line properties passed by user
|
||||
@@ -444,7 +445,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
logDataLoadingResults(infoMessages, errorMessages, totalRowsChanged);
|
||||
}
|
||||
|
||||
private int getTransactionTimeout(String timeout) {
|
||||
private static int getTransactionTimeout(String timeout) {
|
||||
try {
|
||||
return Integer.parseInt(timeout);
|
||||
} catch (Exception e) {
|
||||
@@ -452,7 +453,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private List<URL> prepareDataUrls(Delegator delegator, Delegator baseDelegator,
|
||||
private static List<URL> prepareDataUrls(Delegator delegator, Delegator baseDelegator,
|
||||
Collection<ComponentConfig> allComponents, GenericHelperInfo helperInfo,
|
||||
Map<String, String> loadDataProps) throws ContainerException {
|
||||
|
||||
@@ -493,7 +494,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
return urlList;
|
||||
}
|
||||
|
||||
private List<String> getLoadFiles(String fileProp) {
|
||||
static private List<String> getLoadFiles(String fileProp) {
|
||||
List<String> fileList = new ArrayList<>();
|
||||
Optional.ofNullable(fileProp)
|
||||
.ifPresent(props -> fileList.addAll(StringUtil.split(props, ",")));
|
||||
@@ -506,7 +507,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
return readers != null || (files.isEmpty() && directory == null);
|
||||
}
|
||||
|
||||
private List<String> prepareTenantLoadComponents(Delegator delegator, Delegator baseDelegator,
|
||||
private static List<String> prepareTenantLoadComponents(Delegator delegator, Delegator baseDelegator,
|
||||
Collection<ComponentConfig> allComponents, String component) {
|
||||
|
||||
List<String> loadComponents = new ArrayList<>();
|
||||
@@ -536,7 +537,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
return loadComponents;
|
||||
}
|
||||
|
||||
private List<URL> retireveDataUrlsFromFileList(List<String> files) throws ContainerException {
|
||||
private static List<URL> retireveDataUrlsFromFileList(List<String> files) throws ContainerException {
|
||||
List<URL> fileUrls = new ArrayList<>();
|
||||
for(String file: files) {
|
||||
URL url = UtilURL.fromResource(file);
|
||||
@@ -549,7 +550,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
return fileUrls;
|
||||
}
|
||||
|
||||
private List<URL> retrieveDataUrlsFromDirectory(String directory) {
|
||||
private static List<URL> retrieveDataUrlsFromDirectory(String directory) {
|
||||
return Optional.ofNullable(directory)
|
||||
.map(dir -> Arrays.asList(new File(dir).listFiles()).stream()
|
||||
.filter(file -> file.getName().toLowerCase(Locale.getDefault()).endsWith(".xml"))
|
||||
@@ -558,7 +559,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
.orElse(new ArrayList<URL>());
|
||||
}
|
||||
|
||||
private void logDataLoadingPlan(List<URL> urlList, String delegatorName) {
|
||||
private static void logDataLoadingPlan(List<URL> urlList, String delegatorName) {
|
||||
if (UtilValidate.isNotEmpty(urlList)) {
|
||||
Debug.logImportant("=-=-=-=-=-=-= Doing a data load using delegator '"
|
||||
+ delegatorName + "' with the following files:", module);
|
||||
@@ -569,7 +570,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
}
|
||||
}
|
||||
|
||||
private String createDataLoadMessage(URL dataUrl, int rowsChanged, int totalRowsChanged) {
|
||||
private static String createDataLoadMessage(URL dataUrl, int rowsChanged, int totalRowsChanged) {
|
||||
NumberFormat formatter = NumberFormat.getIntegerInstance();
|
||||
formatter.setMinimumIntegerDigits(5);
|
||||
formatter.setGroupingUsed(false);
|
||||
@@ -578,7 +579,7 @@ public class EntityDataLoadContainer implements Container {
|
||||
+ " from " + dataUrl.toExternalForm();
|
||||
}
|
||||
|
||||
private void logDataLoadingResults(List<String> infoMessages,
|
||||
private static void logDataLoadingResults(List<String> infoMessages,
|
||||
List<Object> errorMessages, int totalRowsChanged) {
|
||||
|
||||
if (UtilValidate.isNotEmpty(infoMessages)) {
|
||||
|
||||
Reference in New Issue
Block a user