=== removed directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation' === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQueries.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQueries.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQueries.java 1970-01-01 00:00:00 +0000 @@ -1,36 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.HashSet; - -public class AggregationQueries - extends HashSet -{ -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQuery.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQuery.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/AggregationQuery.java 1970-01-01 00:00:00 +0000 @@ -1,139 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class AggregationQuery -{ - private String id; - - private String name; - - private String dataSet; - - private String dataElement; - - private String categoryOptionCombo; - - private String dataElementForGroupBy; - - private String operator; - - private String expression; - - @JsonProperty - public String getId() - { - return id; - } - - @JsonProperty - public void setId( String id ) - { - this.id = id; - } - - @JsonProperty - public String getName() - { - return name; - } - - public void setName( String name ) - { - this.name = name; - } - - @JsonProperty - public String getDataSet() - { - return dataSet; - } - - public void setDataSet( String dataSet ) - { - this.dataSet = dataSet; - } - - @JsonProperty - public String getDataElement() - { - return dataElement; - } - - public void setDataElement( String dataElement ) - { - this.dataElement = dataElement; - } - - @JsonProperty - public String getCategoryOptionCombo() - { - return categoryOptionCombo; - } - - public void setCategoryOptionCombo( String categoryOptionCombo ) - { - this.categoryOptionCombo = categoryOptionCombo; - } - - @JsonProperty - public String getDataElementForGroupBy() - { - return dataElementForGroupBy; - } - - public void setDataElementForGroupBy( String dataElementForGroupBy ) - { - this.dataElementForGroupBy = dataElementForGroupBy; - } - - @JsonProperty - public String getOperator() - { - return operator; - } - - public void setOperator( String operator ) - { - this.operator = operator; - } - - @JsonProperty - public String getExpression() - { - return expression; - } - - public void setExpression( String expression ) - { - this.expression = expression; - } -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregateSchedule.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregateSchedule.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregateSchedule.java 1970-01-01 00:00:00 +0000 @@ -1,82 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @author Chau Thu Tran - */ -public class CaseAggregateSchedule -{ - private Integer caseAggregateId; - - private String caseAggregateName; - - private String periodTypeName; - - public CaseAggregateSchedule() - { - } - - public CaseAggregateSchedule( Integer caseAggregateId, String caseAggregateName, String periodTypeName ) - { - this.caseAggregateId = caseAggregateId; - this.caseAggregateName = caseAggregateName; - this.periodTypeName = periodTypeName; - } - - public Integer getCaseAggregateId() - { - return caseAggregateId; - } - - public void setCaseAggregateId( Integer caseAggregateId ) - { - this.caseAggregateId = caseAggregateId; - } - - public String getCaseAggregateName() - { - return caseAggregateName; - } - - public void setCaseAggregateName( String caseAggregateName ) - { - this.caseAggregateName = caseAggregateName; - } - - public String getPeriodTypeName() - { - return periodTypeName; - } - - public void setPeriodTypeName( String periodTypeName ) - { - this.periodTypeName = periodTypeName; - } -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 1970-01-01 00:00:00 +0000 @@ -1,318 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.hisp.dhis.common.BaseNameableObject; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; - -/** - * @author Chau Thu Tran - * - * @version CaseAggregationCondition.java Nov 17, 2010 10:47:12 AM - */ -public class CaseAggregationCondition - extends BaseNameableObject -{ - public static final String SEPARATOR_ID = "\\."; - - public static final String SEPARATOR_OBJECT = ":"; - - public static final String AGGRERATION_COUNT = "COUNT"; - - public static final String AGGRERATION_SUM = "times"; - - public static final String AGGRERATION_SUM_VALUE = "sum"; - - public static final String AGGRERATION_AVG_VALUE = "avg"; - - public static final String AGGRERATION_AVG_MIN = "min"; - - public static final String AGGRERATION_AVG_MAX = "max"; - - public static final String OPERATOR_AND = "AND"; - - public static final String OPERATOR_OR = "OR"; - - public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE"; - - public static String OBJECT_TRACKED_ENTITY_ATTRIBUTE = "CA"; - - public static String OBJECT_PROGRAM_PROPERTY = "PP"; - - public static String OBJECT_PROGRAM = "PG"; - - public static String OBJECT_PROGRAM_STAGE = "PS"; - - public static String OBJECT_PROGRAM_STAGE_PROPERTY = "PSP"; - - public static String OBJECT_TRACKED_ENTITY_PROGRAM_STAGE_PROPERTY = "PC"; - - public static String OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE = "PSIC"; - - public static String FORMULA_AGE = "age"; - - public static String FORMULA_VISIT = "visit"; - - public static String OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE = "incidentDate"; - - public static String OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE = "enrollmentDate"; - - public static String OBJECT_PROGRAM_PROPERTY_REPORT_DATE = "executionDate"; - - public static String MINUS_OPERATOR = "DATEDIFF"; - - public static String MINUS_DATAELEMENT_OPERATOR_TYPE_ONE = "DEDATEDIFF_TYPE_ONE"; - - public static String MINUS_DATAELEMENT_OPERATOR_TYPE_TWO = "DEDATEDIFF_TYPE_TWO"; - - public static String MINUS_2DATAELEMENT_OPERATOR = "DE2DATEDIFF"; - - public static String MINUS_2ATTRIBUTE_OPERATOR = "ATTR2DATEDIFF"; - - public static String MINUS_ATTRIBUTE_OPERATOR_TYPE_ONE = "ATTRDATEDIFF_TYPE_ONE"; - - public static String MINUS_ATTRIBUTE_OPERATOR_TYPE_TWO = "ATTRDATEDIFF_TYPE_TWO"; - - public static String CURRENT_DATE = "current_date"; - - public static String AUTO_STORED_BY = "aggregated_from_tracker"; - - public static final String PARAM_PERIOD_START_DATE = "PERIOD_START_DATE"; - public static final String PARAM_PERIOD_END_DATE = "PARAM_PERIOD_END_DATE"; - public static final String PARAM_PERIOD_ID = "PERIOD_ID"; - public static final String PARAM_PERIOD_ISO_DATE = "PERIOD_ISO_DATE"; - - public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PROGRAM + "|" - + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE + "|" - + OBJECT_TRACKED_ENTITY_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" - + OBJECT_TRACKED_ENTITY_ATTRIBUTE + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT - + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]"; - - // Date dataElement - currentDate/incidentDate/executionDate/enrollmentDate - public static final String minusDataelementRegExp1 = MINUS_OPERATOR + "{1}\\s*\\(\\s*\\[" - + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+)+" + SEPARATOR_ID + "([0-9]+)+" + SEPARATOR_ID - + "([0-9]+)+\\]\\s*(,)\\s*" + "(" + CURRENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_REPORT_DATE - + ")\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}"; - - // currentDate/incidentDate/executionDate/enrollmentDate - Date dataElement - public static final String minusDataelementRegExp2 = MINUS_OPERATOR + "{1}\\s*\\(\\s*(" + CURRENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_REPORT_DATE + ")\\s*(,)\\s*\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT - + "([0-9]+)+" + SEPARATOR_ID + "([0-9]+)+" + SEPARATOR_ID - + "([0-9]+)+\\]\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}"; - - // Date dataElement - Date dataElement - public static final String minus2DataelementRegExp = MINUS_OPERATOR + "{1}\\s*\\(\\s*(\\[" - + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID - + "[0-9]+)+\\])\\s*(,)\\s*(\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" - + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID + "[0-9]+)+\\])\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+)"; - - // currentDate/ incidentDate/executionDate/enrollmentDate - Date attribute - public static final String minusAttributeRegExp1 = MINUS_OPERATOR + "{1}\\s*\\(\\s*(" + CURRENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_REPORT_DATE + ")\\s*(,)\\s*\\[" + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT - + "([0-9]+)+\\]\\s*\\)\\s(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}"; - - // Date attribute - currentDate/ incidentDate/executionDate/enrollmentDate - public static final String minusAttributeRegExp2 = MINUS_OPERATOR + "{1}\\s*\\(\\s*\\[" - + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT + "([0-9]+)+\\]\\s*(,)\\s*(" + CURRENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + "|" - + OBJECT_PROGRAM_PROPERTY_REPORT_DATE + ")\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+){1}"; - - // Date attribute - Date attribute - public static final String minus2AttributeRegExp = MINUS_OPERATOR + "{1}\\s*\\(\\s*(\\[" - + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT + "([0-9]+)+\\])\\s*(,)\\s*(\\[" - + OBJECT_TRACKED_ENTITY_ATTRIBUTE + SEPARATOR_OBJECT + "([0-9]+)+\\])\\s*\\)\\s*(>=|<=|!=|>|<|=){1}\\s*([0-9]+)"; - - // ------------------------------------------------------------------------- - // Fields - // ------------------------------------------------------------------------- - - private String operator; - - private String aggregationExpression; - - private DataElement aggregationDataElement; - - private DataElementCategoryOptionCombo optionCombo; - - private DataElement deSum; - - // ------------------------------------------------------------------------- - // Constructors - // ------------------------------------------------------------------------- - - public CaseAggregationCondition() - { - - } - - public CaseAggregationCondition( String name, String operator, String aggregationExpression, - DataElement aggregationDataElement, DataElementCategoryOptionCombo optionCombo ) - { - this.name = name; - this.operator = operator; - this.aggregationExpression = aggregationExpression; - this.aggregationDataElement = aggregationDataElement; - this.optionCombo = optionCombo; - } - - public CaseAggregationCondition( String name, String operator, String aggregationExpression, - DataElement aggregationDataElement, DataElementCategoryOptionCombo optionCombo, DataElement deSum ) - { - this.name = name; - this.operator = operator; - this.aggregationExpression = aggregationExpression; - this.aggregationDataElement = aggregationDataElement; - this.optionCombo = optionCombo; - this.deSum = deSum; - } - - // ------------------------------------------------------------------------- - // Logical - // ------------------------------------------------------------------------- - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((aggregationExpression == null) ? 0 : aggregationExpression.hashCode()); - result = prime * result + ((operator == null) ? 0 : operator.hashCode()); - return result; - } - - @Override - public boolean equals( Object object ) - { - if ( this == object ) - { - return true; - } - - if ( object == null ) - { - return false; - } - - if ( !getClass().isAssignableFrom( object.getClass() ) ) - { - return false; - } - - final CaseAggregationCondition other = (CaseAggregationCondition) object; - - if ( aggregationExpression == null ) - { - if ( other.aggregationExpression != null ) - { - return false; - } - } - else if ( !aggregationExpression.equals( other.aggregationExpression ) ) - { - return false; - } - - if ( operator == null ) - { - if ( other.operator != null ) - { - return false; - } - } - else if ( !operator.equals( other.operator ) ) - { - return false; - } - - return true; - } - - // ------------------------------------------------------------------------- - // Getters && Setters - // ------------------------------------------------------------------------- - - public DataElement getAggregationDataElement() - { - return aggregationDataElement; - } - - public DataElementCategoryOptionCombo getOptionCombo() - { - return optionCombo; - } - - public void setOptionCombo( DataElementCategoryOptionCombo optionCombo ) - { - this.optionCombo = optionCombo; - } - - public void setAggregationDataElement( DataElement aggregationDataElement ) - { - this.aggregationDataElement = aggregationDataElement; - } - - public String getOperator() - { - return operator; - } - - public void setOperator( String operator ) - { - this.operator = operator; - } - - public void setId( Integer id ) - { - this.id = id; - } - - public String getAggregationExpression() - { - return aggregationExpression; - } - - public void setAggregationExpression( String aggregationExpression ) - { - this.aggregationExpression = aggregationExpression; - } - - public DataElement getDeSum() - { - return deSum; - } - - public void setDeSum( DataElement deSum ) - { - this.deSum = deSum; - } -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java 1970-01-01 00:00:00 +0000 @@ -1,289 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.List; - -import org.hisp.dhis.common.Grid; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.datavalue.DataValue; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.program.Program; -import org.hisp.dhis.scheduling.TaskId; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; -import org.hisp.dhis.trackedentity.TrackedEntityAttribute; - -/** - * @author Chau Thu Tran - * - * @version CaseAggregationConditionService.java Nov 17, 2010 10:56:29 AM - */ -public interface CaseAggregationConditionService -{ - /** - * Adds an {@link CaseAggregationCondition} - * - * @param TrackedEntityAttributeGroup The to CaseAggregationCondition add. - * - * @return A generated unique id of the added - * {@link CaseAggregationCondition}. - */ - int addCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition ); - - /** - * Updates a {@link CaseAggregationCondition}. - * - * @param TrackedEntityAttributeGroup the CaseAggregationCondition to update. - */ - void updateCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition ); - - /** - * Deletes a {@link CaseAggregationCondition}. - * - * @param TrackedEntityAttributeGroup the CaseAggregationCondition to delete. - */ - void deleteCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition ); - - /** - * Returns a {@link CaseAggregationCondition}. - * - * @param id the id of the CaseAggregationCondition to return. - * - * @return the CaseAggregationCondition with the given id - */ - CaseAggregationCondition getCaseAggregationCondition( int id ); - - /** - * Returns a {@link CaseAggregationCondition} with a given name. - * - * @param name the name of the CaseAggregationCondition to return. - * - * @return the CaseAggregationCondition with the given name, or null if no - * match. - */ - CaseAggregationCondition getCaseAggregationCondition( String name ); - - /** - * Returns a {@link CaseAggregationCondition} with a given name. - * - * @param id the uid of the CaseAggregationCondition to return. - * - * @return the CaseAggregationCondition with the given uid, or null if no - * match. - */ - CaseAggregationCondition getCaseAggregationConditionByUid( String id ); - - /** - * Returns all {@link CaseAggregationCondition} - * - * @return A collection of all CaseAggregationCondition, or an empty - * collection if there are no CaseAggregationConditions. - */ - Collection getAllCaseAggregationCondition(); - - /** - * Retrieve {@link CaseAggregationCondition} by a {@link DataElement} - * - * @param dataElement DataElement - * - * @return A collection of CaseAggregationCondition - */ - Collection getCaseAggregationCondition( DataElement dataElement ); - - /** - * Retrieve a {@link CaseAggregationCondition} by a {@link DataElement} and - * {@link DataElementCategoryOptionCombo} - * - * @param dataElement DataElement - * @param optionCombo DataElementCategoryOptionCombo - * - * @return A CaseAggregationCondition - */ - CaseAggregationCondition getCaseAggregationCondition( DataElement dataElement, - DataElementCategoryOptionCombo optionCombo ); - - /** - * Retrieve a {@link CaseAggregationCondition} by a collection of - * {@link DataElement} - * - * @param dataElements DataElement collection - * @param key The name of CaseAggregationCondition - * @param first - * @param max - * - * @return A collection of CaseAggregationCondition - */ - Collection getCaseAggregationConditions( Collection dataElements, String key, Integer first, Integer max ); - - /** - * Retrieve a collection of {@link DataElement} by a - * {@link CaseAggregationCondition} formula - * - * @param aggregationExpression Aggregate Expression - * - * @return A collection of DataElement - */ - Collection getDataElementsInCondition( String aggregationExpression ); - - /** - * Retrieve a collection of {@link Program} by a - * {@link CaseAggregationCondition} formula - * - * @param aggregationExpression Aggregate Expression - * - * @return A collection of Program - */ - Collection getProgramsInCondition( String aggregationExpression ); - - /** - * Retrieve a collection of {@link TrackedEntityAttribute} by a - * {@link CaseAggregationCondition} formula - * - * @param aggregationExpression Aggregate Expression - * - * @return A collection of TrackedEntityAttribute - */ - Collection getTrackedEntityAttributesInCondition( String aggregationExpression ); - - /** - * Retrieve the description of a {@link CaseAggregationCondition} expression - * - * @param aggregationExpression Aggregate Expression - * - * @return The Description of the CaseAggregationCondition - */ - String getConditionDescription( String aggregationExpression ); - - /** - * Aggregate data values from query builder formulas defined based on - * datasets which have data elements defined in the formulas - * - * @param caseAggregateSchedule - * @param taskStrategy Specify how to get period list based on period type - * of each dataset. There are four options, include last month, last - * 3 month, last 6 month and last 12 month - */ - void aggregate( List caseAggregateSchedules, String taskStrategy, TaskId taskId ); - - /** - * Insert value aggregated from a {@link CaseAggregationCondition} - * - * @param caseAggregationConditions {@link CaseAggregationCondition - * @param orgunitIds The list of {@link OrganisationUnit} ids - * @param periods {@link Period} - */ - void insertAggregateValue( Collection caseAggregationConditions, Collection orgunitIds, Collection periods ); - - /** - * Retrieve the details of each {@link DataValue} which are generated by a - * {@link CaseAggregationCondition} - * - * @param caseAggregationCondition CaseAggregationCondition - * @param orgunitIds The list of {@link OrganisationUnit} ids - * @param period {@link Period} - * @param format I18nFormat - * @param i18n I18n - */ - Grid getAggregateValueDetails( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, - Period period, I18nFormat format, I18n i18n ); - - /** - * Convert an expression of {@link CaseAggregationCondition} to standard - * query - * - * @param isInsert True if converting the expression for inserting - * {@link DataValue} - * @param caseExpression The expression of CaseAggregationCondition - * @param operator There are six operators, includes COUNT, TIMES, SUM, AVG, - * MIN and MAX - * @param aggregateDeId The aggregate data element which is used for saving - * a datavalue - * @param aggregateDeName The name of aggregate data element - * @param optionComboId The {@link DataElementCategoryOptionCombo} which is - * used for saving a datavalue - * @param optionComboName The name ofDataElementCategoryOptionCombo - * @param deSumId The id of the data element - * @param orgunitIds The ids of orgunits where data are retrieved to - * calculate value - * @param period The period for retrieving data - * - * @return SQL - */ - String parseExpressionToSql( boolean isInsert, String caseExpression, String operator, Integer aggregateDeId, - String aggregateDeName, Integer optionComboId, String optionComboName, Integer deSumId, - Collection orgunitIds, Period period ); - - /** - * Convert an expression of {@link CaseAggregationCondition} to standard - * query - * - * @param caseExpression The expression of CaseAggregationCondition - * @param operator There are six operators, includes COUNT, TIMES, SUM, AVG, - * MIN and MAX - * @param orgunitIds The id of {@link OrganisationUnit} - * @param period The period for retrieving data - * - * @return SQL - */ - String parseExpressionDetailsToSql( String caseExpression, String operator, Integer orgunitId, Period period ); - - /** - * Get list of {@link TrackedEntityInstance} ids from SQL - * - * @param sql SQL statement - * - * @return List of TrackedEntityInstance ids - */ - List executeSQL( String sql ); - - /** - * @param dataElements - * @return - */ - int countCaseAggregationCondition( Collection dataElements, String key ); - - /** - * Return a data value table aggregated of a query builder formula - * - * @param caseAggregationConditions The collection of query builder expressions - * @param orgunitIds The ids of organisation unit where to aggregate data - * value - * @param period The collections of date ranges for aggregate data value - * @param format - * @param i18n - */ - List getAggregateValue( Collection caseAggregationConditions, Collection orgunitIds, - Collection periods, I18nFormat format, I18n i18n ); - -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStore.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStore.java 1970-01-01 00:00:00 +0000 @@ -1,201 +0,0 @@ -package org.hisp.dhis.caseaggregation; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.List; - -import org.hisp.dhis.common.GenericNameableObjectStore; -import org.hisp.dhis.common.Grid; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.datavalue.DataValue; -import org.hisp.dhis.i18n.I18n; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.trackedentity.TrackedEntityInstance; - -/** - * @author Chau Thu Tran - * - * @version CaseAggregationConditionStore.java Nov 18, 2010 9:27:59 AM - */ -public interface CaseAggregationConditionStore - extends GenericNameableObjectStore -{ - String ID = CaseAggregationConditionStore.class.getName(); - - /** - * Retrieve {@link CaseAggregationCondition} by a {@link DataElement} - * - * @param dataElement DataElement - * - * @return A collection of CaseAggregationCondition - */ - Collection get( DataElement dataElement ); - - CaseAggregationCondition get( DataElement dataElement, DataElementCategoryOptionCombo optionCombo ); - - /** - * Retrieve a collection of {@link CaseAggregationCondition} by a collection of {@link DataElement} - * - * @param dataElements DataElement collection - * @param first - * @param max - * - * @return A CaseAggregationCondition - */ - Collection get( Collection dataElements, String key, Integer first, Integer max ); - - /** - * Generate period list based on period Type and taskStrategy option - * - * @param periodTypeName The name of period type - * @param taskStrategy Specify how to get period list based on period type - * of each dataset. There are four options, include last month, last - * 3 month, last 6 month and last 12 month - * - */ - Collection getPeriods( String periodTypeName, String taskStrategy ); - - /** - * Retrieve the details of each {@link DataValue} which are generated by a - * {@link CaseAggregationCondition} - * - * @param caseAggregationCondition CaseAggregationCondition - * @param orgunitIds The list of {@link OrganisationUnit} ids - * @param period {@link Period} - * @param nonRegistrationProgram Specify if the expression of aggregationCondition has any single event without registration program - * @param format I18nFormat - * @param i18n I18n - */ - Grid getAggregateValueDetails( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, - Period period, boolean nonRegistrationProgram, I18nFormat format, I18n i18n ); - - /** - * Insert data values into database directly - * - * @param sql SQL filter events - * @param dataElementId The id of aggregate data element - * @param optionComboId The id of category option combo - * @param orgunitIds The id collection of organisation units where to aggregate data - * value - * @param period The date range for aggregate data value - */ - void insertAggregateValue( String sql, int dataElementId, int optionComboId, Collection orgunitIds, Period period ); - - /** - * Return standard SQL from query builder formula - * - * @param isInsert Insert aggregate result into database directly - * @param caseExpression The query builder expression - * @param operator There are six operators, includes Number of persons, - * Number of visits, Sum, Average, Minimum and Maximum of data - * element values. - * @param aggregateDeId The id of aggregate data element - * @param aggregateDeName The name of aggregate data element - * @param optionComboId The id of category option combo - * @param optionComboName The name of category option combo - * @param deSumId The id of aggregate data element which used for aggregate - * data values for operator Sum, Average, Minimum and Maximum of data - * element values. This fill is null for other operators. - * @param orgunitId The id of organisation unit where to aggregate data - * value - */ - String parseExpressionToSql( boolean isInsert, String caseExpression, String operator, Integer aggregateDeId, - String aggregateDeName, Integer optionComboId, String optionComboName, int attributeOptioncomboId, Integer deSumId, - Collection orgunitIds ); - - /** - * Return standard SQL from query builder formula - * @param aggregationCondition {@link CaseAggregationCondition} - * @param attributeOptionComboId - * - */ - String parseExpressionToSql( boolean isInsert, CaseAggregationCondition aggregationCondition, int attributeOptionComboId, Collection orgunitIds ); - - /** - * Aggregate data values for the dataset by periods with a organisation unit - * list - * - */ - void runAggregate( Collection orgunitIds, CaseAggregateSchedule dataSet, Collection periods, int attributeOptioncomboId ); - - /** - * Convert an expression of {@link CaseAggregationCondition} to standard - * query - * - * @param caseExpression The expression of CaseAggregationCondition - * @param operator There are six operators, includes COUNT, TIMES, SUM, AVG, - * MIN and MAX - * @param orgunitIds The id of {@link OrganisationUnit} - * @param period The period for retrieving data - * @Param nonRegistrationProgram Specify if the expression of aggregationCondition has any single event without registration program - * - * @return SQL - */ - String parseExpressionDetailsToSql( String caseExpression, String operator, Integer orgunitId, Period period, boolean nonRegistrationProgram ); - - /** - * Get list of {@link TrackedEntityInstance} ids from SQL - * - * @param sql SQL statement - * - * @return List of tracked entity instance ids - */ - List executeSQL( String sql ); - - /** - * Get the numbers of {@link CaseAggregationCondition} by {@link DataElement} list - * @param dataElements - * @param ket The name of CaseAggregationCondition - * @return - */ - int count( Collection dataElements, String key ); - - public Collection getServiceOrgunit(); - - Grid getAggregateValue( String sql, I18nFormat format, I18n i18n ); - - - /** - * Insert data values into database directly - * - * @param sql SQL filter events - * @param dataElement The aggregate data element - * @param optionCombo The category option combo - * @param attributeOptionCombo - * @param orgunitIds The id collection of organisation units where to aggregate data - * value - * @param period The date range for aggregate data value - */ - void insertAggregateValue( String sql, DataElement dataElement, DataElementCategoryOptionCombo optionCombo, - DataElementCategoryOptionCombo attributeOptionCombo, Collection orgunitIds, Period period ); -} === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/startup/TableAlteror.java 2016-02-24 04:25:21 +0000 @@ -28,21 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.program.ProgramExpression.OBJECT_PROGRAM_STAGE; -import static org.hisp.dhis.program.ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT; -import static org.hisp.dhis.program.ProgramExpression.SEPARATOR_ID; -import static org.hisp.dhis.program.ProgramExpression.SEPARATOR_OBJECT; - -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.amplecode.quick.StatementHolder; import org.amplecode.quick.StatementManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.jdbc.StatementBuilder; @@ -54,6 +43,13 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.annotation.Transactional; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.hisp.dhis.program.ProgramExpression.*; + /** * @author Chau Thu Tran */ @@ -81,10 +77,10 @@ @Autowired private ProgramStageService programStageService; - + @Autowired private DataElementService dataElementService; - + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- @@ -112,8 +108,6 @@ executeSql( "DROP TABLE programattribute" ); executeSql( "ALTER TABLE programstageinstance ALTER executiondate TYPE date" ); - executeSql( "ALTER TABLE caseaggregationcondition RENAME description TO name" ); - executeSql( "UPDATE programstage_dataelements SET allowProvidedElsewhere=false WHERE allowProvidedElsewhere is null" ); executeSql( "ALTER TABLE programstageinstance DROP COLUMN providedbyanotherfacility" ); @@ -151,13 +145,11 @@ executeSql( "UPDATE program SET onlyEnrollOnce='false' WHERE onlyEnrollOnce is null" ); executeSql( "UPDATE programStage SET captureCoordinates=false WHERE captureCoordinates is null" ); - executeSql( "update caseaggregationcondition set \"operator\"='times' where \"operator\"='SUM'" ); - executeSql( "update prorgam set \"operator\"='times' where \"operator\"='SUM'" ); executeSql( "update program set remindCompleted=false where remindCompleted is null" ); executeSql( "UPDATE program SET skipoffline=false where skipoffline is null" ); executeSql( "UPDATE program SET displayfrontpagelist=false where displayfrontpagelist is null" ); - + executeSql( "UPDATE programinstance SET followup=false where followup is null" ); updateProgramInstanceStatus(); @@ -166,7 +158,6 @@ executeSql( "ALTER TABLE program ALTER COLUMN dateofincidentdescription DROP NOT NULL" ); executeSql( "UPDATE program SET displayOnAllOrgunit=true where displayOnAllOrgunit is null" ); executeSql( "UPDATE program SET useFormNameDataElement=true where useFormNameDataElement is null" ); - executeSql( "ALTER TABLE caseaggregationcondition ALTER COLUMN aggregationexpression TYPE varchar(1000)" ); executeSql( "update program set selectEnrollmentDatesInFuture = false where selectEnrollmentDatesInFuture is null" ); executeSql( "update program set selectIncidentDatesInFuture = false where selectIncidentDatesInFuture is null" ); executeSql( "update validationcriteria set description = name where description is null or description='' " ); @@ -271,8 +262,6 @@ executeSql( "UPDATE trackedentityattribute SET valuetype='optionSet' WHERE valuetype='combo'" ); - updateAggregateQueryBuilder(); - executeSql( "UPDATE programstageinstance SET status=1 WHERE completed=true" ); executeSql( "ALTER TABLE programstageinstance DROP COLUMN completed" ); @@ -291,7 +280,7 @@ executeSql( "DROP SEQUENCE period_periodid_seq" ); executeSql( "ALTER TABLE programstagesection DROP CONSTRAINT programstagesection_name_key" ); - + executeSql( "update eventreport set collapsedatadimensions = false where collapsedatadimensions is null" ); executeSql( "update eventchart set collapsedatadimensions = false where collapsedatadimensions is null" ); @@ -301,29 +290,26 @@ executeSql( "alter table programindicator drop column valuetype" ); executeSql( "alter table programindicator drop column rootdate" ); executeSql( "alter table programindicator drop column eventoutputtype" ); - + executeSql( "ALTER TABLE programstage ALTER description TYPE text" ); - + executeSql( "update programindicator set displayinform = false where displayinform is null" ); - + executeSql( "drop index index_patientdatavalue" ); - + executeSql( "update program p set dataentryformid = (select dataentryformid from trackedentityform tf where tf.programid=p.programid limit 1)" ); executeSql( "drop table trackedentityform" ); executeSql( "alter table trackedentitydatavalue alter column storedby TYPE character varying(255)" ); executeSql( "alter table datavalue alter column storedby TYPE character varying(255)" ); - + updateProgramStageList(); updateProgramAttributeList(); - - updateFixedAttributeInCaseAggregate( "DEDATEDIFF", CaseAggregationCondition.MINUS_OPERATOR ); + executeSql( "update userroleauthorities set authority='F_ADD_TRACKED_ENTITY_FORM' where authority='F_TRACKED_ENTITY_FORM_ADD'" ); updateProgramExpressionUid(); - - updatePropertiesChangeInCaseAggregate(); - + // TODO fix // executeSql( "DROP TABLE programstage_programindicators" ); } @@ -332,99 +318,6 @@ // Supporting methods // ------------------------------------------------------------------------- - private void updateAggregateQueryBuilder() - { - StatementHolder holder = statementManager.getHolder(); - - try - { - Statement statement = holder.getStatement(); - ResultSet resultSet = statement - .executeQuery( "select trackedentityattributeid from trackedentityattribute where name='Age'" ); - - if ( resultSet.next() ) - { - int id = resultSet.getInt( "trackedentityattributeid" ); - - String source = "PC:DATE@executionDate#-DATE@birthDate#"; - String target = CaseAggregationCondition.OBJECT_TRACKED_ENTITY_ATTRIBUTE - + CaseAggregationCondition.SEPARATOR_OBJECT + id + ".visit"; - - updateFixedAttributeInCaseAggregate( source, target ); - } - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - } - - private void updateFixedAttributeInCaseAggregate( String source, String target ) - { - StatementHolder holder = statementManager.getHolder(); - try - { - Statement statement = holder.getStatement(); - ResultSet resultSet = statement - .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition where aggregationExpression like '%" - + source + "%'" ); - - source = source.replaceAll( "@", "\\@" ).replaceAll( "#", "\\#" ); - - while ( resultSet.next() ) - { - String id = resultSet.getString( "caseaggregationconditionid" ); - String expression = resultSet.getString( "aggregationExpression" ); - - expression = expression.replaceAll( source, target ); - expression = expression.replaceAll( "'", "\"" ); - executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + expression - + "' WHERE caseaggregationconditionid=" + id ); - } - } - catch ( Exception ex ) - { - log.debug( ex ); - } - finally - { - holder.close(); - } - } - - private void updatePropertiesChangeInCaseAggregate() - { - StatementHolder holder = statementManager.getHolder(); - try - { - Statement statement = holder.getStatement(); - ResultSet resultSet = statement - .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition where LOWER(aggregationExpression) like '%dateofincident%'" ); - - while ( resultSet.next() ) - { - String id = resultSet.getString( "caseaggregationconditionid" ); - String expression = resultSet.getString( "aggregationExpression" ); - - expression = expression.replaceAll( "dateOfIncident", "incidentDate" ); - expression = expression.replaceAll( "dateofincident", "incidentDate" ); - expression = expression.replaceAll( "'", "''" ); - - executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + expression - + "' WHERE caseaggregationconditionid=" + id ); - } - } - catch ( Exception ex ) - { - log.debug( ex ); - } - finally - { - holder.close(); - } - } - - private void updateProgramInstanceStatus() { // Set active status for events @@ -479,7 +372,7 @@ { int exist = jdbcTemplate.queryForObject( "SELECT count(*) FROM trackedentity where name='Person'", Integer.class ); - + if ( exist == 0 ) { String id = statementBuilder.getAutoIncrementValue(); @@ -498,7 +391,7 @@ private void updateProgramStageList() { int count = jdbcTemplate.queryForObject( "select count(*) from programstage where sort_order is null", Integer.class ); - + if ( count > 0 ) { StatementHolder holder = statementManager.getHolder(); @@ -634,7 +527,7 @@ holder.close(); } } - + private int executeSql( String sql ) { try === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-02-15 04:57:22 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2016-02-24 04:25:21 +0000 @@ -1761,7 +1761,6 @@ - === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2016-02-24 04:25:21 +0000 @@ -30,7 +30,6 @@ import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.attribute.AttributeValue; -import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.chart.Chart; import org.hisp.dhis.common.filter.MetaDataFilter; import org.hisp.dhis.constant.Constant; @@ -67,7 +66,6 @@ import org.hisp.dhis.mapping.Map; import org.hisp.dhis.mapping.MapView; import org.hisp.dhis.minmax.MinMaxDataElement; -import org.hisp.dhis.security.oauth2.OAuth2Client; import org.hisp.dhis.option.Option; import org.hisp.dhis.option.OptionSet; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -91,6 +89,7 @@ import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.report.Report; import org.hisp.dhis.reporttable.ReportTable; +import org.hisp.dhis.security.oauth2.OAuth2Client; import org.hisp.dhis.sqlview.SqlView; import org.hisp.dhis.trackedentity.TrackedEntity; import org.hisp.dhis.trackedentity.TrackedEntityAttribute; @@ -699,15 +698,6 @@ { } - public String allowDeleteCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition ) - { - return null; - } - - public void deleteCaseAggregationCondition( CaseAggregationCondition caseAggregationCondition ) - { - } - public String allowDeleteOptionSet( OptionSet optionSet ) { return null; === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AggregationQueryController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AggregationQueryController.java 2016-02-23 08:29:23 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AggregationQueryController.java 1970-01-01 00:00:00 +0000 @@ -1,170 +0,0 @@ -package org.hisp.dhis.webapi.controller; - -/* - * Copyright (c) 2004-2016, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hisp.dhis.caseaggregation.AggregationQueries; -import org.hisp.dhis.caseaggregation.AggregationQuery; -import org.hisp.dhis.caseaggregation.CaseAggregationCondition; -import org.hisp.dhis.caseaggregation.CaseAggregationConditionService; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.program.ProgramService; -import org.hisp.dhis.program.ProgramStageService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@Controller -@RequestMapping( value = AggregationQueryController.RESOURCE_PATH ) -public class AggregationQueryController -{ - private static final Log log = LogFactory.getLog( AggregationQueryController.class ); - - public static final String RESOURCE_PATH = "/aggregationQueries"; - - private CaseAggregationConditionService aggregationConditionService; - - @Autowired - private ProgramService programService; - - @Autowired - private ProgramStageService programStageService; - - @Autowired - private DataElementService dataElementService; - - @Autowired - private DataElementCategoryService dataElementCategoryService; - - @RequestMapping( method = RequestMethod.POST, consumes = "application/json" ) - @PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_AGGREGATION')" ) - public void postAggregationQueryJson( @RequestBody AggregationQueries aggregationQueries, - HttpServletResponse response ) - { - for ( AggregationQuery aggregationQuery : aggregationQueries ) - { - CaseAggregationCondition caseAggregationCondition = convertToCaseAggregationCondition( aggregationQuery ); - - if ( caseAggregationCondition.getId() == 0 ) - { - aggregationConditionService.addCaseAggregationCondition( caseAggregationCondition ); - } - else - { - aggregationConditionService.updateCaseAggregationCondition( caseAggregationCondition ); - } - } - } - - private CaseAggregationCondition convertToCaseAggregationCondition( AggregationQuery aggregationQuery ) - { - String id = aggregationQuery.getId(); - CaseAggregationCondition expression = aggregationConditionService.getCaseAggregationConditionByUid( id ); - - if ( expression == null ) - { - expression = new CaseAggregationCondition(); - expression.setUid( id ); - } - - expression.setName( aggregationQuery.getName() ); - expression.setOperator( aggregationQuery.getOperator() ); - expression.setAggregationDataElement( dataElementService.getDataElement( aggregationQuery.getDataElement() ) ); - - if ( aggregationQuery.getCategoryOptionCombo() == null ) - { - expression.setOptionCombo( dataElementCategoryService.getDefaultDataElementCategoryOptionCombo() ); - } - else - { - expression.setOptionCombo( dataElementCategoryService.getDataElementCategoryOptionCombo( aggregationQuery.getCategoryOptionCombo() ) ); - } - - String deIdForGroupBy = aggregationQuery.getDataElementForGroupBy(); - - if ( deIdForGroupBy != null ) - { - DataElement deSum = dataElementService.getDataElement( deIdForGroupBy ); - expression.setDeSum( deSum ); - } - - expression.setAggregationExpression( convertDataElementExpression( aggregationQuery.getExpression() ) ); - - return expression; - } - - private String convertDataElementExpression( String expression ) - { - String uidPattern = "[A-Za-z0-9]+"; - String uidTokenPattern = "(#\\{(" + uidPattern + ")})"; - - StringBuffer replacedExpressionBuffer = new StringBuffer(); - - Pattern dePattern = Pattern.compile( "(?<=\\[" + CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT - + CaseAggregationCondition.SEPARATOR_OBJECT + ")" - + uidTokenPattern + CaseAggregationCondition.SEPARATOR_ID - + uidTokenPattern + CaseAggregationCondition.SEPARATOR_ID - + uidTokenPattern - + "(?=\\])" ); - - Matcher matcher = dePattern.matcher( expression ); - - while ( matcher.find() ) - { - String programUid = matcher.group( 2 ); - int programId = programService.getProgram( programUid ).getId(); - - String programStageUid = matcher.group( 4 ); - int programStageId = programStageService.getProgramStage( programStageUid ).getId(); - - String dataElementUid = matcher.group( 6 ); - int dataElementId = dataElementService.getDataElement( dataElementUid ).getId(); - - matcher.appendReplacement( replacedExpressionBuffer, - String.format( "%d.%d.%d", programId, programStageId, dataElementId ) ); - } - - matcher.appendTail( replacedExpressionBuffer ); - - String parsedExpression = replacedExpressionBuffer.toString(); - log.info( "Replacing " + expression + " with " + parsedExpression ); - return parsedExpression; - } -} === removed file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm 2014-06-13 10:58:05 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonCaseAggregation.vm 1970-01-01 00:00:00 +0000 @@ -1,11 +0,0 @@ -{ "caseAggregation": - { - "id": "${caseAggregation.id}", - "uid": "${caseAggregation.uid}", - "name": "$!encoder.jsonEncode( ${caseAggregation.name} )", - "operator": "${caseAggregation.operator}", - "aggregationDataElement": "$!encoder.jsonEncode( ${caseAggregation.aggregationDataElement.name} )", - "optionCombo": "$!encoder.jsonEncode( ${caseAggregation.optionCombo.name} )", - "aggregationExpression": "$!encoder.jsonEncode( ${caseAggregation.aggregationExpression} )" - } -} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2015-12-25 09:55:06 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2016-02-24 04:25:21 +0000 @@ -547,22 +547,6 @@ "required" : true } }, - "caseAggregation" : { - "name" : { - "required" : true, - "rangelength" : [2,230] - }, - "aggregationDataElementId" : { - "required" : true - }, - "deSumId" : { - "required" : true - }, - "aggregationCondition" : { - "required" : true, - "rangelength" : [2,1000] - } - }, "programStageSection" : { "name" : { "required" : true, === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2016-02-18 12:30:57 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml 2016-02-24 04:25:21 +0000 @@ -666,23 +666,6 @@ attributeGroup.action - - - - - /dhis-web-commons/ajax/jsonProgramStages.vm - - plainTextError - - - - - /dhis-web-maintenance-program/jsonOptions.vm - - - - - -
- - - - - - - - - - - - - - - - -
- $i18n.getString("filter_by_name"): - - - -   - -
- $i18n.getString("filter_by_type"): - - - -
- - - - -
- - - - - - - - - -
$i18n.getString("display_name") - -
$i18n.getString( "sort_by" ) - $i18n.getString("name") - $i18n.getString("code")     -
-
-
- -
- - - - - - - - - - - - - - - -
$i18n.getString('filter_by_name') - - - - - -
- - -
- - -
- -
-
- -
- - - - - - - - - -
- - - -
-
- - -

- - - - - - - - - - - - -
- - - - - - - - - - - - - - - -

- - - - - - | - -
-
- $i18n.getString( "condition" ) * -
- -
-
-
-
- $i18n.getString( "description" ) -
$!encoder.htmlEncode($description)
-
-
- - - === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addCaseAggregationForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addCaseAggregationForm.js 2014-08-06 15:20:54 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addCaseAggregationForm.js 1970-01-01 00:00:00 +0000 @@ -1,13 +0,0 @@ -jQuery(document).ready( function(){ - - validation2( 'addCaseAggregationForm', function( form ) - { - form.submit(); - },{ - 'rules' : getValidationRules( "caseAggregation" ) - }); - - jQuery("#tabs").tabs(); - checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action"); - byId('name').focus(); -}); \ No newline at end of file === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/caseaggregation.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/caseaggregation.js 2015-09-03 08:15:09 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/caseaggregation.js 1970-01-01 00:00:00 +0000 @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// Get dataelements by dataset -//------------------------------------------------------------------------------ - -function getDataElementsByDataset() { - var dataSets = document.getElementById('dataSets'); - var dataSetId = dataSets.options[dataSets.selectedIndex].value; - setFieldValue('aggregationDataElementId', ''); - setFieldValue('aggregationDataElementInput', ''); - - if( dataSetId == "" ) { - disable('dataElementsButton'); - setFieldValue('aggregationDataElementInput', ''); - return; - } - autoCompletedField(); -} - -function autoCompletedField() { - $("#dataElementsButton").unbind('click'); - enable('dataElementsButton'); - - var input = jQuery("#aggregationDataElementInput") - .autocomplete({ - delay: 0, - minLength: 0, - source: function(request, response) { - $.ajax({ - url: "getDataElementsByDataset.action?id=" + getFieldValue('dataSets') + "&query=" + input.val(), - dataType: "json", - success: function(data) { - response($.map(data.dataElements, function(item) { - return { - label: item.name, - id: item.id - }; - })); - } - }); - }, - select: function(event, ui) { - input.val(ui.item.value); - setFieldValue('aggregationDataElementId', ui.item.id); - input.autocomplete("close"); - }, - change: function(event, ui) { - if( !ui.item ) { - var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"), - valid = false; - select.children("option").each(function() { - if( $(this).text().match(matcher) ) { - this.selected = valid = true; - return false; - } - }); - if( !valid ) { - // remove invalid value, as it didn't match anything - $(this).val(""); - select.val(""); - input.data("uiAutocomplete").term = ""; - return false; - } - } - } - }).addClass("ui-widget"); - - input.data("uiAutocomplete")._renderItem = function(ul, item) { - return $("
  • ") - .data("item.autocomplete", item) - .append("" + item.label + "") - .appendTo(ul); - }; - - var wrapper = this.wrapper = $("") - .addClass("ui-combobox") - .insertAfter(input); - - var button = $("#dataElementsButton") - .attr("tabIndex", -1) - .attr("title", i18n_show_all_items) - .appendTo(wrapper) - .button({ - icons: { - primary: "ui-icon-triangle-1-s" - }, - text: false - }) - .click(function() { - // close if already visible - if( input.autocomplete("widget").is(":visible") ) { - input.autocomplete("close"); - return; - } - // work around a bug (likely same cause as #5265) - $(this).blur(); - // pass empty string as value to search for, displaying all results - input.autocomplete("search", ""); - input.focus(); - }); -} - -//------------------------------------------------------------------------------ -// Get Program Stages -//------------------------------------------------------------------------------ - -function getParams() { - clearListById('programStageId'); - clearListById('dataElements'); - clearListById('caseProperty'); - var programId = getFieldValue('programId'); - if( programId == '' ) { - disable('programProperty'); - disable('programStageProperty'); - } - - if( jQuery('#programId option:selected').attr('programType') == 3 ) { - jQuery("[name=multiProgram]").remove(); - if( jQuery("[value=times]").attr('checked') != undefined - && jQuery("[value=times]").attr('checked') != 'true' ) { - jQuery("[value=times]").attr('checked', true); - } - } - - jQuery.getJSON('getParamsByProgram.action', { programId: programId } - , function(json) { - enable('programProperty'); - var programstage = jQuery('#programStageId'); - - for( i in json.programStages ) { - var id = json.programStages[i].id; - var formularId = "[PS:" + id + "]"; - var name = json.programStages[i].name; - - programstage.append(""); - } - - if( json.programStages.length > 1 ) { - programstage.prepend(""); - } - byId('programStageId').options[0].selected = true; - getTrackedEntityDataElements(); - - clearListById('caseProperty'); - clearListById('casePropertyBackups'); - var type = jQuery('#programId option:selected').attr('programType'); - if( type != '3' ) { - var caseProperty = jQuery('#caseProperty'); - var casePropertyBackups = jQuery('#casePropertyBackups'); - for( i in json.attributes ) { - var id = json.attributes[i].id; - var name = json.attributes[i].name; - var optionSet = json.attributes[i].optionSet; - - caseProperty.append(""); - casePropertyBackups.append(""); - } - } - }); -} - -function getProgramStages() { - var programId = getFieldValue('orgunitProgramId'); - if( programId == '' ) return; - - clearListById('orgunitProgramStageId'); - - jQuery.getJSON('getProgramStages.action', { id: programId } - , function(json) { - enable('programProperty'); - var programstage = jQuery('#orgunitProgramStageId'); - - for( i in json.programStages ) { - var id = json.programStages[i].id; - var formularId = "[PSIC:" + id + "]"; - var name = json.programStages[i].name; - - programstage.append(""); - } - }); -} - -//------------------------------------------------------------------------------ -// Get DataElements of Program-Stage -//------------------------------------------------------------------------------ - -function getTrackedEntityDataElements() { - clearListById('dataElements'); - clearListById('dataElementBackups'); - clearListById('deSumId'); - var programStageId = getFieldValue('programStageId'); - - jQuery.getJSON('getTrackedEntityDataElements.action', - { - programId: getFieldValue('programId'), - programStageId: programStageId - } - , function(json) { - if( programStageId != '' ) { - enable('programStageProperty'); - } - else { - disable('programStageProperty'); - } - - var dataElements = jQuery('#dataElements'); - var dataElementBackups = jQuery('#dataElementBackups'); - clearListById('dataElements'); - clearListById('dataElementBackups'); - var deSumId = jQuery('#deSumId'); - deSumId.append(""); - for( i in json.dataElements ) { - var id = json.dataElements[i].localid; - dataElements.append(""); - dataElementBackups.append(""); - if( json.dataElements[i].type == 'int' ) { - deSumId.append(""); - } - } - - }); -} - -//----------------------------------------------------------------- -// Insert items into Condition -//----------------------------------------------------------------- - -function insertDataElement(element) { - var progamId = getFieldValue('programId'); - var programStageId = getFieldValue('programStageId'); - programStageId = ( programStageId == "" ) ? "*" : programStageId; - var dataElementId = element.options[element.selectedIndex].value; - - insertTextCommon('aggregationCondition', "[DE:" + progamId + "." + programStageId + "." + dataElementId + "]"); - getConditionDescription(); -} - -function insertInfo(element, isProgramStageProperty) { - var id = ""; - if( isProgramStageProperty ) { - id = getFieldValue('programStageId'); - } - else { - id = getFieldValue('programId'); - } - - value = element.options[element.selectedIndex].value.replace('*', id); - insertTextCommon('aggregationCondition', value); - getConditionDescription(); -} - -function insertOperator(value) { - insertTextCommon('aggregationCondition', ' ' + value + ' '); - getConditionDescription(); -} - -function insertBoolValue(value) { - insertTextCommon("aggregationCondition", " ='" + value + "' "); - getConditionDescription(); -} - -// ----------------------------------------------------------------------------- -// Remove Case Aggregation Condition -// ----------------------------------------------------------------------------- - -function removeCaseAggregation(context) { - removeItem(context.id, context.name, i18n_confirm_delete, 'removeCaseAggregation.action'); -} - -// ----------------------------------------------------------------------------- -// View details -// ----------------------------------------------------------------------------- - -function showUpdateCaseAggregationForm(context) { - location.href = 'showUpdateCaseAggregationForm.action?id=' + context.id; -} - -function showCaseAggregationDetails(context) { - jQuery.getJSON('getCaseAggregation.action', { id: context.id }, function(json) { - setInnerHTML('nameField', json.caseAggregation.name); - setInnerHTML('operatorField', json.caseAggregation.operator); - setInnerHTML('aggregationDataElementField', json.caseAggregation.aggregationDataElement); - setInnerHTML('optionComboField', json.caseAggregation.optionCombo); - setInnerHTML('aggregationExpressionField', json.caseAggregation.aggregationExpression); - setInnerHTML('deSumField', json.caseAggregation.deSum); - setInnerHTML('idField', json.caseAggregation.uid); - showDetails(); - }); -} - -// ----------------------------------------------------------------------------- -// View details -// ----------------------------------------------------------------------------- - -function getConditionDescription() { - $.postUTF8('getCaseAggregationDescription.action', - { - condition: getFieldValue('aggregationCondition') - }, function(data) { - byId('aggregationDescription').innerHTML = data; - }, 'html'); -} - -// ----------------------------------------------------------------------------- -// Test condition -// ----------------------------------------------------------------------------- - -function testCaseAggregationCondition() { - var operator = jQuery('[name=operator]:checked').val(); - $.postUTF8('testCaseAggregationCondition.action', - { - condition: getFieldValue('aggregationCondition'), - deSumId: getFieldValue('deSumId'), - operator: operator - }, function(json) { - var type = json.response; - - if( type == "input" ) { - showWarningMessage(i18n_run_fail); - } - else { - showSuccessMessage(i18n_run_success); - } - }); -} - -function getoptionSetValues(sourceId, targetId) { - clearListById(targetId); - - var optionSetValues = jQuery('select[id=' + sourceId + '] option:selected').attr('TRACKER_ASSOCIATE'); - if( optionSetValues ) { - var arrValues = new Array(); - arrValues = optionSetValues.replace(/[//[]+/g, '').replace(/]/g, '').split(', '); - - var optionSetValueSelector = byId(targetId); - for( var i = 0; i < arrValues.length; i++ ) { - var option = document.createElement("option"); - var value = jQuery.trim(arrValues[i]); - option.value = "'" + value + "'"; - option.text = value; - option.title = value; - - optionSetValueSelector.add(option, null); - } - } -} - -function insertSingleValue(elementId) { - var element = byId(elementId); - insertTextCommon('aggregationCondition', "=" + element.options[element.selectedIndex].value); - getConditionDescription(); -} - -function insertMultiValues(elementId) { - var list = jQuery('select[id=' + elementId + '] option') - if( list.length == 0 ) { - return; - } - if( list.length > 1 ) { - var selectedValues = ""; - list.each(function() { - selectedValues += jQuery(this).val() + ", "; - }); - selectedValues = " IN @ " + selectedValues.substring(0, selectedValues.length - 2) + " #"; - - insertTextCommon('aggregationCondition', selectedValues); - getConditionDescription(); - } - else { - insertSingleValue(elementId); - } -} - -function getCaseAggConditionByDataset() { - $.get('getCaseAggConditionByDataset.action', - { - dataSetId: getFieldValue('dataSetId'), - key: getFieldValue('key') - } - , function(html) { - setInnerHTML('list', html); - setTableStyles(); - }); -} - -function showAddCaseAggregationForm() { - window.location.href = 'showAddCaseAggregationForm.action?dataSetId=' + getFieldValue('dataSetId'); -} - -function operatorOnchange(operator) { - if( operator == 'sum' || operator == 'avg' - || operator == 'min' || operator == 'max' ) { - enable('deSumId'); - } - else { - disable('deSumId'); - } -} - -function filterDataElement(event, value, fieldName, backupFieldsName) { - // Remove all options in data element fields - var field = jQuery('#' + fieldName + " option ").remove(); - var valueType = getFieldValue('deValueType'); - - jQuery('#' + backupFieldsName + " option ").each(function() { - var option = jQuery(this); - if( valueType == '' || valueType == option.attr('valueType') ) { - if( value.length == 0 ) { - jQuery('#' + fieldName).append(""); - } - else if( option.text().toLowerCase().indexOf(value.toLowerCase()) != -1 ) { - jQuery('#' + fieldName).append(""); - } - } - }); - -} - -function filterAttribute(event, value, fieldName, backupFieldsName) { - // Remove all options in data element fields - var field = jQuery('#' + fieldName + " option ").remove(); - jQuery('#' + backupFieldsName + " option ").each(function() { - var option = jQuery(this); - if( option.text().toLowerCase().indexOf(value.toLowerCase()) != -1 ) { - jQuery('#' + fieldName).append(""); - } - }); -} - -function sortByOnChange(sortBy) { - if( sortBy == 1 ) { - jQuery('#dataElements').each(function() { - - // Keep track of the selected option. - var selectedValue = $(this).val(); - - // sort it out - $(this).html($("option", $(this)).sort(function(a, b) { - return $(a).attr('dename') == $(b).attr('dename') ? 0 : $(a).attr('dename') < $(b).attr('dename') ? -1 : 1 - })); - - // Select one option. - $(this).val(selectedValue); - - }); - } - else { - jQuery('#dataElements').each(function() { - - // Keep track of the selected option. - var selectedValue = $(this).val(); - - // sort it out - $(this).html($("option", $(this)).sort(function(a, b) { - return $(a).attr('decode') == $(b).attr('decode') ? 0 : $(a).attr('decode') < $(b).attr('decode') ? -1 : 1 - })); - - // Select one option. - $(this).val(selectedValue); - - }); - } -} - -function displayNameOnChange(displayName) { - // display - name - if( displayName == '1' ) { - jQuery('#dataElements option').each(function() { - var item = jQuery(this); - item[0].text = item.attr('dename'); - item[0].title = item[0].text; - }); - jQuery('#dataElementBackups option').each(function() { - var item = jQuery(this); - item[0].text = item.attr('dename'); - }); - } - // display - code - else if( displayName == '2' ) { - jQuery('#dataElements option').each(function() { - var item = jQuery(this); - item[0].text = item.attr('decode'); - item[0].title = item[0].text; - }); - jQuery('#dataElementBackups option').each(function() { - var item = jQuery(this); - item[0].text = item.attr('decode'); - }); - } - // display - code and name - else { - jQuery('#dataElements option').each(function() { - var item = jQuery(this); - item[0].text = "(" + item.attr('decode') + ") " + item.attr('dename'); - item[0].title = item[0].text; - }); - jQuery('#dataElementBackups option').each(function() { - var item = jQuery(this); - item[0].text = "(" + item.attr('decode') + ") " + item.attr('dename'); - }); - } -} - -function cancelOnClick() { - var dataSetId = getFieldValue("dataSets"); - window.location.href = 'caseAggregation.action?dataSetId=' + dataSetId; -} - -function attributeAutocompletedField(idField, optionSetUid, btnId, optionId) { - $("#" + btnId).unbind('click'); - enable(btnId); - var input = jQuery("#" + idField); - var select = jQuery("#attributeId"); - input.autocomplete({ - delay: 0, - minLength: 0, - source: function(request, response) { - $.ajax({ - url: "getOptions.action?id=" + optionSetUid + "&query=" + input.val(), - dataType: "json", - success: function(data) { - response($.map(data.options, function(item) { - return { - label: item.n, - id: item.c - }; - })); - } - }); - }, - select: function(event, ui) { - input.val(ui.item.label); - jQuery("#" + optionId).append(""); - input.autocomplete("close"); - - return false; - }, - change: function(event, ui) { - if( !ui.item ) { - var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"), - valid = false; - select.children("option").each(function() { - if( $(this).text().match(matcher) ) { - this.selected = valid = true; - return false; - } - }); - if( !valid ) { - // remove invalid value, as it didn't match anything - $(this).val(""); - select.val(""); - input.data("uiAutocomplete").term = ""; - return false; - } - } - } - }).addClass("ui-widget"); - - input.data("uiAutocomplete")._renderItem = function(ul, item) { - return $("
  • ") - .data("item.autocomplete", item) - .append("" + item.label + "") - .appendTo(ul); - }; - - var wrapper = this.wrapper = $("") - .addClass("ui-combobox") - .insertAfter(input); - - var button = $("#" + btnId) - .attr("tabIndex", -1) - .attr("title", i18n_show_all_items) - .appendTo(wrapper) - .button({ - icons: { - primary: "ui-icon-triangle-1-s" - }, - text: false - }) - .click(function() { - // close if already visible - if( input.autocomplete("widget").is(":visible") ) { - input.autocomplete("close"); - return; - } - // work around a bug (likely same cause as #5265) - $(this).blur(); - // pass empty string as value to search for, displaying all results - input.autocomplete("search", ""); - input.focus(); - }); -} - -function split(val) { - return val.split(/,\s*/); -} - -function getSuggestedValues(_this, suggestedField, btnId, optionId) { - clearListById(optionId); - var field = jQuery('#' + suggestedField); - var option = jQuery("#" + _this.id + " option:selected"); - if( option.attr('optionset') != "" ) { - attributeAutocompletedField(suggestedField, option.attr('optionset'), btnId, optionId); - enable(suggestedField); - jQuery('#' + btnId).css("display", ""); - } - else { - disable(suggestedField); - jQuery('#' + btnId).css("display", "none"); - } -} - -function removeOption(elementId) { - jQuery('#' + elementId + ' option:selected').remove(); -} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateCaseAggregationForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateCaseAggregationForm.js 2014-08-06 15:20:54 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateCaseAggregationForm.js 1970-01-01 00:00:00 +0000 @@ -1,15 +0,0 @@ -jQuery(document).ready( function(){ - - validation2( 'updateCaseAggregationForm', function( form ) - { - form.submit(); - },{ - 'rules' : getValidationRules( "caseAggregation" ) - }); - - checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action", {id:getFieldValue('id')}); - - byId('name').focus(); - jQuery("#tabs").tabs(); - -}); \ No newline at end of file