This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git The following commit(s) were added to refs/heads/trunk by this push: new 403fc39 Improved: Added missing Javadocs for some methods, this is required for all classes which looks like designed for extension (can be subclassed). (OFBIZ-11947) This is done for plugins component. Also corrected some variables as per naming convention best practices. Thanks Jacques for review. 403fc39 is described below commit 403fc39d7f1a0687e427218398c6523f5c1173dc Author: Suraj Khurana <[hidden email]> AuthorDate: Mon Aug 17 12:29:08 2020 +0530 Improved: Added missing Javadocs for some methods, this is required for all classes which looks like designed for extension (can be subclassed). (OFBIZ-11947) This is done for plugins component. Also corrected some variables as per naming convention best practices. Thanks Jacques for review. --- .../apache/ofbiz/birt/email/BirtEmailServices.java | 1 - .../ofbiz/birt/flexible/ReportDesignGenerator.java | 2 - .../java/org/apache/ofbiz/ebaystore/EbayStore.java | 2 +- .../org/apache/ofbiz/ldap/LdapLoginWorker.java | 3 - .../ldap/cas/OFBizCasAuthenticationHandler.java | 1 - .../AbstractOFBizAuthenticationHandler.java | 1 - .../InterfaceOFBizAuthenticationHandler.java | 11 -- .../ofbiz/passport/user/GitHubAuthenticator.java | 10 - .../ofbiz/passport/user/LinkedInAuthenticator.java | 9 - .../apache/ofbiz/htmlreport/AbstractReport.java | 3 - .../org/apache/ofbiz/htmlreport/HtmlReport.java | 4 - .../apache/ofbiz/htmlreport/InterfaceReport.java | 3 - .../apache/ofbiz/pricat/AbstractPricatParser.java | 204 ++++++++++++++++++--- .../apache/ofbiz/pricat/InterfacePricatParser.java | 16 +- .../java/org/apache/ofbiz/pricat/PricatEvents.java | 4 +- .../ofbiz/pricat/PricatParseExcelHtmlThread.java | 15 +- .../ofbiz/pricat/sample/SamplePricatParser.java | 87 +++++---- .../apache/ofbiz/pricat/util/OFBizPricatUtil.java | 22 ++- .../java/org/apache/ofbiz/scrum/ScrumServices.java | 3 - .../ofbiz/solr/control/OFBizSolrLoginWorker.java | 1 - .../ofbiz/solr/webapp/OFBizSolrContextFilter.java | 1 - .../webpos/transaction/WebPosTransaction.java | 88 ++++----- 22 files changed, 309 insertions(+), 182 deletions(-) diff --git a/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java b/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java index 01c5487..0005026 100644 --- a/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java +++ b/birt/src/main/java/org/apache/ofbiz/birt/email/BirtEmailServices.java @@ -67,7 +67,6 @@ public class BirtEmailServices { private static final String RESOURCE = "BirtUiLabels"; /** * send birt mail - * * @param ctx the dispatch context * @param context the context * @return returns the result of the service execution diff --git a/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java b/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java index adb910f..e0ef2f7 100644 --- a/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java +++ b/birt/src/main/java/org/apache/ofbiz/birt/flexible/ReportDesignGenerator.java @@ -107,7 +107,6 @@ public class ReportDesignGenerator { /** * Generate report design (rtdesign file). - * * @throws IOException * @throws GeneralException * @throws BirtException @@ -260,7 +259,6 @@ public class ReportDesignGenerator { * Create the script that will define the OFBiz dataset in Birt Report design. * <p>This dataset will populate the OFBiz datasource of the design * with <code>records</code> returned by <code>serviceName</code> service</p> - * * @throws SemanticException * @throws GeneralException */ diff --git a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java index 94139e8..9267e43 100644 --- a/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java +++ b/ebaystore/src/main/java/org/apache/ofbiz/ebaystore/EbayStore.java @@ -598,7 +598,7 @@ public class EbayStore { String partyId = (productStores.get(0)).getString("partyId"); List<GenericValue> userLoginStore = EntityQuery.use(delegator).from("UserLogin").where("partyId", partyId).queryList(); if (userLoginStore.size() != 0) { - String userLoginId = (userLoginStore.get(0)).getString("userLoginId"); + String userLoginId = (userLoginStore.get(0)).getString("userLoginId"); result.put("userLoginId", userLoginId); } } diff --git a/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java b/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java index f8f8c26..f2e8314 100644 --- a/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java +++ b/ldap/src/main/java/org/apache/ofbiz/ldap/LdapLoginWorker.java @@ -55,7 +55,6 @@ public final class LdapLoginWorker { /** * An HTTP WebEvent handler that checks to see is a userLogin is logged in. * If not, the user is forwarded to the login page. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @return String @@ -105,7 +104,6 @@ public final class LdapLoginWorker { /** * An HTTP WebEvent handler that logs in a userLogin. This should run before the security check. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @return Return a boolean which specifies whether or not the calling Servlet or @@ -143,7 +141,6 @@ public final class LdapLoginWorker { /** * An HTTP WebEvent handler that logs out a userLogin by clearing the session. - * * @param request The HTTP request object for the current request. * @param response The HTTP response object for the current request. * @return Return a boolean which specifies whether or not the calling request diff --git a/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java b/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java index cc92e9e..c097ab2 100644 --- a/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java +++ b/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java @@ -171,7 +171,6 @@ public final class OFBizCasAuthenticationHandler extends AbstractOFBizAuthentica /** * An HTTP WebEvent handler that checks to see is a userLogin is logged out. * If yes, the user is forwarded to the login page. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @param rootElement Element root element of ldap config file diff --git a/ldap/src/main/java/org/apache/ofbiz/ldap/commons/AbstractOFBizAuthenticationHandler.java b/ldap/src/main/java/org/apache/ofbiz/ldap/commons/AbstractOFBizAuthenticationHandler.java index cf287ea..85632d1 100644 --- a/ldap/src/main/java/org/apache/ofbiz/ldap/commons/AbstractOFBizAuthenticationHandler.java +++ b/ldap/src/main/java/org/apache/ofbiz/ldap/commons/AbstractOFBizAuthenticationHandler.java @@ -156,7 +156,6 @@ public abstract class AbstractOFBizAuthenticationHandler implements InterfaceOFB /** * An HTTP WebEvent handler that checks to see is a userLogin is logged out. * If yes, the user is forwarded to the login page. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @param rootElement Element root element of ldap config file diff --git a/ldap/src/main/java/org/apache/ofbiz/ldap/commons/InterfaceOFBizAuthenticationHandler.java b/ldap/src/main/java/org/apache/ofbiz/ldap/commons/InterfaceOFBizAuthenticationHandler.java index 0c4f328..9461374 100644 --- a/ldap/src/main/java/org/apache/ofbiz/ldap/commons/InterfaceOFBizAuthenticationHandler.java +++ b/ldap/src/main/java/org/apache/ofbiz/ldap/commons/InterfaceOFBizAuthenticationHandler.java @@ -34,11 +34,9 @@ public interface InterfaceOFBizAuthenticationHandler { /** * Login a user. - * * @param request HttpServletRequest * @param response HttpServletResponse * @param rootElement Element root element of ldap config file - * * @return success if the user can login successfully; otherwise, error. * @throws Exception */ @@ -46,43 +44,35 @@ public interface InterfaceOFBizAuthenticationHandler { /** * Get the security group of a user. - * * @param rootElement Element root element of ldap config file * @param result SearchResult - * * @return the SecurityGroup object. */ Object getSecurityGroup(Element rootElement, SearchResult result); /** * Get the party id of a user. - * * @param rootElement Element root element of ldap config file * @param result SearchResult - * * @return the PartyId object. */ Object getPartyId(Element rootElement, SearchResult result); /** * Logout a user. - * * @param request HttpServletRequest * @param response HttpServletResponse * @param rootElement Element root element of ldap config file - * * @return success if the user can login successfully; otherwise, error. */ String logout(HttpServletRequest request, HttpServletResponse response, Element rootElement); /** * Get LDAP search result from a username, password and configuration. - * * @param username String * @param password String * @param rootElement Element root element of ldap config file * @param bindRequired boolean if true, bind; false, just search the user in LDAP - * * @return result SearchResult if ldap search successfully; otherwise, null. * @throws NamingException */ @@ -92,7 +82,6 @@ public interface InterfaceOFBizAuthenticationHandler { * An HTTP WebEvent handler that checks to see is a userLogin is logged out in ldap. * If yes, the user is forwarded to the login page. * Currently, this function is only used in CAS authentication handler. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @param rootElement Element root element of ldap config file diff --git a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java index dcc932b..1467b49 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/user/GitHubAuthenticator.java @@ -28,7 +28,6 @@ import java.sql.Timestamp; import javax.transaction.Transaction; import org.apache.ofbiz.passport.event.GitHubEvents; -import org.apache.ofbiz.passport.user.GitHubUserGroupMapper; import org.apache.ofbiz.passport.util.PassportUtil; import org.apache.ofbiz.common.authentication.api.Authenticator; import org.apache.ofbiz.common.authentication.api.AuthenticatorException; @@ -75,7 +74,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Method called when authenticator is first initialized (the delegator * object can be obtained from the LocalDispatcher) - * * @param dispatcher The ServiceDispatcher to use for this Authenticator */ @Override @@ -89,7 +87,6 @@ public class GitHubAuthenticator implements Authenticator { * For GitHub users, we only check if the username(userLoginId) exists an * externalAuthId, and the externalAuthId has a valid accessToken in * GitHubUser entity. - * * @param userLoginId User's login id * @param password User's password * @param isServiceAuth true if authentication is for a service call @@ -127,7 +124,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Logs a user out - * * @param username User's username * @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException * when logout fails @@ -138,7 +134,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Reads user information and syncs it to OFBiz (i.e. UserLogin, Person, etc) - * * @param userLoginId * @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException * user synchronization fails @@ -330,7 +325,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Updates a user's password. - * * @param username User's username * @param password User's current password * @param newPassword User's new password @@ -344,7 +338,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Weight of this authenticator (lower weights are run first) - * * @return the weight of this Authenicator */ @Override @@ -354,7 +347,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Is the user synchronzied back to OFBiz - * * @return true if the user record is copied to the OFB database */ @Override @@ -364,7 +356,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Is this expected to be the only authenticator, if so errors will be thrown when users cannot be found - * * @return true if this is expected to be the only Authenticator */ @Override @@ -374,7 +365,6 @@ public class GitHubAuthenticator implements Authenticator { /** * Flag to test if this Authenticator is enabled - * * @return true if the Authenticator is enabled */ @Override diff --git a/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java b/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java index 032590a..89ac486 100644 --- a/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java +++ b/passport/src/main/java/org/apache/ofbiz/passport/user/LinkedInAuthenticator.java @@ -76,7 +76,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Method called when authenticator is first initialized (the delegator * object can be obtained from the LocalDispatcher) - * * @param dispatcher The ServiceDispatcher to use for this Authenticator */ @Override @@ -90,7 +89,6 @@ public class LinkedInAuthenticator implements Authenticator { * For LinkedIn users, we only check if the username(userLoginId) exists an * externalAuthId, and the externalAuthId has a valid accessToken in * LinkedInUser entity. - * * @param userLoginId User's login id * @param password User's password * @param isServiceAuth true if authentication is for a service call @@ -129,7 +127,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Logs a user out - * * @param username User's username * @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException * when logout fails @@ -140,7 +137,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Reads user information and syncs it to OFBiz (i.e. UserLogin, Person, etc) - * * @param userLoginId * @throws org.apache.ofbiz.common.authentication.api.AuthenticatorException * user synchronization fails @@ -342,7 +338,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Updates a user's password. - * * @param username User's username * @param password User's current password * @param newPassword User's new password @@ -356,7 +351,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Weight of this authenticator (lower weights are run first) - * * @return the weight of this Authenicator */ @Override @@ -366,7 +360,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Is the user synchronzied back to OFBiz - * * @return true if the user record is copied to the OFB database */ @Override @@ -376,7 +369,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Is this expected to be the only authenticator, if so errors will be thrown when users cannot be found - * * @return true if this is expected to be the only Authenticator */ @Override @@ -386,7 +378,6 @@ public class LinkedInAuthenticator implements Authenticator { /** * Flag to test if this Authenticator is enabled - * * @return true if the Authenticator is enabled */ @Override diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java index 529f32f..f1bf262 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java @@ -146,7 +146,6 @@ public abstract class AbstractReport implements InterfaceReport { /** * Prints a String to the report.<p> - * * @param value the String to add */ @Override @@ -158,7 +157,6 @@ public abstract class AbstractReport implements InterfaceReport { * Prints a String to the report, using the indicated formatting.<p> * Use the contants starting with <code>FORMAT</code> from this interface * to indicate which formatting to use.<p> - * * @param value the message container to add * @param format the formatting to use for the output */ @@ -179,7 +177,6 @@ public abstract class AbstractReport implements InterfaceReport { * Prints a String with line break to the report, using the indicated formatting.<p> * Use the contants starting with <code>FORMAT</code> from this interface * to indicate which formatting to use.<p> - * * @param value the String to add * @param format the formatting to use for the output */ diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java index c3670d3..3adabb6 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java @@ -557,7 +557,6 @@ public class HtmlReport extends AbstractReport { /** * Returns the thread parameter value.<p> - * * @return the thread parameter value */ public String getParamThread(HttpServletRequest request) { @@ -567,7 +566,6 @@ public class HtmlReport extends AbstractReport { /** * Returns the threadhasnext parameter value.<p> - * * @return the threadhasnext parameter value */ public String getParamThreadHasNext(HttpServletRequest request) { @@ -1188,9 +1186,7 @@ public class HtmlReport extends AbstractReport { /** * Returns the http URI of the current dialog, to be used * as value for the "action" attribute of a html form.<p> - * * This URI is the real one.<p> - * * @return the http URI of the current dialog */ public String getDialogRealUri(HttpServletRequest request) { diff --git a/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java b/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java index 58b8fda..e4fd320 100644 --- a/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java +++ b/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java @@ -125,7 +125,6 @@ public interface InterfaceReport { * Prints a localized message to the report, using the indicated formatting.<p> * Use the contants starting with <code>FORMAT</code> from this interface * to indicate which formatting to use.<p> - * * @param uiLabel the String to add * @param format the formatting to use for the output */ @@ -144,10 +143,8 @@ public interface InterfaceReport { /** * Prints a localized message to the report, using the indicated formatting.<p> - * * Use the contents starting with <code>FORMAT</code> from this interface * to indicate which formatting to use. - * * @param uiLabel the message container to add * @param format the formatting to use for the output */ diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java index c7094b1..eca0871 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java @@ -78,25 +78,182 @@ import org.apache.ofbiz.service.ServiceUtil; public abstract class AbstractPricatParser implements InterfacePricatParser { private static final String MODULE = AbstractPricatParser.class.getName(); - protected LocalDispatcher dispatcher; - protected Delegator delegator; - protected List<FileItem> fileItems; - protected File pricatFile; - protected String userLoginId; - protected GenericValue userLogin; - protected String pricatFileVersion; - protected String currencyId; - protected Map<CellReference, String> errorMessages = new HashMap<>(); - protected HSSFDataFormatter formatter = new HSSFDataFormatter(); - protected Map<String, String[]> facilities = new HashMap<>(); - protected HttpSession session; - protected List<EntityCondition> basicCategoryConds; - protected List<EntityCondition> basicBrandConds; - protected String selectedPricatType = DEFAULT_PRICAT_TYPE; - protected String selectedFacilityId; - protected InterfaceReport report; - protected Locale locale; - protected long sequenceNum = -1L; + private LocalDispatcher dispatcher; + private Delegator delegator; + private List<FileItem> fileItems; + private File pricatFile; + private String userLoginId; + private GenericValue userLogin; + private String pricatFileVersion; + private String currencyId; + private Map<CellReference, String> errorMessages = new HashMap<>(); + private HSSFDataFormatter formatter = new HSSFDataFormatter(); + private Map<String, String[]> facilities = new HashMap<>(); + private HttpSession session; + private List<EntityCondition> basicCategoryConds; + private List<EntityCondition> basicBrandConds; + private String selectedPricatType = DEFAULT_PRICAT_TYPE; + private String selectedFacilityId; + private InterfaceReport report; + private Locale locale; + private long sequenceNum = -1L; + /** + * Gets pricat file version. + * @return the pricat file version + */ + public String getPricatFileVersion() { + return pricatFileVersion; + } + /** + * Gets delegator. + * @return the delegator + */ + public Delegator getDelegator() { + return delegator; + } + + /** + * Sets delegator. + * @param delegator the delegator + */ + public void setDelegator(Delegator delegator) { + this.delegator = delegator; + } + + /** + * Gets file items. + * @return the file items + */ + public List<FileItem> getFileItems() { + return fileItems; + } + + /** + * Sets file items. + * @param fileItems the file items + */ + public void setFileItems(List<FileItem> fileItems) { + this.fileItems = fileItems; + } + + /** + * Gets currency id. + * @return the currency id + */ + public String getCurrencyId() { + return currencyId; + } + + /** + * Sets currency id. + * @param currencyId the currency id + */ + public void setCurrencyId(String currencyId) { + this.currencyId = currencyId; + } + + /** + * Gets sequence num. + * @return the sequence num + */ + public long getSequenceNum() { + return sequenceNum; + } + + /** + * Sets sequence num. + * @param sequenceNum the sequence num + */ + public void setSequenceNum(long sequenceNum) { + this.sequenceNum = sequenceNum; + } + /** + * Gets pricat file. + * @return the pricat file + */ + public File getPricatFile() { + return pricatFile; + } + + /** + * Sets pricat file. + * @param pricatFile the pricat file + */ + public void setPricatFile(File pricatFile) { + this.pricatFile = pricatFile; + } + + /** + * Gets formatter. + * @return the formatter + */ + public HSSFDataFormatter getFormatter() { + return formatter; + } + + /** + * Sets formatter. + * @param formatter the formatter + */ + public void setFormatter(HSSFDataFormatter formatter) { + this.formatter = formatter; + } + + /** + * Gets error messages. + * @return the error messages + */ + public Map<CellReference, String> getErrorMessages() { + return errorMessages; + } + + /** + * Sets error messages. + * @param errorMessages the error messages + */ + public void setErrorMessages(Map<CellReference, String> errorMessages) { + this.errorMessages = errorMessages; + } + + /** + * Gets facilities. + * @return the facilities + */ + public Map<String, String[]> getFacilities() { + return facilities; + } + + /** + * Sets facilities. + * @param facilities the facilities + */ + public void setFacilities(Map<String, String[]> facilities) { + this.facilities = facilities; + } + + /** + * Gets report. + * @return the report + */ + public InterfaceReport getReport() { + return report; + } + + /** + * Sets report. + * @param report the report + */ + public void setReport(InterfaceReport report) { + this.report = report; + } + + /** + * Gets locale. + * @return the locale + */ + public Locale getLocale() { + return locale; + } public AbstractPricatParser(LocalDispatcher dispatcher, Delegator delegator, Locale locale, InterfaceReport report, Map<String, String[]> facilities, File pricatFile, GenericValue userLogin) { @@ -115,7 +272,6 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { /** * Check whether a commented file exists. - * * @param request * @param sequenceNum * @return @@ -140,7 +296,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { Debug.logError("No ExcelImportHistory value found by sequenceNum[" + sequenceNum + "] and userLoginId[" + userLoginId + "].", MODULE); return false; } - File file = FileUtil.getFile(tempFilesFolder + userLoginId + "/" + sequenceNum + ".xlsx"); + File file = FileUtil.getFile(TEMP_FILES_FOLDER + userLoginId + "/" + sequenceNum + ".xlsx"); return file.exists(); } @@ -264,7 +420,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { // write to file if (sequenceNum > 0L) { - File commentedExcel = FileUtil.getFile(tempFilesFolder + userLoginId + "/" + sequenceNum + ".xlsx"); + File commentedExcel = FileUtil.getFile(TEMP_FILES_FOLDER + userLoginId + "/" + sequenceNum + ".xlsx"); fos = new FileOutputStream(commentedExcel); workbook.write(fos); } else { @@ -624,7 +780,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { for (int i = HISTORY_MAX_FILENUMBER; i < historyValues.size(); i++) { GenericValue historyValue = historyValues.get(i); valuesToRemove.add(historyValue); - File excelFile = FileUtil.getFile(tempFilesFolder + userLoginId + "/" + historyValue.getLong("sequenceNum") + ".xlsx"); + File excelFile = FileUtil.getFile(TEMP_FILES_FOLDER + userLoginId + "/" + historyValue.getLong("sequenceNum") + ".xlsx"); if (excelFile.exists()) { try { excelFile.delete(); @@ -633,7 +789,7 @@ public abstract class AbstractPricatParser implements InterfacePricatParser { report.print(e.getMessage(), InterfaceReport.FORMAT_ERROR); } } - File logFile = FileUtil.getFile(tempFilesFolder + userLoginId + "/" + historyValue.getLong("sequenceNum") + ".log"); + File logFile = FileUtil.getFile(TEMP_FILES_FOLDER + userLoginId + "/" + historyValue.getLong("sequenceNum") + ".log"); if (logFile.exists()) { try { logFile.delete(); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/InterfacePricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/InterfacePricatParser.java index bd42461..0abe72c 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/InterfacePricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/InterfacePricatParser.java @@ -37,19 +37,19 @@ import org.apache.ofbiz.entity.transaction.GenericTransactionException; public interface InterfacePricatParser { String PARSE_EXCEL = "parse_excel"; String CONFIRM = "confirm_action"; - String[] messageLabels = new String[] {"FORMAT_DEFAULT", "FORMAT_WARNING", "FORMAT_HEADLINE", "FORMAT_NOTE", "FORMAT_OK", "FORMAT_ERROR", "FORMAT_THROWABLE"}; - List<String> messages = Collections.unmodifiableList(Arrays.asList(messageLabels)); - String tempFilesFolder = "runtime/pricat/"; - String FileDateTimePattern = "yyyyMMddHHmmss"; - String defaultColorName = "DefaultColor"; - String defaultDimensionName = "DefaultDimension"; - String defaultCategoryName = "DefaultCategory"; + String[] MESSAGE_LABELS = new String[] {"FORMAT_DEFAULT", "FORMAT_WARNING", "FORMAT_HEADLINE", "FORMAT_NOTE", "FORMAT_OK", "FORMAT_ERROR", "FORMAT_THROWABLE"}; + List<String> MESSAGES = Collections.unmodifiableList(Arrays.asList(MESSAGE_LABELS)); + String TEMP_FILES_FOLDER = "runtime/pricat/"; + String FILE_DATETIME_PATTERN = "yyyyMMddHHmmss"; + String DEFAULT_COL_NAME = "DefaultColor"; + String DEFAULT_DIM_NAME = "DefaultDimension"; + String DEFAULT_CAT_NAME = "DefaultCategory"; String EXCEL_TEMPLATE_TYPE = "excelTemplateType"; String FACILITY_ID = "facilityId"; String RESOURCE = "PricatUiLabels"; String PRICAT_FILE = "__PRICAT_FILE__"; String DEFAULT_PRICAT_TYPE = "ApacheOFBiz"; - Map<String, String> PricatTypeLabels = UtilMisc.toMap(DEFAULT_PRICAT_TYPE, "ApacheOFBizPricatTemplate", "SamplePricat", "SamplePricatTemplate"); + Map<String, String> PRICAT_TYPE_LABELS = UtilMisc.toMap(DEFAULT_PRICAT_TYPE, "ApacheOFBizPricatTemplate", "SamplePricat", "SamplePricatTemplate"); int HISTORY_MAX_FILENUMBER = UtilProperties.getPropertyAsInteger("pricat.properties", "pricat.history.max.filenumber", 20); void parsePricatExcel(); void writeCommentsToFile(XSSFWorkbook workbook, XSSFSheet sheet); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java index dbb55ab..42b6ebe 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java @@ -97,7 +97,7 @@ public class PricatEvents { if (sequenceNum > 0 && AbstractPricatParser.isCommentedExcelExists(request, sequenceNum)) { GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin"); String userLoginId = userLogin.getString("userLoginId"); - pricatFileName = InterfacePricatParser.tempFilesFolder + userLoginId + "/" + sequenceNum + ".xlsx"; + pricatFileName = InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + sequenceNum + ".xlsx"; } if (UtilValidate.isNotEmpty(pricatFileName) && UtilValidate.isNotEmpty(originalPricatFileName)) { try { @@ -148,7 +148,7 @@ public class PricatEvents { fileName = sequenceNum + ".xlsx"; } try { - File file = FileUtil.getFile(InterfacePricatParser.tempFilesFolder + userLoginId + "/" + sequenceNum + ".xlsx"); + File file = FileUtil.getFile(InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + sequenceNum + ".xlsx"); if (file.exists()) { Path path = Paths.get(file.getPath()); byte[] bytes = Files.readAllBytes(path); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java index bf483d7..20e3b73 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java @@ -96,7 +96,6 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { /** * Constructor, creates a new html thread. - * * @param request * @param response * @param name @@ -116,11 +115,11 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { session = request.getSession(); } long sequenceNum = addExcelImportHistory(); - File userFolder = FileUtil.getFile(InterfacePricatParser.tempFilesFolder + userLoginId + "/"); + File userFolder = FileUtil.getFile(InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/"); if (!userFolder.exists()) { userFolder.mkdirs(); } - String logFileName = InterfacePricatParser.tempFilesFolder + userLoginId + "/" + sequenceNum + ".log"; + String logFileName = InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + sequenceNum + ".log"; initHtmlReport(request, response, true, true, logFileName); if (sequenceNum > 0) { getReport().setSequenceNum(sequenceNum); @@ -239,7 +238,7 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { pricatFi = fi; pricatBytes = pricatFi.get(); Path path = Paths.get(fi.getName()); - pricatFile = new File(InterfacePricatParser.tempFilesFolder + userLoginId + "/" + path.getFileName().toString()); + pricatFile = new File(InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + path.getFileName().toString()); FileOutputStream fos = new FileOutputStream(pricatFile); fos.write(pricatBytes); fos.flush(); @@ -301,15 +300,15 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { } return facilities; } - + /** getDelegator */ public Delegator getDelegator() { return delegator; } - + /** setDelegator */ public void setDelegator(Delegator delegator) { this.delegator = delegator; } - + /** addExcelImportHistory */ public synchronized long addExcelImportHistory() { long latestId = 1; try { @@ -322,7 +321,7 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { userLoginId, "fileName", pricatFile == null ? "" : pricatFile.getName(), "statusId", isAlive() ? "EXCEL_IMPORTING" : "EXCEL_IMPORTED", "fromDate", UtilDateTime.nowTimestamp(), "threadName", getName(), "logFileName", - InterfacePricatParser.tempFilesFolder + userLoginId + "/" + latestId + ".log")); + InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + latestId + ".log")); newHistoryValue.create(); } catch (GenericEntityException e) { Debug.logError(e, MODULE); diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java index 89acdcc..85b76c8 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java @@ -71,7 +71,6 @@ public class SamplePricatParser extends AbstractPricatParser { * 2. Cell data type to return. * 3. Boolean value to indicate whether the column is required. * 4. Boolean value to indicate whether the column is a price when cell data type is BigDecimal, this element is optional. - * * @param version * @return List of Object[] */ @@ -85,7 +84,6 @@ public class SamplePricatParser extends AbstractPricatParser { /** * Get V1.1 pricat excel header names and attributes. - * * @return list of Object[] */ private static List<Object[]> genExcelHeaderNamesV1() { @@ -151,23 +149,23 @@ public class SamplePricatParser extends AbstractPricatParser { XSSFWorkbook workbook = null; try { // 1. read the pricat excel file - FileInputStream is = new FileInputStream(pricatFile); + FileInputStream is = new FileInputStream(getPricatFile()); // 2. use POI to load this bytes - report.print(UtilProperties.getMessage(RESOURCE, "ParsePricatFileStatement", new Object[]{pricatFile.getName()}, locale), + getReport().print(UtilProperties.getMessage(RESOURCE, "ParsePricatFileStatement", new Object[]{getPricatFile().getName()}, getLocale()), InterfaceReport.FORMAT_DEFAULT); try { workbook = new XSSFWorkbook(is); - report.println(UtilProperties.getMessage(RESOURCE, "ok", locale), InterfaceReport.FORMAT_OK); + getReport().println(UtilProperties.getMessage(RESOURCE, "ok", getLocale()), InterfaceReport.FORMAT_OK); } catch (IOException e) { - report.println(e); - report.println(UtilProperties.getMessage(RESOURCE, "PricatSuggestion", locale), InterfaceReport.FORMAT_ERROR); + getReport().println(e); + getReport().println(UtilProperties.getMessage(RESOURCE, "PricatSuggestion", getLocale()), InterfaceReport.FORMAT_ERROR); return; } // 3. only first sheet will be parsed // 3.1 verify the file has a sheet at least - formatter = new HSSFDataFormatter(locale); + setFormatter(new HSSFDataFormatter(getLocale())); isNumOfSheetsOK(workbook); // 3.2 verify the version is supported @@ -187,18 +185,18 @@ public class SamplePricatParser extends AbstractPricatParser { // 3.5 verify the first table has 6 rows at least containsDataRows(sheet); - if (UtilValidate.isNotEmpty(errorMessages)) { - report.println(UtilProperties.getMessage(RESOURCE, "HeaderContainsError", locale), InterfaceReport.FORMAT_ERROR); + if (UtilValidate.isNotEmpty(getErrorMessages())) { + getReport().println(UtilProperties.getMessage(RESOURCE, "HeaderContainsError", getLocale()), InterfaceReport.FORMAT_ERROR); return; } // 4. parse data // 4.1 parse row by row and store the contents into database parseRowByRow(sheet); - if (UtilValidate.isNotEmpty(errorMessages)) { - report.println(UtilProperties.getMessage(RESOURCE, "DataContainsError", locale), InterfaceReport.FORMAT_ERROR); + if (UtilValidate.isNotEmpty(getErrorMessages())) { + getReport().println(UtilProperties.getMessage(RESOURCE, "DataContainsError", getLocale()), InterfaceReport.FORMAT_ERROR); if (writeFile) { - sequenceNum = report.getSequenceNum(); + setSequenceNum(getReport().getSequenceNum()); writeCommentsToFile(workbook, sheet); } } @@ -206,14 +204,14 @@ public class SamplePricatParser extends AbstractPricatParser { // 5. clean up the log files and commented Excel files cleanupLogAndCommentedExcel(); } catch (IOException e) { - report.println(e); + getReport().println(e); Debug.logError(e, MODULE); } finally { - if (UtilValidate.isNotEmpty(fileItems)) { + if (UtilValidate.isNotEmpty(getFileItems())) { // remove tmp files FileItem fi = null; - for (int i = 0; i < fileItems.size(); i++) { - fi = fileItems.get(i); + for (int i = 0; i < getFileItems().size(); i++) { + fi = getFileItems().get(i); fi.delete(); } } @@ -229,9 +227,13 @@ public class SamplePricatParser extends AbstractPricatParser { /** exists currency id */ @Override public boolean existsCurrencyId(XSSFSheet sheet) { + InterfaceReport report = getReport(); + Locale locale = getLocale(); + Map<CellReference, String> errorMessages = getErrorMessages(); report.print(UtilProperties.getMessage(RESOURCE, "StartCheckCurrencyId", locale), InterfaceReport.FORMAT_NOTE); XSSFCell currencyIdCell = sheet.getRow(2).getCell(1); - currencyId = currencyIdCell.getStringCellValue().trim().toUpperCase(); + setCurrencyId(currencyIdCell.getStringCellValue().trim().toUpperCase()); + String currencyId = getCurrencyId(); if (UtilValidate.isEmpty(currencyId)) { String errorMessage = UtilProperties.getMessage(RESOURCE, "CurrencyIdRequired", locale); report.println(errorMessage, InterfaceReport.FORMAT_ERROR); @@ -239,7 +241,7 @@ public class SamplePricatParser extends AbstractPricatParser { return false; } else { try { - GenericValue currencyUom = EntityQuery.use(delegator).from("Uom").where("uomId", currencyId).queryOne(); + GenericValue currencyUom = EntityQuery.use(getDelegator()).from("Uom").where("uomId", currencyId).queryOne(); if (!"CURRENCY_MEASURE".equals(currencyUom.getString("uomTypeId"))) { String errorMessage = UtilProperties.getMessage(RESOURCE, "CurrencyIdNotCurrency", new Object[]{currencyId}, locale); report.println(errorMessage, InterfaceReport.FORMAT_ERROR); @@ -260,8 +262,10 @@ public class SamplePricatParser extends AbstractPricatParser { /** parse row by row */ @Override public void parseRowByRow(XSSFSheet sheet) { + InterfaceReport report = getReport(); + Locale locale = getLocale(); int rows = sheet.getLastRowNum() + 1; - List<Object[]> colNames = COL_NAMES_LIST.get(pricatFileVersion); + List<Object[]> colNames = COL_NAMES_LIST.get(getPricatFileVersion()); int colNumber = colNames.size(); int emptyRowStart = -1; @@ -317,7 +321,7 @@ public class SamplePricatParser extends AbstractPricatParser { if (UtilValidate.isEmpty(cellContents)) { return false; } - switch (pricatFileVersion) { + switch (getPricatFileVersion()) { case "V1.1": default: return parseCellContentsAndStoreV1(row, cellContents); @@ -331,11 +335,12 @@ public class SamplePricatParser extends AbstractPricatParser { // 1. check if facilityId is in the facilities belong to the user, or if the name is correct for the id String facilityName = (String) getCellContent(cellContents, "Facility Name"); String facilityId = (String) getCellContent(cellContents, "FacilityId"); - if (!isFacilityOk(row, facilityName, facilityId)) + if (!isFacilityOk(row, facilityName, facilityId)) { return false; + } // 2. get productCategoryId - String ownerPartyId = facilities.get(facilityId)[1]; + String ownerPartyId = getFacilities().get(facilityId)[1]; String productCategoryId = getProductCategoryId(cellContents, ownerPartyId); // 3. get productFeatureId of brand @@ -357,23 +362,23 @@ public class SamplePricatParser extends AbstractPricatParser { // 5. update color and size if necessary String color = (String) getCellContent(cellContents, "Color"); if (UtilValidate.isEmpty(color) || UtilValidate.isEmpty(color.trim())) { - color = defaultColorName; + color = DEFAULT_COL_NAME; } String dimension = (String) getCellContent(cellContents, "Size"); if (UtilValidate.isEmpty(dimension) || UtilValidate.isEmpty(dimension.trim())) { - dimension = defaultDimensionName; + dimension = DEFAULT_DIM_NAME; } Map<String, Object> features = updateColorAndDimension(productId, ownerPartyId, color, dimension); if (ServiceUtil.isError(features)) { if (features.containsKey("index") && String.valueOf(features.get("index")).contains("0")) { int cell = headerColNames.indexOf("Color"); XSSFCell colorCell = row.getCell(cell); - errorMessages.put(new CellReference(colorCell), UtilProperties.getMessage(RESOURCE, "PricatColorError", locale)); + getErrorMessages().put(new CellReference(colorCell), UtilProperties.getMessage(RESOURCE, "PricatColorError", getLocale())); } if (features.containsKey("index") && String.valueOf(features.get("index")).contains("1")) { int cell = headerColNames.indexOf("Size"); XSSFCell colorCell = row.getCell(cell); - errorMessages.put(new CellReference(colorCell), UtilProperties.getMessage(RESOURCE, "PricatDimensionError", locale)); + getErrorMessages().put(new CellReference(colorCell), UtilProperties.getMessage(RESOURCE, "PricatDimensionError", getLocale())); } return false; } @@ -427,6 +432,10 @@ public class SamplePricatParser extends AbstractPricatParser { @Override public boolean isFacilityOk(XSSFRow row, String facilityName, String facilityId) { + InterfaceReport report = getReport(); + Locale locale = getLocale(); + Map<String, String[]> facilities = getFacilities(); + Map<CellReference, String> errorMessages = getErrorMessages(); if (!facilities.containsKey(facilityId)) { if (UtilValidate.isEmpty(facilityId) && facilities.keySet().size() == 1) { if (UtilValidate.isEmpty(facilityName)) { @@ -469,9 +478,11 @@ public class SamplePricatParser extends AbstractPricatParser { @Override public boolean isTableHeaderMatched(XSSFSheet sheet) { - List<Object[]> columnNames = COL_NAMES_LIST.get(pricatFileVersion); + InterfaceReport report = getReport(); + Locale locale = getLocale(); + List<Object[]> columnNames = COL_NAMES_LIST.get(getPricatFileVersion()); short cols = sheet.getRow(HEADER_ROW_NO).getLastCellNum(); - report.print(UtilProperties.getMessage(RESOURCE, "StartCheckHeaderColNum", new Object[]{pricatFileVersion}, locale), + report.print(UtilProperties.getMessage(RESOURCE, "StartCheckHeaderColNum", new Object[]{getPricatFileVersion()}, locale), InterfaceReport.FORMAT_NOTE); if (cols != columnNames.size()) { report.print(UtilProperties.getMessage(RESOURCE, "HeaderColNumNotMatch", new Object[]{String.valueOf(cols), @@ -489,7 +500,7 @@ public class SamplePricatParser extends AbstractPricatParser { report.println(UtilProperties.getMessage(RESOURCE, "ok", locale), InterfaceReport.FORMAT_OK); } - report.print(UtilProperties.getMessage(RESOURCE, "StartCheckHeaderColLabel", new Object[]{pricatFileVersion}, locale), + report.print(UtilProperties.getMessage(RESOURCE, "StartCheckHeaderColLabel", new Object[]{getPricatFileVersion()}, locale), InterfaceReport.FORMAT_NOTE); boolean foundLabelNotMatch = false; for (int i = 0; i < cols; i++) { @@ -517,6 +528,9 @@ public class SamplePricatParser extends AbstractPricatParser { @Override public boolean isVersionSupported(XSSFSheet sheet) { + InterfaceReport report = getReport(); + Locale locale = getLocale(); + String pricatFileVersion = getPricatFileVersion(); report.print(UtilProperties.getMessage(RESOURCE, "StartCheckPricatVersion", locale), InterfaceReport.FORMAT_NOTE); pricatFileVersion = sheet.getRow(2).getCell(0).getStringCellValue().trim(); if (COL_NAMES_LIST.containsKey(pricatFileVersion)) { @@ -535,10 +549,10 @@ public class SamplePricatParser extends AbstractPricatParser { public boolean containsDataRows(XSSFSheet sheet) { int rows = sheet.getPhysicalNumberOfRows(); if (rows > HEADER_ROW_NO + 1) { - report.println(UtilProperties.getMessage(RESOURCE, "PricatTableRows", new Object[]{String.valueOf(HEADER_ROW_NO + 1), - String.valueOf(rows - HEADER_ROW_NO - 1), sheet.getSheetName()}, locale), InterfaceReport.FORMAT_NOTE); + getReport().println(UtilProperties.getMessage(RESOURCE, "PricatTableRows", new Object[]{String.valueOf(HEADER_ROW_NO + 1), + String.valueOf(rows - HEADER_ROW_NO - 1), sheet.getSheetName()}, getLocale()), InterfaceReport.FORMAT_NOTE); } else { - report.println(UtilProperties.getMessage(RESOURCE, "PricatNoDataRows", new Object[]{sheet.getSheetName()}, locale), + getReport().println(UtilProperties.getMessage(RESOURCE, "PricatNoDataRows", new Object[]{sheet.getSheetName()}, getLocale()), InterfaceReport.FORMAT_ERROR); return false; } @@ -552,7 +566,6 @@ public class SamplePricatParser extends AbstractPricatParser { /** * Get data by version definition. - * * @param row * @param colNames * @param size @@ -561,6 +574,10 @@ public class SamplePricatParser extends AbstractPricatParser { @Override public List<Object> getCellContents(XSSFRow row, List<Object[]> colNames, int size) { List<Object> results = new ArrayList<>(); + InterfaceReport report = getReport(); + Locale locale = getLocale(); + Map<CellReference, String> errorMessages = getErrorMessages(); + Map<String, String[]> facilities = getFacilities(); boolean foundError = false; if (isEmptyRow(row, size, true)) { return null; @@ -587,7 +604,7 @@ public class SamplePricatParser extends AbstractPricatParser { } } CellType cellType = cell.getCellType(); - String cellValue = formatter.formatCellValue(cell); + String cellValue = getFormatter().formatCellValue(cell); if (UtilValidate.isNotEmpty(cellValue) && UtilValidate.isNotEmpty(cellValue.trim())) { if (cellType == CellType.FORMULA) { try { diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java b/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java index cad8b2b..0cc33ac 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java @@ -29,15 +29,17 @@ import org.apache.poi.xssf.usermodel.XSSFVMLDrawing; import com.microsoft.schemas.vml.CTShape; public final class OFBizPricatUtil { + private OFBizPricatUtil() { } + private static final String MODULE = OFBizPricatUtil.class.getName(); - protected static Method VMLDrawingMethod; + private static Method vmlDrawingMethod; // for POI 4.0.0 and later, this field can be removed - protected static Method FindCommentShapeMethod; + private static Method findCommentShapeMethod; static { Method[] methods = XSSFSheet.class.getDeclaredMethods(); for (Method method : methods) { if (method.getName().equals("getVMLDrawing")) { - VMLDrawingMethod = method; + vmlDrawingMethod = method; break; } } @@ -45,19 +47,19 @@ public final class OFBizPricatUtil { methods = XSSFVMLDrawing.class.getDeclaredMethods(); for (Method method : methods) { if (method.getName().equals("findCommentShape")) { - FindCommentShapeMethod = method; + findCommentShapeMethod = method; break; } } } public static void formatCommentShape(XSSFSheet sheet, CellReference cell) { - if (VMLDrawingMethod != null && FindCommentShapeMethod != null) { + if (vmlDrawingMethod != null && findCommentShapeMethod != null) { try { - XSSFVMLDrawing vml = (XSSFVMLDrawing) VMLDrawingMethod.invoke(sheet, true); + XSSFVMLDrawing vml = (XSSFVMLDrawing) vmlDrawingMethod.invoke(sheet, true); /** for POI 4.0 and later, use: CTShape ctshape = vml.findCommentShape(cell.getRow(), cell.getCol()); */ - CTShape ctshape = (CTShape) FindCommentShapeMethod.invoke(vml, cell.getRow(), cell.getCol()); + CTShape ctshape = (CTShape) findCommentShapeMethod.invoke(vml, cell.getRow(), cell.getCol()); ctshape.setType("#_x0000_t202"); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Debug.logError(e, MODULE); @@ -65,13 +67,13 @@ public final class OFBizPricatUtil { } } public static void formatCommentShape(XSSFSheet sheet, int rowNum, short colNum) { - if (VMLDrawingMethod != null && FindCommentShapeMethod != null) { + if (vmlDrawingMethod != null && findCommentShapeMethod != null) { try { - XSSFVMLDrawing vml = (XSSFVMLDrawing) VMLDrawingMethod.invoke(sheet, true); + XSSFVMLDrawing vml = (XSSFVMLDrawing) vmlDrawingMethod.invoke(sheet, true); /** for POI 4.0 and later, use: CTShape ctshape = vml.findCommentShape(rowNum, colNum); */ - CTShape ctshape = (CTShape) FindCommentShapeMethod.invoke(vml, rowNum, colNum); + CTShape ctshape = (CTShape) findCommentShapeMethod.invoke(vml, rowNum, colNum); ctshape.setType("#_x0000_t202"); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Debug.logError(e, MODULE); diff --git a/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java b/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java index 8bff3f8..a8f7597 100644 --- a/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java +++ b/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java @@ -125,7 +125,6 @@ public class ScrumServices { * viewScrumRevision * <p> * Use for view Scrum Revision - * * @param ctx The DispatchContext that this service is operating in * @param context Map containing the input parameters * @return Map with the result of the service, the output parameters. @@ -170,7 +169,6 @@ public class ScrumServices { * retrieveMissingScrumRevision * <p> * Use for retrieve the missing data of the Revision - * * @param ctx The DispatchContext that this service is operating in * @param context Map containing the input parameters * @return Map with the result of the service, the output parameters. @@ -262,7 +260,6 @@ public class ScrumServices { * removeDuplicateScrumRevision * <p> * Use for remove duplicate scrum revision - * * @param ctx The DispatchContext that this service is operating in * @param context Map containing the input parameters * @return Map with the result of the service. diff --git a/solr/src/main/java/org/apache/ofbiz/solr/control/OFBizSolrLoginWorker.java b/solr/src/main/java/org/apache/ofbiz/solr/control/OFBizSolrLoginWorker.java index 552e048..d2137bb 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/control/OFBizSolrLoginWorker.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/control/OFBizSolrLoginWorker.java @@ -34,7 +34,6 @@ public final class OFBizSolrLoginWorker { /** * An HTTP WebEvent handler that logs in a userLogin. This should run before the security check. - * * @param request The HTTP request object for the current JSP or Servlet request. * @param response The HTTP response object for the current JSP or Servlet request. * @return Return a boolean which specifies whether or not the calling Servlet or diff --git a/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrContextFilter.java b/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrContextFilter.java index 28573ae..947bd5d 100644 --- a/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrContextFilter.java +++ b/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrContextFilter.java @@ -193,7 +193,6 @@ public class OFBizSolrContextFilter extends SolrDispatchFilter { /** * Override this to change CoreContainer initialization - * * @return a CoreContainer to hold this server's cores */ @Override diff --git a/webpos/src/main/java/org/apache/ofbiz/webpos/transaction/WebPosTransaction.java b/webpos/src/main/java/org/apache/ofbiz/webpos/transaction/WebPosTransaction.java index cd4df9f..556ab27 100755 --- a/webpos/src/main/java/org/apache/ofbiz/webpos/transaction/WebPosTransaction.java +++ b/webpos/src/main/java/org/apache/ofbiz/webpos/transaction/WebPosTransaction.java @@ -96,30 +96,31 @@ public class WebPosTransaction { Debug.logInfo("Created WebPosTransaction [" + this.transactionId + "]", MODULE); } + /** get user login id */ public String getUserLoginId() { return webPosSession.getUserLoginId(); } - + /** get drawer number */ public int getDrawerNumber() { return drawerIdx + 1; } - + /** get transaction id */ public String getTransactionId() { return this.transactionId; } - + /** get terminal id */ public String getTerminalId() { return webPosSession.getId(); } - + /** get facilityId */ public String getFacilityId() { return webPosSession.getFacilityId(); } - + /** get terminal log id */ public String getTerminalLogId() { return txLog.getString("posTerminalLogId"); } - + /** is open */ public boolean isOpen() { this.isOpen = false; GenericValue terminalState = this.getTerminalState(); @@ -130,19 +131,20 @@ public class WebPosTransaction { } return this.isOpen; } - + /** get terminal state */ public GenericValue getTerminalState() { Delegator delegator = webPosSession.getDelegator(); List<GenericValue> states = null; try { - states = delegator.findList("PosTerminalState", EntityCondition.makeCondition(UtilMisc.toMap("posTerminalId", webPosSession.getId(), "startingTxId", getTransactionId())), null, null, null, false); + states = delegator.findList("PosTerminalState", EntityCondition.makeCondition(UtilMisc.toMap("posTerminalId", webPosSession.getId(), + "startingTxId", getTransactionId())), null, null, null, false); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } states = EntityUtil.filterByDate(states, UtilDateTime.nowTimestamp(), "openedDate", "closedDate", true); return EntityUtil.getFirst(states); } - + /** close tax */ public void closeTx() { if (UtilValidate.isNotEmpty(txLog)) { txLog.set("statusId", "POSTX_CLOSED"); @@ -157,7 +159,7 @@ public class WebPosTransaction { Debug.logInfo("Transaction closed", MODULE); } } - + /** paid in out */ public void paidInOut(String type) { if (UtilValidate.isNotEmpty(txLog)) { txLog.set("statusId", "POSTX_PAID_" + type); @@ -168,10 +170,10 @@ public class WebPosTransaction { Debug.logError(e, "Unable to store TX log - not fatal", MODULE); } webPosSession.setCurrentTransaction(null); - Debug.logInfo("Paid "+ type, MODULE); + Debug.logInfo("Paid " + type, MODULE); } } - + /** modify price */ public void modifyPrice(int cartLineIdx, BigDecimal price) { ShoppingCartItem item = getCart().findCartItem(cartLineIdx); if (UtilValidate.isNotEmpty(item)) { @@ -181,7 +183,7 @@ public class WebPosTransaction { Debug.logInfo("Item " + cartLineIdx + " not found", MODULE); } } - + /** calc tax */ public void calcTax() { try { ch.calcAndAddTax(this.getStoreOrgAddress()); @@ -189,7 +191,7 @@ public class WebPosTransaction { Debug.logError(e, MODULE); } } - + /** process sale */ public BigDecimal processSale() throws GeneralException { Debug.logInfo("Process sale", MODULE); BigDecimal grandTotal = this.getGrandTotal(); @@ -222,7 +224,8 @@ public class WebPosTransaction { Debug.logInfo("Processing the payment(s)", MODULE); Map<String, ? extends Object> payRes = null; try { - payRes = UtilGenerics.cast(ch.processPayment(ProductStoreWorker.getProductStore(webPosSession.getProductStoreId(), webPosSession.getDelegator()), webPosSession.getUserLogin(), true)); + payRes = UtilGenerics.cast(ch.processPayment(ProductStoreWorker.getProductStore(webPosSession.getProductStoreId(), + webPosSession.getDelegator()), webPosSession.getUserLogin(), true)); } catch (GeneralException e) { Debug.logError(e, MODULE); throw e; @@ -270,7 +273,8 @@ public class WebPosTransaction { List<GenericValue> fcp = null; try { - fcp = facility.getRelated("FacilityContactMechPurpose", UtilMisc.toMap("contactMechPurposeTypeId", "SHIP_ORIG_LOCATION"), null, false); + fcp = facility.getRelated("FacilityContactMechPurpose", UtilMisc.toMap("contactMechPurposeTypeId", "SHIP_ORIG_LOCATION"), + null, false); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -287,35 +291,37 @@ public class WebPosTransaction { } return this.shipAddress; } - + /** clear payments */ public void clearPayments() { Debug.logInfo("all payments cleared from sale", MODULE); getCart().clearPayments(); } - + /** clear payment */ public void clearPayment(int index) { Debug.logInfo("removing payment " + index, MODULE); getCart().clearPayment(index); } - + /** clear payment */ public void clearPayment(String id) { Debug.logInfo("removing payment " + id, MODULE); getCart().clearPayment(id); } - + /** get payment info */ public CartPaymentInfo getPaymentInfo(int index) { return getCart().getPaymentInfo(index); } - + /** get payment method type id */ public String getPaymentMethodTypeId(int index) { return getCart().getPaymentInfo(index).getPaymentMethodTypeId(); } - + /** check payment method type */ public int checkPaymentMethodType(String paymentMethodTypeId) { - Map<String, ? extends Object> fields = UtilMisc.toMap("paymentMethodTypeId", paymentMethodTypeId, "productStoreId", webPosSession.getProductStoreId()); + Map<String, ? extends Object> fields = UtilMisc.toMap("paymentMethodTypeId", paymentMethodTypeId, "productStoreId", + webPosSession.getProductStoreId()); List<GenericValue> values = null; try { - values = webPosSession.getDelegator().findList("ProductStorePaymentSetting", EntityCondition.makeCondition(fields), null, null, null, true); + values = webPosSession.getDelegator().findList("ProductStorePaymentSetting", EntityCondition.makeCondition(fields), null, null, null, + true); } catch (GenericEntityException e) { Debug.logError(e, MODULE); } @@ -353,11 +359,11 @@ public class WebPosTransaction { public static int getInternalPaymentCode() { return INTERNAL_PAYMENT; } - + /** add payment */ public BigDecimal addPayment(String id, BigDecimal amount) { return this.addPayment(id, amount, null, null); } - + /** add payment */ public BigDecimal addPayment(String id, BigDecimal amount, String refNum, String authCode) { Debug.logInfo("Added payment " + id + "/" + amount, MODULE); if ("CASH".equals(id)) { @@ -367,7 +373,7 @@ public class WebPosTransaction { getCart().addPaymentAmount(id, amount, refNum, authCode, true, true, false); return this.getTotalDue(); } - + /** process amount */ public BigDecimal processAmount(BigDecimal amount) throws GeneralException { if (UtilValidate.isEmpty(amount)) { Debug.logInfo("Amount is empty; assumption is full amount : " + this.getTotalDue(), MODULE); @@ -378,7 +384,7 @@ public class WebPosTransaction { } return amount; } - + /** process no payment */ public synchronized void processNoPayment(String paymentMethodTypeId) { try { BigDecimal amount = processAmount(null); @@ -390,7 +396,7 @@ public class WebPosTransaction { // errors handled } } - + /** process external payment */ public synchronized void processExternalPayment(String paymentMethodTypeId, BigDecimal amount, String refNum) { if (refNum == null) { //TODO handle error message @@ -407,7 +413,7 @@ public class WebPosTransaction { // errors handled } } - + /** make credit card vo */ public String makeCreditCardVo(String cardNumber, String expDate, String firstName, String lastName) { LocalDispatcher dispatcher = webPosSession.getDispatcher(); String expMonth = expDate.substring(0, 2); @@ -441,14 +447,14 @@ public class WebPosTransaction { return (String) svcRes.get("paymentMethodId"); } } - + /** set payment ref num */ public void setPaymentRefNum(int paymentIndex, String refNum, String authCode) { Debug.logInfo("setting payment index reference number " + paymentIndex + " / " + refNum + " / " + authCode, MODULE); ShoppingCart.CartPaymentInfo inf = getCart().getPaymentInfo(paymentIndex); inf.setRefNum(refNum, authCode); } - /* CVV2 code should be entered when a card can't be swiped */ + /** CVV2 code should be entered when a card can't be swiped */ public void setPaymentSecurityCode(String paymentId, String refNum, String securityCode) { Debug.logInfo("setting payment security code " + paymentId, MODULE); int paymentIndex = getCart().getPaymentInfoIndex(paymentId, refNum); @@ -457,7 +463,7 @@ public class WebPosTransaction { inf.setIsSwiped(false); } - /* Track2 data should be sent to processor when a card is swiped. */ + /** Track2 data should be sent to processor when a card is swiped. */ public void setPaymentTrack2(String paymentId, String refNum, String securityCode) { Debug.logInfo("setting payment security code " + paymentId, MODULE); int paymentIndex = getCart().getPaymentInfoIndex(paymentId, refNum); @@ -466,40 +472,40 @@ public class WebPosTransaction { inf.setIsSwiped(true); } - /* Postal code should be entered when a card can't be swiped */ + /** Postal code should be entered when a card can't be swiped */ public void setPaymentPostalCode(String paymentId, String refNum, String postalCode) { Debug.logInfo("setting payment security code " + paymentId, MODULE); int paymentIndex = getCart().getPaymentInfoIndex(paymentId, refNum); ShoppingCart.CartPaymentInfo inf = getCart().getPaymentInfo(paymentIndex); inf.setPostalCode(postalCode); } - + /** get tax total */ public BigDecimal getTaxTotal() { return getCart().getTotalSalesTax(); } - + /** get grand total */ public BigDecimal getGrandTotal() { return getCart().getGrandTotal(); } - + /** get number of payments */ public int getNumberOfPayments() { return getCart().selectedPayments(); } - + /** get payment total */ public BigDecimal getPaymentTotal() { return getCart().getPaymentTotal(); } - + /** get total quantity */ public BigDecimal getTotalQuantity() { return getCart().getTotalQuantity(); } - + /** get total due */ public BigDecimal getTotalDue() { BigDecimal grandTotal = this.getGrandTotal(); BigDecimal paymentAmt = this.getPaymentTotal(); return grandTotal.subtract(paymentAmt); } - + /** add product promo code */ public String addProductPromoCode(String code) { String result = getCart().addProductPromoCode(code, webPosSession.getDispatcher()); calcTax(); |
Free forum by Nabble | Edit this page |