=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2015-08-02 14:59:59 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2015-09-03 08:15:09 +0000 @@ -28,34 +28,34 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - import org.hisp.dhis.analytics.AggregationType; import org.hisp.dhis.legend.LegendSet; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.util.ObjectUtils; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + /** - * Class which encapsulates a query parameter and value. Operator and filter + * Class which encapsulates a query parameter and value. Operator and filter * are inherited from QueryFilter. - * + * * @author Lars Helge Overland */ public class QueryItem { private DimensionalObject item; - + private LegendSet legendSet; private List filters = new ArrayList<>(); - - private String valueType; - + + private ValueType valueType; + private AggregationType aggregationType; - + private OptionSet optionSet; // ------------------------------------------------------------------------- @@ -67,7 +67,7 @@ this.item = item; } - public QueryItem( DimensionalObject item, LegendSet legendSet, String valueType, AggregationType aggregationType, OptionSet optionSet ) + public QueryItem( DimensionalObject item, LegendSet legendSet, ValueType valueType, AggregationType aggregationType, OptionSet optionSet ) { this.item = item; this.legendSet = legendSet; @@ -75,71 +75,71 @@ this.aggregationType = aggregationType; this.optionSet = optionSet; } - - public QueryItem( DimensionalObject item, QueryOperator operator, String filter, String valueType, AggregationType aggregationType, OptionSet optionSet ) + + public QueryItem( DimensionalObject item, QueryOperator operator, String filter, ValueType valueType, AggregationType aggregationType, OptionSet optionSet ) { this.item = item; this.valueType = valueType; this.aggregationType = aggregationType; this.optionSet = optionSet; - + if ( operator != null && filter != null ) { this.filters.add( new QueryFilter( operator, filter ) ); } } - + // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- - + public String getItemId() { return item.getUid(); } - + public String getItemName() { String itemName = item.getUid(); - + if ( legendSet != null ) { itemName += "_" + legendSet.getUid(); } - + return itemName; } - + public String getTypeAsString() { return ObjectUtils.VALUE_TYPE_JAVA_CLASS_MAP.get( valueType ).getName(); } - + public boolean isNumeric() { return Double.class.equals( ObjectUtils.VALUE_TYPE_JAVA_CLASS_MAP.get( valueType ) ); } - + public boolean hasLegendSet() { return legendSet != null; } - + public boolean hasOptionSet() { return optionSet != null; } - + public String getLegendSetUid() { return legendSet != null ? legendSet.getUid() : null; } - + public String getOptionSetUid() { return optionSet != null ? optionSet.getUid() : null; } - + public boolean hasFilter() { return filters != null && !filters.isEmpty(); @@ -148,19 +148,19 @@ public static List getQueryItems( Collection attributes ) { List queryItems = new ArrayList<>(); - + for ( TrackedEntityAttribute attribute : attributes ) { queryItems.add( new QueryItem( attribute, attribute.getLegendSet(), attribute.getValueType(), attribute.getAggregationType(), attribute.hasOptionSet() ? attribute.getOptionSet() : null ) ); } - + return queryItems; } - + // ------------------------------------------------------------------------- // hashCode, equals and toString // ------------------------------------------------------------------------- - + @Override public int hashCode() { @@ -174,19 +174,19 @@ { return true; } - + if ( object == null ) { return false; } - + if ( getClass() != object.getClass() ) { return false; } - + final QueryItem other = (QueryItem) object; - + return item.equals( other.getItem() ); } @@ -195,7 +195,7 @@ { return "[Item: " + item + ", legend set: " + legendSet + ", filters: " + filters + ", value type: " + valueType + ", optionSet: " + optionSet + "]"; } - + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -230,12 +230,12 @@ this.filters = filters; } - public String getValueType() + public ValueType getValueType() { return valueType; } - public void setValueType( String valueType ) + public void setValueType( ValueType valueType ) { this.valueType = valueType; } === 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-03 04:42:52 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ValueType.java 2015-09-03 08:15:09 +0000 @@ -69,7 +69,7 @@ INTEGER, INTEGER_POSITIVE, INTEGER_NEGATIVE, INTEGER_ZERO_OR_POSITIVE, NUMBER, UNIT_INTERVAL, PERCENTAGE ); - public static List TEXT_TYPES = Lists.newArrayList( TEXT, LONG_TEXT ); + public static List TEXT_TYPES = Lists.newArrayList( TEXT, LONG_TEXT, LETTER ); public static List INTEGER_TYPE_STRINGS = Lists.newArrayList( INTEGER.toString(), INTEGER_POSITIVE.toString(), INTEGER_NEGATIVE.toString(), INTEGER_ZERO_OR_POSITIVE.toString() @@ -80,7 +80,7 @@ NUMBER.toString(), UNIT_INTERVAL.toString(), PERCENTAGE.toString() ); - public static List TEXT_TYPE_STRINGS = Lists.newArrayList( TEXT.toString(), LONG_TEXT.toString() ); + public static List TEXT_TYPE_STRINGS = Lists.newArrayList( TEXT.toString(), LONG_TEXT.toString(), LETTER.toString() ); private final Class javaClass; @@ -114,6 +114,11 @@ return this == TEXT || this == LONG_TEXT; } + public boolean isDate() + { + return this == DATE || this == DATETIME; + } + /** * TODO replace string value type on data element with ValueType and remove * this method. @@ -220,4 +225,17 @@ return ValueType.TEXT; // Fall back } + + public static ValueType fromValue( String value ) + { + for ( ValueType valueType : ValueType.values() ) + { + if ( valueType.toString().equalsIgnoreCase( value ) ) + { + return valueType; + } + } + + return null; + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-08-28 10:23:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-09-03 08:15:09 +0000 @@ -28,9 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Set; -import java.util.regex.Pattern; - +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +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.analytics.EventOutputType; import org.hisp.dhis.common.BaseIdentifiableObject; @@ -42,12 +45,8 @@ import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -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.Set; +import java.util.regex.Pattern; /** * @author Chau Thu Tran @@ -62,18 +61,18 @@ public static final String KEY_ATTRIBUTE = "A"; public static final String KEY_PROGRAM_VARIABLE = "V"; public static final String KEY_CONSTANT = "C"; - + public static final String VAR_EXECUTION_DATE = "execution_date"; public static final String VAR_INCIDENT_DATE = "incident_date"; public static final String VAR_ENROLLMENT_DATE = "enrollment_date"; public static final String VAR_CURRENT_DATE = "current_date"; public static final String VAR_VALUE_COUNT = "value_count"; public static final String VAR_ZERO_POS_VALUE_COUNT = "zero_pos_value_count"; - + public static final String VALUE_TYPE_DATE = "date"; public static final String VALUE_TYPE_INT = "int"; - - private static final String EXPRESSION_REGEXP = "(" + KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT + ")\\{(\\w+|" + + + private static final String EXPRESSION_REGEXP = "(" + KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT + ")\\{(\\w+|" + VAR_INCIDENT_DATE + "|" + VAR_ENROLLMENT_DATE + "|" + VAR_CURRENT_DATE + ")" + SEPARATOR_ID + "?(\\w*)\\}"; private static final String SQL_FUNC_REGEXP = "d2:(.+?)\\(([^,]+)\\,?([^,]*)\\,?([^,]*)\\)"; @@ -82,31 +81,31 @@ public static final Pattern DATAELEMENT_PATTERN = Pattern.compile( KEY_DATAELEMENT + "\\{(\\w{11})" + SEPARATOR_ID + "(\\w{11})\\}" ); public static final Pattern ATTRIBUTE_PATTERN = Pattern.compile( KEY_ATTRIBUTE + "\\{(\\w{11})\\}" ); public static final Pattern VALUECOUNT_PATTERN = Pattern.compile( "V\\{(" + VAR_VALUE_COUNT + "|" + VAR_ZERO_POS_VALUE_COUNT + ")\\}" ); - + public static final String VALID = "valid"; public static final String EXPRESSION_NOT_WELL_FORMED = "expression_not_well_formed"; public static final String INVALID_IDENTIFIERS_IN_EXPRESSION = "invalid_identifiers_in_expression"; public static final String FILTER_NOT_EVALUATING_TO_TRUE_OR_FALSE = "filter_not_evaluating_to_true_or_false"; private Program program; - + private String valueType; private String expression; - + private String filter; - + private AggregationType aggregationType; private EventOutputType eventOutputType; - + /** * Number of decimals to use for indicator value, null implies default. */ private Integer decimals; private Boolean displayInForm; - + private String rootDate; // ------------------------------------------------------------------------- @@ -130,7 +129,7 @@ { return decimals != null && decimals >= 0; } - + /** * Returns aggregation type, if not exists returns AVERAGE. */ @@ -138,21 +137,21 @@ { return aggregationType != null ? aggregationType : AggregationType.AVERAGE; } - + /** * Returns a set of data element and attribute identifiers part of the given * input expression. - * + * * @param input the expression. * @return a set of UIDs. */ public static Set getDataElementAndAttributeIdentifiers( String input ) { - return Sets.union( + return Sets.union( RegexUtils.getMatches( DATAELEMENT_PATTERN, input, 2 ), RegexUtils.getMatches( ATTRIBUTE_PATTERN, input, 1 ) ); } - + // ------------------------------------------------------------------------- // Getters && Setters // ------------------------------------------------------------------------- @@ -283,7 +282,7 @@ if ( other.getClass().isInstance( this ) ) { ProgramIndicator programIndicator = (ProgramIndicator) other; - + if ( strategy.isReplace() ) { program = programIndicator.getProgram(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-08-27 15:28:24 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-09-03 08:15:09 +0000 @@ -28,27 +28,27 @@ * 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.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.BaseDimensionalObject; import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.MergeStrategy; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.schema.annotation.PropertyRange; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -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.HashSet; +import java.util.Set; /** * @author Abyot Asalefew @@ -71,8 +71,8 @@ private String description; - private String valueType; - + private ValueType valueType; + private Boolean inherit = false; private TrackedEntityAttributeGroup attributeGroup; @@ -115,8 +115,7 @@ } - public TrackedEntityAttribute( String name, String description, String valueType, Boolean inherit, - Boolean displayOnVisitSchedule ) + public TrackedEntityAttribute( String name, String description, ValueType valueType, Boolean inherit, Boolean displayOnVisitSchedule ) { this.name = name; this.description = description; @@ -134,7 +133,7 @@ */ public boolean isNumericType() { - return TYPE_NUMBER.equals( valueType ); + return valueType.isNumeric(); } /** @@ -142,7 +141,7 @@ */ public boolean isDateType() { - return TYPE_DATE.equals( valueType ); + return valueType.isDate(); } /** @@ -169,7 +168,7 @@ { return false; } - + for ( Option option : getOptionSet().getOptions() ) { if ( value.equals( option.getCode() ) ) @@ -191,7 +190,7 @@ { return optionSet != null; } - + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -228,12 +227,12 @@ @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getValueType() + public ValueType getValueType() { return valueType; } - public void setValueType( String valueType ) + public void setValueType( ValueType valueType ) { this.valueType = valueType; } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderService.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderService.java 2015-09-03 08:15:09 +0000 @@ -96,7 +96,7 @@ * orgunit phone numbers, phone numbers of DHIS users at the orgunit * OR phone numbers of DHIS users in a user group. */ - Set getPhonenumbers( TrackedEntityInstanceReminder reminder, TrackedEntityInstance instance ); + Set getPhoneNumbers( TrackedEntityInstanceReminder reminder, TrackedEntityInstance instance ); /** * Retrieve DHIS users from a template which is defined to send messages to === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-08-21 02:55:35 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-09-03 08:15:09 +0000 @@ -28,15 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID; -import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.hisp.dhis.analytics.AggregationType; import org.hisp.dhis.analytics.DataQueryParams; import org.hisp.dhis.analytics.EventOutputType; @@ -55,6 +46,15 @@ import org.hisp.dhis.program.ProgramIndicator; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID; +import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID; + /** * @author Lars Helge Overland */ @@ -62,41 +62,41 @@ extends DataQueryParams { private Date startDate; - + private Date endDate; - + private List items = new ArrayList<>(); - + private List itemFilters = new ArrayList<>(); - + private DimensionalObject value; - + private List itemProgramIndicators = new ArrayList<>(); private ProgramIndicator programIndicator; - + private List asc = new ArrayList<>(); - + private List desc = new ArrayList<>(); - + private String organisationUnitMode; - + private Integer page; - + private Integer pageSize; private SortOrder sortOrder; - + private Integer limit; - + private EventOutputType outputType; - + private boolean collapseDataDimensions; - + private boolean coordinatesOnly; private boolean aggregateData; - + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -109,7 +109,7 @@ public EventQueryParams instance() { EventQueryParams params = new EventQueryParams(); - + params.dimensions = new ArrayList<>( this.dimensions ); params.filters = new ArrayList<>( this.filters ); params.displayProperty = this.displayProperty; @@ -118,7 +118,7 @@ params.partitions = new Partitions( this.partitions ); params.periodType = this.periodType; - + params.program = this.program; params.programStage = this.programStage; params.startDate = this.startDate; @@ -139,45 +139,44 @@ params.collapseDataDimensions = this.collapseDataDimensions; params.coordinatesOnly = this.coordinatesOnly; params.aggregateData = this.aggregateData; - + params.periodType = this.periodType; - + return params; } - + public static EventQueryParams fromDataQueryParams( DataQueryParams dataQueryParams ) { //TODO indicator filter - EventQueryParams params = new EventQueryParams(); - + dataQueryParams.copyTo( params ); - + for ( NameableObject object : dataQueryParams.getProgramDataElements() ) { - DataElement element = (DataElement) object; - QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getAggregationType(), element.getOptionSet() ); + DataElement element = (DataElement) object; + QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() ); params.getItems().add( item ); } for ( NameableObject object : dataQueryParams.getProgramAttributes() ) { - TrackedEntityAttribute element = (TrackedEntityAttribute) object; + TrackedEntityAttribute element = (TrackedEntityAttribute) object; QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() ); params.getItems().add( item ); - } + } for ( NameableObject object : dataQueryParams.getFilterProgramDataElements() ) { - DataElement element = (DataElement) object; - QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getAggregationType(), element.getOptionSet() ); + DataElement element = (DataElement) object; + QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() ); params.getItemFilters().add( item ); } for ( NameableObject object : dataQueryParams.getFilterProgramAttributes() ) { - TrackedEntityAttribute element = (TrackedEntityAttribute) object; - QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() ); + TrackedEntityAttribute element = (TrackedEntityAttribute) object; + QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() ); params.getItemFilters().add( item ); } @@ -186,17 +185,17 @@ ProgramIndicator programIndicator = (ProgramIndicator) object; params.getItemProgramIndicators().add( programIndicator ); } - + params.setAggregateData( true ); params.removeDimension( DATA_X_DIM_ID ); - + return params; } // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- - + /** * Replaces periods with start and end dates, using the earliest start date * from the periods as start date and the latest end date from the periods @@ -205,23 +204,23 @@ public void replacePeriodsWithStartEndDates() { List periods = NameableObjectUtils.asTypedList( getDimensionOrFilterItems( PERIOD_DIM_ID ), Period.class ); - + for ( Period period : periods ) { Date start = period.getStartDate(); Date end = period.getEndDate(); - - if ( startDate == null || ( start != null && start.before( startDate ) ) ) + + if ( startDate == null || (start != null && start.before( startDate )) ) { startDate = start; } - - if ( endDate == null || ( end != null && end.after( endDate ) ) ) + + if ( endDate == null || (end != null && end.after( endDate )) ) { endDate = end; } } - + removeDimensionOrFilter( PERIOD_DIM_ID ); } @@ -233,7 +232,7 @@ { Set dims = new HashSet<>(); List duplicates = new ArrayList<>(); - + for ( QueryItem dim : items ) { if ( !dims.add( dim ) ) @@ -241,32 +240,32 @@ duplicates.add( dim ); } } - + return duplicates; } - + /** * Get nameable objects part of items and item filters. */ public Set getNameableObjectItems() { Set objects = new HashSet(); - + for ( QueryItem item : ListUtils.union( items, itemFilters ) ) { objects.add( item.getItem() ); } - + return objects; } - + /** * Get legend sets part of items and item filters. */ public Set getLegends() { Set legends = new HashSet<>(); - + for ( QueryItem item : ListUtils.union( items, itemFilters ) ) { if ( item.hasLegendSet() ) @@ -274,17 +273,17 @@ legends.addAll( item.getLegendSet().getLegends() ); } } - + return legends; } - + /** * Get option sets part of items. */ public Set getItemOptionSets() { Set optionSets = new HashSet<>(); - + for ( QueryItem item : items ) { if ( item.hasOptionSet() ) @@ -292,7 +291,7 @@ optionSets.add( item.getOptionSet() ); } } - + return optionSets; } @@ -311,7 +310,7 @@ { return value.getAggregationType(); } - + return AggregationType.AVERAGE; } @@ -323,10 +322,10 @@ public boolean isAggregationType( AggregationType aggregationType ) { AggregationType type = getAggregationTypeFallback(); - + return type != null && type.equals( aggregationType ); - } - + } + /** * Indicates whether this query is of the given organisation unit mode. */ @@ -350,25 +349,25 @@ { return startDate != null && endDate != null; } - + public Set getOrganisationUnitChildren() { Set children = new HashSet<>(); - + for ( NameableObject object : getDimensionOrFilterItems( DimensionalObject.ORGUNIT_DIM_ID ) ) { - OrganisationUnit unit = (OrganisationUnit) object; + OrganisationUnit unit = (OrganisationUnit) object; children.addAll( unit.getChildren() ); } - + return children; } - + public boolean isSorting() { - return ( asc != null && !asc.isEmpty() ) || ( desc != null && !desc.isEmpty() ); + return (asc != null && !asc.isEmpty()) || (desc != null && !desc.isEmpty()); } - + public boolean isPaging() { return page != null || pageSize != null; @@ -378,7 +377,7 @@ { return page != null && page > 0 ? page : 1; } - + public int getPageSizeWithDefault() { return pageSize != null && pageSize >= 0 ? pageSize : 50; @@ -386,29 +385,29 @@ public int getOffset() { - return ( getPageWithDefault() - 1 ) * getPageSizeWithDefault(); + return (getPageWithDefault() - 1) * getPageSizeWithDefault(); } - + public boolean hasSortOrder() { return sortOrder != null; } - + public boolean hasLimit() { return limit != null && limit > 0; } - + public boolean hasValueDimension() { return value != null; } - + public boolean hasProgramIndicatorDimension() { return programIndicator != null; } - + /** * Indicates whether the program of this query requires registration of * tracked entity instances. @@ -417,7 +416,7 @@ { return program != null && program.isRegistration(); } - + /** * Returns a negative integer in case of ascending sort order, a positive in * case of descending sort order and 0 in case of no sort order. @@ -426,7 +425,7 @@ { return SortOrder.ASC.equals( sortOrder ) ? -1 : SortOrder.DESC.equals( sortOrder ) ? 1 : 0; } - + public String toString() { return "[" + @@ -443,7 +442,7 @@ "Dimensions: " + dimensions + ", " + "Filters: " + filters + "]"; } - + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -599,7 +598,7 @@ { this.limit = limit; } - + public EventOutputType getOutputType() { return outputType; === modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-08-07 17:59:15 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-09-03 08:15:09 +0000 @@ -691,7 +691,7 @@ if ( de != null ) //TODO check if part of program { - return new QueryItem( de, legendSet, de.getType(), de.getAggregationType(), de.getOptionSet() ); + return new QueryItem( de, legendSet, de.getValueType(), de.getAggregationType(), de.getOptionSet() ); } TrackedEntityAttribute at = attributeService.getTrackedEntityAttribute( item ); === 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-08-30 12:42:15 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-09-03 08:15:09 +0000 @@ -28,16 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.i18n.I18nUtils.i18n; - -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; - +import com.google.common.collect.ImmutableMap; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.sqlfunc.ConditionalSqlFunction; import org.hisp.dhis.commons.sqlfunc.DaysBetweenSqlFunction; import org.hisp.dhis.commons.sqlfunc.OneIfZeroOrPositiveSqlFunction; @@ -65,7 +57,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.google.common.collect.ImmutableMap; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; + +import static org.hisp.dhis.i18n.I18nUtils.i18n; /** * @author Chau Thu Tran @@ -78,7 +78,7 @@ put( OneIfZeroOrPositiveSqlFunction.KEY, new OneIfZeroOrPositiveSqlFunction() ). put( DaysBetweenSqlFunction.KEY, new DaysBetweenSqlFunction() ). put( ConditionalSqlFunction.KEY, new ConditionalSqlFunction() ).build(); - + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -145,14 +145,14 @@ { i18nService = service; } - + private StatementBuilder statementBuilder; public void setStatementBuilder( StatementBuilder statementBuilder ) { this.statementBuilder = statementBuilder; } - + @Autowired private I18nManager i18nManager; @@ -259,7 +259,7 @@ for ( ProgramIndicator programIndicator : programIndicators ) { String value = getProgramIndicatorValue( programIndicator, programInstance ); - + if ( value != null ) { result.put( programIndicator.getDisplayName(), value ); @@ -268,7 +268,7 @@ return result; } - + @Override @Transactional public String getExpressionDescription( String expression ) @@ -277,13 +277,13 @@ { return null; } - + I18n i18n = i18nManager.getI18n(); - + StringBuffer description = new StringBuffer(); Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String key = matcher.group( 1 ); @@ -307,7 +307,7 @@ else if ( ProgramIndicator.KEY_ATTRIBUTE.equals( key ) ) { TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( uid ); - + if ( attribute != null ) { matcher.appendReplacement( description, attribute.getDisplayName() ); @@ -316,7 +316,7 @@ else if ( ProgramIndicator.KEY_CONSTANT.equals( key ) ) { Constant constant = constantService.getConstant( uid ); - + if ( constant != null ) { matcher.appendReplacement( description, constant.getDisplayName() ); @@ -325,7 +325,7 @@ else if ( ProgramIndicator.KEY_PROGRAM_VARIABLE.equals( key ) ) { String varName = i18n.getString( uid ); - + if ( varName != null ) { matcher.appendReplacement( description, varName ); @@ -353,16 +353,16 @@ StringBuffer buffer = new StringBuffer(); Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String key = matcher.group( 1 ); String val = matcher.group( 2 ); - + if ( ProgramIndicator.KEY_DATAELEMENT.equals( key ) ) { String de = statementBuilder.columnQuote( matcher.group( 3 ) ); - + matcher.appendReplacement( buffer, de ); } else if ( ProgramIndicator.KEY_ATTRIBUTE.equals( key ) ) @@ -372,7 +372,7 @@ else if ( ProgramIndicator.KEY_CONSTANT.equals( key ) ) { Constant constant = constantService.getConstant( val ); - + if ( constant != null ) { matcher.appendReplacement( buffer, String.valueOf( constant.getValue() ) ); @@ -381,14 +381,14 @@ else if ( ProgramIndicator.KEY_PROGRAM_VARIABLE.equals( key ) ) { String sql = getVariableAsSql( val, expression ); - + if ( sql != null ) { matcher.appendReplacement( buffer, sql ); } } } - + expression = TextUtils.appendTail( matcher, buffer ); // --------------------------------------------------------------------- @@ -396,25 +396,25 @@ // --------------------------------------------------------------------- buffer = new StringBuffer(); - + matcher = ProgramIndicator.SQL_FUNC_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String func = matcher.group( 1 ); String arg1 = matcher.group( 2 ); String arg2 = matcher.group( 3 ); String arg3 = matcher.group( 4 ); - + SqlFunction function = SQL_FUNC_MAP.get( func ); - + if ( function == null ) { throw new IllegalStateException( "Function not recognized: " + func ); } - + String result = function.evaluate( arg1, arg2, arg3 ); - + matcher.appendReplacement( buffer, result ); } @@ -422,18 +422,18 @@ return expression; } - + @Override @Transactional public String expressionIsValid( String expression ) { String expr = getSubstitutedExpression( expression ); - + if ( ProgramIndicator.INVALID_IDENTIFIERS_IN_EXPRESSION.equals( expr ) ) { return expr; } - + if ( !ExpressionUtils.isValid( expr, null ) ) { return ProgramIndicator.EXPRESSION_NOT_WELL_FORMED; @@ -441,7 +441,7 @@ return ProgramIndicator.VALID; } - + @Override @Transactional public String filterIsValid( String filter ) @@ -452,19 +452,19 @@ { return expr; } - + if ( !ExpressionUtils.isBoolean( expr, null ) ) { return ProgramIndicator.FILTER_NOT_EVALUATING_TO_TRUE_OR_FALSE; } - + return ProgramIndicator.VALID; - } - + } + /** * Generates an expression where all items are substituted with a sample value * in order to maintain a valid expression syntax. - * + * * @param expression the expression. */ private String getSubstitutedExpression( String expression ) @@ -472,7 +472,7 @@ StringBuffer expr = new StringBuffer(); Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String key = matcher.group( 1 ); @@ -488,7 +488,7 @@ if ( programStage != null && dataElement != null ) { String sample = dataElement.isNumericType() ? String.valueOf( 1 ) : dataElement.isDateType() ? "'2000-01-01'" : "'A'"; - + matcher.appendReplacement( expr, sample ); } else @@ -499,11 +499,11 @@ else if ( ProgramIndicator.KEY_ATTRIBUTE.equals( key ) ) { TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( uid ); - + if ( attribute != null ) { String sample = attribute.isNumericType() ? String.valueOf( 1 ) : attribute.isDateType() ? "'2000-01-01'" : "'A'"; - + matcher.appendReplacement( expr, sample ); } else @@ -514,7 +514,7 @@ else if ( ProgramIndicator.KEY_CONSTANT.equals( key ) ) { Constant constant = constantService.getConstant( uid ); - + if ( constant != null ) { matcher.appendReplacement( expr, String.valueOf( constant.getValue() ) ); @@ -529,37 +529,37 @@ matcher.appendReplacement( expr, String.valueOf( 1 ) ); } } - + matcher.appendTail( expr ); return expr.toString(); } - + @Override @Transactional public Set getProgramStageDataElementsInExpression( String expression ) { Set elements = new HashSet<>(); - + Matcher matcher = ProgramIndicator.DATAELEMENT_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String ps = matcher.group( 1 ); String de = matcher.group( 2 ); - + ProgramStage programStage = programStageService.getProgramStage( ps ); DataElement dataElement = dataElementService.getDataElement( de ); - + if ( programStage != null && dataElement != null ) { elements.add( new ProgramStageDataElement( programStage, dataElement ) ); } } - + return elements; } - + @Override @Transactional public Set getAttributesInExpression( String expression ) @@ -567,20 +567,20 @@ Set attributes = new HashSet<>(); Matcher matcher = ProgramIndicator.ATTRIBUTE_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String at = matcher.group( 1 ); - + TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( at ); - + if ( attribute != null ) { attributes.add( attribute ); } } - - return attributes; + + return attributes; } @Override @@ -590,33 +590,33 @@ Set constants = new HashSet<>(); Matcher matcher = ExpressionService.CONSTANT_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String co = matcher.group( 1 ); - + Constant constant = constantService.getConstant( co ); - + if ( constant != null ) { constants.add( constant ); } } - - return constants; + + return constants; } - + // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- /** - * Get indicator value for the given arguments. If programStageInstance - * argument is null, the program stage instance will be retrieved based on + * Get indicator value for the given arguments. If programStageInstance + * argument is null, the program stage instance will be retrieved based on * the given program instance in combination with the program stage from the indicator expression. - * - * @param indicator the indicator, must be not null. - * @param programInstance the program instance, can be null. + * + * @param indicator the indicator, must be not null. + * @param programInstance the program instance, can be null. * @param programStageInstance the program stage instance, can be null. */ private Double getValue( ProgramIndicator indicator, ProgramInstance programInstance, ProgramStageInstance programStageInstance ) @@ -624,12 +624,12 @@ StringBuffer buffer = new StringBuffer(); String expression = indicator.getExpression(); - + Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression ); int valueCount = 0; int zeroPosValueCount = 0; - + while ( matcher.find() ) { String key = matcher.group( 1 ); @@ -662,9 +662,9 @@ } matcher.appendReplacement( buffer, value ); - + valueCount++; - zeroPosValueCount = isZeroOrPositive( value ) ? ( zeroPosValueCount + 1 ) : zeroPosValueCount; + zeroPosValueCount = isZeroOrPositive( value ) ? (zeroPosValueCount + 1) : zeroPosValueCount; } else { @@ -674,7 +674,7 @@ else if ( ProgramIndicator.KEY_ATTRIBUTE.equals( key ) ) { TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( uid ); - + if ( attribute != null ) { TrackedEntityAttributeValue attributeValue = attributeValueService.getTrackedEntityAttributeValue( @@ -683,16 +683,16 @@ if ( attributeValue != null ) { String value = attributeValue.getValue(); - - if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_DATE ) ) + + if ( ValueType.DATE == attribute.getValueType() ) { value = DateUtils.daysBetween( new Date(), DateUtils.getDefaultDate( value ) ) + " "; } - + matcher.appendReplacement( buffer, value ); - + valueCount++; - zeroPosValueCount = isZeroOrPositive( value ) ? ( zeroPosValueCount + 1 ) : zeroPosValueCount; + zeroPosValueCount = isZeroOrPositive( value ) ? (zeroPosValueCount + 1) : zeroPosValueCount; } else { @@ -707,7 +707,7 @@ else if ( ProgramIndicator.KEY_CONSTANT.equals( key ) ) { Constant constant = constantService.getConstant( uid ); - + if ( constant != null ) { matcher.appendReplacement( buffer, String.valueOf( constant.getValue() ) ); @@ -721,7 +721,7 @@ { Date currentDate = new Date(); Date date = null; - + if ( ProgramIndicator.VAR_ENROLLMENT_DATE.equals( uid ) ) { date = programInstance.getEnrollmentDate(); @@ -738,7 +738,7 @@ { date = currentDate; } - + if ( date != null ) { matcher.appendReplacement( buffer, DateUtils.daysBetween( currentDate, date ) + "" ); @@ -754,11 +754,11 @@ buffer = new StringBuffer(); matcher = ProgramIndicator.VALUECOUNT_PATTERN.matcher( expression ); - + while ( matcher.find() ) { String var = matcher.group( 1 ); - + if ( ProgramIndicator.VAR_VALUE_COUNT.equals( var ) ) { matcher.appendReplacement( buffer, String.valueOf( valueCount ) ); @@ -766,20 +766,20 @@ else if ( ProgramIndicator.VAR_ZERO_POS_VALUE_COUNT.equals( var ) ) { matcher.appendReplacement( buffer, String.valueOf( zeroPosValueCount ) ); - } + } } - + expression = TextUtils.appendTail( matcher, buffer ); - + return MathUtils.calculateExpression( expression ); } - + /** - * Creates a SQL select clause from the given program indicator variable - * based on the given expression. Wraps the count variables with + * Creates a SQL select clause from the given program indicator variable + * based on the given expression. Wraps the count variables with * nullif to avoid potential division by zero. - * - * @param var the program indicator variable. + * + * @param var the program indicator variable. * @param expression the program indicator expression. * @return a SQL select clause. */ @@ -800,26 +800,26 @@ else if ( ProgramIndicator.VAR_VALUE_COUNT.equals( var ) ) { String sql = "nullif(("; - + for ( String uid : ProgramIndicator.getDataElementAndAttributeIdentifiers( expression ) ) { sql += "case when " + statementBuilder.columnQuote( uid ) + " is not null then 1 else 0 end + "; } - + return TextUtils.removeLast( sql, "+" ) + "),0)"; } else if ( ProgramIndicator.VAR_ZERO_POS_VALUE_COUNT.equals( var ) ) { String sql = "nullif(("; - + for ( String uid : ProgramIndicator.getDataElementAndAttributeIdentifiers( expression ) ) { sql += "case when " + statementBuilder.columnQuote( uid ) + " > 0 then 1 else 0 end + "; } - + return TextUtils.removeLast( sql, "+" ) + "),0)"; } - + return null; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-08-06 20:09:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-09-03 08:15:09 +0000 @@ -896,7 +896,7 @@ { I18nFormat format = i18nManager.getI18nFormat(); - Set phoneNumbers = reminderService.getPhonenumbers( reminder, entityInstance ); + Set phoneNumbers = reminderService.getPhoneNumbers( reminder, entityInstance ); OutboundSms outboundSms = null; if ( phoneNumbers.size() > 0 ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2015-07-02 07:05:55 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2015-09-03 08:15:09 +0000 @@ -28,16 +28,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.i18n.I18nUtils.i18n; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; - +import com.google.common.collect.Sets; import org.apache.commons.lang3.StringUtils; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.i18n.I18nService; @@ -57,7 +50,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; + +import static org.hisp.dhis.i18n.I18nUtils.i18n; /** * @author Abyot Asalefew @@ -113,7 +113,7 @@ @Autowired private TrackedEntityAttributeValueService attributeValueService; - + // ------------------------------------------------------------------------- // Implementation methods // ------------------------------------------------------------------------- @@ -177,7 +177,7 @@ } @Override - public List getPrograms( ProgramType type) + public List getPrograms( ProgramType type ) { return i18n( i18nService, programStore.getByType( type ) ); } @@ -201,7 +201,7 @@ } @Override - public List getProgramsByCurrentUser( ProgramType type) + public List getProgramsByCurrentUser( ProgramType type ) { return i18n( i18nService, getByCurrentUser( type ) ); } @@ -283,7 +283,7 @@ } @Override - public List getByCurrentUser( ProgramType type) + public List getByCurrentUser( ProgramType type ) { List programs = new ArrayList<>(); @@ -307,7 +307,7 @@ return programs; } - + @Override public String prepareDataEntryFormForAdd( String htmlCode, Program program, Collection healthWorkers, @@ -466,22 +466,23 @@ + "\" tabindex=\"" + index + "\" style=\"" + style + "\""; inputHtml += "\" class=\"" + hidden + " {validate:{required:" + mandatory; - if ( TrackedEntityAttribute.TYPE_NUMBER.equals( attribute.getValueType() ) ) + + if ( ValueType.NUMBER == attribute.getValueType() ) { inputHtml += ",number:true"; } - else if ( TrackedEntityAttribute.TYPE_PHONE_NUMBER.equals( attribute.getValueType() ) ) + else if ( ValueType.PHONE_NUMBER == attribute.getValueType() ) { inputHtml += ",phone:true"; } + inputHtml += "}}\" "; - - if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_PHONE_NUMBER ) ) - { + if ( ValueType.PHONE_NUMBER == attribute.getValueType() ) + { inputHtml += " phoneNumber value=\"" + value + "\"" + TAG_CLOSE; } - else if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_TRUE_ONLY ) ) + else if ( ValueType.TRUE_ONLY == attribute.getValueType() ) { inputHtml += " type='checkbox' value='true' "; if ( value.equals( "true" ) ) @@ -489,7 +490,7 @@ inputHtml += " checked "; } } - else if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_BOOL ) ) + else if ( ValueType.BOOLEAN == attribute.getValueType() ) { inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">"; @@ -514,7 +515,7 @@ inputHtml += ""; } - else if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_OPTION_SET ) ) + else if ( ValueType.OPTION_SET == attribute.getValueType() ) { inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">"; inputHtml += ""; @@ -530,18 +531,20 @@ } inputHtml += ""; } - else if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_DATE ) ) + else if ( ValueType.DATE == attribute.getValueType() ) { String jQueryCalendar = ""; - - inputHtml += " value=\"" + value + "\"" + TAG_CLOSE; + + inputHtml += " value=\"" + value + "\"" + TAG_CLOSE; inputHtml += jQueryCalendar; } else === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-08-06 20:09:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-09-03 08:15:09 +0000 @@ -489,7 +489,7 @@ private OutboundSms sendEventMessage( TrackedEntityInstanceReminder reminder, ProgramStageInstance programStageInstance, TrackedEntityInstance entityInstance, I18nFormat format ) { - Set phoneNumbers = reminderService.getPhonenumbers( reminder, entityInstance ); + Set phoneNumbers = reminderService.getPhoneNumbers( reminder, entityInstance ); OutboundSms outboundSms = null; if ( phoneNumbers.size() > 0 ) === 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-02 16:15:15 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2015-09-03 08:15:09 +0000 @@ -28,13 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.amplecode.quick.BatchHandler; import org.amplecode.quick.BatchHandlerFactory; import org.amplecode.quick.StatementHolder; @@ -49,6 +42,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @author Lars Helge Overland */ @@ -728,7 +728,7 @@ executeSql( "UPDATE program SET version=0 WHERE version IS NULL" ); executeSql( "update program set categorycomboid = " + defaultCategoryComboId + " where categorycomboid is null" ); executeSql( "update programstageinstance set attributeOptionCombo = " + defaultOptionComboId + " where attributeOptionCombo is null" ); - + executeSql( "ALTER TABLE datavalue ALTER COLUMN lastupdated TYPE timestamp" ); executeSql( "ALTER TABLE completedatasetregistration ALTER COLUMN date TYPE timestamp" ); @@ -856,7 +856,7 @@ executeSql( "drop table aggregatedorgunitdatavalue_temp" ); executeSql( "drop table aggregatedorgunitindicatorvalue" ); executeSql( "drop table aggregatedorgunitindicatorvalue_temp" ); - + oauth2(); upgradeDataValuesWithAttributeOptionCombo(); @@ -894,6 +894,18 @@ 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( "update trackedentityattribute set valuetype='TEXT' where valuetype='string'" ); + executeSql( "update trackedentityattribute set valuetype='PHONE_NUMBER' where valuetype='phoneNumber'" ); + executeSql( "update trackedentityattribute set valuetype='EMAIL' where valuetype='email'" ); + executeSql( "update trackedentityattribute set valuetype='NUMBER' where valuetype='number'" ); + executeSql( "update trackedentityattribute set valuetype='LETTER' where valuetype='letter'" ); + executeSql( "update trackedentityattribute set valuetype='BOOLEAN' where valuetype='bool'" ); + executeSql( "update trackedentityattribute set valuetype='TRUE_ONLY' where valuetype='trueOnly'" ); + executeSql( "update trackedentityattribute set valuetype='DATE' where valuetype='date'" ); + executeSql( "update trackedentityattribute set valuetype='OPTION_SET' where valuetype='optionSet'" ); + executeSql( "update trackedentityattribute set valuetype='TRACKER_ASSOCIATE' where valuetype='trackerAssociate'" ); + executeSql( "update trackedentityattribute set valuetype='USERNAME' where valuetype='users'" ); } public void oauth2() === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java 2015-09-03 08:15:09 +0000 @@ -28,18 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder.ATTRIBUTE; -import static org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder.ATTRIBUTE_PATTERN; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; - import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramStageInstance; @@ -48,6 +38,17 @@ import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserService; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; + +import static org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder.ATTRIBUTE; +import static org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder.ATTRIBUTE_PATTERN; + /** * @author Chau Thu Tran */ @@ -188,7 +189,7 @@ return templateMessage; } - + @Override public List getAttributeUids( String message ) { @@ -209,66 +210,69 @@ } @Override - public Set getPhonenumbers( TrackedEntityInstanceReminder reminder, TrackedEntityInstance entityInstance ) + public Set getPhoneNumbers( TrackedEntityInstanceReminder reminder, TrackedEntityInstance entityInstance ) { Set phoneNumbers = new HashSet<>(); switch ( reminder.getSendTo() ) { - case TrackedEntityInstanceReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED: - Collection users = entityInstance.getOrganisationUnit().getUsers(); - for ( User user : users ) - { - if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) - { - phoneNumbers.add( user.getPhoneNumber() ); - } - } - break; - case TrackedEntityInstanceReminder.SEND_TO_ATTRIBUTE_TYPE_USERS: - if ( entityInstance.getAttributeValues() != null ) - { - for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) - { - if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_USERS ) ) - { - User user = userService.getUser( Integer.parseInt( attributeValue.getValue() ) ); - if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) - { - phoneNumbers.add( user.getPhoneNumber() ); - } - } - } - } - break; - case TrackedEntityInstanceReminder.SEND_TO_ORGUGNIT_REGISTERED: - if ( entityInstance.getOrganisationUnit().getPhoneNumber() != null - && !entityInstance.getOrganisationUnit().getPhoneNumber().isEmpty() ) - { - phoneNumbers.add( entityInstance.getOrganisationUnit().getPhoneNumber() ); - } - break; - case TrackedEntityInstanceReminder.SEND_TO_USER_GROUP: - for ( User user : reminder.getUserGroup().getMembers() ) - { - if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) - { - phoneNumbers.add( user.getPhoneNumber() ); - } - } - break; - default: - if ( entityInstance.getAttributeValues() != null ) - { - for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) - { - if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_PHONE_NUMBER ) ) - { - phoneNumbers.add( attributeValue.getValue() ); - } - } - } - break; + case TrackedEntityInstanceReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED: + Collection users = entityInstance.getOrganisationUnit().getUsers(); + + for ( User user : users ) + { + if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) + { + phoneNumbers.add( user.getPhoneNumber() ); + } + } + break; + case TrackedEntityInstanceReminder.SEND_TO_ATTRIBUTE_TYPE_USERS: + if ( entityInstance.getAttributeValues() != null ) + { + for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) + { + if ( ValueType.USERNAME == attributeValue.getAttribute().getValueType() ) + { + User user = userService.getUser( Integer.parseInt( attributeValue.getValue() ) ); + + if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) + { + phoneNumbers.add( user.getPhoneNumber() ); + } + } + } + } + break; + case TrackedEntityInstanceReminder.SEND_TO_ORGUGNIT_REGISTERED: + if ( entityInstance.getOrganisationUnit().getPhoneNumber() != null + && !entityInstance.getOrganisationUnit().getPhoneNumber().isEmpty() ) + { + phoneNumbers.add( entityInstance.getOrganisationUnit().getPhoneNumber() ); + } + break; + case TrackedEntityInstanceReminder.SEND_TO_USER_GROUP: + for ( User user : reminder.getUserGroup().getMembers() ) + { + if ( user.getPhoneNumber() != null && !user.getPhoneNumber().isEmpty() ) + { + phoneNumbers.add( user.getPhoneNumber() ); + } + } + break; + default: + if ( entityInstance.getAttributeValues() != null ) + { + for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) + { + if ( ValueType.PHONE_NUMBER == attributeValue.getAttribute().getValueType() ) + { + phoneNumbers.add( attributeValue.getValue() ); + } + } + } + break; } + return phoneNumbers; } @@ -279,29 +283,29 @@ switch ( reminder.getSendTo() ) { - case TrackedEntityInstanceReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED: - users.addAll( entityInstance.getOrganisationUnit().getUsers() ); - break; - case TrackedEntityInstanceReminder.SEND_TO_ATTRIBUTE_TYPE_USERS: - if ( entityInstance.getAttributeValues() != null ) - { - for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) + case TrackedEntityInstanceReminder.SEND_TO_ALL_USERS_IN_ORGUGNIT_REGISTERED: + users.addAll( entityInstance.getOrganisationUnit().getUsers() ); + break; + case TrackedEntityInstanceReminder.SEND_TO_ATTRIBUTE_TYPE_USERS: + if ( entityInstance.getAttributeValues() != null ) { - if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_USERS ) ) + for ( TrackedEntityAttributeValue attributeValue : entityInstance.getAttributeValues() ) { - users.add( userService.getUser( Integer.parseInt( attributeValue.getValue() ) ) ); + if ( ValueType.USERNAME == attributeValue.getAttribute().getValueType() ) + { + users.add( userService.getUser( Integer.parseInt( attributeValue.getValue() ) ) ); + } } } - } - break; - case TrackedEntityInstanceReminder.SEND_TO_USER_GROUP: - if ( reminder.getUserGroup().getMembers().size() > 0 ) - { - users.addAll( reminder.getUserGroup().getMembers() ); - } - break; - default: - break; + break; + case TrackedEntityInstanceReminder.SEND_TO_USER_GROUP: + if ( reminder.getUserGroup().getMembers().size() > 0 ) + { + users.addAll( reminder.getUserGroup().getMembers() ); + } + break; + default: + break; } return users; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-08-25 21:48:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-09-03 08:15:09 +0000 @@ -39,6 +39,7 @@ import org.hisp.dhis.common.QueryFilter; import org.hisp.dhis.common.QueryItem; import org.hisp.dhis.common.QueryOperator; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.event.EventStatus; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -750,9 +751,9 @@ if ( attributeValue.getAttribute().getUid().equals( criteria.getProperty() ) ) { String value = attributeValue.getValue(); - String type = attributeValue.getAttribute().getValueType(); + ValueType valueType = attributeValue.getAttribute().getValueType(); - if ( type.equals( TrackedEntityAttribute.TYPE_NUMBER ) ) + if ( valueType.isNumeric() ) { int value1 = Integer.parseInt( value ); int value2 = Integer.parseInt( criteria.getValue() ); @@ -764,7 +765,7 @@ return criteria; } } - else if ( type.equals( TrackedEntityAttribute.TYPE_DATE ) ) + else if ( valueType.isDate() ) { Date value1 = format.parseDate( value ); Date value2 = format.parseDate( criteria.getValue() ); @@ -777,14 +778,12 @@ } else { - if ( criteria.getOperator() == ValidationCriteria.OPERATOR_EQUAL_TO - && !value.equals( criteria.getValue() ) ) + if ( criteria.getOperator() == ValidationCriteria.OPERATOR_EQUAL_TO && !value.equals( criteria.getValue() ) ) { return criteria; } } - } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java 2015-06-23 15:59:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityService.java 2015-09-03 08:15:09 +0000 @@ -120,5 +120,4 @@ { return trackedEntityStore.getAllOrderedName( min, max ); } - } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-09-02 05:15:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-09-03 08:15:09 +0000 @@ -19,7 +19,13 @@ - + + + org.hisp.dhis.common.ValueType + true + 12 + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-09-03 08:15:09 +0000 @@ -28,22 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.program.ProgramIndicator.KEY_ATTRIBUTE; -import static org.hisp.dhis.program.ProgramIndicator.KEY_CONSTANT; -import static org.hisp.dhis.program.ProgramIndicator.KEY_DATAELEMENT; -import static org.hisp.dhis.program.ProgramIndicator.KEY_PROGRAM_VARIABLE; -import static org.hisp.dhis.program.ProgramIndicator.VALUE_TYPE_DATE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.Date; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.constant.Constant; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; @@ -63,6 +49,14 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.Date; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.hisp.dhis.program.ProgramIndicator.*; +import static org.junit.Assert.*; + /** * @author Chau Thu Tran */ @@ -70,7 +64,7 @@ extends DhisSpringTest { private static final String COL_QUOTE = "\""; - + @Autowired private ProgramIndicatorService programIndicatorService; @@ -154,7 +148,7 @@ private ProgramIndicator indicatorI; - private ProgramIndicator indicatorJ; + private ProgramIndicator indicatorJ; @Override public void setUpTest() @@ -228,17 +222,17 @@ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate, incidenDate, organisationUnit ); - + // TODO enroll twice? // --------------------------------------------------------------------- // TrackedEntityAttribute // --------------------------------------------------------------------- - atA = createTrackedEntityAttribute( 'A', TrackedEntityAttribute.TYPE_NUMBER ); - atB = createTrackedEntityAttribute( 'B', TrackedEntityAttribute.TYPE_NUMBER ); - atC = createTrackedEntityAttribute( 'C', TrackedEntityAttribute.TYPE_DATE ); - atD = createTrackedEntityAttribute( 'D', TrackedEntityAttribute.TYPE_DATE ); + atA = createTrackedEntityAttribute( 'A', ValueType.NUMBER ); + atB = createTrackedEntityAttribute( 'B', ValueType.NUMBER ); + atC = createTrackedEntityAttribute( 'C', ValueType.DATE ); + atD = createTrackedEntityAttribute( 'D', ValueType.DATE ); attributeService.addTrackedEntityAttribute( atA ); attributeService.addTrackedEntityAttribute( atB ); @@ -247,10 +241,8 @@ TrackedEntityAttributeValue attributeValueA = new TrackedEntityAttributeValue( atA, entityInstance, "1" ); TrackedEntityAttributeValue attributeValueB = new TrackedEntityAttributeValue( atB, entityInstance, "2" ); - TrackedEntityAttributeValue attributeValueC = new TrackedEntityAttributeValue( atC, entityInstance, - "2015-01-01" ); - TrackedEntityAttributeValue attributeValueD = new TrackedEntityAttributeValue( atD, entityInstance, - "2015-01-03" ); + TrackedEntityAttributeValue attributeValueC = new TrackedEntityAttributeValue( atC, entityInstance, "2015-01-01" ); + TrackedEntityAttributeValue attributeValueD = new TrackedEntityAttributeValue( atD, entityInstance, "2015-01-03" ); attributeValueService.addTrackedEntityAttributeValue( attributeValueA ); attributeValueService.addTrackedEntityAttributeValue( attributeValueB ); @@ -504,7 +496,7 @@ public void testGetAnalyticsSQl() { String expected = COL_QUOTE + deA.getUid() + COL_QUOTE + " + " + COL_QUOTE + atA.getUid() + COL_QUOTE + " > 10"; - + assertEquals( expected, programIndicatorService.getAnalyticsSQl( indicatorE.getFilter() ) ); } @@ -515,7 +507,7 @@ String expected = "case when " + col + " < 0 then 0 else " + col + " end"; String expression = "d2:zing(" + col + ")"; - assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); + assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); } @Test @@ -525,7 +517,7 @@ String expected = "case when " + col + " >= 0 then 1 else 0 end"; String expression = "d2:oizp(" + col + ")"; - assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); + assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); } @Test @@ -536,7 +528,7 @@ String expected = "(cast(" + col2 + " as date) - cast(" + col1 + " as date))"; String expression = "d2:daysBetween(" + col1 + "," + col2 + ")"; - assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); + assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); } @Test @@ -546,7 +538,7 @@ String expected = "case when (" + col1 + " > 3) then 10 else 5 end"; String expression = "d2:condition('" + col1 + " > 3',10,5)"; - assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); + assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); } @Test( expected = IllegalStateException.class ) @@ -556,9 +548,9 @@ String expected = "case when " + col + " >= 0 then 1 else " + col + " end"; String expression = "d2:xyza(" + col + ")"; - assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); + assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) ); } - + @Test public void testExpressionIsValid() { @@ -578,10 +570,10 @@ String filterB = KEY_ATTRIBUTE + "{" + atA.getUid() + "} == " + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} - 5"; String filterC = KEY_ATTRIBUTE + "{invaliduid} == 100"; String filterD = KEY_ATTRIBUTE + "{" + atA.getUid() + "} + 200"; - + assertEquals( ProgramIndicator.VALID, programIndicatorService.filterIsValid( filterA ) ); assertEquals( ProgramIndicator.VALID, programIndicatorService.filterIsValid( filterB ) ); assertEquals( ProgramIndicator.INVALID_IDENTIFIERS_IN_EXPRESSION, programIndicatorService.filterIsValid( filterC ) ); - assertEquals( ProgramIndicator.FILTER_NOT_EVALUATING_TO_TRUE_OR_FALSE, programIndicatorService.filterIsValid( filterD ) ); + assertEquals( ProgramIndicator.FILTER_NOT_EVALUATING_TO_TRUE_OR_FALSE, programIndicatorService.filterIsValid( filterD ) ); } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramStageInstanceServiceTest.java 2015-09-03 08:15:09 +0000 @@ -40,6 +40,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.DataElementService; import org.hisp.dhis.event.EventStatus; @@ -167,7 +168,7 @@ entityInstanceService.addTrackedEntityInstance( entityInstanceB ); TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'A' ); - attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER ); + attribute.setValueType( ValueType.PHONE_NUMBER ); attributeService.addTrackedEntityAttribute( attribute ); TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstanceA, attribute ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java 2015-06-23 15:59:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeServiceTest.java 2015-09-03 08:15:09 +0000 @@ -28,16 +28,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ValueType; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * @author Chau Thu Tran */ @@ -63,7 +64,7 @@ { attributeA = createTrackedEntityAttribute( 'A' ); attributeB = createTrackedEntityAttribute( 'B' ); - attributeC = createTrackedEntityAttribute( 'C', TrackedEntityAttribute.TYPE_NUMBER ); + attributeC = createTrackedEntityAttribute( 'C', ValueType.NUMBER ); List attributesA = new ArrayList<>(); attributesA.add( attributeA ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2015-06-23 15:59:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeStoreTest.java 2015-09-03 08:15:09 +0000 @@ -28,18 +28,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ValueType; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + /** * @author Chau Thu Tran */ @@ -65,7 +63,7 @@ { attributeA = createTrackedEntityAttribute( 'A' ); attributeB = createTrackedEntityAttribute( 'B' ); - attributeC = createTrackedEntityAttribute( 'C', TrackedEntityAttribute.TYPE_NUMBER ); + attributeC = createTrackedEntityAttribute( 'C', ValueType.NUMBER ); List attributesA = new ArrayList<>(); attributesA.add( attributeA ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2015-09-03 08:15:09 +0000 @@ -28,14 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.mock.MockI18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; @@ -54,6 +48,13 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + /** * @author Chau Thu Tran */ @@ -192,10 +193,10 @@ } @Test - public void testGetPhonenumbers() + public void testGetPhoneNumbers() { TrackedEntityAttribute attribute = createTrackedEntityAttribute( 'A' ); - attribute.setValueType( TrackedEntityAttribute.TYPE_PHONE_NUMBER ); + attribute.setValueType( ValueType.PHONE_NUMBER ); attributeService.addTrackedEntityAttribute( attribute ); TrackedEntityAttributeValue attributeValue = createTrackedEntityAttributeValue( 'A', entityInstance, attribute ); @@ -205,7 +206,7 @@ entityInstance.getAttributeValues().add( attributeValue ); entityInstanceService.updateTrackedEntityInstance( entityInstance ); - Set phoneNumbers = reminderService.getPhonenumbers( reminderA, entityInstance ); + Set phoneNumbers = reminderService.getPhoneNumbers( reminderA, entityInstance ); assertEquals( 1, phoneNumbers.size() ); assertTrue( phoneNumbers.contains( "123456789" ) ); } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-08-06 20:09:10 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-09-03 08:15:09 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.common.QueryItem; import org.hisp.dhis.common.QueryOperator; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.collection.CachingMap; import org.hisp.dhis.dbms.DbmsManager; import org.hisp.dhis.dxf2.events.event.Note; @@ -619,34 +620,30 @@ importConflicts.add( new ImportConflict( "Attribute.value", "Value length is greater than 256 chars." ) ); } - if ( TrackedEntityAttribute.TYPE_NUMBER.equals( teAttribute.getValueType() ) - && !MathUtils.isNumeric( attribute.getValue() ) ) + if ( ValueType.NUMBER == teAttribute.getValueType() && !MathUtils.isNumeric( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not numeric." ) ); } - else if ( TrackedEntityAttribute.TYPE_BOOL.equals( teAttribute.getValueType() ) - && !MathUtils.isBool( attribute.getValue() ) ) + else if ( ValueType.BOOLEAN == teAttribute.getValueType() && !MathUtils.isBool( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not boolean." ) ); } - else if ( TrackedEntityAttribute.TYPE_DATE.equals( teAttribute.getValueType() ) - && !DateUtils.dateIsValid( attribute.getValue() ) ) + else if ( ValueType.DATE == teAttribute.getValueType() && !DateUtils.dateIsValid( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not date." ) ); } - else if ( TrackedEntityAttribute.TYPE_TRUE_ONLY.equals( teAttribute.getValueType() ) - && "true".equals( attribute.getValue() ) ) + else if ( ValueType.TRUE_ONLY == teAttribute.getValueType() && "true".equals( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not true (true-only value type)." ) ); } - else if ( TrackedEntityAttribute.TYPE_USERS.equals( teAttribute.getValueType() ) ) + else if ( ValueType.USERNAME == teAttribute.getValueType() ) { if ( userService.getUserCredentialsByUsername( attribute.getValue() ) == null ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid username." ) ); } } - else if ( TrackedEntityAttribute.TYPE_OPTION_SET.equals( teAttribute.getValueType() ) + else if ( ValueType.OPTION_SET == teAttribute.getValueType() && !teAttribute.getOptionSet().getOptionCodes().contains( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid option code." ) ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-07-15 09:45:45 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-09-03 08:15:09 +0000 @@ -28,18 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdList; -import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString; -import static org.hisp.dhis.system.util.DateUtils.getMediumDateString; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.util.SqlHelper; import org.hisp.dhis.dxf2.common.IdSchemes; import org.hisp.dhis.dxf2.events.report.EventRow; @@ -53,8 +46,15 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.rowset.SqlRowSet; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdList; +import static org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString; +import static org.hisp.dhis.system.util.DateUtils.getMediumDateString; /** * @author Morten Olav Hansen @@ -106,8 +106,8 @@ event.setProgram( IdSchemes.getValue( rowSet.getString( "p_uid" ), rowSet.getString( "p_code" ), idSchemes.getProgramIdScheme() ) ); event.setProgramStage( IdSchemes.getValue( rowSet.getString( "ps_uid" ), rowSet.getString( "ps_code" ), idSchemes.getProgramStageIdScheme() ) ); event.setOrgUnit( IdSchemes.getValue( rowSet.getString( "ou_uid" ), rowSet.getString( "ou_code" ), idSchemes.getOrgUnitIdScheme() ) ); - ProgramType programTye = ProgramType.fromValue(rowSet.getString( "p_type" ) ); - + ProgramType programTye = ProgramType.fromValue( rowSet.getString( "p_type" ) ); + if ( programTye != ProgramType.WITHOUT_REGISTRATION ) { event.setEnrollment( rowSet.getString( "pi_uid" ) ); @@ -244,7 +244,7 @@ Attribute attribute = new Attribute(); attribute.setValue( rowSet.getString( "pav_value" ) ); attribute.setDisplayName( rowSet.getString( "ta_name" ) ); - attribute.setType( rowSet.getString( "ta_valuetype" ) ); + attribute.setValueType( ValueType.fromValue( rowSet.getString( "ta_valuetype" ) ) ); attribute.setAttribute( rowSet.getString( "ta_uid" ) ); eventRow.getAttributes().add( attribute ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-08-26 10:26:31 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-09-03 08:15:09 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.common.QueryItem; import org.hisp.dhis.common.QueryOperator; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.collection.CachingMap; import org.hisp.dhis.dbms.DbmsManager; import org.hisp.dhis.dxf2.importsummary.ImportConflict; @@ -146,7 +147,7 @@ trackedEntityInstance.setTrackedEntity( entityInstance.getTrackedEntity().getUid() ); trackedEntityInstance.setCreated( entityInstance.getCreated().toString() ); trackedEntityInstance.setLastUpdated( entityInstance.getLastUpdated().toString() ); - trackedEntityInstance.setInactive( entityInstance.isInactive()); + trackedEntityInstance.setInactive( entityInstance.isInactive() ); Collection relationships = relationshipService.getRelationshipsForTrackedEntityInstance( entityInstance ); @@ -181,7 +182,7 @@ attribute.setDisplayName( attributeValue.getAttribute().getDisplayName() ); attribute.setAttribute( attributeValue.getAttribute().getUid() ); - attribute.setType( attributeValue.getAttribute().getValueType() ); + attribute.setValueType( attributeValue.getAttribute().getValueType() ); attribute.setCode( attributeValue.getAttribute().getCode() ); attribute.setValue( attributeValue.getValue() ); @@ -328,12 +329,12 @@ importSummary.getImportCount().incrementIgnored(); return importSummary; - } - + } + entityInstance.setInactive( trackedEntityInstance.isInactive() ); - + removeRelationships( entityInstance ); - removeAttributeValues( entityInstance ); + removeAttributeValues( entityInstance ); teiService.updateTrackedEntityInstance( entityInstance ); updateRelationships( trackedEntityInstance, entityInstance ); @@ -570,30 +571,30 @@ importConflicts.add( new ImportConflict( "Attribute.value", "Value length is greater than 256 chars for attribute: " + attribute ) ); } - if ( TrackedEntityAttribute.TYPE_NUMBER.equals( teAttribute.getValueType() ) && !MathUtils.isNumeric( attribute.getValue() ) ) + if ( ValueType.NUMBER == teAttribute.getValueType() && !MathUtils.isNumeric( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not numeric for attribute: " + attribute ) ); } - else if ( TrackedEntityAttribute.TYPE_BOOL.equals( teAttribute.getValueType() ) && !MathUtils.isBool( attribute.getValue() ) ) + else if ( ValueType.BOOLEAN == teAttribute.getValueType() && !MathUtils.isBool( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not boolean for attribute: " + attribute ) ); } - else if ( TrackedEntityAttribute.TYPE_DATE.equals( teAttribute.getValueType() ) && !DateUtils.dateIsValid( attribute.getValue() ) ) + else if ( ValueType.DATE == teAttribute.getValueType() && !DateUtils.dateIsValid( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not date for attribute: " + attribute ) ); } - else if ( TrackedEntityAttribute.TYPE_TRUE_ONLY.equals( teAttribute.getValueType() ) && !"true".equals( attribute.getValue() ) ) + else if ( ValueType.TRUE_ONLY == teAttribute.getValueType() && !"true".equals( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not true (true-only value type) for attribute: " + attribute ) ); } - else if ( TrackedEntityAttribute.TYPE_USERS.equals( teAttribute.getValueType() ) ) + else if ( ValueType.USERNAME == teAttribute.getValueType() ) { if ( userService.getUserCredentialsByUsername( attribute.getValue() ) == null ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid username for attribute: " + attribute ) ); } } - else if ( TrackedEntityAttribute.TYPE_OPTION_SET.equals( teAttribute.getValueType() ) && !teAttribute.isValidOptionValue( attribute.getValue() ) ) + else if ( ValueType.OPTION_SET == teAttribute.getValueType() && !teAttribute.isValidOptionValue( attribute.getValue() ) ) { importConflicts.add( new ImportConflict( "Attribute.value", "Value is not pointing to a valid option for attribute: " + attribute ) ); } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 2015-09-03 08:15:09 +0000 @@ -32,6 +32,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import org.hisp.dhis.common.DxfNamespaces; +import org.hisp.dhis.common.ValueType; /** * @author Morten Olav Hansen @@ -43,7 +44,7 @@ private String attribute; - private String type; + private ValueType valueType; private String code; @@ -58,10 +59,10 @@ this.value = value; } - public Attribute( String attribute, String type, String value ) + public Attribute( String attribute, ValueType valueType, String value ) { this.attribute = attribute; - this.type = type; + this.valueType = valueType; this.value = value; } @@ -91,14 +92,14 @@ @JsonProperty @JacksonXmlProperty( isAttribute = true ) - public String getType() + public ValueType getValueType() { - return type; + return valueType; } - public void setType( String type ) + public void setValueType( ValueType valueType ) { - this.type = type; + this.valueType = valueType; } @JsonProperty @@ -139,7 +140,7 @@ return false; if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null ) return false; - if ( type != null ? !type.equals( attribute1.type ) : attribute1.type != null ) + if ( valueType != null ? !valueType.equals( attribute1.valueType ) : attribute1.valueType != null ) return false; if ( code != null ? !code.equals( attribute1.code ) : attribute1.code != null ) return false; @@ -154,7 +155,7 @@ { int result = displayName != null ? displayName.hashCode() : 0; result = 31 * result + (attribute != null ? attribute.hashCode() : 0); - result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (valueType != null ? valueType.hashCode() : 0); result = 31 * result + (code != null ? code.hashCode() : 0); result = 31 * result + (value != null ? value.hashCode() : 0); return result; @@ -164,6 +165,6 @@ public String toString() { return "Attribute{" + "displayName='" + displayName + '\'' + ", attribute='" + attribute + '\'' + ", type='" - + type + '\'' + ", code='" + code + '\'' + ", value='" + value + '\'' + '}'; + + valueType + '\'' + ", code='" + code + '\'' + ", value='" + value + '\'' + '}'; } } \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java' --- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2015-09-03 08:15:09 +0000 @@ -896,7 +896,8 @@ if ( isExist ) { TrackedEntityAttribute attribute = attributeService.getTrackedEntityAttribute( Integer.parseInt( attributeId ) ); - if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_NUMBER ) ) + + if ( ValueType.NUMBER == attribute.getValueType() ) { sql += " AND cast( _pav.value as " + statementBuilder.getDoubleColumnType() + " ) "; } === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-09-03 08:15:09 +0000 @@ -41,9 +41,6 @@ import org.hisp.dhis.api.mobile.model.LWUITmodel.Notification; import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient; import org.hisp.dhis.api.mobile.model.LWUITmodel.PatientList; -import org.hisp.dhis.api.mobile.model.LWUITmodel.Section; -import org.hisp.dhis.api.mobile.model.OptionSet; -import org.hisp.dhis.api.mobile.model.PatientAttribute; import org.hisp.dhis.api.mobile.model.Task; import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator; import org.hisp.dhis.api.mobile.model.comparator.TrackedEntityAttributeValueSortOrderComparator; @@ -55,6 +52,7 @@ import org.hisp.dhis.common.QueryFilter; import org.hisp.dhis.common.QueryItem; import org.hisp.dhis.common.QueryOperator; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.event.EventStatus; @@ -812,11 +810,13 @@ { if ( value != null ) { + /* org.hisp.dhis.api.mobile.model.PatientAttribute patientAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute( value.getAttribute().getName(), value.getValue(), value.getAttribute().getValueType(), false, value .getAttribute().getDisplayInListNoProgram(), new OptionSet() ); patientAtts.add( patientAttribute ); + */ } } @@ -1416,14 +1416,15 @@ { List list = new ArrayList<>(); + /* for ( TrackedEntityAttribute patientAtt : getPatientAtts( null ) ) { list.add( new PatientAttribute( patientAtt.getName(), null, patientAtt.getValueType(), false, patientAtt .getDisplayInListNoProgram(), new OptionSet() ) ); } + */ return list; - } @Override @@ -1431,6 +1432,7 @@ { List list = new ArrayList<>(); + /* for ( TrackedEntityAttribute pa : getPatientAtts( programId ) ) { PatientAttribute patientAttribute = new PatientAttribute(); @@ -1442,6 +1444,7 @@ list.add( patientAttribute ); } + */ return list; } @@ -1926,7 +1929,7 @@ for ( TrackedEntityAttributeValue attrValue : programStageInstance.getProgramInstance() .getEntityInstance().getAttributeValues() ) { - if ( attrValue.getAttribute().getValueType().equals( "phoneNumber" ) ) + if ( ValueType.PHONE_NUMBER == attrValue.getAttribute().getValueType() ) { User user = new User(); user.setPhoneNumber( attrValue.getValue() ); @@ -1934,8 +1937,7 @@ } } - smsSender.sendMessage( lostEvent.getName(), lostEvent.getSMS(), currentUserService.getCurrentUser(), - recipientsList, false ); + smsSender.sendMessage( lostEvent.getName(), lostEvent.getSMS(), currentUserService.getCurrentUser(), recipientsList, false ); } notification.setMessage( "Success" ); @@ -2440,7 +2442,7 @@ { I18nFormat format = i18nManager.getI18nFormat(); - Set phoneNumbers = reminderService.getPhonenumbers( reminder, entityInstance ); + Set phoneNumbers = reminderService.getPhoneNumbers( reminder, entityInstance ); OutboundSms outboundSms = null; if ( phoneNumbers.size() > 0 ) === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2015-09-03 03:11:47 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2015-09-03 08:15:09 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.api.mobile.model.OptionSet; import org.hisp.dhis.api.mobile.model.Program; import org.hisp.dhis.api.mobile.model.ProgramStage; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.ProgramStageDataElement; import org.hisp.dhis.program.ProgramStageSection; @@ -314,7 +315,7 @@ org.hisp.dhis.api.mobile.model.PatientAttribute mobileAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute(); mobileAttribute.setName( pa.getName() ); - mobileAttribute.setType( pa.getValueType() ); + // mobileAttribute.setType( pa.getValueType() ); mobileAttribute.setValue( "" ); if ( ppa.isDisplayInList() ) @@ -328,7 +329,7 @@ mobileAttribute.setMandatory( ppa.isMandatory() ); - if ( pa.getValueType().equals( TrackedEntityAttribute.TYPE_OPTION_SET ) ) + if ( ValueType.OPTION_SET == pa.getValueType() ) { OptionSet optionSet = new OptionSet(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java 2015-07-12 14:19:35 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/AggregatableTrackedEntityAttributeValueFilter.java 2015-09-03 08:15:09 +0000 @@ -28,24 +28,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Set; - +import com.google.common.collect.Sets; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.commons.filter.Filter; -import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; -import com.google.common.collect.Sets; +import java.util.Set; public class AggregatableTrackedEntityAttributeValueFilter implements Filter { public static final AggregatableTrackedEntityAttributeValueFilter INSTANCE = new AggregatableTrackedEntityAttributeValueFilter(); - - private static final Set TYPES = Sets.newHashSet( TrackedEntityAttribute.TYPE_NUMBER, DataElement.VALUE_TYPE_INT, - TrackedEntityAttribute.TYPE_BOOL, TrackedEntityAttribute.TYPE_OPTION_SET ); - + + private static final Set TYPES = Sets.newHashSet( + ValueType.INTEGER, ValueType.INTEGER_POSITIVE, ValueType.INTEGER_NEGATIVE, ValueType.INTEGER_ZERO_OR_POSITIVE, ValueType.NUMBER, + ValueType.UNIT_INTERVAL, ValueType.PERCENTAGE, ValueType.BOOLEAN, ValueType.OPTION_SET ); + //TODO Option set is not robust as it might contain any value type, needs to change with new Enum is in place - @Override public boolean retain( TrackedEntityAttribute object ) { === 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-03 04:42:52 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-09-03 08:15:09 +0000 @@ -1364,7 +1364,7 @@ attribute.setName( "Attribute" + uniqueChar ); attribute.setDescription( "Attribute" + uniqueChar ); - attribute.setValueType( TrackedEntityAttribute.TYPE_STRING ); + attribute.setValueType( ValueType.TEXT ); return attribute; } @@ -1373,14 +1373,14 @@ * @param uniqueChar A unique character to identify the object. * @return TrackedEntityAttribute */ - public static TrackedEntityAttribute createTrackedEntityAttribute( char uniqueChar, String type ) + public static TrackedEntityAttribute createTrackedEntityAttribute( char uniqueChar, ValueType valueType ) { TrackedEntityAttribute attribute = new TrackedEntityAttribute(); attribute.setAutoFields(); attribute.setName( "Attribute" + uniqueChar ); attribute.setDescription( "Attribute" + uniqueChar ); - attribute.setValueType( type ); + attribute.setValueType( valueType ); return attribute; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/reminder/SendSmsAction.java 2015-09-03 08:15:09 +0000 @@ -172,7 +172,7 @@ reminder.setTemplateMessage( msg ); reminder.setSendTo( sendTo ); - Set phoneNumbers = reminderService.getPhonenumbers( reminder, programStageInstance + Set phoneNumbers = reminderService.getPhoneNumbers( reminder, programStageInstance .getProgramInstance().getEntityInstance() ); try @@ -212,7 +212,7 @@ reminder.setTemplateMessage( msg ); reminder.setSendTo( sendTo ); - Set phoneNumbers = reminderService.getPhonenumbers( reminder, programInstance.getEntityInstance() ); + Set phoneNumbers = reminderService.getPhoneNumbers( reminder, programInstance.getEntityInstance() ); try { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2015-08-02 12:27:56 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2015-09-03 08:15:09 +0000 @@ -29,10 +29,10 @@ */ import com.opensymphony.xwork2.Action; - import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.analytics.AggregationType; import org.hisp.dhis.attribute.AttributeService; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.legend.LegendService; import org.hisp.dhis.option.OptionService; import org.hisp.dhis.period.PeriodService; @@ -121,9 +121,9 @@ { this.valueType = valueType; } - + private String aggregationType; - + public void setAggregationType( String aggregationType ) { this.aggregationType = aggregationType; @@ -206,18 +206,18 @@ trackedEntityAttribute.setShortName( StringUtils.trimToNull( shortName ) ); trackedEntityAttribute.setCode( StringUtils.trimToNull( code ) ); trackedEntityAttribute.setDescription( StringUtils.trimToNull( description ) ); - trackedEntityAttribute.setValueType( valueType ); + trackedEntityAttribute.setValueType( ValueType.fromValue( valueType ) ); trackedEntityAttribute.setAggregationType( AggregationType.fromValue( aggregationType ) ); trackedEntityAttribute.setExpression( expression ); trackedEntityAttribute.setDisplayOnVisitSchedule( false ); - unique = (unique == null) ? false : true; + unique = unique != null; trackedEntityAttribute.setUnique( unique ); - inherit = (inherit == null) ? false : true; + inherit = inherit != null; trackedEntityAttribute.setInherit( inherit ); - confidential = (confidential == null) ? false : true; + confidential = confidential != null; trackedEntityAttribute.setConfidential( confidential ); if ( unique ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2015-08-02 12:27:56 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2015-09-03 08:15:09 +0000 @@ -29,13 +29,12 @@ */ import com.opensymphony.xwork2.Action; - import org.apache.commons.lang3.StringUtils; import org.hisp.dhis.analytics.AggregationType; import org.hisp.dhis.attribute.AttributeService; +import org.hisp.dhis.common.ValueType; import org.hisp.dhis.legend.LegendService; import org.hisp.dhis.option.OptionService; -import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.system.util.AttributeUtils; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; @@ -75,9 +74,6 @@ private OptionService optionService; @Autowired - private PeriodService periodService; - - @Autowired private LegendService legendService; @Autowired @@ -130,7 +126,7 @@ } private String aggregationType; - + public void setAggregationType( String aggregationType ) { this.aggregationType = aggregationType; @@ -213,19 +209,19 @@ trackedEntityAttribute.setShortName( StringUtils.trimToNull( shortName ) ); trackedEntityAttribute.setCode( StringUtils.trimToNull( code ) ); trackedEntityAttribute.setDescription( StringUtils.trimToNull( description ) ); - trackedEntityAttribute.setValueType( valueType ); + trackedEntityAttribute.setValueType( ValueType.fromValue( valueType ) ); trackedEntityAttribute.setAggregationType( AggregationType.fromValue( aggregationType ) ); trackedEntityAttribute.setExpression( expression ); trackedEntityAttribute.setDisplayOnVisitSchedule( false ); trackedEntityAttribute.setOptionSet( null ); - unique = (unique != null); + unique = unique != null; trackedEntityAttribute.setUnique( unique ); - inherit = (inherit != null); + inherit = inherit != null; trackedEntityAttribute.setInherit( inherit ); - confidential = (confidential != null); + confidential = confidential != null; trackedEntityAttribute.setConfidential( confidential ); if ( unique ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2015-08-02 12:27:56 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2015-09-03 08:15:09 +0000 @@ -82,27 +82,27 @@ - + - - - - - + + + + + - + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm 2015-04-16 07:08:07 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addValidationCriteria.vm 2015-09-03 08:15:09 +0000 @@ -24,7 +24,7 @@ - - - - - - - - - - - - + - + - + - - - - - - - - - - + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm 2015-04-16 07:08:07 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateValidationCriteria.vm 2015-09-03 08:15:09 +0000 @@ -28,7 +28,7 @@ #set($attribute = '') #foreach($programAttribute in $program.programAttributes) - #if( $programAttribute.attribute.valueType!='trackerAssociate') + #if( $programAttribute.attribute.valueType!='TRACKER_ASSOCIATE') set($opt="") #foreach($option in $programAttribute.attribute.optionSet.options) #set($opt=$opt + ';' + $option.code + ':' + $option.name )