← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13058: add legendSet to dataSets

 

------------------------------------------------------------
revno: 13058
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-11-28 21:52:27 +0100
message:
  add legendSet to dataSets
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm


--
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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2013-11-28 20:52:27 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.period.PeriodType;
@@ -208,6 +209,11 @@
      */
     private boolean renderHorizontally;
 
+    /**
+     * The legend set for this indicator.
+     */
+    private MapLegendSet legendSet;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -734,6 +740,20 @@
         this.dataElementDecoration = dataElementDecoration;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public MapLegendSet getLegendSet()
+    {
+        return legendSet;
+    }
+
+    public void setLegendSet( MapLegendSet legendSet )
+    {
+        this.legendSet = legendSet;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other )
     {
@@ -756,6 +776,7 @@
             skipOffline = dataSet.isSkipOffline();
             renderAsTabs = dataSet.isRenderAsTabs();
             renderHorizontally = dataSet.isRenderHorizontally();
+            legendSet = dataSet.getLegendSet() == null ? legendSet : dataSet.getLegendSet();
 
             dataElementDecoration = dataSet.isDataElementDecoration();
             notificationRecipients = dataSet.getNotificationRecipients();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java	2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicator.java	2013-11-28 20:52:27 +0000
@@ -371,6 +371,7 @@
             explodedNumerator = indicator.getExplodedNumerator() == null ? explodedNumerator : indicator.getExplodedNumerator();
             explodedDenominator = indicator.getExplodedDenominator() == null ? explodedDenominator : indicator.getExplodedDenominator();
             indicatorType = indicator.getIndicatorType() == null ? indicatorType : indicator.getIndicatorType();
+            legendSet = indicator.getLegendSet() == null ? legendSet : indicator.getLegendSet();
 
             dataSets.clear();
             groups.clear();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml	2013-11-28 20:52:27 +0000
@@ -108,5 +108,8 @@
       <many-to-many class="org.hisp.dhis.user.UserGroupAccess" column="usergroupaccessid" unique="true" />
     </set>
 
+    <many-to-one name="legendSet" class="org.hisp.dhis.mapping.MapLegendSet" column="legendsetid"
+      foreign-key="fk_indicator_legendset" />
+
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/AddDataSetAction.java	2013-11-28 20:52:27 +0000
@@ -34,6 +34,8 @@
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.UserGroupService;
 import org.hisp.dhis.user.UserService;
@@ -90,6 +92,13 @@
         this.userGroupService = userGroupService;
     }
 
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -227,6 +236,13 @@
         this.indicatorsSelectedList = indicatorsSelectedList;
     }
 
+    private Integer selectedLegendSetId;
+
+    public void setSelectedLegendSetId( Integer selectedLegendSetId )
+    {
+        this.selectedLegendSetId = selectedLegendSetId;
+    }
+
     // -------------------------------------------------------------------------
     // Action
     // -------------------------------------------------------------------------
@@ -246,6 +262,8 @@
 
         DataSet dataSet = new DataSet( name, shortName, code, periodType );
 
+        MapLegendSet legendSet = mappingService.getMapLegendSet( selectedLegendSetId );
+
         dataSet.setExpiryDays( expiryDays );
         dataSet.setTimelyDays( timelyDays );
         dataSet.setSkipAggregation( skipAggregation );
@@ -275,6 +293,7 @@
         dataSet.setDataElementDecoration( dataElementDecoration );
         dataSet.setRenderAsTabs( renderAsTabs );
         dataSet.setRenderHorizontally( renderHorizontally );
+        dataSet.setLegendSet( legendSet );
 
         dataSetService.addDataSet( dataSet );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/EditDataSetFormAction.java	2013-11-28 20:52:27 +0000
@@ -37,12 +37,15 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupService;
 
 import com.opensymphony.xwork2.Action;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author mortenoh
@@ -75,6 +78,14 @@
         this.userGroupService = userGroupService;
     }
 
+    private MappingService mappingService;
+
+    @Autowired
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -121,6 +132,13 @@
         return indicators;
     }
 
+    private List<MapLegendSet> legendSets;
+
+    public List<MapLegendSet> getLegendSets()
+    {
+        return legendSets;
+    }
+
     // -------------------------------------------------------------------------
     // Execute
     // -------------------------------------------------------------------------
@@ -130,6 +148,7 @@
     {
         periodTypes = periodService.getAllPeriodTypes();
         userGroups = new ArrayList<UserGroup>( userGroupService.getAllUserGroups() );
+        legendSets = new ArrayList<MapLegendSet>( mappingService.getAllMapLegendSets() );
 
         if ( dataSetId != null )
         {
@@ -141,6 +160,7 @@
         Collections.sort( userGroups, IdentifiableObjectNameComparator.INSTANCE );
         Collections.sort( dataElements, IdentifiableObjectNameComparator.INSTANCE );
         Collections.sort( indicators, IdentifiableObjectNameComparator.INSTANCE );
+        Collections.sort( legendSets, IdentifiableObjectNameComparator.INSTANCE );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java	2013-11-28 20:52:27 +0000
@@ -37,6 +37,8 @@
 import org.hisp.dhis.dataset.SectionService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.UserGroupService;
@@ -101,6 +103,13 @@
         this.userGroupService = userGroupService;
     }
 
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
     // -------------------------------------------------------------------------
     // Input & output
     // -------------------------------------------------------------------------
@@ -245,6 +254,13 @@
         this.indicatorsSelectedList = indicatorsSelectedList;
     }
 
