dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26287
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13029: in programInstanceStore, for hql that uses Restrictions.in, check for null/isEmpty since the sql ...
------------------------------------------------------------
revno: 13029
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-26 14:57:43 +0100
message:
in programInstanceStore, for hql that uses Restrictions.in, check for null/isEmpty since the sql built from it will fail
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.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-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-11-14 08:17:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2013-11-26 13:57:43 +0000
@@ -28,10 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
@@ -46,6 +42,11 @@
import org.hisp.dhis.program.SchedulingProgramObject;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+
/**
* @author Abyot Asalefew
*/
@@ -72,6 +73,11 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramInstance> get( Collection<Program> programs )
{
+ if ( programs == null || programs.isEmpty() )
+ {
+ return new ArrayList<ProgramInstance>();
+ }
+
return getCriteria( Restrictions.in( "program", programs ) ).list();
}
@@ -79,6 +85,11 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit )
{
+ if ( programs == null || programs.isEmpty() )
+ {
+ return new ArrayList<ProgramInstance>();
+ }
+
return getCriteria( Restrictions.in( "program", programs ) ).createAlias( "patient", "patient" )
.add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).list();
}
@@ -87,6 +98,11 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, int status )
{
+ if ( programs == null || programs.isEmpty() )
+ {
+ return new ArrayList<ProgramInstance>();
+ }
+
return getCriteria( Restrictions.eq( "status", status ), Restrictions.in( "program", programs ) )
.createAlias( "patient", "patient" ).add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
.list();
@@ -101,6 +117,11 @@
@SuppressWarnings( "unchecked" )
public Collection<ProgramInstance> get( Collection<Program> programs, Integer status )
{
+ if ( programs == null || programs.isEmpty() )
+ {
+ return new ArrayList<ProgramInstance>();
+ }
+
return getCriteria( Restrictions.in( "program", programs ), Restrictions.eq( "status", status ) ).list();
}
@@ -155,6 +176,7 @@
Restrictions.ge( "enrollmentDate", startDate ), Restrictions.le( "enrollmentDate", endDate ) )
.createAlias( "patient", "patient" ).createAlias( "patient.organisationUnit", "organisationUnit" )
.add( Restrictions.in( "organisationUnit.id", orgunitIds ) ).addOrder( Order.asc( "patient.id" ) );
+
if ( min != null && max != null )
{
criteria.setFirstResult( min ).setMaxResults( max );
@@ -234,16 +256,16 @@
String organisationunitName = rs.getString( "orgunitName" );
String programName = rs.getString( "programName" );
String incidentDate = rs.getString( "dateofincident" ).split( " " )[0];// just
- // get
- // date,
- // remove
- // timestamp
+ // get
+ // date,
+ // remove
+ // timestamp
String daysSinceIncidentDate = rs.getString( "days_since_incident_date" );
String erollmentDate = rs.getString( "enrollmentdate" ).split( " " )[0];// just
- // get
- // date,
- // remove
- // timestamp
+ // get
+ // date,
+ // remove
+ // timestamp
String daysSinceEnrollementDate = rs.getString( "days_since_erollment_date" );
message = message.replace( PatientReminder.TEMPLATE_MESSSAGE_PATIENT_NAME, patientName );