Related to ISSUE-42595: Apply same isInDevelopment logic for caching
authorCristian Berner <cristian.berner@openbravo.com>
Wed, 08 Jan 2020 13:52:10 +0100
changeset 36926 82de1963f8ba
parent 36925 1287a292a138
child 36927 7b13593cab65
Related to ISSUE 42595: Apply same isInDevelopment logic for caching

Caching of resources should be the same across all BaseComponents, with some small exceptions. BaseComponent isInDevelopment method should be used instead of new private methods.
modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachmentWindowComponent.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
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachmentWindowComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachmentWindowComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012-2018 Openbravo SLU
+ * All portions are Copyright (C) 2012-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -48,7 +48,6 @@
   private static final String DEFAULT_TEMPLATE_ID = "01E447F740584E02BA4612F6BDFB900D";
   private static final Logger log = LogManager.getLogger();
 
-  private Boolean inDevelopment = null;
   private String uniqueString = "" + System.currentTimeMillis();
   private Tab tab;
   private AttachmentMethod attMethod;
@@ -69,32 +68,13 @@
   public String getWindowClientClassName() {
     String baseClassName = KernelConstants.ID_PREFIX + tab.getId() + KernelConstants.ID_PREFIX
         + attMethod.getId();
-    if (isIndevelopment()) {
+    if (isInDevelopment()) {
       return baseClassName + KernelConstants.ID_PREFIX + uniqueString;
     }
     return baseClassName;
   }
 
   /**
-   * Compares if the module of the class tab variable is in development
-   * 
-   * @return True if the module is in development
-   */
-  public boolean isIndevelopment() {
-    if (inDevelopment != null) {
-      return inDevelopment;
-    }
-
-    // check window, tabs and fields
-    inDevelopment = Boolean.FALSE;
-    if (tab.getModule().isInDevelopment() && tab.getModule().isEnabled()) {
-      inDevelopment = Boolean.TRUE;
-    }
-
-    return inDevelopment;
-  }
-
-  /**
    * Generates java-script code
    * 
    * @return generated code
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ParameterWindowComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2012-2016 Openbravo SLU
+ * All portions are Copyright (C) 2012-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -55,7 +55,6 @@
 
   static final String BUTTON_LIST_REFERENCE_ID = "FF80818132F94B500132F9575619000A";
 
-  private Boolean inDevelopment = null;
   private String uniqueString = "" + System.currentTimeMillis();
   private Process process;
 
@@ -72,7 +71,7 @@
   public String getWindowClientClassName() {
     // see the ViewComponent#correctViewId
     // changes made in this if statement should also be done in that method
-    if (isIndevelopment()) {
+    if (isInDevelopment()) {
       return KernelConstants.ID_PREFIX + process.getId() + KernelConstants.ID_PREFIX + uniqueString;
     }
     return KernelConstants.ID_PREFIX + process.getId();
@@ -82,20 +81,6 @@
     this.uniqueString = uniqueString;
   }
 
-  public boolean isIndevelopment() {
-    if (inDevelopment != null) {
-      return inDevelopment;
-    }
-
-    // check window, tabs and fields
-    inDevelopment = Boolean.FALSE;
-    if (process.getModule().isInDevelopment() && process.getModule().isEnabled()) {
-      inDevelopment = Boolean.TRUE;
-    }
-
-    return inDevelopment;
-  }
-
   @Override
   public String generate() {
     final String jsCode = super.generate();
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2018 Openbravo SLU
+ * All portions are Copyright (C) 2010-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -68,7 +68,7 @@
   public String getWindowClientClassName() {
     // see the ViewComponent#correctViewId
     // changes made in this if statement should also be done in that method
-    if (isIndevelopment()) {
+    if (isInDevelopment()) {
       return KernelConstants.ID_PREFIX + window.getId() + KernelConstants.ID_PREFIX + uniqueString;
     }
     return KernelConstants.ID_PREFIX + getWindowId();
@@ -78,10 +78,6 @@
     this.uniqueString = uniqueString;
   }
 
-  public boolean isIndevelopment() {
-    return adcs.isInDevelopment();
-  }
-
   @Override
   public String generate() {
     final String jsCode = super.generate();
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/BaseComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2010-2018 Openbravo SLU 
+ * All portions are Copyright (C) 2010-2020 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -276,7 +276,20 @@
 
   @Override
   public boolean isInDevelopment() {
-    return adcs.isInDevelopment(getModule().getId());
+    return adcs.isInDevelopment();
+  }
+
+  /**
+   * Returns if a module is set or not to 'in development'
+   *
+   * @param moduleId
+   *          Id of the module
+   * @return {@code true} if there are modules in "in development" status. Otherwise, return
+   *         {@code false}
+   * @see ApplicationDictionaryCachedStructures#isInDevelopment(String)
+   */
+  protected boolean isInDevelopment(String moduleId) {
+    return adcs.isInDevelopment(moduleId);
   }
 
   protected String getApplicationName() {
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StaticResourceComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -33,7 +33,6 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.openbravo.base.session.OBPropertiesProvider;
-import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource.ComponentResourceType;
 import org.openbravo.dal.core.OBContext;
@@ -58,14 +57,6 @@
   @Inject
   private StaticResourceProvider resourceProvider;
 
-  @Inject
-  private ApplicationDictionaryCachedStructures adCachedStructures;
-
-  @Override
-  public boolean isInDevelopment() {
-    return adCachedStructures.isInDevelopment();
-  }
-
   /**
    * @return returns this instance
    * @see org.openbravo.client.kernel.BaseComponent#getData()
@@ -133,8 +124,9 @@
           "var isomorphicDir='../web/org.openbravo.userinterface.smartclient/isomorphic/';\n");
 
       final String scDevModulePackage = "org.openbravo.userinterface.smartclient.dev";
+      final String scDevModuleId = "5C3673B66CA3494B9981BE61F73A3A85";
       if (KernelUtils.getInstance().isModulePresent(scDevModulePackage)
-          && KernelUtils.getInstance().getModule(scDevModulePackage).isInDevelopment()) {
+          && isInDevelopment(scDevModuleId)) {
         result.append(
             "document.write('<'+'SCRIPT SRC=' + window.isomorphicDir + 'ISC_Combined.uncompressed.js><'+'/SCRIPT>');");
       }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java	Wed Jan 08 12:48:53 2020 +0100
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/StyleSheetResourceComponent.java	Wed Jan 08 13:52:10 2020 +0100
@@ -33,7 +33,6 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource;
 import org.openbravo.client.kernel.BaseComponentProvider.ComponentResource.ComponentResourceType;
 import org.openbravo.model.ad.module.Module;
@@ -57,14 +56,6 @@
   @Inject
   private StaticResourceProvider resourceProvider;
 
-  @Inject
-  private ApplicationDictionaryCachedStructures adCachedStructures;
-
-  @Override
-  public boolean isInDevelopment() {
-    return adCachedStructures.isInDevelopment();
-  }
-
   /**
    * @return returns this instance
    * @see org.openbravo.client.kernel.BaseComponent#getData()