Author: shijh
Date: Wed Nov 23 14:46:54 2016 New Revision: 1770979 URL: http://svn.apache.org/viewvc?rev=1770979&view=rev Log: OFBIZ-9123 Add a PriCat component under specialpurpose 1. Add a readme. 2. Replace tabs with spaces. Added: ofbiz/trunk/specialpurpose/pricat/README.md Modified: ofbiz/trunk/specialpurpose/pricat/config/PricatUiLabels.xml ofbiz/trunk/specialpurpose/pricat/data/PricatData.xml ofbiz/trunk/specialpurpose/pricat/entitydef/entitymodel.xml ofbiz/trunk/specialpurpose/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractHtmlReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/InterfacePricatParser.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/PricatEvents.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlReport.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatEvents.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/poi/xssf/usermodel/OFBizPricatUtil.java ofbiz/trunk/specialpurpose/pricat/webapp/pricat/WEB-INF/controller.xml ofbiz/trunk/specialpurpose/pricat/webapp/pricat/ftl/ExcelImportHistoryReport.ftl ofbiz/trunk/specialpurpose/pricat/webapp/pricat/ftl/pricatreport.ftl ofbiz/trunk/specialpurpose/pricat/webapp/pricat/ftl/report.ftl ofbiz/trunk/specialpurpose/pricat/webapp/pricat/ftl/viewExcelImportHistory.ftl ofbiz/trunk/specialpurpose/pricat/webapp/pricat/ftl/viewExcelImportLog.ftl ofbiz/trunk/specialpurpose/pricat/webapp/pricat/includes/pricat.css ofbiz/trunk/specialpurpose/pricat/webapp/pricatdemo/ftl/SamplePricat.ftl ofbiz/trunk/specialpurpose/pricat/widget/CommonScreens.xml ofbiz/trunk/specialpurpose/pricat/widget/SampleScreens.xml Added: ofbiz/trunk/specialpurpose/pricat/README.md URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/README.md?rev=1770979&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/README.md (added) +++ ofbiz/trunk/specialpurpose/pricat/README.md Wed Nov 23 14:46:54 2016 @@ -0,0 +1,14 @@ +<img src="http://ofbiz.apache.org/images/logo.png" alt="Apache OFBiz" /> + +# PriCat component +PriCat is the abbreviation of Price and Catalog/Category. The PriCat component is to support importing/parsing excel files with price and catalog/category data. The excel files can be checked by version, header column names, currencyId. Each row can be validated by facility(name, Id and ownership), required fields, string or number and etc. + +PriCat component contains two webapps: /pricat/ and /pricatdemo/. In production environment, you SHOULD remove or disable the /pricatdemo/. + +## more information +--------------------------------------- +PriCat Demos +--------------------------------------- +/pricatdemo/control/SamplePricat/: you can use this demo to implement your own excel templates. + +/pricatdemo/control/countdownreport and /pricatdemo/control/countupreport: these 2 demos are on html report, you can try this way to display the processing report of rebuilding of lucene index or marchine learning data. \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/pricat/config/PricatUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/config/PricatUiLabels.xml?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/config/PricatUiLabels.xml (original) +++ ofbiz/trunk/specialpurpose/pricat/config/PricatUiLabels.xml Wed Nov 23 14:46:54 2016 @@ -238,11 +238,11 @@ under the License. <value xml:lang="en">The lable of row {0} colum {1} is [{2}], it does not match [{3}] as expected.</value> <value xml:lang="zh">è¡{0}å{1}çæåæ¯[{2}]ï¼ä¸ææç[{3}]ä¸ä¸è´ã</value> </property> - <property key="HeaderColNumShortThanRequired"> + <property key="HeaderColNumShortThanRequired"> <value xml:lang="en">Table header column number less than the required {0}</value> <value xml:lang="zh">表头åæ°å°äºè¦æ±ç{0}å</value> </property> - <property key="UseHeaderColNum"> + <property key="UseHeaderColNum"> <value xml:lang="en">the first {0} column labels will be checked</value> <value xml:lang="zh">å°æ£æ¥è¡¨å¤´çå{0}åçæ ç¾</value> </property> @@ -432,101 +432,101 @@ under the License. <value xml:lang="zh">è·³è¿</value> </property> - <property key="ExcelImportHistoryList"> + <property key="ExcelImportHistoryList"> <value xml:lang="en">Excel Import History</value> <value xml:lang="zh">Excelå¯¼å ¥æä½åå²è®°å½</value> </property> - <property key="OnlyYourOwnImportHistoryDisplayed"> + <property key="OnlyYourOwnImportHistoryDisplayed"> <value xml:lang="en">(Only current login user's history can be displayed)</value> <value xml:lang="zh">ï¼ä» è½æ¾ç¤ºå½åç¨æ·çå¯¼å ¥æä½åå²è®°å½ï¼</value> </property> - <property key="SerialNumber"> + <property key="SerialNumber"> <value xml:lang="en">No.</value> <value xml:lang="zh">åºå·</value> </property> - <property key="Filename"> + <property key="Filename"> <value xml:lang="en">Filename</value> <value xml:lang="zh">æ件å</value> </property> - <property key="FromDate"> + <property key="FromDate"> <value xml:lang="en">Start Time</value> <value xml:lang="zh">å¼å§æ¶é´</value> </property> - <property key="ThruDate"> + <property key="ThruDate"> <value xml:lang="en">End Time</value> <value xml:lang="zh">ç»ææ¶é´</value> </property> - <property key="ThruReasonId"> + <property key="ThruReasonId"> <value xml:lang="en">End Reason</value> <value xml:lang="zh">ç»æåå </value> </property> - <property key="ImportStatus"> + <property key="ImportStatus"> <value xml:lang="en">Import Status</value> <value xml:lang="zh">å¯¼å ¥ç¶æ</value> </property> - <property key="Actions"> + <property key="Actions"> <value xml:lang="en">Actions</value> <value xml:lang="zh">æä½</value> </property> - <property key="ExcelImportTipNoData"> + <property key="ExcelImportTipNoData"> <value xml:lang="en">No excel import history data.</value> <value xml:lang="zh">没æExcelå¯¼å ¥åå²è®°å½</value> </property> - <property key="EXCEL_IMPORTING"> + <property key="EXCEL_IMPORTING"> <value xml:lang="en">Importing</value> <value xml:lang="zh">æ£å¨å¯¼å ¥</value> </property> - <property key="EXCEL_IMPORTED"> + <property key="EXCEL_IMPORTED"> <value xml:lang="en">Imported</value> <value xml:lang="zh">å·²å¯¼å ¥</value> </property> - <property key="EXCEL_IMPORT_SUCCESS"> + <property key="EXCEL_IMPORT_SUCCESS"> <value xml:lang="en">Success</value> <value xml:lang="zh">æå</value> </property> - <property key="EXCEL_IMPORT_STOPPED"> + <property key="EXCEL_IMPORT_STOPPED"> <value xml:lang="en">Stopped by user</value> <value xml:lang="zh">ç¨æ·ç»æ¢äºå¯¼å ¥</value> </property> - <property key="EXCEL_IMPORT_ERROR"> + <property key="EXCEL_IMPORT_ERROR"> <value xml:lang="en">Stopped by error</value> <value xml:lang="zh">å åºéèåæ¢äºå¯¼å ¥</value> </property> - <property key="EXCEL_IMPORT_QUEST"> + <property key="EXCEL_IMPORT_QUEST"> <value xml:lang="en">Data error found</value> <value xml:lang="zh">æ°æ®ä¸æé误</value> </property> - <property key="ViewExcelImportLogContent"> + <property key="ViewExcelImportLogContent"> <value xml:lang="en">View log content</value> <value xml:lang="zh">æµè§æ¥å¿å 容</value> </property> - <property key="DownloadCommentedExcel"> + <property key="DownloadCommentedExcel"> <value xml:lang="en">Download excel</value> <value xml:lang="zh">ä¸è½½Excel</value> </property> - <property key="ViewExcelImportHistory"> + <property key="ViewExcelImportHistory"> <value xml:lang="en">View Import History</value> <value xml:lang="zh">å¯¼å ¥æä½åå²è®°å½</value> </property> - <property key="ViewPricatLog"> + <property key="ViewPricatLog"> <value xml:lang="en">View</value> <value xml:lang="zh">æµè§</value> </property> - <property key="DownloadCommentedPricat"> + <property key="DownloadCommentedPricat"> <value xml:lang="en">Download</value> <value xml:lang="zh">ä¸è½½</value> </property> - <property key="ReasonOK"> + <property key="ReasonOK"> <value xml:lang="en">OK</value> </property> - <property key="ReasonStopped"> + <property key="ReasonStopped"> <value xml:lang="en">[S]</value> </property> - <property key="ReasonError"> + <property key="ReasonError"> <value xml:lang="en">[E]</value> </property> - <property key="ReasonWarning"> + <property key="ReasonWarning"> <value xml:lang="en">[W]</value> </property> </resource> Modified: ofbiz/trunk/specialpurpose/pricat/data/PricatData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/data/PricatData.xml?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/data/PricatData.xml (original) +++ ofbiz/trunk/specialpurpose/pricat/data/PricatData.xml Wed Nov 23 14:46:54 2016 @@ -18,7 +18,7 @@ specific language governing permissions under the License. --> <entity-engine-xml> - <!-- Enumeration for thruReasonId of ExcelImportHistory entity --> + <!-- Enumeration for thruReasonId of ExcelImportHistory entity --> <EnumerationType description="Excel import thru reasons" enumTypeId="EXCEL_IMPORT_THRU" hasTable="N" parentTypeId=""/> <Enumeration enumId="EXCEL_IMPORT_SUCCESS" enumCode="EXCEL_IMPORT_SUCCESS" description="Excel Imported Successfully" sequenceId="01" enumTypeId="EXCEL_IMPORT_THRU"/> @@ -26,7 +26,7 @@ under the License. <Enumeration enumId="EXCEL_IMPORT_ERROR" enumCode="EXCEL_IMPORT_ERROR" description="Excel Imported Exits Errorly" sequenceId="03" enumTypeId="EXCEL_IMPORT_THRU"/> <Enumeration enumId="EXCEL_IMPORT_QUEST" enumCode="EXCEL_IMPORT_QUEST" description="Excel Imported Has Error Messages" sequenceId="04" enumTypeId="EXCEL_IMPORT_THRU"/> - <!-- Enumeration for statusId of ExcelImportHistory entity --> + <!-- Enumeration for statusId of ExcelImportHistory entity --> <EnumerationType description="Excel import status" enumTypeId="EXCEL_IMPORT_STATUS" hasTable="N" parentTypeId=""/> <Enumeration enumId="EXCEL_IMPORTING" enumCode="EXCEL_IMPORTING" description="Excel is being imported in progress" sequenceId="01" enumTypeId="EXCEL_IMPORT_STATUS"/> Modified: ofbiz/trunk/specialpurpose/pricat/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/entitydef/entitymodel.xml?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/specialpurpose/pricat/entitydef/entitymodel.xml Wed Nov 23 14:46:54 2016 @@ -21,7 +21,7 @@ under the License. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/entitymodel.xsd"> <entity entity-name="ExcelImportHistory" - package-name="org.ofbiz.product.catalog" + package-name="org.apache.ofbiz.product.catalog" title="Excel Import History Entity"> <field name="userLoginId" type="id-vlong-ne"></field> <field name="sequenceNum" type="numeric"></field> @@ -35,13 +35,13 @@ under the License. <prim-key field="userLoginId"/> <prim-key field="sequenceNum"/> <relation rel-entity-name="UserLogin" type="one" fk-name="EXCELIMPORT_USERLOGIN"> - <key-map field-name="userLoginId"/> + <key-map field-name="userLoginId"/> </relation> <relation rel-entity-name="Enumeration" type="one" fk-name="EXCELIMPORT_STATUS"> - <key-map field-name="statusId" rel-field-name="enumId"/> + <key-map field-name="statusId" rel-field-name="enumId"/> </relation> <relation rel-entity-name="Enumeration" type="one" fk-name="EXCELIMPORT_REASON"> - <key-map field-name="thruReasonId" rel-field-name="enumId"/> + <key-map field-name="thruReasonId" rel-field-name="enumId"/> </relation> </entity> Modified: ofbiz/trunk/specialpurpose/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy (original) +++ ofbiz/trunk/specialpurpose/pricat/groovyScripts/pricat/FindMyExcelImportLog.groovy Wed Nov 23 14:46:54 2016 @@ -27,19 +27,19 @@ context.borderSimpleStyle = "2px solid / sequenceNum = request.getParameter("sequenceNum"); if (sequenceNum == null) { - context.logFileContent = "No sequenceNum parameter found."; - return; + context.logFileContent = "No sequenceNum parameter found."; + return; } historyEntry = delegator.findOne("ExcelImportHistory", [sequenceNum : Long.valueOf(sequenceNum), userLoginId : userLogin.userLoginId], false); if (historyEntry == null) { - context.logFileContent = "No import history found."; - return; + context.logFileContent = "No import history found."; + return; } logFile = FileUtil.getFile("runtime/pricat/" + userLogin.userLoginId + "/" + sequenceNum + ".log"); if (!logFile.exists()) { - context.logFileContent = "No log file found."; + context.logFileContent = "No log file found."; } FileInputStream fis = new FileInputStream(logFile); @@ -47,7 +47,7 @@ InputStreamReader isr = new InputStreamR BufferedReader br = new BufferedReader(isr); logFileContent = ""; while((s = br.readLine())!=null){ - logFileContent += s; + logFileContent += s; } context.logFileContent = logFileContent; Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractHtmlReport.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractHtmlReport.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractHtmlReport.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractHtmlReport.java Wed Nov 23 14:46:54 2016 @@ -31,17 +31,17 @@ import org.apache.ofbiz.htmlreport.util. * */ public abstract class AbstractHtmlReport extends HtmlReport { - - public static final String module = AbstractHtmlReport.class.getName(); + + public static final String module = AbstractHtmlReport.class.getName(); - public final static String THREAD_TYPE = "thread_type"; - - public final static String RUN_CREATETABLE_SCRIPT = "runcreatetablescript"; - - public final static String RUN_DROPTABLE_SCRIPT = "rundroptablescript"; - - public final static String FILE_REPORT_OUTPUT = "specialpurpose/pricat/webapp/pricat/ftl/report.ftl"; - + public final static String THREAD_TYPE = "thread_type"; + + public final static String RUN_CREATETABLE_SCRIPT = "runcreatetablescript"; + + public final static String RUN_DROPTABLE_SCRIPT = "rundroptablescript"; + + public final static String FILE_REPORT_OUTPUT = "specialpurpose/pricat/webapp/pricat/ftl/report.ftl"; + /** * Constructs a new report using the provided locale for the output language. * @@ -75,9 +75,9 @@ public abstract class AbstractHtmlReport */ public void prepareDisplayReport(HttpServletRequest request, HttpServletResponse response, String name, String dialogUri) throws IOException { - if (ReportStringUtil.isNotEmpty(dialogUri)) { - setDialogRealUri(request, dialogUri); - } + if (ReportStringUtil.isNotEmpty(dialogUri)) { + setDialogRealUri(request, dialogUri); + } String action = getParamAction(request); if (action == null) action = ""; @@ -106,39 +106,39 @@ public abstract class AbstractHtmlReport * @param dialogUri */ public void setDialogRealUri(HttpServletRequest request, String dialogUri) { - request.setAttribute(DIALOG_URI, dialogUri); + request.setAttribute(DIALOG_URI, dialogUri); } public static String checkButton(HttpServletRequest request, HttpServletResponse response) { - String action = request.getParameter("action"); - if (ReportStringUtil.isNotEmpty(action)) { - if (action.equalsIgnoreCase("ok")) { - request.removeAttribute(SESSION_REPORT_CLASS); - request.removeAttribute(DIALOG_URI); - return "ok"; - } else if (action.equalsIgnoreCase("cancel")) { - request.removeAttribute(SESSION_REPORT_CLASS); - request.removeAttribute(DIALOG_URI); - return "cancel"; - } - } - action = request.getParameter("ok"); - if (ReportStringUtil.isNotEmpty(action)) { - if (action.equalsIgnoreCase("ok")) { - request.removeAttribute(SESSION_REPORT_CLASS); - request.removeAttribute(DIALOG_URI); - return "ok"; - } - } + String action = request.getParameter("action"); + if (ReportStringUtil.isNotEmpty(action)) { + if (action.equalsIgnoreCase("ok")) { + request.removeAttribute(SESSION_REPORT_CLASS); + request.removeAttribute(DIALOG_URI); + return "ok"; + } else if (action.equalsIgnoreCase("cancel")) { + request.removeAttribute(SESSION_REPORT_CLASS); + request.removeAttribute(DIALOG_URI); + return "cancel"; + } + } + action = request.getParameter("ok"); + if (ReportStringUtil.isNotEmpty(action)) { + if (action.equalsIgnoreCase("ok")) { + request.removeAttribute(SESSION_REPORT_CLASS); + request.removeAttribute(DIALOG_URI); + return "ok"; + } + } action = request.getParameter("cancel"); if (ReportStringUtil.isNotEmpty(action)) { - if (action.equalsIgnoreCase("cancel")) { - request.removeAttribute(SESSION_REPORT_CLASS); - request.removeAttribute(DIALOG_URI); - return "cancel"; - } + if (action.equalsIgnoreCase("cancel")) { + request.removeAttribute(SESSION_REPORT_CLASS); + request.removeAttribute(DIALOG_URI); + return "cancel"; + } } - return "success"; + return "success"; } } \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReport.java Wed Nov 23 14:46:54 2016 @@ -66,7 +66,7 @@ public abstract class AbstractReport imp public String formatRuntime() { - long runtime = getRuntime(); + long runtime = getRuntime(); long seconds = (runtime / SECONDS) % 60; long minutes = (runtime / MINUTES) % 60; long hours = (runtime / HOURS) % 24; @@ -137,7 +137,7 @@ public abstract class AbstractReport imp protected void init(Locale locale) { startTime = System.currentTimeMillis(); this.locale = locale; - errors = new ArrayList<Object>(); + errors = new ArrayList<Object>(); } /** Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java Wed Nov 23 14:46:54 2016 @@ -72,7 +72,7 @@ public abstract class AbstractReportThre public UUID getUUID() { - return uuid; + return uuid; } /** @@ -211,7 +211,7 @@ public abstract class AbstractReportThre } protected Locale getLocale() { - return locale; + return locale; } } Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/HtmlReport.java Wed Nov 23 14:46:54 2016 @@ -50,7 +50,7 @@ import org.apache.ofbiz.htmlreport.util. */ public class HtmlReport extends AbstractReport { - public static final String module = HtmlReport.class.getName(); + public static final String module = HtmlReport.class.getName(); /** The delimiter that is used in the resource list request parameter. */ public static final String DELIMITER_RESOURCES = "|"; @@ -171,7 +171,7 @@ public class HtmlReport extends Abstract public static final String FORM_URI = "formuri"; public static final String resource = "PricatUiLabels"; - + /** Log file. */ protected File logFile; @@ -213,43 +213,43 @@ public class HtmlReport extends Abstract } public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response) { - HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); - if (wp == null) { - wp = new HtmlReport(request, response, true, true); - request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); - } - return wp; + HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); + if (wp == null) { + wp = new HtmlReport(request, response, true, true); + request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); + } + return wp; } public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response, boolean writeHtml, boolean isTransient) { - HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); - if (wp == null) { - wp = new HtmlReport(request, response, writeHtml, isTransient); - request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); - } - return wp; + HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); + if (wp == null) { + wp = new HtmlReport(request, response, writeHtml, isTransient); + request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); + } + return wp; } public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response, boolean writeHtml, boolean isTransient, String logFileName) { - HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); - if (wp == null || UtilValidate.isEmpty(wp.getLogFileName()) || !wp.getLogFileName().equals(logFileName)) { - wp = new HtmlReport(request, response, writeHtml, isTransient); - request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); - } - return wp; + HtmlReport wp = (HtmlReport) request.getSession().getAttribute(SESSION_REPORT_CLASS); + if (wp == null || UtilValidate.isEmpty(wp.getLogFileName()) || !wp.getLogFileName().equals(logFileName)) { + wp = new HtmlReport(request, response, writeHtml, isTransient); + request.getSession().setAttribute(SESSION_REPORT_CLASS, wp); + } + return wp; } public String getParamAction(HttpServletRequest request) { - paramAction = request.getParameter("action"); - return paramAction != null ? paramAction : "reportbegin"; + paramAction = request.getParameter("action"); + return paramAction != null ? paramAction : "reportbegin"; } public void setParamAction(String action) { - paramAction = action; + paramAction = action; } public void setParamThread(String name) { - paramThread = name; + paramThread = name; } public synchronized String getReportUpdate() { @@ -283,12 +283,12 @@ public class HtmlReport extends Abstract indexNext = isTransient ? 0 : indexEnd; if (isTransient && logFileOutputStream != null && logResult.toString().length() > 0) { - try { - logFileOutputStream.write((logResult.toString() + "\n").getBytes()); - logFileOutputStream.flush(); - } catch (IOException e) { - Debug.logError(e.getMessage(), module); - } + try { + logFileOutputStream.write((logResult.toString() + "\n").getBytes()); + logFileOutputStream.flush(); + } catch (IOException e) { + Debug.logError(e.getMessage(), module); + } } return result.toString(); } @@ -351,44 +351,44 @@ public class HtmlReport extends Abstract content.add(buf.toString()); switch (format) { - case FORMAT_HEADLINE: - buf = new StringBuffer(); - buf.append("<span class='head'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_WARNING: - buf = new StringBuffer(); - buf.append("<span class='warn'>"); - buf.append(value); - buf.append("</span>"); - addWarning(value); - break; - case FORMAT_ERROR: - buf = new StringBuffer(); - buf.append("<span class='err'>"); - buf.append(value); - buf.append("</span>"); - addError(value); - break; - case FORMAT_NOTE: - buf = new StringBuffer(); - buf.append("<span class='note'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_OK: - buf = new StringBuffer(); - buf.append("<span class='ok'>"); - buf.append(value); - buf.append("</span>"); - break; - case FORMAT_DEFAULT: - default: - buf = new StringBuffer(value); + case FORMAT_HEADLINE: + buf = new StringBuffer(); + buf.append("<span class='head'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_WARNING: + buf = new StringBuffer(); + buf.append("<span class='warn'>"); + buf.append(value); + buf.append("</span>"); + addWarning(value); + break; + case FORMAT_ERROR: + buf = new StringBuffer(); + buf.append("<span class='err'>"); + buf.append(value); + buf.append("</span>"); + addError(value); + break; + case FORMAT_NOTE: + buf = new StringBuffer(); + buf.append("<span class='note'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_OK: + buf = new StringBuffer(); + buf.append("<span class='ok'>"); + buf.append(value); + buf.append("</span>"); + break; + case FORMAT_DEFAULT: + default: + buf = new StringBuffer(value); } if (value.trim().endsWith(getLineBreak())) { - buf.append("\n"); + buf.append("\n"); } logContent.add(buf.toString()); } @@ -432,7 +432,7 @@ public class HtmlReport extends Abstract buf.append(UtilProperties.getMessage(resource, "REPORT_EXCEPTION", getLocale())); String exception = ReportEncoder.escapeXml(throwable.getLocalizedMessage()); if (UtilValidate.isEmpty(exception)) { - exception = ReportEncoder.escapeXml(throwable.getMessage()); + exception = ReportEncoder.escapeXml(throwable.getMessage()); } if (UtilValidate.isNotEmpty(exception)) { exception = exception.replaceAll("[\r\n]+", LINEBREAK); @@ -457,7 +457,7 @@ public class HtmlReport extends Abstract buf.append(UtilProperties.getMessage(resource, "REPORT_EXCEPTION", getLocale())); String exception = ReportEncoder.escapeXml(throwable.getLocalizedMessage()); if (UtilValidate.isEmpty(exception)) { - exception = ReportEncoder.escapeXml(throwable.getMessage()); + exception = ReportEncoder.escapeXml(throwable.getMessage()); } if (UtilValidate.isNotEmpty(exception)) { exception = exception.replaceAll("[\r\n]+", LINEBREAK); @@ -478,11 +478,11 @@ public class HtmlReport extends Abstract public void printMessageWithParam(String uiLabel, Object param) { print(uiLabel, InterfaceReport.FORMAT_NOTE); - } + } - public void printMessageWithParam(int m, int n, String uiLabel, Object param) { + public void printMessageWithParam(int m, int n, String uiLabel, Object param) { print(uiLabel, InterfaceReport.FORMAT_NOTE); - } + } /** * Builds the start html of the page, including setting of DOCTYPE and @@ -571,13 +571,13 @@ public class HtmlReport extends Abstract threadGroup.enumerate(threads, true); AbstractReportThread thread = null; for (int j=0; j<threads.length; j++) { - Thread threadInstance = threads[j]; - if (threadInstance instanceof AbstractReportThread) { - if(((AbstractReportThread)threadInstance).getUUID().toString().equals(getParamThread(request))) { - thread = (AbstractReportThread) threadInstance; - break; - } - } + Thread threadInstance = threads[j]; + if (threadInstance instanceof AbstractReportThread) { + if(((AbstractReportThread)threadInstance).getUUID().toString().equals(getParamThread(request))) { + thread = (AbstractReportThread) threadInstance; + break; + } + } } if (thread != null) { return thread.isAlive(); @@ -592,8 +592,8 @@ public class HtmlReport extends Abstract * @return the thread parameter value */ public String getParamThread(HttpServletRequest request) { - String thread = request.getParameter("thread"); - return ReportStringUtil.isNotEmptyOrWhitespaceOnly(thread) ? thread : (paramThread == null? "" : paramThread); + String thread = request.getParameter("thread"); + return ReportStringUtil.isNotEmptyOrWhitespaceOnly(thread) ? thread : (paramThread == null? "" : paramThread); } /** @@ -602,8 +602,8 @@ public class HtmlReport extends Abstract * @return the threadhasnext parameter value */ public String getParamThreadHasNext(HttpServletRequest request) { - String threadhasnext = request.getParameter("threadhasnext"); - return ReportStringUtil.isNotEmptyOrWhitespaceOnly(threadhasnext) ? threadhasnext : "false"; + String threadhasnext = request.getParameter("threadhasnext"); + return ReportStringUtil.isNotEmptyOrWhitespaceOnly(threadhasnext) ? threadhasnext : "false"; } /** @@ -792,10 +792,10 @@ public class HtmlReport extends Abstract * @return the value of the title parameter */ public String getParamTitle(HttpServletRequest request) { - if (paramTitle == null) { - paramTitle = request.getParameter("title"); - } - return paramTitle != null ? paramTitle : ""; + if (paramTitle == null) { + paramTitle = request.getParameter("title"); + } + return paramTitle != null ? paramTitle : ""; } /** @@ -1214,7 +1214,7 @@ public class HtmlReport extends Abstract * @return the value of the file parameter */ public String getParamResource(HttpServletRequest request) { - paramResource = request.getParameter("resource"); + paramResource = request.getParameter("resource"); if ((paramResource != null) && !"null".equals(paramResource)) { return paramResource; } else { @@ -1288,7 +1288,7 @@ public class HtmlReport extends Abstract * @param formUri */ public void setFormRealUri(HttpServletRequest request, String formUri) { - request.setAttribute(FORM_URI, formUri); + request.setAttribute(FORM_URI, formUri); } /** @@ -1298,50 +1298,50 @@ public class HtmlReport extends Abstract * @return */ public String getFormRealUri(HttpServletRequest request) { - return (String) request.getAttribute(FORM_URI); + return (String) request.getAttribute(FORM_URI); } - public void addLogFile(String logFileName) { - if (logFile == null || logFileOutputStream == null) { - this.logFileName = logFileName; - logFile = FileUtil.getFile(logFileName); - try { - logFileOutputStream = new FileOutputStream(logFile); - } catch (FileNotFoundException e) { - // do nothing - } - } - } - - public String closeLogFile() { - if (logFileOutputStream != null) { - try { - logFileOutputStream.flush(); - } catch (IOException e) { - // do nothing - } finally { - if (logFileOutputStream != null) { - try { - logFileOutputStream.close(); - } catch (IOException e) { - // do nothing - Debug.logError(e, HtmlReport.module); - } - } - } - } - return logFileName; - } - - public String getLogFileName() { - return logFileName; - } - - public long getSequenceNum() { - return sequenceNum; - } - - public void setSequenceNum(long sequenceNum) { - this.sequenceNum = sequenceNum; - } + public void addLogFile(String logFileName) { + if (logFile == null || logFileOutputStream == null) { + this.logFileName = logFileName; + logFile = FileUtil.getFile(logFileName); + try { + logFileOutputStream = new FileOutputStream(logFile); + } catch (FileNotFoundException e) { + // do nothing + } + } + } + + public String closeLogFile() { + if (logFileOutputStream != null) { + try { + logFileOutputStream.flush(); + } catch (IOException e) { + // do nothing + } finally { + if (logFileOutputStream != null) { + try { + logFileOutputStream.close(); + } catch (IOException e) { + // do nothing + Debug.logError(e, HtmlReport.module); + } + } + } + } + return logFileName; + } + + public String getLogFileName() { + return logFileName; + } + + public long getSequenceNum() { + return sequenceNum; + } + + public void setSequenceNum(long sequenceNum) { + this.sequenceNum = sequenceNum; + } } Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/InterfaceReport.java Wed Nov 23 14:46:54 2016 @@ -211,20 +211,20 @@ public interface InterfaceReport { * * @param logFileName */ - void addLogFile(String logFileName); + void addLogFile(String logFileName); - /** - * Close log file if necessary. - * - */ - String closeLogFile(); - - /** - * Set log's sequence number. - * @param sequenceNum - */ - void setSequenceNum(long sequenceNum); - - long getSequenceNum(); + /** + * Close log file if necessary. + * + */ + String closeLogFile(); + + /** + * Set log's sequence number. + * @param sequenceNum + */ + void setSequenceNum(long sequenceNum); + + long getSequenceNum(); } \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlReport.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlReport.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlReport.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlReport.java Wed Nov 23 14:46:54 2016 @@ -29,7 +29,7 @@ import org.apache.ofbiz.htmlreport.Inter * */ public class SampleHtmlReport extends AbstractHtmlReport { - + /** * Public constructor with report variables.<p> * @@ -42,35 +42,35 @@ public class SampleHtmlReport extends Ab } public static SampleHtmlReport getReport(HttpServletRequest request, HttpServletResponse response) { - - SampleHtmlReport wp = (SampleHtmlReport) request.getAttribute(SESSION_REPORT_CLASS); - if (wp == null) { - wp = new SampleHtmlReport(request, response); - request.setAttribute(SESSION_REPORT_CLASS, wp); - } - return wp; + + SampleHtmlReport wp = (SampleHtmlReport) request.getAttribute(SESSION_REPORT_CLASS); + if (wp == null) { + wp = new SampleHtmlReport(request, response); + request.setAttribute(SESSION_REPORT_CLASS, wp); + } + return wp; } public InterfaceReportThread initializeThread(HttpServletRequest request, HttpServletResponse response, String name) { - if (name == null) { - name = ""; - } + if (name == null) { + name = ""; + } ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); int i = threadGroup.activeCount(); Thread[] threads = new Thread[i]; threadGroup.enumerate(threads, true); InterfaceReportThread thread = null; for (int j=0; j<threads.length; j++) { - Thread threadInstance = threads[j]; - if (threadInstance instanceof SampleHtmlThread) { - thread = (InterfaceReportThread) threadInstance; - break; - } + Thread threadInstance = threads[j]; + if (threadInstance instanceof SampleHtmlThread) { + thread = (InterfaceReportThread) threadInstance; + break; + } } if (thread == null) { - thread = new SampleHtmlThread(request, response, name.toLowerCase()); + thread = new SampleHtmlThread(request, response, name.toLowerCase()); } return thread; } Modified: ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java?rev=1770979&r1=1770978&r2=1770979&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java (original) +++ ofbiz/trunk/specialpurpose/pricat/src/main/java/org/apache/ofbiz/htmlreport/sample/SampleHtmlThread.java Wed Nov 23 14:46:54 2016 @@ -38,18 +38,18 @@ import org.apache.ofbiz.htmlreport.Inter */ public class SampleHtmlThread extends AbstractReportThread { - public static final String COUNT_DOWN = "countdown"; - - public static final String COUNT_UP = "countup"; - - public static final String CONFIRM = "confirm_action"; - - public static final String[] messageLables = new String[] {"FORMAT_DEFAULT", "FORMAT_WARNING", "FORMAT_HEADLINE", "FORMAT_NOTE", "FORMAT_OK", "FORMAT_ERROR", "FORMAT_THROWABLE"}; - - public static final List<String> messages = Collections.unmodifiableList(Arrays.asList(messageLables)); - - private static final String resource = "PricatUiLabels"; - + public static final String COUNT_DOWN = "countdown"; + + public static final String COUNT_UP = "countup"; + + public static final String CONFIRM = "confirm_action"; + + public static final String[] messageLables = new String[] {"FORMAT_DEFAULT", "FORMAT_WARNING", "FORMAT_HEADLINE", "FORMAT_NOTE", "FORMAT_OK", "FORMAT_ERROR", "FORMAT_THROWABLE"}; + + public static final List<String> messages = Collections.unmodifiableList(Arrays.asList(messageLables)); + + private static final String resource = "PricatUiLabels"; + /** * Constructor, creates a new HtmlImportThreat. * @@ -69,35 +69,35 @@ public class SampleHtmlThread extends Ab public void run() { try { if (getName().startsWith(COUNT_DOWN)) { - getReport().println(UtilProperties.getMessage(resource, "START_COUNT_DOWN", getLocale()), InterfaceReport.FORMAT_HEADLINE); - Random random = new Random(); - int j = 0; - for (int i=1000; i>0; i--) { - sleep(20); - j = random.nextInt(7); - if (j == 6) { - getReport().println(new Throwable(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()))); - } else { - getReport().println(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()), j); - } - } - getReport().println(UtilProperties.getMessage(resource, "COUNT_COMPLETED", getLocale()), InterfaceReport.FORMAT_HEADLINE); + getReport().println(UtilProperties.getMessage(resource, "START_COUNT_DOWN", getLocale()), InterfaceReport.FORMAT_HEADLINE); + Random random = new Random(); + int j = 0; + for (int i=1000; i>0; i--) { + sleep(20); + j = random.nextInt(7); + if (j == 6) { + getReport().println(new Throwable(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()))); + } else { + getReport().println(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()), j); + } + } + getReport().println(UtilProperties.getMessage(resource, "COUNT_COMPLETED", getLocale()), InterfaceReport.FORMAT_HEADLINE); } else if (getName().startsWith(COUNT_UP)) { - getReport().println(UtilProperties.getMessage(resource, "START_COUNT_UP", getLocale()), InterfaceReport.FORMAT_HEADLINE); - Random random = new Random(); - int j = 0; - for (int i=1; i<=1000; i++) { - sleep(20); - j = random.nextInt(7); - if (j == 6) { - getReport().println(new Throwable(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()))); - } else { - getReport().println(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()), j); - } - } - getReport().println(UtilProperties.getMessage(resource, "COUNT_COMPLETED", getLocale()), InterfaceReport.FORMAT_HEADLINE); - } else { - getReport().println(getName(), InterfaceReport.FORMAT_ERROR); + getReport().println(UtilProperties.getMessage(resource, "START_COUNT_UP", getLocale()), InterfaceReport.FORMAT_HEADLINE); + Random random = new Random(); + int j = 0; + for (int i=1; i<=1000; i++) { + sleep(20); + j = random.nextInt(7); + if (j == 6) { + getReport().println(new Throwable(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()))); + } else { + getReport().println(UtilProperties.getMessage(resource, messages.get(j), new Object[] {i}, getLocale()), j); + } + } + getReport().println(UtilProperties.getMessage(resource, "COUNT_COMPLETED", getLocale()), InterfaceReport.FORMAT_HEADLINE); + } else { + getReport().println(getName(), InterfaceReport.FORMAT_ERROR); } } catch (Exception e) { getReport().println(e); |
Free forum by Nabble | Edit this page |