[pw] applyied changed suggested in code review
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 28 Jan 2013 14:15:27 +0100
changeset 19484 8917ff30b35c
parent 19483 f0be705eaf76
child 19485 9e98aa726bba
[pw] applyied changed suggested in code review
*index for obuiapp_process_access.obuiapp_process_id
*ad_message for no access to process definition
*setAdminMode with boolean param
*removed unused code
*fixed some typos
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PROCESS_ACCESS.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/process/DefaultsProcessActionHandler.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml	Mon Jan 28 14:15:27 2013 +0100
@@ -135,5 +135,6 @@
       <check name="OBUIAPP_PARAMETER_ISACTIVE_CHK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PARAMETER_ISFIXED_CHK"><![CDATA[ISFIXED IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PARAMETER_MANDAT_CHK"><![CDATA[ISMANDATORY IN ('Y', 'N')]]></check>
+      <check name="OBUIAPP_PARAMETER_NEWLINE_CHK"><![CDATA[STARTINNEWLINE IN ('Y', 'N')]]></check>
     </table>
   </database>
--- a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PROCESS_ACCESS.xml	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PROCESS_ACCESS.xml	Mon Jan 28 14:15:27 2013 +0100
@@ -57,6 +57,9 @@
       <foreign-key foreignTable="AD_ORG" name="OBUIAPP_PROC_ORG">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
+      <index name="OBUIAPP_PROCESSACC_PROCESS_IDX" unique="false">
+        <index-column name="OBUIAPP_PROCESS_ID"/>
+      </index>
       <check name="OBUIAPP_PROC_ACC_ISACTIVE_CHK"><![CDATA[ISACTIVE IN ('Y', 'N')]]></check>
       <check name="OBUIAPP_PROC_ACC_ISREADWR_CHK"><![CDATA[ISREADWRITE IN ('Y', 'N')]]></check>
     </table>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jan 28 14:15:27 2013 +0100
@@ -5877,8 +5877,8 @@
 <!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <NAME><![CDATA[EM_OBUIAPP_Process_ID]]></NAME>
 <!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <DESCRIPTION><![CDATA[Process to be executed by the button]]></DESCRIPTION>
-<!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kind of processes:
-*"Process": Implements the 2.50 style processes with a sevlet.
+<!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kinds of processes:
+*"Process": Implements the 2.50 style processes with a Servlet.
 *"Process Definition": Implements 3.0 processes with a pure SmartClient UI.]]></HELP>
 <!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <COLUMNNAME><![CDATA[EM_OBUIAPP_Process_ID]]></COLUMNNAME>
 <!--CD3A95C8A05D45A0A2B6D250E9C83170-->  <AD_TABLE_ID><![CDATA[101]]></AD_TABLE_ID>
@@ -6745,8 +6745,8 @@
 <!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <NAME><![CDATA[EM_OBUIAPP_Process Definition]]></NAME>
 <!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <DESCRIPTION><![CDATA[Process to be executed by the button]]></DESCRIPTION>
-<!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kind of processes:
-*"Process": Implements the 2.50 style processes with a sevlet.
+<!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kinds of processes:
+*"Process": Implements the 2.50 style processes with a Servlet.
 *"Process Definition": Implements 3.0 processes with a pure SmartClient UI.]]></HELP>
 <!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <COLUMNNAME><![CDATA[EM_Obuiapp_Process_ID]]></COLUMNNAME>
 <!--F6ABE97E8E6D4E99878ADFF3B09F9249-->  <AD_TABLE_ID><![CDATA[116]]></AD_TABLE_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jan 28 14:15:27 2013 +0100
@@ -388,8 +388,8 @@
 <!--A40E05056A904DD8970BFAB4F5AF7E37-->  <NAME><![CDATA[Process Definition]]></NAME>
 <!--A40E05056A904DD8970BFAB4F5AF7E37-->  <PRINTNAME><![CDATA[Process Definition]]></PRINTNAME>
 <!--A40E05056A904DD8970BFAB4F5AF7E37-->  <DESCRIPTION><![CDATA[Process to be executed by the button]]></DESCRIPTION>
-<!--A40E05056A904DD8970BFAB4F5AF7E37-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kind of processes:
-*"Process": Implements the 2.50 style processes with a sevlet.
+<!--A40E05056A904DD8970BFAB4F5AF7E37-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kinds of processes:
+*"Process": Implements the 2.50 style processes with a Servlet.
 *"Process Definition": Implements 3.0 processes with a pure SmartClient UI.]]></HELP>
 <!--A40E05056A904DD8970BFAB4F5AF7E37-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--A40E05056A904DD8970BFAB4F5AF7E37-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_FIELD.xml	Mon Jan 28 14:15:27 2013 +0100
@@ -1374,8 +1374,8 @@
 <!--51E1B1350A334292A67AEBAA9011AB95-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--51E1B1350A334292A67AEBAA9011AB95-->  <NAME><![CDATA[Process Definition]]></NAME>
 <!--51E1B1350A334292A67AEBAA9011AB95-->  <DESCRIPTION><![CDATA[Process to be executed by the button]]></DESCRIPTION>
