← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18389: Analytics, using constants instead of inline strings

 

------------------------------------------------------------
revno: 18389
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-02-24 14:57:25 +0100
message:
  Analytics, using constants instead of inline strings
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTable.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-02-24 13:16:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-02-24 13:57:25 +0000
@@ -512,6 +512,11 @@
         return optionSet != null;
     }
 
+    public boolean hasLegendSet()
+    {
+        return legendSet != null;
+    }
+    
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-02-19 07:27:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-02-24 13:57:25 +0000
@@ -185,6 +185,26 @@
     }
 
     /**
+     * Returns data elements which are part of the stages of this program which
+     * have a legend set.
+     */
+    public Set<DataElement> getDataElementsWithLegendSet()
+    {
+        Set<DataElement> elements = new HashSet<>();
+
+        for ( DataElement element : getAllDataElements() )
+        {
+            if ( element != null && element.hasLegendSet() )
+            {
+                elements.add( element );
+            }
+        }
+
+        return elements;
+    }
+    
+
+    /**
      * Returns TrackedEntityAttributes from ProgramTrackedEntityAttributes. Use
      * getAttributes() to access the persisted attribute list.
      */

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTable.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTable.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTable.java	2015-02-24 13:57:25 +0000
@@ -30,6 +30,7 @@
 
 import java.util.List;
 
+import org.hisp.dhis.analytics.table.PartitionUtils;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
@@ -86,12 +87,12 @@
 
         if ( period != null )
         {
-            name += "_" + PeriodType.getCalendar().fromIso( period.getStartDate() ).getYear();
+            name += PartitionUtils.SEP + PeriodType.getCalendar().fromIso( period.getStartDate() ).getYear();
         }
 
         if ( program != null )
         {
-            name += "_" + program.getUid().toLowerCase();
+            name += PartitionUtils.SEP + program.getUid().toLowerCase();
         }
 
         return name;
@@ -103,12 +104,12 @@
 
         if ( period != null )
         {
-            name += "_" + PeriodType.getCalendar().fromIso( period.getStartDate() ).getYear();
+            name += PartitionUtils.SEP + PeriodType.getCalendar().fromIso( period.getStartDate() ).getYear();
         }
 
         if ( program != null )
         {
-            name += "_" + program.getUid().toLowerCase();
+            name += PartitionUtils.SEP + program.getUid().toLowerCase();
         }
 
         return name;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2015-02-17 17:45:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2015-02-24 13:57:25 +0000
@@ -178,7 +178,7 @@
     {
         Set<String> validPartitions = partitionManager.getEventAnalyticsPartitions();
 
-        String tableSuffix = "_" + params.getProgram().getUid();
+        String tableSuffix = PartitionUtils.SEP + params.getProgram().getUid();
         
         if ( params.hasStartEndDate() )
         {
@@ -220,7 +220,7 @@
 
     private List<EventQueryParams> groupByPartition( EventQueryParams params, Set<String> validPartitions )
     {
-        String tableSuffix = "_" + params.getProgram().getUid();
+        String tableSuffix = PartitionUtils.SEP + params.getProgram().getUid();
         
         if ( params.hasStartEndDate() )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-02-15 17:50:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java	2015-02-24 13:57:25 +0000
@@ -268,7 +268,7 @@
             String[] col = { quote( dataElement.getUid() ), dataType, sql };
             columns.add( col );
         }
-
+        
         for ( TrackedEntityAttribute attribute : table.getProgram().getTrackedEntityAttributes() )
         {
             String dataType = attribute.isNumericType() ? dbl : text;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2015-02-24 13:57:25 +0000
@@ -53,7 +53,7 @@
 {
     private static final YearlyPeriodType PERIODTYPE = new YearlyPeriodType();
 
-    private static final String SEP = "_";
+    public static final String SEP = "_";
 
     public static Period getPeriod( Integer year )
     {