← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20194: switch dataSet.dataSetType and programStage.dataEntryType to dataSet.formType programStage.formTy...

 

------------------------------------------------------------
revno: 20194
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-17 12:52:20 +0700
message:
  switch dataSet.dataSetType and programStage.dataEntryType to dataSet.formType programStage.formType, wip
removed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/DataSetTypeFilter.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/FormType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml


--
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	2015-09-13 16:04:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2015-09-17 05:52:20 +0000
@@ -28,9 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import com.google.common.collect.Sets;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.BaseNameableObject;
@@ -57,14 +62,8 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.UserGroup;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import com.google.common.collect.Sets;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * This class is used for defining the standardized DataSets. A DataSet consists
@@ -77,11 +76,6 @@
     extends BaseNameableObject
     implements VersionedObject
 {
-    public static final String TYPE_DEFAULT = "default";
-    public static final String TYPE_SECTION = "section";
-    public static final String TYPE_CUSTOM = "custom";
-    public static final String TYPE_SECTION_MULTIORG = "multiorg_section";
-
     public static final int NO_EXPIRY = 0;
 
     /**
@@ -186,7 +180,7 @@
      * not allowed for current period.
      */
     private int openFuturePeriods;
-    
+
     /**
      * Property indicating that all fields for a data element must be filled.
      */
@@ -292,10 +286,10 @@
     {
         Set<OrganisationUnit> toRemove = Sets.difference( sources, updates );
         Set<OrganisationUnit> toAdd = Sets.difference( updates, sources );
-        
+
         toRemove.parallelStream().forEach( u -> u.getDataSets().remove( this ) );
         toAdd.parallelStream().forEach( u -> u.getDataSets().add( this ) );
-        
+
         sources.clear();
         sources.addAll( updates );
     }
@@ -316,10 +310,10 @@
     {
         Set<DataElement> toRemove = Sets.difference( dataElements, updates );
         Set<DataElement> toAdd = Sets.difference( updates, dataElements );
-        
+
         toRemove.parallelStream().forEach( d -> d.getDataSets().remove( this ) );
         toAdd.parallelStream().forEach( d -> d.getDataSets().add( this ) );
-        
+
         dataElements.clear();
         dataElements.addAll( updates );
     }
@@ -360,19 +354,19 @@
     @JsonProperty
     @JsonView( { DetailedView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public String getDataSetType()
+    public FormType getFormType()
     {
         if ( hasDataEntryForm() )
         {
-            return TYPE_CUSTOM;
+            return FormType.CUSTOM;
         }
 
         if ( hasSections() )
         {
-            return TYPE_SECTION;
+            return FormType.SECTION;
         }
 
-        return TYPE_DEFAULT;
+        return FormType.DEFAULT;
     }
 
     public Set<DataElement> getDataElementsInSections()
@@ -390,7 +384,7 @@
     public Set<DataElementCategoryOptionCombo> getDataElementOptionCombos()
     {
         Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<>();
-        
+
         for ( DataElement element : dataElements )
         {
             if ( element.hasCategoryCombo() )
@@ -398,7 +392,7 @@
                 optionCombos.addAll( element.getCategoryCombo().getOptionCombos() );
             }
         }
-        
+
         return optionCombos;
     }
 
@@ -438,7 +432,7 @@
     {
         return categoryCombo != null && !DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME.equals( categoryCombo.getName() );
     }
-    
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/FormType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/FormType.java	2015-09-17 05:02:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/FormType.java	2015-09-17 05:52:20 +0000
@@ -34,10 +34,20 @@
 public enum FormType
 {
     DEFAULT,
+    CUSTOM,
     SECTION,
-    CUSTOM,
     SECTION_MULTIORG;
 
+    public boolean isDefault()
+    {
+        return this == DEFAULT;
+    }
+
+    public boolean isCustom()
+    {
+        return this == CUSTOM;
+    }
+
     public boolean isSection()
     {
         return this == SECTION || this == SECTION_MULTIORG;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-08-25 09:48:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java	2015-09-17 05:52:20 +0000
@@ -28,11 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
@@ -45,17 +47,15 @@
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataset.FormType;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.schema.annotation.PropertyRange;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * @author Abyot Asalefew
@@ -64,10 +64,6 @@
 public class ProgramStage
     extends BaseIdentifiableObject
 {
-    public static final String TYPE_DEFAULT = "default";
-    public static final String TYPE_SECTION = "section";
-    public static final String TYPE_CUSTOM = "custom";
-
     /**
      * Determines if a de-serialized file is compatible with this class.
      */
@@ -163,23 +159,23 @@
 
         return dataElements;
     }
-    
+
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public String getDataEntryType()
+    public FormType getFormType()
     {
         if ( dataEntryForm != null )
         {
-            return TYPE_CUSTOM;
+            return FormType.CUSTOM;
         }
 
         if ( programStageSections.size() > 0 )
         {
-            return TYPE_SECTION;
+            return FormType.SECTION;
         }
 
-        return TYPE_DEFAULT;
+        return FormType.DEFAULT;
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java	2015-09-13 22:09:08 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java	2015-09-17 05:52:20 +0000
@@ -28,18 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
-import static org.hisp.dhis.commons.collection.ListUtils.getDuplicates;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.ListMap;
@@ -78,6 +66,18 @@
 import org.hisp.dhis.validation.ValidationRuleService;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
+import static org.hisp.dhis.commons.collection.ListUtils.getDuplicates;
+
 /**
  * @author Lars Helge Overland
  */
@@ -86,9 +86,9 @@
     implements DataIntegrityService
 {
     private static final Log log = LogFactory.getLog( DefaultDataIntegrityService.class );
-    
+
     private static final String FORMULA_SEPARATOR = "#";
-    
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -113,7 +113,7 @@
     {
         this.dataSetService = dataSetService;
     }
-    
+
     private SectionService sectionService;
 
     public void setSectionService( SectionService sectionService )
@@ -148,21 +148,21 @@
     {
         this.expressionService = expressionService;
     }
-    
+
     private DataEntryFormService dataEntryFormService;
 
     public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
     {
         this.dataEntryFormService = dataEntryFormService;
     }
-    
+
     private DataElementCategoryService categoryService;
 
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
-    
+
     private ConstantService constantService;
 
     public void setConstantService( ConstantService constantService )
@@ -175,8 +175,8 @@
     public void setPeriodService( PeriodService periodService )
     {
         this.periodService = periodService;
-    }    
-    
+    }
+
     // -------------------------------------------------------------------------
     // DataIntegrityService implementation
     // -------------------------------------------------------------------------
@@ -238,9 +238,9 @@
 
         for ( DataElementGroupSet groupSet : groupSets )
         {
-            Collection<DataElement> duplicates = getDuplicates(  
+            Collection<DataElement> duplicates = getDuplicates(
                 new ArrayList<>( groupSet.getDataElements() ), IdentifiableObjectNameComparator.INSTANCE );
-            
+
             for ( DataElement duplicate : duplicates )
             {
                 targets.put( duplicate, duplicate.getGroups() );
@@ -254,15 +254,15 @@
     public SortedMap<DataSet, Collection<DataElement>> getDataElementsInDataSetNotInForm()
     {
         SortedMap<DataSet, Collection<DataElement>> map = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE );
-        
+
         Collection<DataSet> dataSets = dataSetService.getAllDataSets();
-        
+
         for ( DataSet dataSet : dataSets )
         {
-            if ( !DataSet.TYPE_DEFAULT.equals( dataSet.getDataSetType() ) )
+            if ( !dataSet.getFormType().isDefault() )
             {
                 Set<DataElement> formElements = new HashSet<>();
-                
+
                 if ( dataSet.hasDataEntryForm() )
                 {
                     formElements.addAll( dataEntryFormService.getDataElementsInDataEntryForm( dataSet ) );
@@ -271,18 +271,18 @@
                 {
                     formElements.addAll( dataSet.getDataElementsInSections() );
                 }
-                
+
                 Set<DataElement> dataSetElements = new HashSet<>( dataSet.getDataElements() );
-                
+
                 dataSetElements.removeAll( formElements );
-                
+
                 if ( dataSetElements.size() > 0 )
                 {
                     map.put( dataSet, dataSetElements );
                 }
             }
         }
-        
+
         return map;
     }
 
@@ -296,13 +296,13 @@
         SetMap<DataSet, DataElementOperand> map = new SetMap<>();
 
         Collection<DataSet> dataSets = dataSetService.getAllDataSets();
-        
+
         for ( DataSet dataSet : dataSets )
         {
             if ( dataSet.hasDataEntryForm() )
             {
                 Set<DataElementOperand> operands = dataEntryFormService.getOperandsInDataEntryForm( dataSet );
-                
+
                 if ( operands != null )
                 {
                     if ( operands.size() > 2000 )
@@ -310,13 +310,13 @@
                         log.warn( "Skipped integrity check for data set: " + dataSet.getName() + ", too many operands: " + operands.size() );
                         continue;
                     }
-                    
+
                     for ( DataElementOperand operand : operands )
                     {
                         DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
                         DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand.getOptionComboId() );
                         Set<DataElementCategoryOptionCombo> optionCombos = dataElement.getCategoryCombo() != null ? dataElement.getCategoryCombo().getOptionCombos() : null;
-                        
+
                         if ( optionCombos == null || !optionCombos.contains( optionCombo ) )
                         {
                             DataElementOperand persistedOperand = new DataElementOperand( dataElement, optionCombo );
@@ -326,10 +326,10 @@
                 }
             }
         }
-        
+
         return map;
     }
-    
+
     @Override
     public Collection<DataSet> getDataSetsNotAssignedToOrganisationUnits()
     {
@@ -353,7 +353,7 @@
     public Collection<Section> getSectionsWithInvalidCategoryCombinations()
     {
         Collection<Section> sections = new HashSet<>();
-        
+
         for ( Section section : sectionService.getAllSections() )
         {
             if ( section != null && section.categorComboIsInvalid() )
@@ -361,10 +361,10 @@
                 sections.add( section );
             }
         }
-        
+
         return sections;
     }
-    
+
     // -------------------------------------------------------------------------
     // Indicator
     // -------------------------------------------------------------------------
@@ -423,7 +423,7 @@
         Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
         Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
         Set<String> orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) );
-        
+
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
             String result = expressionService.expressionIsValid( indicator.getNumerator(), dataElements, categoryOptionCombos, constants, orgUnitGroups );
@@ -446,7 +446,7 @@
         Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
         Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
         Set<String> orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) );
-        
+
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
             String result = expressionService.expressionIsValid( indicator.getDenominator(), dataElements, categoryOptionCombos, constants, orgUnitGroups );
@@ -469,9 +469,9 @@
 
         for ( IndicatorGroupSet groupSet : groupSets )
         {
-            Collection<Indicator> duplicates = getDuplicates( 
+            Collection<Indicator> duplicates = getDuplicates(
                 new ArrayList<>( groupSet.getIndicators() ), IdentifiableObjectNameComparator.INSTANCE );
-            
+
             for ( Indicator duplicate : duplicates )
             {
                 targets.put( duplicate, duplicate.getGroups() );
@@ -489,33 +489,33 @@
     public List<Period> getDuplicatePeriods()
     {
         Collection<Period> periods = periodService.getAllPeriods();
-        
+
         List<Period> duplicates = new ArrayList<>();
-        
+
         ListMap<String, Period> map = new ListMap<>();
-        
+
         for ( Period period : periods )
         {
             String key = period.getPeriodType().getName() + period.getStartDate().toString();
-            
+
             period.setName( period.toString() );
-            
+
             map.putValue( key, period );
         }
-        
+
         for ( String key : map.keySet() )
         {
             List<Period> values = map.get( key );
-            
+
             if ( values != null && values.size() > 1 )
             {
                 duplicates.addAll( values );
             }
         }
-        
+
         return duplicates;
     }
-    
+
     // -------------------------------------------------------------------------
     // OrganisationUnit
     // -------------------------------------------------------------------------
@@ -535,7 +535,7 @@
         {
             parent = unit;
 
-            while ( ( parent = parent.getParent() ) != null )
+            while ( (parent = parent.getParent()) != null )
             {
                 if ( parent.equals( unit ) ) // Cyclic reference
                 {
@@ -585,14 +585,14 @@
     {
         Collection<OrganisationUnitGroupSet> groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets();
 
-        TreeMap<OrganisationUnit, Collection<OrganisationUnitGroup>> targets = 
+        TreeMap<OrganisationUnit, Collection<OrganisationUnitGroup>> targets =
             new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE );
 
         for ( OrganisationUnitGroupSet groupSet : groupSets )
         {
-            Collection<OrganisationUnit> duplicates = getDuplicates( 
+            Collection<OrganisationUnit> duplicates = getDuplicates(
                 new ArrayList<>( groupSet.getOrganisationUnits() ), IdentifiableObjectNameComparator.INSTANCE );
-            
+
             for ( OrganisationUnit duplicate : duplicates )
             {
                 targets.put( duplicate, new HashSet<>( duplicate.getGroups() ) );
@@ -639,7 +639,7 @@
         Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
         Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
         Set<String> orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) );
-        
+
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
             String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression(), dataElements, categoryOptionCombos, constants, orgUnitGroups );
@@ -663,7 +663,7 @@
         Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
         Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
         Set<String> orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) );
-        
+
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
             String result = expressionService.expressionIsValid( rule.getRightSide().getExpression(), dataElements, categoryOptionCombos, constants, orgUnitGroups );

=== removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/DataSetTypeFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/DataSetTypeFilter.java	2015-05-28 18:21:56 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/DataSetTypeFilter.java	1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-package org.hisp.dhis.system.filter;
-
-/*
- * Copyright (c) 2004-2015, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.commons.filter.Filter;
-
-/**
- * @author mortenoh
- */
-public class DataSetTypeFilter
-    implements Filter<DataSet>
-{
-    private List<String> dataSetTypes = new ArrayList<>();
-
-    public DataSetTypeFilter( String... types )
-    {
-        dataSetTypes = Arrays.asList( types );
-    }
-
-    @Override
-    public boolean retain( DataSet dataSet )
-    {
-        return dataSetTypes.contains( dataSet.getDataSetType() );
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-09-15 16:03:55 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-09-17 05:52:20 +0000
@@ -151,8 +151,8 @@
 
                 <!-- data entry form begins -->
                 <div ng-if="currentEvent.eventDate">                            
-                    <div class="clear vertical-spacing" ng-if="displayCustomForm === 'custom'" ng-include="'../dhis-web-commons/angular-forms/custom-form.html'"></div>  
-                    <div class="clear vertical-spacing" ng-if="displayCustomForm === 'default'" ng-include="'components/dataentry/default-form.html'"></div>
+                    <div class="clear vertical-spacing" ng-if="displayCustomForm === 'CUSTOM'" ng-include="'../dhis-web-commons/angular-forms/custom-form.html'"></div>
+                    <div class="clear vertical-spacing" ng-if="displayCustomForm === 'DEFAULT'" ng-include="'components/dataentry/default-form.html'"></div>
                 </div>    
                 <!-- the table form is insensitive to the event date being present. In this situation the eventdate is set inside the table form -->
                 <div class="clear vertical-spacing" ng-if="displayCustomForm === 'table'" ng-include="'components/dataentry/table-entry-form.html'"></div>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java	2015-06-06 11:44:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java	2015-09-17 05:52:20 +0000
@@ -29,7 +29,6 @@
  */
 
 import com.opensymphony.xwork2.Action;
-
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
@@ -44,6 +43,7 @@
 import org.hisp.dhis.dataentryform.DataEntryFormService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.FormType;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
 import org.hisp.dhis.i18n.I18n;
@@ -96,7 +96,7 @@
     }
 
     private DataElementCategoryService categoryService;
-    
+
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
@@ -244,17 +244,17 @@
             return INPUT;
         }
 
-        String dataSetType = dataSet.getDataSetType();
+        FormType formType = dataSet.getFormType();
 
         // ---------------------------------------------------------------------
         // Custom form
         // ---------------------------------------------------------------------
 
-        if ( DataSet.TYPE_CUSTOM.equals( dataSetType ) && dataSet.hasDataEntryForm() )
+        if ( formType.isCustom() && dataSet.hasDataEntryForm() )
         {
-            dataEntryForm = dataSet.getDataEntryForm();            
+            dataEntryForm = dataSet.getDataEntryForm();
             customDataEntryFormCode = dataEntryFormService.prepareDataEntryFormForEntry( dataEntryForm, dataSet, i18n );
-            return dataSetType;
+            return formType.toString();
         }
 
         // ---------------------------------------------------------------------
@@ -296,7 +296,7 @@
             for ( DataElementCategory dec : categoryCombo.getCategories() )
             {
                 DataElementCategory category = categoryService.getDataElementCategory( dec.getId(), true );
-                
+
                 optionsMap.put( category.getId(), category.getCategoryOptions() );
             }
 
@@ -342,7 +342,7 @@
 
         DataSet dsOriginal = dataSet;
 
-        if ( dataSetType.equals( DataSet.TYPE_DEFAULT ) )
+        if ( dataSet.getFormType().isDefault() )
         {
             DataSet dataSetCopy = new DataSet();
             dataSetCopy.setName( dataSet.getName() );
@@ -356,7 +356,7 @@
             {
                 DataElementCategoryCombo categoryCombo = orderedCategoryCombos.get( i );
                 String name = !categoryCombo.isDefault() ? categoryCombo.getName() : dataSetCopy.getName();
-                
+
                 Section section = new Section();
                 section.setUid( CodeGenerator.generateCode() );
                 section.setId( i );
@@ -369,7 +369,7 @@
                 section.setIndicators( new ArrayList<>( dataSet.getIndicators() ) );
             }
 
-            dataSetType = DataSet.TYPE_SECTION;
+            formType = FormType.SECTION;
         }
 
         // ---------------------------------------------------------------------
@@ -400,12 +400,12 @@
 
             getSectionForm( dataElements, dataSet );
 
-            dataSetType = DataSet.TYPE_SECTION_MULTIORG;
+            formType = FormType.SECTION_MULTIORG;
         }
 
         getSectionForm( dataElements, dataSet );
 
-        return dataSetType;
+        return formType.toString();
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2014-11-17 17:24:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml	2015-09-17 05:52:20 +0000
@@ -31,9 +31,9 @@
     </action>
 
     <action name="loadForm" class="org.hisp.dhis.de.action.LoadFormAction">
-      <result name="custom" type="velocity">/dhis-web-dataentry/customForm.vm</result>
-      <result name="section" type="velocity">/dhis-web-dataentry/sectionForm.vm</result>
-      <result name="multiorg_section" type="velocity">/dhis-web-dataentry/multiOrgSectionForm.vm</result>
+      <result name="CUSTOM" type="velocity">/dhis-web-dataentry/customForm.vm</result>
+      <result name="SECTION" type="velocity">/dhis-web-dataentry/sectionForm.vm</result>
+      <result name="SECTION_MULTIORG" type="velocity">/dhis-web-dataentry/multiOrgSectionForm.vm</result>
       <result name="input" type="velocity">/dhis-web-dataentry/responseVoid.vm</result>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-08-31 06:34:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-09-17 05:52:20 +0000
@@ -106,10 +106,10 @@
 
 // Form types
 
-dhis2.de.cst.formTypeCustom = 'custom';
-dhis2.de.cst.formTypeSection = 'section';
-dhis2.de.cst.formTypeMultiOrgSection = 'multiorg_section';
-dhis2.de.cst.formTypeDefault = 'default';
+dhis2.de.cst.formTypeCustom = 'CUSTOM';
+dhis2.de.cst.formTypeSection = 'SECTION';
+dhis2.de.cst.formTypeMultiOrgSection = 'SECTION_MULTIORG';
+dhis2.de.cst.formTypeDefault = 'DEFAULT';
 
 // Events
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2015-08-31 06:34:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2015-09-17 05:52:20 +0000
@@ -36,7 +36,7 @@
 #set( $size = $dataSets.size() )
 #foreach( $dataSet in $dataSets )
 "${dataSet.uid}":{"name":"$encoder.jsonEncode( ${dataSet.displayName} )","periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )","categoryCombo":"${dataSet.categoryCombo.uid}","version":"${dataSet.version}",
-"type":"${dataSet.getDataSetType()}","expiryDays":"${dataSet.expiryDays}","openFuturePeriods":${dataSet.openFuturePeriods},"fieldCombinationRequired":${dataSet.fieldCombinationRequired},
+"type":"${dataSet.getFormType()}","expiryDays":"${dataSet.expiryDays}","openFuturePeriods":${dataSet.openFuturePeriods},"fieldCombinationRequired":${dataSet.fieldCombinationRequired},
 "validCompleteOnly":${dataSet.validCompleteOnly},"skipOffline":${dataSet.skipOffline}, "renderAsTabs":${dataSet.renderAsTabs}, "renderHorizontally":${dataSet.renderHorizontally}}#if( $velocityCount < $size ),#end
 #end },
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetSectionFormAction.java	2015-09-17 05:52:20 +0000
@@ -43,10 +43,14 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
- * @author mortenoh
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public class GetSectionFormAction
     implements Action
@@ -218,7 +222,7 @@
 
         validationRuleViolations = formUtils.getValidationRuleViolations( organisationUnit, dataSet, period );
 
-        if ( dataSet.getDataSetType().equals( DataSet.TYPE_SECTION ) )
+        if ( dataSet.getFormType().isSection() )
         {
             setGreyedFields();
         }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2015-07-15 15:49:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java	2015-09-17 05:52:20 +0000
@@ -28,23 +28,17 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.dataset.DataSet.TYPE_CUSTOM;
-import static org.hisp.dhis.dataset.DataSet.TYPE_SECTION;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletResponse;
-
+import com.opensymphony.xwork2.Action;
 import org.apache.struts2.ServletActionContext;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.cache.CacheStrategy;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.FormType;
 import org.hisp.dhis.datasetreport.DataSetReportService;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -54,10 +48,12 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.common.cache.CacheStrategy;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.opensymphony.xwork2.Action;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
 /**
  * @author Chau Thu Tran
@@ -65,7 +61,7 @@
  */
 public class GenerateDataSetReportAction
     implements Action
-{    
+{
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -83,7 +79,7 @@
     {
         this.dataSetService = dataSetService;
     }
-    
+
     private CompleteDataSetRegistrationService registrationService;
 
     public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
@@ -92,21 +88,21 @@
     }
 
     private OrganisationUnitService organisationUnitService;
-    
+
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
     {
         this.organisationUnitService = organisationUnitService;
     }
-    
+
     private PeriodService periodService;
-    
+
     public void setPeriodService( PeriodService periodService )
     {
         this.periodService = periodService;
     }
-    
+
     private DataElementCategoryService categoryService;
-    
+
     public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
@@ -125,7 +121,7 @@
     {
         this.i18n = i18n;
     }
-    
+
     @Autowired
     private ContextUtils contextUtils;
 
@@ -148,12 +144,12 @@
     }
 
     private String ou;
-    
+
     public void setOu( String ou )
     {
         this.ou = ou;
     }
-        
+
     private Set<String> dimension;
 
     public void setDimension( Set<String> dimension )
@@ -172,14 +168,14 @@
     {
         this.selectedUnitOnly = selectedUnitOnly;
     }
-    
+
     private String type;
 
     public void setType( String type )
     {
         this.type = type;
     }
-    
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -204,9 +200,9 @@
     {
         return selectedPeriod;
     }
-    
+
     private CompleteDataSetRegistration registration;
-    
+
     public CompleteDataSetRegistration getRegistration()
     {
         return registration;
@@ -239,7 +235,7 @@
         // ---------------------------------------------------------------------
 
         HttpServletResponse response = ServletActionContext.getResponse();
-        
+
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false );
 
         // ---------------------------------------------------------------------
@@ -253,16 +249,16 @@
             selectedPeriod = PeriodType.getPeriodFromIsoString( pe );
             selectedPeriod = periodService.reloadPeriod( selectedPeriod );
         }
-     
+
         selectedOrgunit = organisationUnitService.getOrganisationUnit( ou );
 
-        String dataSetType = selectedDataSet.getDataSetType();
+        FormType formType = selectedDataSet.getFormType();
 
         DataElementCategoryOptionCombo attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
 
         registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, selectedPeriod, selectedOrgunit, attributeOptionCombo );
-        
-        if ( TYPE_CUSTOM.equals( dataSetType ) )
+
+        if ( formType.isCustom() )
         {
             if ( type != null )
             {
@@ -273,7 +269,7 @@
                 customDataEntryFormCode = dataSetReportService.getCustomDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format );
             }
         }
-        else if ( TYPE_SECTION.equals( dataSetType ) )
+        else if ( formType.isSection() )
         {
             grids = dataSetReportService.getSectionDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format, i18n );
         }
@@ -281,7 +277,7 @@
         {
             grids = dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, dimension, selectedUnitOnly, format, i18n );
         }
-                
-        return type != null ? type : dataSetType;
+
+        return type != null ? type : formType.toString();
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2015-08-30 14:21:41 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml	2015-09-17 05:52:20 +0000
@@ -181,9 +181,9 @@
     </action>
 
     <action name="generateDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateDataSetReportAction">
-      <result name="default" type="velocity">/dhis-web-reporting/renderSectionDataSetReportForm.vm</result>
-      <result name="section" type="velocity">/dhis-web-reporting/renderSectionDataSetReportForm.vm</result>
-      <result name="custom" type="velocity">/dhis-web-reporting/renderCustomDataSetReportForm.vm</result>
+      <result name="DEFAULT" type="velocity">/dhis-web-reporting/renderSectionDataSetReportForm.vm</result>
+      <result name="SECTION" type="velocity">/dhis-web-reporting/renderSectionDataSetReportForm.vm</result>
+      <result name="CUSTOM" type="velocity">/dhis-web-reporting/renderCustomDataSetReportForm.vm</result>
       <result name="xls" type="gridXlsResult" />
       <result name="pdf" type="gridPdfResult" />
     </action>