dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28885
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14503: Tracker, moved some methods around
------------------------------------------------------------
revno: 14503
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-03-28 00:40:38 +0100
message:
Tracker, moved some methods around
modified:
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAuditService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.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/DefaultTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.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/trackedentity/DefaultTrackedEntityAttributeService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-26 17:39:16 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAttributeService.java 2014-03-27 23:40:38 +0000
@@ -172,7 +172,5 @@
public int getTrackedEntityAttributeCountByName( String name )
{
return attributeStore.getCountLikeName( name );
- }
-
-
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAuditService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAuditService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityAuditService.java 2014-03-27 23:40:38 +0000
@@ -96,5 +96,4 @@
{
return auditStore.get( instanceId, visitor, date, accessedModule );
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-03-21 07:30:53 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityFormService.java 2014-03-27 23:40:38 +0000
@@ -248,9 +248,9 @@
if ( hasBirthdate && hasAge )
{
dobType = "<select id=\'dobType\' name=\"dobType\" style=\'width:120px\' onchange=\'dobTypeOnChange(\"instanceForm\")\' >";
- dobType += " <option value=\"V\" >" + i18n.getString( "verified" ) + "</option>";
- dobType += " <option value=\"D\" >" + i18n.getString( "declared" ) + "</option>";
- dobType += " <option value=\"A\" >" + i18n.getString( "approximated" ) + "</option>";
+ dobType += "<option value=\"V\" >" + i18n.getString( "verified" ) + "</option>";
+ dobType += "<option value=\"D\" >" + i18n.getString( "declared" ) + "</option>";
+ dobType += "<option value=\"A\" >" + i18n.getString( "approximated" ) + "</option>";
dobType += "</select>";
}
else if ( hasBirthdate )
=== 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-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceReminderService.java 2014-03-27 23:40:38 +0000
@@ -96,8 +96,8 @@
}
@Override
- public String getMessageFromTemplate( TrackedEntityInstanceReminder reminder,
- ProgramInstance programInstance, I18nFormat format )
+ public String getMessageFromTemplate( TrackedEntityInstanceReminder reminder, ProgramInstance programInstance,
+ I18nFormat format )
{
TrackedEntityInstance entityInstance = programInstance.getEntityInstance();
String templateMessage = reminder.getTemplateMessage();
@@ -133,7 +133,8 @@
if ( matcher.group( 1 ).equals( ATTRIBUTE ) )
{
String uid = matcher.group( 2 );
- for ( TrackedEntityAttributeValue attributeValue : programInstance.getEntityInstance().getAttributeValues() )
+ for ( TrackedEntityAttributeValue attributeValue : programInstance.getEntityInstance()
+ .getAttributeValues() )
{
if ( attributeValue.getAttribute().getUid().equals( uid ) )
{
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2014-03-24 17:25:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2014-03-27 23:40:38 +0000
@@ -808,20 +808,14 @@
}
@Override
- public Collection<TrackedEntityInstance> searchTrackedEntityInstancesForMobile( String searchText,
-
- int orgUnitId, int attributeId )
+ public Collection<TrackedEntityInstance> searchTrackedEntityInstancesForMobile( String searchText, int orgUnitId, int attributeId )
{
-
Set<TrackedEntityInstance> entityInstances = new HashSet<TrackedEntityInstance>();
- entityInstances.addAll( getTrackedEntityInstancesByAttributeValue( searchText,
-
- attributeId, 0, Integer.MAX_VALUE ) );
+ entityInstances.addAll( getTrackedEntityInstancesByAttributeValue( searchText, attributeId, 0, Integer.MAX_VALUE ) );
if ( orgUnitId != 0 )
{
-
Set<TrackedEntityInstance> toRemoveList = new HashSet<TrackedEntityInstance>();
for ( TrackedEntityInstance instance : entityInstances )
@@ -834,6 +828,7 @@
}
entityInstances.removeAll( toRemoveList );
}
+
return entityInstances;
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-03-26 15:49:35 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-03-27 23:40:38 +0000
@@ -351,84 +351,6 @@
}
@Override
- // TODO this method must be changed - cannot retrieve one by one
- public Collection<TrackedEntityInstance> search( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
- Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
- Integer max )
- {
- String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
- statusEnrollment, min, max );
- Collection<TrackedEntityInstance> instances = new HashSet<TrackedEntityInstance>();
- try
- {
- instances = jdbcTemplate.query( sql, new RowMapper<TrackedEntityInstance>()
- {
- public TrackedEntityInstance mapRow( ResultSet rs, int rowNum )
- throws SQLException
- {
- return get( rs.getInt( 1 ) );
- }
- } );
- }
- catch ( Exception ex )
- {
- ex.printStackTrace();
- }
- return instances;
- }
-
- @Override
- public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
- Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
- Integer max )
- {
- String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
- statusEnrollment, min, max );
-
- List<Integer> programStageInstanceIds = new ArrayList<Integer>();
- try
- {
- programStageInstanceIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
- {
- public Integer mapRow( ResultSet rs, int rowNum )
- throws SQLException
- {
- return rs.getInt( "programstageinstanceid" );
- }
- } );
- }
- catch ( Exception ex )
- {
- ex.printStackTrace();
- }
-
- return programStageInstanceIds;
- }
-
- public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
- Integer statusEnrollment )
- {
- String sql = searchTrackedEntityInstanceSql( true, searchKeys, orgunits, followup, null, statusEnrollment,
- null, null );
- return jdbcTemplate.queryForObject( sql, Integer.class );
- }
-
- @Override
- public Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys,
- Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
- Integer statusEnrollment, Integer min, Integer max )
- {
- String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
- statusEnrollment, min, max );
-
- SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
- GridUtils.addRows( grid, rowSet );
-
- return grid;
- }
-
- @Override
@SuppressWarnings( "unchecked" )
public Collection<TrackedEntityInstance> getByPhoneNumber( String phoneNumber, Integer min, Integer max )
{
@@ -612,9 +534,87 @@
}
// -------------------------------------------------------------------------
- // Supportive methods TODO Remplement all this!
+ // TODO Everything from here downwards must be replaced or removed!
// -------------------------------------------------------------------------
+ @Override
+ // TODO this method must be changed - cannot retrieve one by one
+ public Collection<TrackedEntityInstance> search( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
+ Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
+ Integer max )
+ {
+ String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
+ statusEnrollment, min, max );
+ Collection<TrackedEntityInstance> instances = new HashSet<TrackedEntityInstance>();
+ try
+ {
+ instances = jdbcTemplate.query( sql, new RowMapper<TrackedEntityInstance>()
+ {
+ public TrackedEntityInstance mapRow( ResultSet rs, int rowNum )
+ throws SQLException
+ {
+ return get( rs.getInt( 1 ) );
+ }
+ } );
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ return instances;
+ }
+
+ @Override
+ public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
+ Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
+ Integer max )
+ {
+ String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
+ statusEnrollment, min, max );
+
+ List<Integer> programStageInstanceIds = new ArrayList<Integer>();
+ try
+ {
+ programStageInstanceIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
+ {
+ public Integer mapRow( ResultSet rs, int rowNum )
+ throws SQLException
+ {
+ return rs.getInt( "programstageinstanceid" );
+ }
+ } );
+ }
+ catch ( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+
+ return programStageInstanceIds;
+ }
+
+ public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
+ Integer statusEnrollment )
+ {
+ String sql = searchTrackedEntityInstanceSql( true, searchKeys, orgunits, followup, null, statusEnrollment,
+ null, null );
+ return jdbcTemplate.queryForObject( sql, Integer.class );
+ }
+
+ @Override
+ public Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys,
+ Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
+ Integer statusEnrollment, Integer min, Integer max )
+ {
+ String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
+ statusEnrollment, min, max );
+
+ SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+
+ GridUtils.addRows( grid, rowSet );
+
+ return grid;
+ }
+
private String searchTrackedEntityInstanceSql( boolean count, List<String> searchKeys,
Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
Integer statusEnrollment, Integer min, Integer max )
@@ -997,12 +997,10 @@
return orgUnitIds;
}
- @SuppressWarnings( { "unchecked" } )
+ @SuppressWarnings("unchecked")
@Override
- public Collection<TrackedEntityInstance> getByAttributeValue( String searchText, int attributeId, Integer min,
- Integer max )
+ public Collection<TrackedEntityInstance> getByAttributeValue( String searchText, int attributeId, Integer min, Integer max )
{
-
String hql = "FROM TrackedEntityAttributeValue pav WHERE lower (pav.value) LIKE lower ('%" + searchText
+ "%') AND pav.attribute.id =:attributeId order by pav.entityInstance";
@@ -1023,7 +1021,5 @@
}
return entityInstances;
-
}
-
-}
\ No newline at end of file
+}