------------------------------------------------------------ revno: 19994 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Fri 2015-09-04 17:49:08 +0700 message: remove old type/numbertype/texttype from data element modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.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/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramDataEntryServiceTest.java dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.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/ValueType.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2015-09-04 05:24:21 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2015-09-04 10:49:08 +0000 @@ -118,120 +118,7 @@ return this == DATE || this == DATETIME; } - /** - * TODO replace string value type on data element with ValueType and remove - * this method. - */ - public static ValueType getFromDataElement( DataElement dataElement ) - { - return getFromDataElementTypes( dataElement.getType(), dataElement.getNumberType(), dataElement.getTextType() ); - } - - public static void setDataElementTypes( DataElement dataElement, ValueType valueType ) - { - switch ( valueType ) - { - case INTEGER: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_INT ); - dataElement.setTextType( null ); - break; - } - case INTEGER_POSITIVE: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_POSITIVE_INT ); - dataElement.setTextType( null ); - break; - } - case INTEGER_NEGATIVE: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_NEGATIVE_INT ); - dataElement.setTextType( null ); - break; - } - case INTEGER_ZERO_OR_POSITIVE: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_ZERO_OR_POSITIVE_INT ); - dataElement.setTextType( null ); - break; - } - case NUMBER: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_NUMBER ); - dataElement.setTextType( null ); - break; - } - case UNIT_INTERVAL: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_UNIT_INTERVAL ); - dataElement.setTextType( null ); - break; - } - case PERCENTAGE: - { - dataElement.setType( DataElement.VALUE_TYPE_INT ); - dataElement.setNumberType( DataElement.VALUE_TYPE_PERCENTAGE ); - dataElement.setTextType( null ); - break; - } - case TEXT: - { - dataElement.setType( DataElement.VALUE_TYPE_STRING ); - dataElement.setTextType( DataElement.VALUE_TYPE_TEXT ); - dataElement.setNumberType( null ); - break; - } - case LONG_TEXT: - { - dataElement.setType( DataElement.VALUE_TYPE_STRING ); - dataElement.setTextType( DataElement.VALUE_TYPE_LONG_TEXT ); - dataElement.setNumberType( null ); - break; - } - case BOOLEAN: - { - dataElement.setType( DataElement.VALUE_TYPE_BOOL ); - dataElement.setNumberType( null ); - dataElement.setTextType( null ); - break; - } - case TRUE_ONLY: - { - dataElement.setType( DataElement.VALUE_TYPE_TRUE_ONLY ); - dataElement.setNumberType( null ); - dataElement.setTextType( null ); - break; - } - case DATE: - { - dataElement.setType( DataElement.VALUE_TYPE_DATE ); - dataElement.setNumberType( null ); - dataElement.setTextType( null ); - break; - } - case DATETIME: - { - dataElement.setType( DataElement.VALUE_TYPE_DATETIME ); - dataElement.setNumberType( null ); - dataElement.setTextType( null ); - break; - } - case USERNAME: - { - dataElement.setType( DataElement.VALUE_TYPE_USER_NAME ); - dataElement.setNumberType( null ); - dataElement.setTextType( null ); - break; - } - } - } - + // TODO keeping this in for now, legacy reasons public static ValueType getFromDataElementTypes( String type, String numberType, String textType ) { if ( DataElement.VALUE_TYPE_STRING.equals( type ) ) === 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-09-04 09:29:23 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2015-09-04 10:49:08 +0000 @@ -35,7 +35,6 @@ 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.analytics.AggregationType; import org.hisp.dhis.attribute.AttributeValue; import org.hisp.dhis.common.BaseDimensionalObject; @@ -143,22 +142,6 @@ private DataElementDomain domainType; /** - * The value type of this DataElement; e.g. DataElement.VALUE_TYPE_INT or - * DataElement.VALUE_TYPE_BOOL. - */ - private String type; - - /** - * The number type. Is relevant when type is VALUE_TYPE_INT. - */ - private String numberType; - - /** - * The text type. Is relevant when type is VALUE_TYPE_STRING. - */ - private String textType; - - /** * The aggregation operator of this DataElement; e.g. DataElement.SUM og * DataElement.AVERAGE. */ @@ -283,46 +266,6 @@ } /** - * Returns the value type. If value type is int and the number type exists, - * the number type is returned, otherwise the type is returned. - */ - public String getDetailedNumberType() - { - return (type != null && type.equals( VALUE_TYPE_INT ) && numberType != null) ? numberType : type; - } - - /** - * Returns the value type. If value type is string and the text type exists, - * the text type is returned, if the type is string and the text type does - * not exist string is returned. - */ - public String getDetailedTextType() - { - return (type != null && type.equals( VALUE_TYPE_STRING ) && textType != null) ? textType : type; - } - - /** - * Returns the detailed data element type. If value type is int, the number - * type is returned. If value type is string, the text type is returned. - * Otherwise the type is returned. - */ - public String getDetailedType() - { - if ( VALUE_TYPE_INT.equals( type ) ) - { - return numberType; - } - else if ( VALUE_TYPE_STRING.equals( type ) ) - { - return textType; - } - else - { - return type; - } - } - - /** * Returns the data set of this data element. If this data element has * multiple data sets, the data set with the highest collection frequency is * returned. @@ -596,7 +539,7 @@ { return DimensionType.PROGRAM_DATAELEMENT; } - + // ------------------------------------------------------------------------- // Helper getters // ------------------------------------------------------------------------- @@ -617,45 +560,14 @@ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public ValueType getValueType() { - return valueType != null ? valueType : ValueType.getFromDataElement( this ); + return valueType; } public void setValueType( ValueType valueType ) { - ValueType.setDataElementTypes( this, valueType ); this.valueType = valueType; } - public String getType() - { - return type; - } - - public void setType( String type ) - { - this.type = type; - } - - public String getNumberType() - { - return numberType; - } - - public void setNumberType( String numberType ) - { - this.numberType = numberType; - } - - public String getTextType() - { - return textType; - } - - public void setTextType( String textType ) - { - this.textType = textType; - } - @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @@ -835,9 +747,6 @@ { formName = dataElement.getFormName(); domainType = dataElement.getDomainType(); - type = dataElement.getType(); - numberType = dataElement.getNumberType(); - textType = dataElement.getTextType(); valueType = dataElement.getValueType(); aggregationOperator = dataElement.getAggregationOperator(); categoryCombo = dataElement.getCategoryCombo(); @@ -849,9 +758,6 @@ { formName = dataElement.getFormName() == null ? formName : dataElement.getFormName(); domainType = dataElement.getDomainType() == null ? domainType : dataElement.getDomainType(); - type = dataElement.getType() == null ? type : dataElement.getType(); - numberType = dataElement.getNumberType() == null ? numberType : dataElement.getNumberType(); - textType = dataElement.getTextType() == null ? textType : dataElement.getTextType(); valueType = dataElement.getValueType() == null ? valueType : dataElement.getValueType(); aggregationOperator = dataElement.getAggregationOperator() == null ? aggregationOperator : dataElement.getAggregationOperator(); categoryCombo = dataElement.getCategoryCombo() == null ? categoryCombo : dataElement.getCategoryCombo(); === 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-09-03 10:21:08 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-09-04 10:49:08 +0000 @@ -263,7 +263,7 @@ { ValueType valueType = dataElement.getValueType(); String dataType = getColumnType( valueType ); - String dataClause = dataElement.isNumericType() ? numericClause : dataElement.isDateType() ? dateClause : ""; + String dataClause = dataElement.isNumericType() ? numericClause : dataElement.getValueType().isDate() ? dateClause : ""; String select = getSelectClause( valueType ); String sql = "(select " + select + " from trackedentitydatavalue where programstageinstanceid=psi.programstageinstanceid " + === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java' --- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java 2015-07-02 23:34:24 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java 2015-09-04 10:49:08 +0000 @@ -28,23 +28,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.common.NameableObjectUtils.getList; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - import org.hisp.dhis.DhisConvenienceTest; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.hisp.dhis.common.NameableObjectUtils.getList; +import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM; +import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM; +import static org.junit.Assert.*; + /** * @author Lars Helge Overland */ @@ -54,7 +52,7 @@ // ------------------------------------------------------------------------- // Fixture // ------------------------------------------------------------------------- - + private DataElement deA; private DataElement deB; private DataElement deC; @@ -62,7 +60,7 @@ private DataElement deE; private DataElement deF; private DataElement deG; - + private OrganisationUnit ouA; private OrganisationUnit ouB; private OrganisationUnit ouC; @@ -72,60 +70,60 @@ // ------------------------------------------------------------------------- // Tests // ------------------------------------------------------------------------- - + @Before public void before() { - deA = createDataElement( 'A', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deB = createDataElement( 'B', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deC = createDataElement( 'C', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deD = createDataElement( 'D', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deE = createDataElement( 'E', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deF = createDataElement( 'F', VALUE_TYPE_INT, AGGREGATION_OPERATOR_AVERAGE_SUM ); - deG = createDataElement( 'G', VALUE_TYPE_INT, AGGREGATION_OPERATOR_AVERAGE_SUM ); - + deA = createDataElement( 'A', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deB = createDataElement( 'B', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deC = createDataElement( 'C', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deD = createDataElement( 'D', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deE = createDataElement( 'E', ValueType.INTEGER.INTEGER, AGGREGATION_OPERATOR_SUM ); + deF = createDataElement( 'F', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM ); + deG = createDataElement( 'G', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM ); + ouA = createOrganisationUnit( 'A' ); ouB = createOrganisationUnit( 'B' ); ouC = createOrganisationUnit( 'C' ); ouD = createOrganisationUnit( 'D' ); ouE = createOrganisationUnit( 'E' ); } - + @Test public void planQueryA() { DataQueryParams paramsA = new DataQueryParams(); paramsA.setDataElements( getList( deA, deB ) ); paramsA.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - paramsA.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); + paramsA.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); paramsA.setAggregationType( AggregationType.SUM ); - + DataQueryParams paramsB = new DataQueryParams(); paramsB.setDataElements( getList( deC, deD ) ); paramsB.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - paramsB.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); + paramsB.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); paramsB.setAggregationType( AggregationType.SUM ); - + DataQueryParams paramsC = new DataQueryParams(); paramsC.setDataElements( getList( deE ) ); paramsC.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - paramsC.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); + paramsC.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); paramsC.setAggregationType( AggregationType.SUM ); - + DataQueryParams paramsD = new DataQueryParams(); paramsD.setDataElements( getList( deF, deG ) ); paramsD.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - paramsD.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); + paramsD.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); paramsD.setAggregationType( AggregationType.AVERAGE_SUM_INT ); - + List<DataQueryParams> queries = new ArrayList<>(); queries.add( paramsA ); queries.add( paramsB ); queries.add( paramsC ); - queries.add( paramsD ); - + queries.add( paramsD ); + DataQueryGroups queryGroups = new DataQueryGroups( queries ); - + assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 4, queryGroups.getAllQueries().size() ); assertEquals( 3, queryGroups.getLargestGroupSize() ); === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java' --- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java 2015-06-25 20:45:56 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java 2015-09-04 10:49:08 +0000 @@ -28,26 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.analytics.AnalyticsTableManager.ANALYTICS_TABLE_NAME; -import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP; -import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID; -import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID; -import static org.hisp.dhis.common.NameableObjectUtils.getList; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_NONE; -import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_INT; -import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_STRING; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.analytics.DataQueryGroups; import org.hisp.dhis.analytics.DataQueryParams; @@ -58,6 +38,7 @@ import org.hisp.dhis.common.ListMap; import org.hisp.dhis.common.MapMap; import org.hisp.dhis.common.NameableObject; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; @@ -79,6 +60,20 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import static org.hisp.dhis.analytics.AnalyticsTableManager.ANALYTICS_TABLE_NAME; +import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP; +import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID; +import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID; +import static org.hisp.dhis.common.NameableObjectUtils.getList; +import static org.hisp.dhis.dataelement.DataElement.*; +import static org.junit.Assert.*; + /** * @author Lars Helge Overland */ @@ -87,29 +82,29 @@ { @Autowired private QueryPlanner queryPlanner; - + @Autowired private DataElementService dataElementService; - + @Autowired private DataSetService dataSetService; - + @Autowired private DataElementCategoryService categoryService; - + @Autowired private IndicatorService indicatorService; - + @Autowired private OrganisationUnitService organisationUnitService; - + // ------------------------------------------------------------------------- // Fixture // ------------------------------------------------------------------------- private IndicatorType itA; private Indicator inA; - + private DataElement deA; private DataElement deB; private DataElement deC; @@ -118,14 +113,14 @@ private DataElement deF; private DataElement deG; private DataElement deH; - + private DataSet dsA; private DataSet dsB; private DataSet dsC; private DataSet dsD; - + private DataElementCategoryOptionCombo coc; - + private OrganisationUnit ouA; private OrganisationUnit ouB; private OrganisationUnit ouC; @@ -133,29 +128,29 @@ private OrganisationUnit ouE; //TODO test for indicators, periods in filter - + @Override public void setUpTest() { PeriodType pt = new MonthlyPeriodType(); - + itA = createIndicatorType( 'A' ); - + indicatorService.addIndicatorType( itA ); - + inA = createIndicator( 'A', itA ); - + indicatorService.addIndicator( inA ); - - deA = createDataElement( 'A', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deB = createDataElement( 'B', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deC = createDataElement( 'C', VALUE_TYPE_INT, AGGREGATION_OPERATOR_AVERAGE_SUM ); - deD = createDataElement( 'D', VALUE_TYPE_INT, AGGREGATION_OPERATOR_AVERAGE_SUM ); - deE = createDataElement( 'E', VALUE_TYPE_STRING, AGGREGATION_OPERATOR_NONE ); - deF = createDataElement( 'F', VALUE_TYPE_STRING, AGGREGATION_OPERATOR_NONE ); - deG = createDataElement( 'G', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - deH = createDataElement( 'H', VALUE_TYPE_INT, AGGREGATION_OPERATOR_SUM ); - + + deA = createDataElement( 'A', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deB = createDataElement( 'B', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deC = createDataElement( 'C', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM ); + deD = createDataElement( 'D', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM ); + deE = createDataElement( 'E', ValueType.TEXT, AGGREGATION_OPERATOR_NONE ); + deF = createDataElement( 'F', ValueType.TEXT, AGGREGATION_OPERATOR_NONE ); + deG = createDataElement( 'G', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + deH = createDataElement( 'H', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM ); + dataElementService.addDataElement( deA ); dataElementService.addDataElement( deB ); dataElementService.addDataElement( deC ); @@ -164,25 +159,25 @@ dataElementService.addDataElement( deF ); dataElementService.addDataElement( deG ); dataElementService.addDataElement( deH ); - + dsA = createDataSet( 'A', pt ); dsB = createDataSet( 'B', pt ); dsC = createDataSet( 'C', pt ); dsD = createDataSet( 'D', pt ); - + dataSetService.addDataSet( dsA ); dataSetService.addDataSet( dsB ); dataSetService.addDataSet( dsC ); dataSetService.addDataSet( dsD ); - + coc = categoryService.getDefaultDataElementCategoryOptionCombo(); - + ouA = createOrganisationUnit( 'A' ); ouB = createOrganisationUnit( 'B' ); ouC = createOrganisationUnit( 'C' ); ouD = createOrganisationUnit( 'D' ); ouE = createOrganisationUnit( 'E' ); - + organisationUnitService.addOrganisationUnit( ouA ); organisationUnitService.addOrganisationUnit( ouB ); organisationUnitService.addOrganisationUnit( ouC ); @@ -202,25 +197,25 @@ List<NameableObject> ousB = getList( ouC, ouD ); List<NameableObject> pesA = getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ) ); List<NameableObject> pesB = getList( createPeriod( "200001" ), createPeriod( "200002" ) ); - + DataQueryParams paramsA = new DataQueryParams(); paramsA.setDataElements( desA ); paramsA.setOrganisationUnits( ousA ); paramsA.setPeriods( pesA ); - + DataQueryParams paramsB = paramsA.instance(); paramsB.setOrganisationUnits( ousB ); paramsB.setPeriods( pesB ); - + assertEquals( desA, paramsA.getDataElements() ); assertEquals( ousA, paramsA.getOrganisationUnits() ); assertEquals( pesA, paramsA.getPeriods() ); - + assertEquals( desA, paramsB.getDataElements() ); assertEquals( ousB, paramsB.getOrganisationUnits() ); assertEquals( pesB, paramsB.getPeriods() ); } - + @Test public void testGetPermutationOperandValueMapCocEnabled() { @@ -233,31 +228,31 @@ aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q2", 6d ); aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q1", 7d ); aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q2", 8d ); - + MapMap<String, DataElementOperand, Double> permutationMap = new MapMap<>(); - + DataQueryParams.putPermutationOperandValueMap( permutationMap, aggregatedDataMap, true ); - + assertNotNull( permutationMap ); - + String ouAQ1Key = ouA.getUid() + DIMENSION_SEP + "2000Q1"; String ouAQ2Key = ouA.getUid() + DIMENSION_SEP + "2000Q2"; String ouBQ1Key = ouB.getUid() + DIMENSION_SEP + "2000Q1"; String ouBQ2Key = ouB.getUid() + DIMENSION_SEP + "2000Q2"; - + Map<DataElementOperand, Double> ouAQ1 = permutationMap.get( ouAQ1Key ); Map<DataElementOperand, Double> ouAQ2 = permutationMap.get( ouAQ2Key ); Map<DataElementOperand, Double> ouBQ1 = permutationMap.get( ouBQ1Key ); Map<DataElementOperand, Double> ouBQ2 = permutationMap.get( ouBQ2Key ); - + assertEquals( 2, ouAQ1.size() ); assertEquals( 2, ouAQ2.size() ); assertEquals( 2, ouBQ1.size() ); assertEquals( 2, ouBQ2.size() ); - + DataElementOperand deACoc = new DataElementOperand( deA.getUid(), coc.getUid() ); DataElementOperand deBCoc = new DataElementOperand( deB.getUid(), coc.getUid() ); - + Map<DataElementOperand, Double> ouAQ1Expected = new HashMap<>(); ouAQ1Expected.put( deACoc, 1d ); ouAQ1Expected.put( deBCoc, 5d ); @@ -273,7 +268,7 @@ Map<DataElementOperand, Double> ouBQ2Expected = new HashMap<>(); ouBQ2Expected.put( deACoc, 4d ); ouBQ2Expected.put( deBCoc, 8d ); - + assertEquals( ouAQ1Expected, ouAQ1 ); assertEquals( ouAQ2Expected, ouAQ2 ); assertEquals( ouBQ1Expected, ouBQ1 ); @@ -292,31 +287,31 @@ aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200102", 6d ); aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200101", 7d ); aggregatedDataMap.put( deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200102", 8d ); - + MapMap<String, DataElementOperand, Double> permutationMap = new MapMap<>(); - + DataQueryParams.putPermutationOperandValueMap( permutationMap, aggregatedDataMap, false ); - + assertNotNull( permutationMap ); - + String ouAM1Key = ouA.getUid() + DIMENSION_SEP + "200101"; String ouAM2Key = ouA.getUid() + DIMENSION_SEP + "200102"; String ouBM1Key = ouB.getUid() + DIMENSION_SEP + "200101"; String ouBM2Key = ouB.getUid() + DIMENSION_SEP + "200102"; - + Map<DataElementOperand, Double> ouAM1 = permutationMap.get( ouAM1Key ); Map<DataElementOperand, Double> ouAM2 = permutationMap.get( ouAM2Key ); Map<DataElementOperand, Double> ouBM1 = permutationMap.get( ouBM1Key ); Map<DataElementOperand, Double> ouBM2 = permutationMap.get( ouBM2Key ); - + assertEquals( 2, ouAM1.size() ); assertEquals( 2, ouAM2.size() ); assertEquals( 2, ouBM1.size() ); assertEquals( 2, ouBM2.size() ); - + DataElementOperand deACoc = new DataElementOperand( deA.getUid(), null ); DataElementOperand deBCoc = new DataElementOperand( deB.getUid(), null ); - + Map<DataElementOperand, Double> ouAM1Expected = new HashMap<>(); ouAM1Expected.put( deACoc, 1d ); ouAM1Expected.put( deBCoc, 5d ); @@ -332,7 +327,7 @@ Map<DataElementOperand, Double> ouBM2Expected = new HashMap<>(); ouBM2Expected.put( deACoc, 4d ); ouBM2Expected.put( deBCoc, 8d ); - + assertEquals( ouAM1Expected, ouAM1 ); assertEquals( ouAM2Expected, ouAM2 ); assertEquals( ouBM1Expected, ouBM1 ); @@ -347,38 +342,38 @@ aggregatedTotalsDataMap.put( deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q2", 2d ); aggregatedTotalsDataMap.put( deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q1", 3d ); aggregatedTotalsDataMap.put( deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q2", 4d ); - + Map<String, Double> aggregatedCocDataMap = new HashMap<>(); aggregatedCocDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q1", 5d ); aggregatedCocDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q2", 6d ); aggregatedCocDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q1", 7d ); aggregatedCocDataMap.put( deB.getUid() + DIMENSION_SEP + coc.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q2", 8d ); - + MapMap<String, DataElementOperand, Double> permutationMap = new MapMap<>(); - + DataQueryParams.putPermutationOperandValueMap( permutationMap, aggregatedTotalsDataMap, false ); DataQueryParams.putPermutationOperandValueMap( permutationMap, aggregatedCocDataMap, true ); - + assertNotNull( permutationMap ); - + String ouAQ1Key = ouA.getUid() + DIMENSION_SEP + "2000Q1"; String ouAQ2Key = ouA.getUid() + DIMENSION_SEP + "2000Q2"; String ouBQ1Key = ouB.getUid() + DIMENSION_SEP + "2000Q1"; String ouBQ2Key = ouB.getUid() + DIMENSION_SEP + "2000Q2"; - + Map<DataElementOperand, Double> ouAQ1 = permutationMap.get( ouAQ1Key ); Map<DataElementOperand, Double> ouAQ2 = permutationMap.get( ouAQ2Key ); Map<DataElementOperand, Double> ouBQ1 = permutationMap.get( ouBQ1Key ); Map<DataElementOperand, Double> ouBQ2 = permutationMap.get( ouBQ2Key ); - + assertEquals( 2, ouAQ1.size() ); assertEquals( 2, ouAQ2.size() ); assertEquals( 2, ouBQ1.size() ); assertEquals( 2, ouBQ2.size() ); - + DataElementOperand deACoc = new DataElementOperand( deA.getUid(), null ); DataElementOperand deBCoc = new DataElementOperand( deB.getUid(), coc.getUid() ); - + Map<DataElementOperand, Double> ouAQ1Expected = new HashMap<>(); ouAQ1Expected.put( deACoc, 1d ); ouAQ1Expected.put( deBCoc, 5d ); @@ -394,7 +389,7 @@ Map<DataElementOperand, Double> ouBQ2Expected = new HashMap<>(); ouBQ2Expected.put( deACoc, 4d ); ouBQ2Expected.put( deBCoc, 8d ); - + assertEquals( ouAQ1Expected, ouAQ1 ); assertEquals( ouAQ2Expected, ouAQ2 ); assertEquals( ouBQ1Expected, ouBQ1 ); @@ -412,12 +407,12 @@ params.setDataElements( getList( deA, deB ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC ) ); params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ) ) ); - + List<List<DimensionItem>> permutations = params.getDimensionItemPermutations(); - + assertNotNull( permutations ); assertEquals( 6, permutations.size() ); - + for ( List<DimensionItem> permutation : permutations ) { assertNotNull( permutation ); @@ -426,7 +421,7 @@ assertEquals( PERIOD_DIM_ID, permutation.get( 1 ).getDimension() ); } } - + @Test public void testGetDataPeriodAggregationPeriodMap() { @@ -436,17 +431,17 @@ params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); params.setPeriodType( QuarterlyPeriodType.NAME ); params.setDataPeriodType( new YearlyPeriodType() ); - + ListMap<NameableObject, NameableObject> map = params.getDataPeriodAggregationPeriodMap(); - + assertEquals( 2, map.size() ); - + assertTrue( map.keySet().contains( createPeriod( "2000" ) ) ); assertTrue( map.keySet().contains( createPeriod( "2001" ) ) ); - + assertEquals( 4, map.get( createPeriod( "2000" ) ).size() ); assertEquals( 2, map.get( createPeriod( "2001" ) ).size() ); - + assertTrue( map.get( createPeriod( "2000" ) ).contains( createPeriod( "2000Q1" ) ) ); assertTrue( map.get( createPeriod( "2000" ) ).contains( createPeriod( "2000Q2" ) ) ); assertTrue( map.get( createPeriod( "2000" ) ).contains( createPeriod( "2000Q3" ) ) ); @@ -455,10 +450,10 @@ assertTrue( map.get( createPeriod( "2001" ) ).contains( createPeriod( "2001Q1" ) ) ); assertTrue( map.get( createPeriod( "2001" ) ).contains( createPeriod( "2001Q2" ) ) ); } - + /** * Query spans 2 partitions. Splits in 2 queries for each partition, then - * splits in 4 queries on data elements to satisfy optimal for a total + * splits in 4 queries on data elements to satisfy optimal for a total * of 8 queries, because query has 2 different aggregation types. */ @Test @@ -467,14 +462,14 @@ DataQueryParams params = new DataQueryParams(); params.setDataElements( getList( deA, deB, deC, deD ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - params.setPeriods( getList( createPeriod( "200101" ), createPeriod( "200103" ), createPeriod( "200105" ), createPeriod( "200107" ), createPeriod( "2002Q3" ), createPeriod( "2002Q4" ) ) ); - + params.setPeriods( getList( createPeriod( "200101" ), createPeriod( "200103" ), createPeriod( "200105" ), createPeriod( "200107" ), createPeriod( "2002Q3" ), createPeriod( "2002Q4" ) ) ); + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); - + assertEquals( 8, queryGroups.getAllQueries().size() ); assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 4, queryGroups.getLargestGroupSize() ); - + for ( DataQueryParams query : queryGroups.getAllQueries() ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -482,10 +477,10 @@ assertDimensionNameNotNull( query ); } } - + /** * Query spans 3 period types. Splits in 3 queries for each period type, then - * splits in 2 queries on organisation units to satisfy optimal for a total + * splits in 2 queries on organisation units to satisfy optimal for a total * of 6 queries. */ @Test @@ -495,13 +490,13 @@ params.setDataElements( getList( deA ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 6, ANALYTICS_TABLE_NAME ); - + assertEquals( 6, queryGroups.getAllQueries().size() ); assertEquals( 1, queryGroups.getSequentialQueries().size() ); assertEquals( 6, queryGroups.getLargestGroupSize() ); - + for ( DataQueryParams query : queryGroups.getAllQueries() ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -509,10 +504,10 @@ assertDimensionNameNotNull( query ); } } - + /** * Query spans 3 organisation unit levels. Splits in 3 queries for each level, - * then splits in 2 queries on organisation units to satisfy optimal for a total + * then splits in 2 queries on organisation units to satisfy optimal for a total * of 5 queries, as there are only 5 organisation units in total. */ @Test @@ -531,18 +526,18 @@ organisationUnitService.updateOrganisationUnit( ouC ); organisationUnitService.updateOrganisationUnit( ouD ); organisationUnitService.updateOrganisationUnit( ouE ); - + DataQueryParams params = new DataQueryParams(); params.setDataElements( getList( deA ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 6, ANALYTICS_TABLE_NAME ); - + assertEquals( 5, queryGroups.getAllQueries().size() ); assertEquals( 1, queryGroups.getSequentialQueries().size() ); assertEquals( 5, queryGroups.getLargestGroupSize() ); - + for ( DataQueryParams query : queryGroups.getAllQueries() ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -550,7 +545,7 @@ assertDimensionNameNotNull( query ); } } - + /** * Query spans 1 partition. Splits on 2 aggregation types, then splits one * query on 3 days in period to satisfy optimal for a total of 4 queries. @@ -563,13 +558,13 @@ params.setOrganisationUnits( getList( ouA ) ); params.setPeriods( getList( createPeriod( "200001" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ), createPeriod( "200005" ), createPeriod( "200006" ), createPeriod( "200007" ), createPeriod( "200008" ), createPeriod( "200009" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); - + assertEquals( 4, queryGroups.getAllQueries().size() ); assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 3, queryGroups.getLargestGroupSize() ); - + for ( DataQueryParams query : queryGroups.getAllQueries() ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -577,10 +572,10 @@ assertDimensionNameNotNull( query ); } } - + /** * Query spans 1 partition. Splits on 2 aggregation types, then splits one - * query on 3 days in period to satisfy optimal for a total of 4 queries. No + * query on 3 days in period to satisfy optimal for a total of 4 queries. No * organisation units specified. */ @Test @@ -588,7 +583,7 @@ { DataQueryParams params = new DataQueryParams(); params.setDataElements( getList( deA, deB, deC ) ); - params.setPeriods( getList( createPeriod( "200001" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ), + params.setPeriods( getList( createPeriod( "200001" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ), createPeriod( "200005" ), createPeriod( "200006" ), createPeriod( "200007" ), createPeriod( "200008" ), createPeriod( "200009" ) ) ); DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); @@ -606,7 +601,7 @@ } /** - * Splits on 3 queries on organisation units for an optimal of 3 queries. No + * Splits on 3 queries on organisation units for an optimal of 3 queries. No * data elements specified. */ @Test @@ -614,7 +609,7 @@ { DataQueryParams params = new DataQueryParams(); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - params.setPeriods( getList( createPeriod( "200001" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ), + params.setPeriods( getList( createPeriod( "200001" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ), createPeriod( "200005" ), createPeriod( "200006" ), createPeriod( "200007" ), createPeriod( "200008" ), createPeriod( "200009" ) ) ); DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); @@ -630,7 +625,7 @@ assertDimensionNameNotNull( query ); } } - + /** * Expected to fail because of no periods specified. */ @@ -646,7 +641,7 @@ /** * Query filters span 2 partitions. Splits in 2 queries on data elements, - * then 2 queries on organisation units to satisfy optimal for a total of 8 + * then 2 queries on organisation units to satisfy optimal for a total of 8 * queries. */ @Test @@ -656,9 +651,9 @@ params.setDataElements( getList( deA, deB, deC, deD ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); params.setFilterPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); - + assertEquals( 8, queryGroups.getAllQueries().size() ); assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 4, queryGroups.getLargestGroupSize() ); @@ -674,7 +669,7 @@ /** * Query spans 3 period types. Splits in 3 queries for each period type, then * splits in 2 queries on data type, then splits in 2 queries on data elements - * to satisfy optimal for a total of 12 queries, because query has 2 different + * to satisfy optimal for a total of 12 queries, because query has 2 different * aggregation types. */ @Test @@ -684,9 +679,9 @@ params.setDataElements( getList( deA, deB, deE, deF ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000" ), createPeriod( "200002" ), createPeriod( "200003" ), createPeriod( "200004" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 6, ANALYTICS_TABLE_NAME ); - + assertEquals( 12, queryGroups.getAllQueries().size() ); assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 6, queryGroups.getLargestGroupSize() ); @@ -702,19 +697,19 @@ /** * No periods specified, illegal query. */ - @Test( expected=IllegalQueryException.class ) + @Test( expected = IllegalQueryException.class ) public void planQueryJ() { DataQueryParams params = new DataQueryParams(); params.setDataElements( getList( deA, deB, deC, deD ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - + queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); } /** * Query spans 2 partitions. Splits in 2 queries for each partition, then - * splits in 2 queries on data sets to satisfy optimal for a total + * splits in 2 queries on data sets to satisfy optimal for a total * of 4 queries. */ @Test @@ -723,12 +718,12 @@ DataQueryParams params = new DataQueryParams(); params.setDataSets( getList( dsA, dsB, dsC, dsD ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD, ouE ) ); - params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); - + params.setPeriods( getList( createPeriod( "2000Q1" ), createPeriod( "2000Q2" ), createPeriod( "2000Q3" ), createPeriod( "2000Q4" ), createPeriod( "2001Q1" ), createPeriod( "2001Q2" ) ) ); + List<DataQueryParams> queries = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ).getAllQueries(); - + assertEquals( 4, queries.size() ); - + for ( DataQueryParams query : queries ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -749,9 +744,9 @@ params.setDataElements( getList( deA, deB, deE, deF ) ); params.setOrganisationUnits( getList( ouA, ouB, ouC, ouD ) ); params.setFilterPeriods( getList( createPeriod( "2000Q1" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); - + assertEquals( 8, queryGroups.getAllQueries().size() ); assertEquals( 2, queryGroups.getSequentialQueries().size() ); assertEquals( 4, queryGroups.getLargestGroupSize() ); @@ -764,7 +759,7 @@ } /** - * Query spans 1 partition. Splits on 2 queries for data types, then splits + * Query spans 1 partition. Splits on 2 queries for data types, then splits * on 2 queries for data elements to satisfy optimal for a total of 4 queries. */ @Test @@ -774,13 +769,13 @@ params.setDataElements( getList( deA, deB, deG, deH ) ); params.setOrganisationUnits( getList( ouA ) ); params.setPeriods( getList( createPeriod( "200101" ), createPeriod( "200103" ) ) ); - + DataQueryGroups queryGroups = queryPlanner.planQuery( params, 4, ANALYTICS_TABLE_NAME ); - + assertEquals( 4, queryGroups.getAllQueries().size() ); assertEquals( 1, queryGroups.getSequentialQueries().size() ); assertEquals( 4, queryGroups.getLargestGroupSize() ); - + for ( DataQueryParams query : queryGroups.getAllQueries() ) { assertTrue( samePeriodType( query.getPeriods() ) ); @@ -788,7 +783,7 @@ assertDimensionNameNotNull( query ); } } - + // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- @@ -796,48 +791,48 @@ private static boolean samePeriodType( List<NameableObject> isoPeriods ) { Iterator<NameableObject> periods = new ArrayList<>( isoPeriods ).iterator(); - + PeriodType first = ((Period) periods.next()).getPeriodType(); - + while ( periods.hasNext() ) { PeriodType next = ((Period) periods.next()).getPeriodType(); - + if ( !first.equals( next ) ) - { + { return false; } } - + return true; } - + private static boolean samePartition( List<NameableObject> isoPeriods ) { Iterator<NameableObject> periods = new ArrayList<>( isoPeriods ).iterator(); - + int year = new DateTime( ((Period) periods.next()).getStartDate() ).getYear(); - + while ( periods.hasNext() ) { int next = new DateTime( ((Period) periods.next()).getStartDate() ).getYear(); - + if ( year != next ) - { + { return false; } } - + return true; } - + private static void assertDimensionNameNotNull( DataQueryParams params ) { for ( DimensionalObject dim : params.getDimensions() ) { assertNotNull( dim.getDimensionName() ); } - + for ( DimensionalObject filter : params.getFilters() ) { assertNotNull( filter.getDimensionName() ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2015-09-01 06:14:53 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2015-09-04 10:49:08 +0000 @@ -188,12 +188,6 @@ } // ------------------------------------------------------------- - // Find type of data element - // ------------------------------------------------------------- - - String dataElementType = dataElement.getDetailedNumberType(); - - // ------------------------------------------------------------- // Find existing value of data element in data set // ------------------------------------------------------------- @@ -233,12 +227,12 @@ if ( inputHTML.contains( "title=\"\"" ) ) { inputHTML = inputHTML.replace( "title=\"\"", "title=\"[ " + dataElement.getUid() + " - " - + dataElement.getName() + " - " + dataElementType + " ]\" " ); + + dataElement.getName() + " - " + dataElement.getValueType() + " ]\" " ); } else { inputHTML += "title=\"[ " + dataElement.getUid() + " - " + dataElement.getName() + " - " - + dataElementType + " ]\" "; + + dataElement.getValueType() + " ]\" "; } // ------------------------------------------------------------- @@ -306,7 +300,7 @@ inputHTML = inputHTML.replace( "$PROGRAMSTAGEID", String.valueOf( programStageUid ) ); inputHTML = inputHTML.replace( "$PROGRAMSTAGENAME", programStageName ); inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getFormNameFallback() ); - inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElementType ); + inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElement.getValueType().toString() ); inputHTML = inputHTML.replace( "$DISABLED", disabled ); inputHTML = inputHTML.replace( "$COMPULSORY", compulsory ); inputHTML = inputHTML.replace( "$SAVEMODE", "false" ); @@ -405,12 +399,6 @@ } // ------------------------------------------------------------- - // Find type of data element - // ------------------------------------------------------------- - - String dataElementType = dataElement.getDetailedNumberType(); - - // ------------------------------------------------------------- // Find existing value of data element in data set // ------------------------------------------------------------- @@ -426,12 +414,12 @@ if ( inputHTML.contains( "title=\"\"" ) ) { inputHTML = inputHTML.replace( "title=\"\"", "title=\"[ " + dataElement.getUid() + " - " - + dataElement.getName() + " - " + dataElementType + " ]\" " ); + + dataElement.getName() + " - " + dataElement.getValueType() + " ]\" " ); } else { inputHTML += "title=\"[ " + dataElement.getUid() + " - " + dataElement.getName() + " - " - + dataElementType + " ]\" "; + + dataElement.getValueType() + " ]\" "; } // ------------------------------------------------------------- @@ -489,7 +477,7 @@ inputHTML = inputHTML.replace( "$PROGRAMSTAGEID", String.valueOf( programStageUid ) ); inputHTML = inputHTML.replace( "$PROGRAMSTAGENAME", programStageName ); inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getName() ); - inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElementType ); + inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElement.getValueType().toString() ); inputHTML = inputHTML.replace( "$DISABLED", disabled ); inputHTML = inputHTML.replace( "$COMPULSORY", compulsory ); inputHTML = inputHTML.replace( "$SAVEMODE", "false" ); @@ -573,7 +561,7 @@ String metaData = "<input class='optionset' id=\'" + id + "\' name=\'" + id + "\' options=\'no\' type=\'radio\' optionset='" + dataElement.getOptionSet().getUid() + "'"; metaData += " data=\"{compulsory:$COMPULSORY, deName:\'$DATAELEMENTNAME\', deType:\'" - + dataElement.getDetailedNumberType() + "\' }\" "; + + dataElement.getValueType() + "\' }\" "; inputHTML = "<table style=\'width:100%\'>"; inputHTML += "<tr>"; @@ -633,7 +621,7 @@ + "]\" "; String displayTitle = dataElement.getUid() + " - " + dataElement.getName() + " - " - + dataElement.getDetailedNumberType(); + + dataElement.getValueType(); inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, "title=\"[ " + displayTitle + " ]\"" ) : inputHTML + " title=\"[ " + displayTitle + " ]\""; } @@ -740,7 +728,7 @@ + "\" data-optionset=\"" + dataElement.getOptionSet().getUid() + "\" "; } - if ( DataElement.VALUE_TYPE_LONG_TEXT.equals( dataElement.getDetailedTextType() ) ) + if ( ValueType.LONG_TEXT == dataElement.getValueType() ) { inputHTML = inputHTML.replaceFirst( "input", "textarea" ); inputHTML += " >$VALUE</textarea>"; === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-09-04 09:29:23 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-09-04 10:49:08 +0000 @@ -608,7 +608,7 @@ if ( programStage != null && dataElement != null ) { - String sample = dataElement.isNumericType() ? String.valueOf( 1 ) : dataElement.isDateType() ? "'2000-01-01'" : "'A'"; + String sample = dataElement.isNumericType() ? String.valueOf( 1 ) : dataElement.getValueType().isDate() ? "'2000-01-01'" : "'A'"; matcher.appendReplacement( expr, sample ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2015-09-03 09:03:51 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2015-09-04 10:49:08 +0000 @@ -213,7 +213,7 @@ executeSql( "ALTER TABLE organisationunit DROP COLUMN hasPatients" ); - executeSql( "update dataelement set texttype='text' where valuetype='string' and texttype is null" ); + // executeSql( "update dataelement set texttype='text' where valuetype='string' and texttype is null" ); // categories_categoryoptions // set to 0 temporarily @@ -285,9 +285,9 @@ executeSql( "ALTER TABLE section DROP CONSTRAINT section_name_key" ); executeSql( "UPDATE patientattribute set inheritable=false where inheritable is null" ); - executeSql( "UPDATE dataelement SET numbertype='number' where numbertype is null and valuetype='int'" ); - executeSql( "UPDATE dataelement SET valuetype='posInt' where valuetype='positiveNumber'" ); - executeSql( "UPDATE dataelement SET valuetype='negInt' where valuetype='negativeNumber'" ); + // executeSql( "UPDATE dataelement SET numbertype='number' where numbertype is null and valuetype='int'" ); + // executeSql( "UPDATE dataelement SET valuetype='posInt' where valuetype='positiveNumber'" ); + // executeSql( "UPDATE dataelement SET valuetype='negInt' where valuetype='negativeNumber'" ); executeSql( "UPDATE dataelement SET aggregationtype='avg_sum_org_unit' where aggregationtype='average'" ); // revert prepare aggregate*Value tables for offline diffs @@ -878,22 +878,28 @@ private void updateValueTypes() { - executeSql( "update dataelement set vtype='NUMBER' where valuetype='int' and numbertype='number' and vtype is null" ); - executeSql( "update dataelement set vtype='INTEGER' where valuetype='int' and numbertype='int' and vtype is null" ); - executeSql( "update dataelement set vtype='INTEGER_POSITIVE' where valuetype='int' and numbertype='posInt' and vtype is null" ); - executeSql( "update dataelement set vtype='INTEGER_NEGATIVE' where valuetype='int' and numbertype='negInt' and vtype is null" ); - executeSql( "update dataelement set vtype='INTEGER_ZERO_OR_POSITIVE' where valuetype='int' and numbertype='zeroPositiveInt' and vtype is null" ); - executeSql( "update dataelement set vtype='PERCENTAGE' where valuetype='int' and numbertype='percentage' and vtype is null" ); - executeSql( "update dataelement set vtype='UNIT_INTERVAL' where valuetype='int' and numbertype='unitInterval' and vtype is null" ); - - executeSql( "update dataelement set vtype='TEXT' where valuetype='string' and texttype='text' and vtype is null" ); - executeSql( "update dataelement set vtype='LONG_TEXT' where valuetype='string' and texttype='longText' and vtype is null" ); - - executeSql( "update dataelement set vtype='DATE' where valuetype='date' and vtype is null" ); - executeSql( "update dataelement set vtype='DATETIME' where valuetype='datetime' and vtype is null" ); - executeSql( "update dataelement set vtype='BOOLEAN' where valuetype='bool' and vtype is null" ); - executeSql( "update dataelement set vtype='TRUE_ONLY' where valuetype='trueOnly' and vtype is null" ); - executeSql( "update dataelement set vtype='USERNAME' where valuetype='username' and vtype is null" ); + executeSql( "alter table dataelement alter column valuetype type varchar(50)" ); + + executeSql( "update dataelement set vtype='NUMBER' where valuetype='int' and numbertype='number'" ); + executeSql( "update dataelement set vtype='INTEGER' where valuetype='int' and numbertype='int'" ); + executeSql( "update dataelement set vtype='INTEGER_POSITIVE' where valuetype='int' and numbertype='posInt'" ); + executeSql( "update dataelement set vtype='INTEGER_NEGATIVE' where valuetype='int' and numbertype='negInt'" ); + executeSql( "update dataelement set vtype='INTEGER_ZERO_OR_POSITIVE' where valuetype='int' and numbertype='zeroPositiveInt'" ); + executeSql( "update dataelement set vtype='PERCENTAGE' where valuetype='int' and numbertype='percentage'" ); + executeSql( "update dataelement set vtype='UNIT_INTERVAL' where valuetype='int' and numbertype='unitInterval'" ); + + executeSql( "update dataelement set vtype='TEXT' where valuetype='string' and texttype='text'" ); + executeSql( "update dataelement set vtype='LONG_TEXT' where valuetype='string' and texttype='longText'" ); + + executeSql( "update dataelement set vtype='DATE' where valuetype='date'" ); + executeSql( "update dataelement set vtype='DATETIME' where valuetype='datetime'" ); + executeSql( "update dataelement set vtype='BOOLEAN' where valuetype='bool'" ); + executeSql( "update dataelement set vtype='TRUE_ONLY' where valuetype='trueOnly'" ); + executeSql( "update dataelement set vtype='USERNAME' where valuetype='username'" ); + + executeSql( "alter table dataelement drop column valuetype" ); + executeSql( "alter table dataelement drop column numbertype" ); + executeSql( "alter table dataelement drop column texttype" ); executeSql( "update trackedentityattribute set valuetype='TEXT' where valuetype='string'" ); executeSql( "update trackedentityattribute set valuetype='PHONE_NUMBER' where valuetype='phoneNumber'" ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2015-09-04 09:29:23 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2015-09-04 10:49:08 +0000 @@ -22,13 +22,7 @@ <property name="formName" length="230" /> - <property name="type" column="valuetype" length="16" not-null="false" /> - - <property name="numberType" column="numbertype" length="16" not-null="false" /> - - <property name="textType" column="textType" length="16" not-null="false" /> - - <property name="valueType" column="vtype" length="36" access="property" not-null="false"> + <property name="valueType" column="vtype" length="50" access="property"> <type name="org.hibernate.type.EnumType"> <param name="enumClass">org.hisp.dhis.common.ValueType</param> <param name="useNamed">true</param> === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramDataEntryServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramDataEntryServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramDataEntryServiceTest.java 2015-09-04 10:49:08 +0000 @@ -28,11 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.junit.Assert.assertEquals; - -import java.util.HashSet; -import java.util.Set; - import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; @@ -44,6 +39,11 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + /** * @author Chau Thu Tran */ @@ -114,11 +114,11 @@ dataElementService.addDataElement( dataElementA ); dataElementService.addDataElement( dataElementB ); - + ProgramStageDataElement programStageDataElementA = new ProgramStageDataElement( stageA, dataElementA, false, 1 ); stageA.getProgramStageDataElements().add( programStageDataElementA ); programStageDataElementService.addProgramStageDataElement( programStageDataElementA ); - + ProgramStageDataElement programStageDataElementB = new ProgramStageDataElement( stageA, dataElementB, false, 2 ); stageA.getProgramStageDataElements().add( programStageDataElementB ); programStageDataElementService.addProgramStageDataElement( programStageDataElementB ); @@ -129,17 +129,17 @@ @Test public void testPrepareDataEntryFormForAdd() { - String expected = "<input id=\"StageA-DeA-val\" style=\"width:4em;text-align:center\" value=\"\" title=\"[ DeA - DataElementA - int ]\" " - + " name=\"entryfield\" tabIndex=\"1\" data=\"{compulsory:false, deName:\'DataElementA\', deType:\'int\'}\" options=\'false\' " + String expected = "<input id=\"StageA-DeA-val\" style=\"width:4em;text-align:center\" value=\"\" title=\"[ DeA - DataElementA - INTEGER ]\" " + + " name=\"entryfield\" tabIndex=\"1\" data=\"{compulsory:false, deName:\'DataElementA\', deType:\'INTEGER\'}\" options=\'false\' " + "maxlength=255 onchange=\"saveVal( \'DeA\', this.value )\" onkeypress=\"return keyPress(event, this)\" />"; String actual = programDataEntryService.prepareDataEntryFormForAdd( htmlCode, mockI18n, stageA ); - assertEquals( expected, actual ); + assertEquals( expected, actual ); } @Test public void testPrepareDataEntryFormForEdit() { - String expected = "<input id=\"StageA-DeA-val\" style=\"width:4em;text-align:center\" value=\"[DataElementA]\" title=\"[ DeA - DataElementA - int ]\" />"; + String expected = "<input id=\"StageA-DeA-val\" style=\"width:4em;text-align:center\" value=\"[DataElementA]\" title=\"[ DeA - DataElementA - INTEGER ]\" />"; String actual = programDataEntryService.prepareDataEntryFormForEdit( htmlCode ); assertEquals( expected, actual ); } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java 2015-09-04 10:49:08 +0000 @@ -30,6 +30,7 @@ import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.common.IdentifiableObjectManager; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dxf2.events.event.DataValue; import org.hisp.dhis.dxf2.events.event.Event; @@ -94,7 +95,7 @@ identifiableObjectManager.save( organisationUnitA ); dataElementA = createDataElement( 'A' ); - dataElementA.setType( DataElement.VALUE_TYPE_INT ); + dataElementA.setValueType( ValueType.INTEGER ); identifiableObjectManager.save( dataElementA ); programStageA = createProgramStage( 'A', 0 ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2015-09-04 10:49:08 +0000 @@ -39,6 +39,7 @@ import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.OrganisationUnitSelectionMode; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dxf2.events.enrollment.Enrollment; import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService; @@ -149,8 +150,8 @@ dataElementA = createDataElement( 'A' ); dataElementB = createDataElement( 'B' ); - dataElementA.setType( DataElement.VALUE_TYPE_INT ); - dataElementB.setType( DataElement.VALUE_TYPE_INT ); + dataElementA.setValueType( ValueType.INTEGER ); + dataElementB.setValueType( ValueType.INTEGER ); identifiableObjectManager.save( dataElementA ); identifiableObjectManager.save( dataElementB ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2015-09-04 10:49:08 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.OrganisationUnitSelectionMode; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dxf2.events.enrollment.Enrollment; import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService; @@ -132,7 +133,7 @@ trackedEntityInstanceMaleA = trackedEntityInstanceService.getTrackedEntityInstance( maleA ); dataElementA = createDataElement( 'A' ); - dataElementA.setType( DataElement.VALUE_TYPE_INT ); + dataElementA.setValueType( ValueType.INTEGER ); identifiableObjectManager.save( dataElementA ); programStageA = createProgramStage( 'A', 0 ); === modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java' --- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2015-09-04 10:49:08 +0000 @@ -29,14 +29,29 @@ */ import org.hisp.dhis.DhisSpringTest; -import org.hisp.dhis.dataelement.*; +import org.hisp.dhis.common.ValueType; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategory; +import org.hisp.dhis.dataelement.DataElementCategoryCombo; +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementDomain; +import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.DailyPeriodType; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; -import org.hisp.dhis.program.*; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; +import org.hisp.dhis.program.ProgramStageService; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.trackedentity.TrackedEntityInstance; @@ -56,7 +71,6 @@ /** * @author Chau Thu Tran - * * @version $ CaseAggregationConditionServiceTest.java Nov 29, 2013 10:01:48 AM * $ */ @@ -173,11 +187,11 @@ categoryService.addDataElementCategoryOptionCombo( categoryOptionCombo ); dataElementA = createDataElement( 'A' ); - dataElementA.setType( DataElement.VALUE_TYPE_STRING ); + dataElementA.setValueType( ValueType.TEXT ); dataElementA.setDomainType( DataElementDomain.TRACKER ); dataElementB = createDataElement( 'B' ); - dataElementB.setType( DataElement.VALUE_TYPE_STRING ); + dataElementB.setValueType( ValueType.TEXT ); dataElementB.setDomainType( DataElementDomain.TRACKER ); dataElementC = createDataElement( 'C' ); === modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java' --- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2015-09-04 10:49:08 +0000 @@ -36,6 +36,7 @@ import java.util.Set; import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategory; import org.hisp.dhis.dataelement.DataElementCategoryCombo; @@ -187,11 +188,11 @@ categoryService.addDataElementCategoryOptionCombo( categoryOptionCombo ); dataElementA = createDataElement( 'A' ); - dataElementA.setType( DataElement.VALUE_TYPE_STRING ); + dataElementA.setValueType( ValueType.TEXT ); dataElementA.setDomainType( DataElementDomain.TRACKER ); dataElementB = createDataElement( 'B' ); - dataElementB.setType( DataElement.VALUE_TYPE_STRING ); + dataElementB.setValueType( ValueType.TEXT ); dataElementB.setDomainType( DataElementDomain.TRACKER ); dataElementC = createDataElement( 'C' ); === modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java' --- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-09-04 08:57:35 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-09-04 10:49:08 +0000 @@ -352,7 +352,6 @@ dataElement.setShortName( "DataElementShort" + uniqueCharacter ); dataElement.setCode( "DataElementCode" + uniqueCharacter ); dataElement.setDescription( "DataElementDescription" + uniqueCharacter ); - dataElement.setType( DataElement.VALUE_TYPE_INT ); dataElement.setValueType( ValueType.INTEGER ); dataElement.setDomainType( DataElementDomain.AGGREGATE ); dataElement.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ); @@ -373,7 +372,6 @@ dataElement.setShortName( "DataElementShort" + uniqueCharacter ); dataElement.setCode( "DataElementCode" + uniqueCharacter ); dataElement.setDescription( "DataElementDescription" + uniqueCharacter ); - dataElement.setType( DataElement.VALUE_TYPE_INT ); // remove dataElement.setValueType( valueType ); dataElement.setDomainType( DataElementDomain.AGGREGATE ); dataElement.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ); @@ -397,21 +395,6 @@ /** * @param uniqueCharacter A unique character to identify the object. - * @param type The value type. - * @param aggregationOperator The aggregation operator. - */ - public static DataElement createDataElement( char uniqueCharacter, String type, String aggregationOperator ) - { - DataElement dataElement = createDataElement( uniqueCharacter ); - dataElement.setType( type ); - dataElement.setDomainType( DataElementDomain.AGGREGATE ); - dataElement.setAggregationOperator( aggregationOperator ); - - return dataElement; - } - - /** - * @param uniqueCharacter A unique character to identify the object. * @param valueType The value type. * @param aggregationOperator The aggregation operator. */ @@ -427,15 +410,15 @@ /** * @param uniqueCharacter A unique character to identify the object. - * @param type The value type. + * @param valueType The value type. * @param aggregationOperator The aggregation operator. * @param categoryCombo The category combo. */ - public static DataElement createDataElement( char uniqueCharacter, String type, String aggregationOperator, + public static DataElement createDataElement( char uniqueCharacter, ValueType valueType, String aggregationOperator, DataElementCategoryCombo categoryCombo ) { DataElement dataElement = createDataElement( uniqueCharacter ); - dataElement.setType( type ); + dataElement.setValueType( valueType ); dataElement.setDomainType( DataElementDomain.AGGREGATE ); dataElement.setAggregationOperator( aggregationOperator ); dataElement.setCategoryCombo( categoryCombo ); === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-09-03 12:15:43 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataValueController.java 2015-09-04 10:49:08 +0000 @@ -193,7 +193,7 @@ if ( valueValid != null ) { - throw new WebMessageException( WebMessageUtils.conflict( "Invalid value: " + value + ", must match data element type: " + dataElement.getDetailedType() ) ); + throw new WebMessageException( WebMessageUtils.conflict( "Invalid value: " + value + ", must match data element type: " + dataElement.getValueType() ) ); } String commentValid = ValidationUtils.commentIsValid( comment );
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp