dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29983
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15205: Tracker service code style/cleanup
------------------------------------------------------------
revno: 15205
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-05-09 17:49:36 +0200
message:
Tracker service code style/cleanup
modified:
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipTypeStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAuditStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueDeletionHandler.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2014-05-09 15:49:36 +0000
@@ -90,8 +90,10 @@
return new ArrayList<ProgramInstance>();
}
- return getCriteria( Restrictions.in( "program", programs ) ).createAlias( "entityInstance", "entityInstance" )
- .add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).list();
+ return getCriteria(
+ Restrictions.in( "program", programs ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).list();
}
@Override
@@ -103,9 +105,11 @@
return new ArrayList<ProgramInstance>();
}
- return getCriteria( Restrictions.eq( "status", status ), Restrictions.in( "program", programs ) )
- .createAlias( "entityInstance", "entityInstance" ).add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) )
- .list();
+ return getCriteria(
+ Restrictions.eq( "status", status ),
+ Restrictions.in( "program", programs ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).list();
}
@SuppressWarnings( "unchecked" )
@@ -147,14 +151,22 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Integer min, Integer max )
{
- Criteria criteria = getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) )
- .add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).createAlias( "entityInstance", "entityInstance" )
- .addOrder( Order.asc( "entityInstance.id" ) );
+ Criteria criteria = getCriteria(
+ Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ).
+ add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ addOrder( Order.asc( "entityInstance.id" ) );
- if ( min != null && max != null )
- {
- criteria.setFirstResult( min ).setMaxResults( max );
- }
+ if ( min != null )
+ {
+ criteria.setFirstResult( min );
+ }
+
+ if ( max != null )
+ {
+ criteria.setMaxResults( max );
+ }
+
return criteria.list();
}
@@ -162,10 +174,14 @@
public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Date startDate,
Date endDate )
{
- return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ),
- Restrictions.ge( "enrollmentDate", startDate ), Restrictions.le( "enrollmentDate", endDate ) )
- .createAlias( "entityInstance", "entityInstance" ).add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) )
- .addOrder( Order.asc( "entityInstance.id" ) ).list();
+ return getCriteria(
+ Restrictions.eq( "program", program ),
+ Restrictions.isNull( "endDate" ),
+ Restrictions.ge( "enrollmentDate", startDate ),
+ Restrictions.le( "enrollmentDate", endDate ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).
+ addOrder( Order.asc( "entityInstance.id" ) ).list();
}
@SuppressWarnings( "unchecked" )
@@ -177,41 +193,54 @@
.createAlias( "entityInstance", "entityInstance" ).createAlias( "entityInstance.organisationUnit", "organisationUnit" )
.add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).addOrder( Order.asc( "entityInstance.id" ) );
- if ( min != null && max != null )
- {
- criteria.setFirstResult( min ).setMaxResults( max );
- }
-
+ if ( min != null )
+ {
+ criteria.setFirstResult( min );
+ }
+
+ if ( max != null )
+ {
+ criteria.setMaxResults( max );
+ }
+
return criteria.list();
}
public int count( Program program, OrganisationUnit organisationUnit )
{
- Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) )
- .createAlias( "entityInstance", "entityInstance" ).add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) )
- .setProjection( Projections.rowCount() ).uniqueResult();
+ Number rs = (Number) getCriteria(
+ Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ add( Restrictions.eq( "entityInstance.organisationUnit", organisationUnit ) ).
+ setProjection( Projections.rowCount() ).uniqueResult();
+
return rs != null ? rs.intValue() : 0;
}
public int count( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
{
- Number rs = (Number) getCriteria( Restrictions.eq( "program", program ),
- Restrictions.ge( "enrollmentDate", startDate ), Restrictions.le( "enrollmentDate", endDate ) )
- .createAlias( "entityInstance", "entityInstance" ).createAlias( "entityInstance.organisationUnit", "organisationUnit" )
- .add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).setProjection( Projections.rowCount() )
- .uniqueResult();
+ Number rs = (Number) getCriteria(
+ Restrictions.eq( "program", program ),
+ Restrictions.ge( "enrollmentDate", startDate ),
+ Restrictions.le( "enrollmentDate", endDate ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ createAlias( "entityInstance.organisationUnit", "organisationUnit" ).
+ add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).
+ setProjection( Projections.rowCount() ).uniqueResult();
return rs != null ? rs.intValue() : 0;
}
- public int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate,
- Date endDate )
+ public int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
{
- Number rs = (Number) getCriteria( Restrictions.eq( "program", program ),
- Restrictions.between( "enrollmentDate", startDate, endDate ) ).createAlias( "entityInstance", "entityInstance" )
- .createAlias( "entityInstance.organisationUnit", "organisationUnit" )
- .add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).add( Restrictions.eq( "status", status ) )
- .setProjection( Projections.rowCount() ).uniqueResult();
+ Number rs = (Number) getCriteria(
+ Restrictions.eq( "program", program ),
+ Restrictions.between( "enrollmentDate", startDate, endDate ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ createAlias( "entityInstance.organisationUnit", "organisationUnit" ).
+ add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).
+ add( Restrictions.eq( "status", status ) ).
+ setProjection( Projections.rowCount() ).uniqueResult();
return rs != null ? rs.intValue() : 0;
}
@@ -220,12 +249,16 @@
public Collection<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate )
{
- return getCriteria( Restrictions.eq( "program", program ),
- Restrictions.between( "enrollmentDate", startDate, endDate ) ).createAlias( "entityInstance", "entityInstance" )
- .createAlias( "entityInstance.organisationUnit", "organisationUnit" )
- .add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).add( Restrictions.eq( "status", status ) )
- .list();
+ return getCriteria(
+ Restrictions.eq( "program", program ),
+ Restrictions.between( "enrollmentDate", startDate, endDate ) ).
+ createAlias( "entityInstance", "entityInstance" ).
+ createAlias( "entityInstance.organisationUnit", "organisationUnit" ).
+ add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).
+ add( Restrictions.eq( "status", status ) ).list();
}
+
+ //TODO from here this class must be rewritten
public Collection<SchedulingProgramObject> getSendMesssageEvents( String dateToCompare )
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageDataElementStore.java 2014-05-09 15:49:36 +0000
@@ -42,7 +42,6 @@
/**
* @author Viet Nguyen
- * @version $Id$
*/
public class HibernateProgramStageDataElementStore
implements ProgramStageDataElementStore
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2014-05-07 10:09:11 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2014-05-09 15:49:36 +0000
@@ -86,9 +86,10 @@
@SuppressWarnings( "unchecked" )
public ProgramStageInstance get( ProgramInstance programInstance, ProgramStage programStage )
{
- List<ProgramStageInstance> list = new ArrayList<ProgramStageInstance>( getCriteria(
- Restrictions.eq( "programInstance", programInstance ), Restrictions.eq( "programStage", programStage ) )
- .addOrder( Order.asc( "id" ) ).list() );
+ List<ProgramStageInstance> list = getCriteria(
+ Restrictions.eq( "programInstance", programInstance ),
+ Restrictions.eq( "programStage", programStage ) ).
+ addOrder( Order.asc( "id" ) ).list();
return list.isEmpty() ? null : list.get( list.size() - 1 );
}
@@ -97,10 +98,10 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramStageInstance> getAll( ProgramInstance programInstance, ProgramStage programStage )
{
- Criteria criteria = getCriteria( Restrictions.eq( "programInstance", programInstance ),
- Restrictions.eq( "programStage", programStage ) ).addOrder( Order.asc( "id" ) );
-
- return criteria.list();
+ return getCriteria(
+ Restrictions.eq( "programInstance", programInstance ),
+ Restrictions.eq( "programStage", programStage ) )
+ .addOrder( Order.asc( "id" ) ).list();
}
@Override
@@ -114,7 +115,8 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances, boolean completed )
{
- return getCriteria( Restrictions.in( "programInstance", programInstances ),
+ return getCriteria(
+ Restrictions.in( "programInstance", programInstances ),
Restrictions.eq( "completed", completed ) ).list();
}
@@ -127,6 +129,8 @@
return getQuery( hql ).setEntity( "entityInstance", entityInstance ).setBoolean( "completed", completed ).list();
}
+ // TODO this class must be re-written from here
+
@Override
public void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit )
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageStore.java 2014-05-09 15:49:36 +0000
@@ -48,7 +48,8 @@
public ProgramStage getByNameAndProgram( String name, Program program )
{
- return (ProgramStage) getCriteria( Restrictions.eq( "name", name ), Restrictions.eq( "program", program ) )
- .uniqueResult();
+ return (ProgramStage) getCriteria(
+ Restrictions.eq( "name", name ),
+ Restrictions.eq( "program", program ) ).uniqueResult();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2014-04-06 17:03:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStore.java 2014-05-09 15:49:36 +0000
@@ -94,6 +94,7 @@
criteria2.add( Restrictions.eq( "orgunitMember.id", organisationUnit.getId() ) );
Collection<Program> programs = new HashSet<Program>();
+
if ( criteria1.list() != null )
{
programs.addAll( criteria1.list() );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipStore.java 2014-05-09 15:49:36 +0000
@@ -48,7 +48,9 @@
@SuppressWarnings( "unchecked" )
public Collection<Relationship> getForTrackedEntityInstance( TrackedEntityInstance instance )
{
- return getCriteria( Restrictions.disjunction().add( Restrictions.eq( "entityInstanceA", instance ) ).add(
+ return getCriteria(
+ Restrictions.disjunction().add(
+ Restrictions.eq( "entityInstanceA", instance ) ).add(
Restrictions.eq( "entityInstanceB", instance ) ) ).list();
}
@@ -61,15 +63,17 @@
@SuppressWarnings( "unchecked" )
public Collection<Relationship> get( TrackedEntityInstance entityInstanceA, RelationshipType relationshipType )
{
- return getCriteria( Restrictions.eq( "entityInstanceA", entityInstanceA ),
+ return getCriteria(
+ Restrictions.eq( "entityInstanceA", entityInstanceA ),
Restrictions.eq( "relationshipType", relationshipType ) ).list();
}
public Relationship get( TrackedEntityInstance entityInstanceA, TrackedEntityInstance entityInstanceB, RelationshipType relationshipType )
{
- return (Relationship) getCriteria( Restrictions.eq( "entityInstanceA", entityInstanceA ),
- Restrictions.eq( "entityInstanceB", entityInstanceB ), Restrictions.eq( "relationshipType", relationshipType ) )
- .uniqueResult();
+ return (Relationship) getCriteria(
+ Restrictions.eq( "entityInstanceA", entityInstanceA ),
+ Restrictions.eq( "entityInstanceB", entityInstanceB ),
+ Restrictions.eq( "relationshipType", relationshipType ) ).uniqueResult();
}
public Relationship get( TrackedEntityInstance entityInstanceA, TrackedEntityInstance entityInstanceB )
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipTypeStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipTypeStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/relationship/hibernate/HibernateRelationshipTypeStore.java 2014-05-09 15:49:36 +0000
@@ -42,7 +42,8 @@
{
public RelationshipType getRelationshipType( String aIsToB, String bIsToA )
{
- return (RelationshipType) getCriteria( Restrictions.eq( "aIsToB", aIsToB ), Restrictions.eq( "bIsToA", bIsToA ) )
- .uniqueResult();
+ return (RelationshipType) getCriteria(
+ Restrictions.eq( "aIsToB", aIsToB ),
+ Restrictions.eq( "bIsToA", bIsToA ) ).uniqueResult();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java 2014-04-14 15:59:05 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeGroupService.java 2014-05-09 15:49:36 +0000
@@ -123,8 +123,7 @@
}
@Override
- public Collection<? extends TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetweenByName( String name,
- int min, int max )
+ public Collection<? extends TrackedEntityAttributeGroup> getTrackedEntityAttributeGroupsBetweenByName( String name, int min, int max )
{
return attributeGroupStore.getAllLikeNameOrderedName( name, min, max );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java 2014-03-27 23:40:38 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java 2014-05-09 15:49:36 +0000
@@ -141,7 +141,6 @@
value = attributeValue.getValue();
}
}
-
}
templateMessage = templateMessage.replace( match, value );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAuditStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAuditStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityAuditStore.java 2014-05-09 15:49:36 +0000
@@ -57,8 +57,10 @@
@Override
public TrackedEntityAudit get( Integer entityInstanceId, String visitor, Date date, String accessedModule )
{
- return (TrackedEntityAudit) getCriteria( Restrictions.eq( "entityInstance.id", entityInstanceId ),
- Restrictions.eq( "visitor", visitor ), Restrictions.eq( "date", date ),
+ return (TrackedEntityAudit) getCriteria(
+ Restrictions.eq( "entityInstance.id", entityInstanceId ),
+ Restrictions.eq( "visitor", visitor ),
+ Restrictions.eq( "date", date ),
Restrictions.eq( "accessedModule", accessedModule ) ).uniqueResult();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java 2014-03-19 06:44:30 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueStore.java 2014-05-09 15:49:36 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Collection;
import org.hibernate.Query;
@@ -77,7 +78,8 @@
@Override
public TrackedEntityAttributeValue get( TrackedEntityInstance entityInstance, TrackedEntityAttribute attribute )
{
- return (TrackedEntityAttributeValue) getCriteria( Restrictions.eq( "entityInstance", entityInstance ),
+ return (TrackedEntityAttributeValue) getCriteria(
+ Restrictions.eq( "entityInstance", entityInstance ),
Restrictions.eq( "attribute", attribute ) ).uniqueResult();
}
@@ -99,6 +101,11 @@
@SuppressWarnings( "unchecked" )
public Collection<TrackedEntityAttributeValue> get( Collection<TrackedEntityInstance> entityInstances )
{
+ if ( entityInstances == null || entityInstances.isEmpty() )
+ {
+ return new ArrayList<TrackedEntityAttributeValue>();
+ }
+
return getCriteria( Restrictions.in( "entityInstance", entityInstances ) ).list();
}
@@ -106,7 +113,8 @@
@SuppressWarnings( "unchecked" )
public Collection<TrackedEntityAttributeValue> searchByValue( TrackedEntityAttribute attribute, String searchText )
{
- return getCriteria( Restrictions.eq( "attribute", attribute ),
+ return getCriteria(
+ Restrictions.eq( "attribute", attribute ),
Restrictions.ilike( "value", "%" + searchText + "%" ) ).list();
}
@@ -115,8 +123,9 @@
public Collection<TrackedEntityInstance> getTrackedEntityInstances( TrackedEntityAttribute attribute, String value )
{
return getCriteria(
- Restrictions.and( Restrictions.eq( "attribute", attribute ), Restrictions.eq( "value", value ) ) )
- .setProjection( Projections.property( "entityInstance" ) ).list();
+ Restrictions.and( Restrictions.eq( "attribute", attribute ),
+ Restrictions.eq( "value", value ) ) ).
+ setProjection( Projections.property( "entityInstance" ) ).list();
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueService.java 2014-05-09 15:49:36 +0000
@@ -41,7 +41,6 @@
/**
* @author Abyot Asalefew Gizaw
- * @version $Id$
*/
@Transactional
public class DefaultTrackedEntityDataValueService
@@ -108,8 +107,7 @@
return dataValueStore.get( programStageInstance, dataElements );
}
- public Collection<TrackedEntityDataValue> getTrackedEntityDataValues(
- Collection<ProgramStageInstance> programStageInstances )
+ public Collection<TrackedEntityDataValue> getTrackedEntityDataValues( Collection<ProgramStageInstance> programStageInstances )
{
return dataValueStore.get( programStageInstances );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueDeletionHandler.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueDeletionHandler.java 2014-05-09 15:49:36 +0000
@@ -38,8 +38,6 @@
/**
* @author Chau Thu Tran
- * @version $ TrackedEntityDataValueDeletionHandler.java Jun 24, 2011 1:10:46 PM $
- *
*/
public class TrackedEntityDataValueDeletionHandler
extends DeletionHandler
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueStore.java 2014-05-09 15:49:36 +0000
@@ -71,6 +71,11 @@
public Collection<TrackedEntityDataValue> get( ProgramStageInstance programStageInstance,
Collection<DataElement> dataElements )
{
+ if ( dataElements == null || dataElements.isEmpty() )
+ {
+ return new ArrayList<TrackedEntityDataValue>();
+ }
+
String hql = "from TrackedEntityDataValue pdv where pdv.dataElement in ( :dataElements ) "
+ "and pdv.programStageInstance = :programStageInstance";
@@ -99,6 +104,11 @@
public Collection<TrackedEntityDataValue> get( TrackedEntityInstance entityInstance, Collection<DataElement> dataElements, Date startDate,
Date endDate )
{
+ if ( dataElements == null || dataElements.isEmpty() )
+ {
+ return new ArrayList<TrackedEntityDataValue>();
+ }
+
String hql = "from TrackedEntityDataValue pdv where pdv.dataElement in ( :dataElements ) "
+ "and pdv.programStageInstance.programInstance.entityInstance = :entityInstance "
+ "and pdv.programStageInstance.executionDate >= :startDate and pdv.programStageInstance.executionDate <= :endDate ";