Author: mthl
Date: Sat Jun 8 14:59:02 2019 New Revision: 1860838 URL: http://svn.apache.org/viewvc?rev=1860838&view=rev Log: Improved: Add static modifiers in ‘EntityDataLoadContainer’ (OFBIZ-11070) When no reference to ‘this’ is made, it is better to declare methods as static. Modified: ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java Modified: ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=1860838&r1=1860837&r2=1860838&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java Sat Jun 8 14:59:02 2019 @@ -131,7 +131,7 @@ public class EntityDataLoadContainer imp 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 imp } } - 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 imp * 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 imp * 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 imp } } - 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 imp } } - 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 imp } } - 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 imp 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 imp } } - 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 imp } } - 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 imp 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 imp 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 imp 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 imp 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 imp 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 imp 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 imp } } - 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 imp 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 imp 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 imp 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 imp 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 imp .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 imp } } - 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 imp + " 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)) { |
Free forum by Nabble | Edit this page |