+    private Integer selectedLegendSetId;
+
+    public void setSelectedLegendSetId( Integer selectedLegendSetId )
+    {
+        this.selectedLegendSetId = selectedLegendSetId;
+    }
+
     // -------------------------------------------------------------------------
     // Action
     // -------------------------------------------------------------------------
@@ -262,6 +278,8 @@
 
         Set<DataElement> dataElements = new HashSet<DataElement>();
 
+        MapLegendSet legendSet = mappingService.getMapLegendSet( selectedLegendSetId );
+
         for ( String id : dataElementsSelectedList )
         {
             dataElements.add( dataElementService.getDataElement( Integer.parseInt( id ) ) );
@@ -282,11 +300,11 @@
         dataSet.setTimelyDays( timelyDays );
         dataSet.setSkipAggregation( skipAggregation );
 
-        if ( !( equalsNullSafe( name, dataSet.getName() ) && 
-            periodType.equals( dataSet.getPeriodType() ) && 
-            dataElements.equals( dataSet.getDataElements() ) && 
+        if ( !(equalsNullSafe( name, dataSet.getName() ) &&
+            periodType.equals( dataSet.getPeriodType() ) &&
+            dataElements.equals( dataSet.getDataElements() ) &&
             indicators.equals( dataSet.getIndicators() ) &&
-            renderAsTabs == dataSet.isRenderAsTabs() ) )
+            renderAsTabs == dataSet.isRenderAsTabs()) )
         {
             dataSet.increaseVersion(); // Check if version must be updated
         }
@@ -303,10 +321,11 @@
         dataSet.setValidCompleteOnly( validCompleteOnly );
         dataSet.setNotifyCompletingUser( notifyCompletingUser );
         dataSet.setSkipOffline( skipOffline );
-        dataSet.setDataElementDecoration( dataElementDecoration );		
+        dataSet.setDataElementDecoration( dataElementDecoration );
         dataSet.setRenderAsTabs( renderAsTabs );
         dataSet.setRenderHorizontally( renderHorizontally );
         dataSet.setNotificationRecipients( userGroupService.getUserGroup( notificationRecipients ) );
+        dataSet.setLegendSet( legendSet );
 
         dataSetService.updateDataSet( dataSet );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2013-05-12 17:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml	2013-11-28 20:52:27 +0000
@@ -124,6 +124,7 @@
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
     <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataset.action.UpdateDataSetAction" class="org.hisp.dhis.dataset.action.UpdateDataSetAction"
@@ -134,6 +135,7 @@
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="userGroupService" ref="org.hisp.dhis.user.UserGroupService" />
+    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
   </bean>
 
   <bean id="org.hisp.dhis.dataset.action.GetDataSetAction" class="org.hisp.dhis.dataset.action.GetDataSetAction"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2013-11-20 14:47:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties	2013-11-28 20:52:27 +0000
@@ -112,3 +112,4 @@
 pdf_data_entry_form=Get PDF for Data Entry
 select_symbol=Select symbol
 symbol=Symbol
+legend_set=Legend set

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2013-11-28 20:52:27 +0000
@@ -158,6 +158,18 @@
           </select>
         </td>
       </tr>
+      </tr>
+      <tr>
+        <td>$i18n.getString( 'legend_set' )</td>
+        <td>
+          <select id="selectedLegendSetId" name="selectedLegendSetId">
+            <option value="0">[$i18n.getString('please_select')]</option>
+            #foreach ( $legendSet in $legendSets )
+              <option value="$legendSet.id">$encoder.htmlEncode( $legendSet.name )</option>
+            #end
+          </select>
+        </td>
+      </tr>
       <tr>
         <td><label>$i18n.getString( "skip_offline" )</label></td>
         <td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2013-11-28 19:26:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2013-11-28 20:52:27 +0000
@@ -159,6 +159,17 @@
         </td>
       </tr>
       <tr>
+        <td>$i18n.getString( 'legend_set' )</td>
+        <td>
+          <select id="selectedLegendSetId" name="selectedLegendSetId">
+            <option value="0">[$i18n.getString('please_select')]</option>
+            #foreach ( $legendSet in $legendSets )
+              <option value="$legendSet.id" #if( $dataSet.legendSet && $dataSet.legendSet.id == "$legendSet.id" )selected #end>$encoder.htmlEncode( $legendSet.name )</option>
+            #end
+          </select>
+        </td>
+      </tr>
+      <tr>
         <td><label for="skipOffline">$i18n.getString( "skip_offline" )</label></td>
         <td>
           <select id="skipOffline" name="skipOffline">