-<!--51E1B1350A334292A67AEBAA9011AB95-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kind of processes:
-*"Process": Implements the 2.50 style processes with a sevlet.
+<!--51E1B1350A334292A67AEBAA9011AB95-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kinds of processes:
+*"Process": Implements the 2.50 style processes with a Servlet.
 *"Process Definition": Implements 3.0 processes with a pure SmartClient UI.]]></HELP>
 <!--51E1B1350A334292A67AEBAA9011AB95-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--51E1B1350A334292A67AEBAA9011AB95-->  <AD_TAB_ID><![CDATA[101]]></AD_TAB_ID>
@@ -3316,8 +3316,8 @@
 <!--E43B890AE59B4CC8A80140CCDEFFE927-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E43B890AE59B4CC8A80140CCDEFFE927-->  <NAME><![CDATA[Process Definition]]></NAME>
 <!--E43B890AE59B4CC8A80140CCDEFFE927-->  <DESCRIPTION><![CDATA[Process to be executed by the button]]></DESCRIPTION>
-<!--E43B890AE59B4CC8A80140CCDEFFE927-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kind of processes:
-*"Process": Implements the 2.50 style processes with a sevlet.
+<!--E43B890AE59B4CC8A80140CCDEFFE927-->  <HELP><![CDATA[Process to be executed by the button. There are 2 kinds of processes:
+*"Process": Implements the 2.50 style processes with a Servlet.
 *"Process Definition": Implements 3.0 processes with a pure SmartClient UI.]]></HELP>
 <!--E43B890AE59B4CC8A80140CCDEFFE927-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--E43B890AE59B4CC8A80140CCDEFFE927-->  <AD_TAB_ID><![CDATA[110]]></AD_TAB_ID>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java	Mon Jan 28 14:15:27 2013 +0100
@@ -36,6 +36,7 @@
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.Preferences;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.model.ad.access.WindowAccess;
 import org.openbravo.model.ad.ui.Window;
@@ -52,7 +53,7 @@
   protected final JSONObject execute(Map<String, Object> parameters, String content) {
 
     try {
-      OBContext.setAdminMode();
+      OBContext.setAdminMode(true);
 
       final String processId = (String) parameters.get("processId");
       Check.isNotNull(processId, "Process ID missing in request");
@@ -65,7 +66,7 @@
 
         JSONObject err = new JSONObject();
         err.put("severity", "error");
-        err.put("text", "No access to process " + processDefinition);
+        err.put("text", OBMessageUtils.getI18NMessage("OBUIAPP_NoAccess", null));
         jsonRequest.put("message", err);
 
         log.error("No access to process " + processDefinition);
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/DefaultsProcessActionHandler.java	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/DefaultsProcessActionHandler.java	Mon Jan 28 14:15:27 2013 +0100
@@ -39,6 +39,8 @@
 import org.openbravo.model.ad.domain.Reference;
 
 /**
+ * This ActionHandler is invoked when opening a Process Definition window. It is in charge of
+ * computing default values for the parameters in the window.
  * 
  * @author alostale
  */
@@ -49,7 +51,7 @@
   @Override
   protected final JSONObject doExecute(Map<String, Object> parameters, String content) {
     try {
-      OBContext.setAdminMode();
+      OBContext.setAdminMode(true);
 
       final String processId = (String) parameters.get("processId");
       final Process processDefinition = OBDal.getInstance().get(Process.class, processId);
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java	Mon Jan 28 14:15:27 2013 +0100
@@ -19,9 +19,7 @@
 package org.openbravo.client.application.window;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.inject.Inject;
 
@@ -42,7 +40,6 @@
 public class ParameterWindowComponent extends BaseTemplateComponent {
   private static final String DEFAULT_TEMPLATE_ID = "FF80818132F916130132F9357DE10016";
 
-  protected static final Map<String, String> TEMPLATE_MAP = new HashMap<String, String>();
   static final String BUTTON_LIST_REFERENCE_ID = "FF80818132F94B500132F9575619000A";
 
   private Boolean inDevelopment = null;
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Mon Jan 28 13:55:25 2013 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Mon Jan 28 14:15:27 2013 +0100
@@ -19,9 +19,7 @@
 package org.openbravo.client.application.window;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.log4j.Logger;
 import org.openbravo.client.kernel.BaseTemplateComponent;
@@ -43,8 +41,6 @@
   private static final Logger log = Logger.getLogger(StandardWindowComponent.class);
   private static final String DEFAULT_TEMPLATE_ID = "ADD5EF45333C458098286D0E639B3290";
 
-  protected static final Map<String, String> TEMPLATE_MAP = new HashMap<String, String>();
-
   private Window window;
   private OBViewTab rootTabComponent = null;
   private Boolean inDevelopment = null;