details: https://code.openbravo.com/erp/devel/pi/rev/b26d445bb8b1 changeset: 35526:b26d445bb8b1 user: Asier Lostalé <asier.lostale <at> openbravo.com> date: Mon Mar 11 14:52:04 2019 +0100 summary: related to 40174, related to 39883: fixed Java formatting
diffstat: modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java | 4 +- modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportBPSet.java | 14 +- modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportProductInDiscount.java | 22 ++-- modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ProcessUploadedFile.java | 45 +++++---- 4 files changed, 44 insertions(+), 41 deletions(-) diffs (227 lines): diff -r b5da46fd9c1c -r b26d445bb8b1 modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java Mon Mar 11 11:59:35 2019 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java Mon Mar 11 14:52:04 2019 +0100 @@ -315,8 +315,8 @@ "web/org.openbravo.client.application/js/upload/ob-upload-bp-select-button.js", false)); globalResources.add(createStaticResource( "web/org.openbravo.client.application/js/upload/ob-upload-product-button.js", false)); - globalResources.add(createStyleSheetResource( - "web/org.openbravo.userinterface.smartclient/openbravo/skins/" + globalResources + .add(createStyleSheetResource("web/org.openbravo.userinterface.smartclient/openbravo/skins/" + KernelConstants.SKIN_PARAMETER + "/org.openbravo.client.application/ob-upload-styles.css", false)); diff -r b5da46fd9c1c -r b26d445bb8b1 modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportBPSet.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportBPSet.java Mon Mar 11 11:59:35 2019 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportBPSet.java Mon Mar 11 14:52:04 2019 +0100 @@ -43,16 +43,18 @@ private static final long serialVersionUID = 1L; private static final DateFormat dateFormat = JsonUtils.createDateFormat(); + @Override protected void clearBeforeImport(String ownerId, JSONObject paramValues) { @SuppressWarnings("unchecked") - NativeQuery<String> qry = OBDal.getInstance().getSession() + NativeQuery<String> qry = OBDal.getInstance() + .getSession() .createNativeQuery("delete from c_bp_set_line where c_bp_set_id = :c_bp_set_id"); qry.setParameter("c_bp_set_id", ownerId); qry.executeUpdate(); } - protected UploadResult doProcessFile(JSONObject paramValues, File file) - throws Exception { + @Override + protected UploadResult doProcessFile(JSONObject paramValues, File file) throws Exception { final UploadResult uploadResult = new UploadResult(); final String bpSetId = paramValues.getString("inpOwnerId"); final Date startDate = getDate(paramValues.getString("startDate")); @@ -85,9 +87,9 @@ } else { // check if the line already exists final String bpId = bpIds.get(0); - final OBQuery<BusinessPartnerSetLine> bpSetLineQry = OBDal.getInstance().createQuery( - BusinessPartnerSetLine.class, - "c_bp_set_id=:c_bp_set_id and c_bpartner_id=:c_bpartner_id"); + final OBQuery<BusinessPartnerSetLine> bpSetLineQry = OBDal.getInstance() + .createQuery(BusinessPartnerSetLine.class, + "c_bp_set_id=:c_bp_set_id and c_bpartner_id=:c_bpartner_id"); bpSetLineQry.setNamedParameter("c_bp_set_id", bpSetId); bpSetLineQry.setNamedParameter("c_bpartner_id", bpId); final List<BusinessPartnerSetLine> lines = bpSetLineQry.list(); diff -r b5da46fd9c1c -r b26d445bb8b1 modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportProductInDiscount.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportProductInDiscount.java Mon Mar 11 11:59:35 2019 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ImportProductInDiscount.java Mon Mar 11 14:52:04 2019 +0100 @@ -38,24 +38,25 @@ public class ImportProductInDiscount extends ProcessUploadedFile { private static final long serialVersionUID = 1L; + @Override protected void clearBeforeImport(String ownerId, JSONObject paramValues) { @SuppressWarnings("unchecked") - NativeQuery<String> qry = OBDal.getInstance().getSession() + NativeQuery<String> qry = OBDal.getInstance() + .getSession() .createNativeQuery("delete from m_offer_product where m_offer_id = :m_offer_id"); qry.setParameter("m_offer_id", ownerId); qry.executeUpdate(); } - protected UploadResult doProcessFile(JSONObject paramValues, File file) - throws Exception { + @Override + protected UploadResult doProcessFile(JSONObject paramValues, File file) throws Exception { final UploadResult uploadResult = new UploadResult(); final String discountId = paramValues.getString("inpOwnerId"); final PriceAdjustment discount = OBDal.getInstance().get(PriceAdjustment.class, discountId); final String errorMsgProductNotFound = OBMessageUtils.getI18NMessage("OBUIAPP_ProductNotFound", new String[0]); - final String errorMsgProductNotUnique = OBMessageUtils.getI18NMessage( - "OBUIAPP_ProductNotUnique", - new String[0]); + final String errorMsgProductNotUnique = OBMessageUtils + .getI18NMessage("OBUIAPP_ProductNotUnique", new String[0]); try (BufferedReader br = Files.newBufferedReader(Paths.get(file.getAbsolutePath()))) { String line; @@ -79,9 +80,8 @@ } else { // check if the line already exists final String productId = productIds.get(0); - final OBQuery<Product> productDiscountQry = OBDal.getInstance().createQuery( - Product.class, - "m_offer_id=:m_offer_id and m_product_id=:m_product_id"); + final OBQuery<Product> productDiscountQry = OBDal.getInstance() + .createQuery(Product.class, "m_offer_id=:m_offer_id and m_product_id=:m_product_id"); productDiscountQry.setNamedParameter("m_offer_id", discountId); productDiscountQry.setNamedParameter("m_product_id", productId); final List<Product> lines = productDiscountQry.list(); @@ -92,8 +92,8 @@ productDiscount.setClient(discount.getClient()); productDiscount.setOrganization(discount.getOrganization()); productDiscount.setPriceAdjustment(discount); - productDiscount.setProduct(OBDal.getInstance().get( - org.openbravo.model.common.plm.Product.class, productId)); + productDiscount.setProduct( + OBDal.getInstance().get(org.openbravo.model.common.plm.Product.class, productId)); } else { // get the line from the result productDiscount = lines.get(0); diff -r b5da46fd9c1c -r b26d445bb8b1 modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ProcessUploadedFile.java --- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ProcessUploadedFile.java Mon Mar 11 11:59:35 2019 +0100 +++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/ProcessUploadedFile.java Mon Mar 11 14:52:04 2019 +0100 @@ -45,8 +45,8 @@ import org.openbravo.erpCommon.utility.OBMessageUtils; /** - * Generic base class to be extended to implement an import by uploading a file. The actual processing happens in a subclass which - * needs to override two methods. + * Generic base class to be extended to implement an import by uploading a file. The actual + * processing happens in a subclass which needs to override two methods. * * The resulting (error) messages can be returned as a file to download by the user. * @@ -58,14 +58,15 @@ private static Logger log = LogManager.getLogger(); @Override - public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, - ServletException { + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { final VariablesSecureApp vars = new VariablesSecureApp(request); post(vars, request, response); } - public void post(VariablesSecureApp vars, HttpServletRequest request, HttpServletResponse response) { + public void post(VariablesSecureApp vars, HttpServletRequest request, + HttpServletResponse response) { final String strParamValues = vars.getStringParameter("paramValues"); JSONObject paramValues = null; @@ -91,8 +92,8 @@ printResponse(response, paramValues, null, e.getMessage()); } catch (Exception e2) { log.error("Error sending error message", e2); - throw new OBException(OBMessageUtils.messageBD("ErrorUploadingFile") + " " - + e2.getMessage(), e2, true); + throw new OBException( + OBMessageUtils.messageBD("ErrorUploadingFile") + " " + e2.getMessage(), e2, true); } throw new OBException(OBMessageUtils.messageBD("ErrorUploadingFile"), e, true); } finally { @@ -146,13 +147,13 @@ writer.write("var iscWindow = top.OB || parent.OB;\n"); if (obj != null) { final String buttonId = paramValues.getString("buttonID"); - writer.write("iscWindow.Utilities.uploadFinished(\"" + buttonId + "\"," + obj.toString() - + ");"); + writer.write( + "iscWindow.Utilities.uploadFinished(\"" + buttonId + "\"," + obj.toString() + ");"); } if (StringUtils.isNotBlank(strMessage)) { final String viewId = paramValues.getString("viewID"); - writer.write("iscWindow.Utilities.writeErrorMessage(\"" + viewId + "\",\"" + strMessage - + "\");"); + writer.write( + "iscWindow.Utilities.writeErrorMessage(\"" + viewId + "\",\"" + strMessage + "\");"); } writer.write("</SCRIPT></BODY></HTML>"); } @@ -166,8 +167,8 @@ response.setHeader("Content-disposition", "attachment; filename=" + fileName); Writer w = response.getWriter(); try { - try (BufferedReader br = Files.newBufferedReader(Paths.get(tmpFolder + File.separator - + fileName))) { + try (BufferedReader br = Files + .newBufferedReader(Paths.get(tmpFolder + File.separator + fileName))) { String line; while ((line = br.readLine()) != null) { if (line.trim().length() == 0) { @@ -194,18 +195,18 @@ } /** - * This method is called when the parameter import mode is set to import and replace. In that case the current content should be - * removed. + * This method is called when the parameter import mode is set to import and replace. In that case + * the current content should be removed. * * The ownerId is the id of the parent record. */ protected abstract void clearBeforeImport(String ownerId, JSONObject paramValues); /** - * Is called to process the content of the uploaded file. The results should be returned in the uploadResult object. + * Is called to process the content of the uploaded file. The results should be returned in the + * uploadResult object. */ - protected abstract UploadResult doProcessFile(JSONObject paramValues, File file) - throws Exception; + protected abstract UploadResult doProcessFile(JSONObject paramValues, File file) throws Exception; protected static class UploadResult { private int lineCount = 0; @@ -241,15 +242,15 @@ } public String getResultMessage() { - return OBMessageUtils.getI18NMessage("OBUIAPP_PROCESSEDOVERVIEW", new String[] { - lineCount + "", errorCount + "" }); + return OBMessageUtils.getI18NMessage("OBUIAPP_PROCESSEDOVERVIEW", + new String[] { lineCount + "", errorCount + "" }); } public String writeToFile(String fileName) throws Exception { final String resultFileName = "result_" + fileName; final String tmpFolder = System.getProperty("java.io.tmpdir"); - try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(tmpFolder + File.separator - + resultFileName))) { + try (BufferedWriter writer = Files + .newBufferedWriter(Paths.get(tmpFolder + File.separator + resultFileName))) { writer.write(getResultMessage() + "\n" + errorMessages); } return resultFileName; _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits