← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19702: Removed CacheableBaseIdentifiableObject, implemented directly in relevant classes instead

 

------------------------------------------------------------
revno: 19702
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-03 13:33:39 +0200
message:
  Removed CacheableBaseIdentifiableObject, implemented directly in relevant classes instead
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/CacheableBaseIdentifiableObject.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/Cacheable.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/Cacheable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/Cacheable.java	2015-07-31 11:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/Cacheable.java	2015-08-03 11:33:39 +0000
@@ -29,8 +29,8 @@
  */
 
 /**
- * Inheritors of this interface gain the cacheStrategy property which allows
- * specifically setting and persisting the CacheStrategy for that particular object.
+ * Implementers of this interface gain the cacheStrategy property which allows
+ * specifically setting and persisting the CacheStrategy for the object.
  * The chosen CacheStrategy should be honored on a per-object-basis for any Cacheable
  * and will ultimately decide the cache parameters of any web request returning the object.
  *
@@ -38,6 +38,8 @@
  */
 public interface Cacheable
 {
+    CacheStrategy DEFAULT_CACHE_STRATEGY = CacheStrategy.RESPECT_SYSTEM_SETTING;
+
     /**
      * Returns the CacheStrategy for this Cacheable. Should never return null.
      *

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/CacheableBaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/CacheableBaseIdentifiableObject.java	2015-07-31 11:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/cache/CacheableBaseIdentifiableObject.java	1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.common.cache;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.DxfNamespaces;
-import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.common.MergeStrategy;
-import org.hisp.dhis.common.view.DetailedView;
-import org.hisp.dhis.common.view.ExportView;
-
-/**
- * @author Halvdan Hoem Grelland
- */
-public class CacheableBaseIdentifiableObject
-    extends BaseIdentifiableObject
-    implements Cacheable
-{
-    public static final CacheStrategy DEFAULT_CACHE_STRATEGY = CacheStrategy.RESPECT_SYSTEM_SETTING;
-
-    private CacheStrategy cacheStrategy = CacheStrategy.RESPECT_SYSTEM_SETTING;
-
-    public void setCacheStrategy( CacheStrategy cacheStrategy )
-    {
-        this.cacheStrategy = cacheStrategy;
-    }
-
-    @Override
-    public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
-    {
-        super.mergeWith( other, strategy );
-
-        if ( other.getClass().isInstance( this ) )
-        {
-            Cacheable cacheable = (Cacheable) other;
-
-            if ( strategy.isReplace() )
-            {
-                cacheStrategy = cacheable.getCacheStrategy();
-            }
-            else if ( strategy.isMerge() )
-            {
-                cacheStrategy = cacheable.getCacheStrategy() == null ? cacheStrategy : cacheable.getCacheStrategy();
-            }
-        }
-    }
-
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    @Override
-    public CacheStrategy getCacheStrategy()
-    {
-        return cacheStrategy;
-    }
-}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2015-07-31 11:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2015-08-03 11:33:39 +0000
@@ -37,7 +37,8 @@
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
-import org.hisp.dhis.common.cache.CacheableBaseIdentifiableObject;
+import org.hisp.dhis.common.cache.CacheStrategy;
+import org.hisp.dhis.common.cache.Cacheable;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.period.RelativePeriods;
@@ -49,7 +50,8 @@
  */
 @JacksonXmlRootElement( localName = "report", namespace = DxfNamespaces.DXF_2_0 )
 public class Report
-    extends CacheableBaseIdentifiableObject
+    extends BaseIdentifiableObject
+    implements Cacheable
 {
     private static final long serialVersionUID = 7880117720157807526L;
 
@@ -69,6 +71,8 @@
 
     private ReportParams reportParams;
 
+    private CacheStrategy cacheStrategy = CacheStrategy.RESPECT_SYSTEM_SETTING;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -208,6 +212,20 @@
         this.reportParams = reportParams;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @Override
+    public CacheStrategy getCacheStrategy()
+    {
+        return cacheStrategy;
+    }
+
+    public void setCacheStrategy( CacheStrategy cacheStrategy )
+    {
+        this.cacheStrategy = cacheStrategy;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {
@@ -221,12 +239,13 @@
             {
                 designContent = report.getDesignContent();
                 reportTable = report.getReportTable();
+                cacheStrategy = report.getCacheStrategy();
             }
             else if ( strategy.isMerge() )
             {
                 designContent = report.getDesignContent() == null ? designContent : report.getDesignContent();
                 reportTable = report.getReportTable() == null ? reportTable : report.getReportTable();
-
+                cacheStrategy = report.getCacheStrategy() == null ? cacheStrategy : report.getCacheStrategy();
             }
         }
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java	2015-07-31 11:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlView.java	2015-08-03 11:33:39 +0000
@@ -34,10 +34,12 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.google.common.collect.Sets;
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
-import org.hisp.dhis.common.cache.CacheableBaseIdentifiableObject;
+import org.hisp.dhis.common.cache.CacheStrategy;
+import org.hisp.dhis.common.cache.Cacheable;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.schema.annotation.PropertyRange;
@@ -52,7 +54,8 @@
  */
 @JacksonXmlRootElement( localName = "sqlView", namespace = DxfNamespaces.DXF_2_0 )
 public class SqlView
-    extends CacheableBaseIdentifiableObject
+    extends BaseIdentifiableObject
+    implements Cacheable
 {
     public static final String PREFIX_VIEWNAME = "_view";
 
@@ -66,7 +69,7 @@
     private static final String REGEX_SEP = "|";
     
     // -------------------------------------------------------------------------
-    // Variables
+    // Properties
     // -------------------------------------------------------------------------
 
     private String description;
@@ -74,6 +77,8 @@
     private String sqlQuery;
 
     private SqlViewType type;
+
+    private CacheStrategy cacheStrategy = CacheStrategy.RESPECT_SYSTEM_SETTING;
     
     // -------------------------------------------------------------------------
     // Constructors
@@ -235,6 +240,20 @@
         this.type = type;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    @Override
+    public CacheStrategy getCacheStrategy()
+    {
+        return cacheStrategy;
+    }
+
+    public void setCacheStrategy( CacheStrategy cacheStrategy )
+    {
+        this.cacheStrategy = cacheStrategy;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
     {
@@ -249,12 +268,14 @@
                 description = sqlView.getDescription();
                 sqlQuery = sqlView.getSqlQuery();
                 type = sqlView.getType();
+                cacheStrategy = sqlView.getCacheStrategy();
             }
             else if ( strategy.isMerge() )
             {
                 description = sqlView.getDescription() == null ? description : sqlView.getDescription();
                 sqlQuery = sqlView.getSqlQuery() == null ? sqlQuery : sqlView.getSqlQuery();
                 type = sqlView.getType() == null ? type : sqlView.getType();
+                cacheStrategy = sqlView.getCacheStrategy() == null ? cacheStrategy : sqlView.getCacheStrategy();
             }
         }
     }