dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28242
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14082: Fixed bug - Don't run aggregate query builder formulas wtih Age dynamic atrtibute.
------------------------------------------------------------
revno: 14082
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-02-20 23:11:16 +0700
message:
Fixed bug - Don't run aggregate query builder formulas wtih Age dynamic atrtibute.
modified:
dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-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 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2014-02-20 16:11:16 +0000
@@ -641,20 +641,26 @@
*/
private String getConditionForTrackedEntityAttribute( String attributeId, Collection<Integer> orgunitIds, boolean isExist )
{
- String sql = " EXISTS ( SELECT * FROM trackedentityattributevalue _pav " + " WHERE _pav.trackedentityinstanceid=pi.trackedentityinstanceid ";
+ String sql = " SELECT * FROM trackedentityattributevalue _pav " + " WHERE _pav.trackedentityinstanceid=pi.trackedentityinstanceid ";
if ( attributeId.split( SEPARATOR_ID ).length == 2 )
{
- sql += " AND _pav.trackedentityattributeid=" + attributeId.split( "\\." )[0]
- + " AND DATE(now) - DATE( _pav.value ) ";
+ attributeId = attributeId.split( SEPARATOR_ID )[0];
+ sql += " AND _pav.trackedentityattributeid=" + attributeId
+ + " AND DATE(now()) - DATE( _pav.value ) ";
}
- if ( isExist )
+ else
{
sql += " AND _pav.trackedentityattributeid=" + attributeId + " AND _pav.value ";
}
+
+ if ( isExist )
+ {
+ sql = " EXISTS ( " + sql;
+ }
else
{
- sql = " NOT " + sql;
+ sql = " NOT ( " + sql;
}
return sql;
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java 2014-02-20 16:11:16 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.validation.ValidationCriteria;
@@ -52,7 +53,7 @@
{
this.programService = programService;
}
-
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -102,4 +103,12 @@
}
}
}
+
+ @Override
+ public String allowTrackedEntity( TrackedEntity trackedEntity )
+ {
+ Collection<Program> programs = programService.getProgramsByTrackedEntity( trackedEntity );
+
+ return (programs!=null && programs.size() > 0) ? ERROR : null;
+ }
}
=== 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 2014-02-17 14:36:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2014-02-20 16:11:16 +0000
@@ -83,6 +83,7 @@
import org.hisp.dhis.report.Report;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.sqlview.SqlView;
+import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeOption;
@@ -754,4 +755,13 @@
{
return null;
}
+
+ public void deleteTrackedEntity( TrackedEntity trackedEntity )
+ {
+ }
+
+ public String allowTrackedEntity( TrackedEntity trackedEntity )
+ {
+ return null;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java 2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveAttributeAction.java 2014-02-20 16:11:16 +0000
@@ -98,7 +98,7 @@
{
this.attributeValueService = attributeValueService;
}
-
+
public void setProgramService( ProgramService programService )
{
this.programService = programService;
@@ -163,7 +163,7 @@
String value = null;
Collection<TrackedEntityAttribute> attributes = attributeService.getAllTrackedEntityAttributes();
-
+
TrackedEntityAttributeValue attributeValue = null;
if ( attributes != null && attributes.size() > 0 )
@@ -172,9 +172,14 @@
{
value = request.getParameter( AddTrackedEntityInstanceAction.PREFIX_ATTRIBUTE + attribute.getId() );
attributeValue = attributeValueService.getTrackedEntityAttributeValue( entityInstance, attribute );
-
+
if ( StringUtils.isNotBlank( value ) )
{
+ if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_AGE ) )
+ {
+ value = format.formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) );
+ }
+
if ( attributeValue == null )
{
attributeValue = new TrackedEntityAttributeValue();
@@ -182,19 +187,13 @@
attributeValue.setAttribute( attribute );
attributeValue.setValue( value.trim() );
- if ( attribute.getValueType().equals( TrackedEntityAttribute.TYPE_AGE ) )
- {
- value = format
- .formatDate( TrackedEntityAttribute.getDateFromAge( Integer.parseInt( value ) ) );
- }
-
if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
{
TrackedEntityAttributeOption option = attributeService
.getTrackedEntityAttributeOption( Integer.parseInt( value ) );
-
+
if ( option != null )
- {
+ {
attributeValue.setAttributeOption( option );
attributeValue.setValue( option.getName() );
}
@@ -207,8 +206,8 @@
{
if ( TrackedEntityAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) )
{
- TrackedEntityAttributeOption option = attributeService.getTrackedEntityAttributeOption( NumberUtils.toInt( value,
- 0 ) );
+ TrackedEntityAttributeOption option = attributeService
+ .getTrackedEntityAttributeOption( NumberUtils.toInt( value, 0 ) );
if ( option != null )
{
attributeValue.setAttributeOption( option );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java 2014-02-17 15:00:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java 2014-02-20 16:11:16 +0000
@@ -27,6 +27,8 @@
package org.hisp.dhis.trackedentity.action.trackedentity;
+import org.hisp.dhis.common.DeleteNotAllowedException;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -59,11 +61,22 @@
this.id = id;
}
- private TrackedEntity trackedEntity;
-
- public TrackedEntity getTrackedEntity()
- {
- return trackedEntity;
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
}
// -------------------------------------------------------------------------
@@ -74,9 +87,21 @@
public String execute()
throws Exception
{
- TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( id );
-
- trackedEntityService.deleteTrackedEntity( trackedEntity );
+ try
+ {
+ TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( id );
+
+ trackedEntityService.deleteTrackedEntity( trackedEntity );
+ }
+ catch ( DeleteNotAllowedException ex )
+ {
+ if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) )
+ {
+ message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage();
+
+ return ERROR;
+ }
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm 2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm 2014-02-20 16:11:16 +0000
@@ -80,7 +80,8 @@
<select id="caseProperty" name="caseProperty" size="10" ondblclick="insertInfo(this, false);" onclick="getSuggestedValues(this.id, 'caSuggestedValues' )">
#foreach($attribute in $attributes)
#if($attribute.valueType=='age')
- <option suggested="" title="$attribute.displayName" value="[CA:$attribute.id.age]">$attribute.displayName</option>
+ #set($attId=$patientAttribute.id + ".age")
+ <option suggested="" title="$attribute.displayName" value="[CA:$attId]">$attribute.displayName</option>
#else
<option suggested="" title="$attribute.displayName" value="[CA:$attribute.id]">$attribute.displayName</option>
#end