dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38430
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19568: Minor fixes and docs
------------------------------------------------------------
revno: 19568
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 10:26:22 +0700
message:
Minor fixes and docs
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceQueryParams.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.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-api/src/main/java/org/hisp/dhis/program/ProgramInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceQueryParams.java 2015-07-07 06:11:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceQueryParams.java 2015-07-08 03:26:22 +0000
@@ -46,7 +46,7 @@
public static final int DEFAULT_PAGE_SIZE = 50;
/**
- * Last updated for enrollment.
+ * Last updated for PI.
*/
private Date lastUpdated;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2015-07-07 06:11:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2015-07-08 03:26:22 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -85,13 +86,68 @@
*/
ProgramInstance getProgramInstance( String uid );
+ /**
+ * Returns a ProgramInstanceQueryParams based on the given input.
+ *
+ * @param ou the set of organisation unit identifiers.
+ * @param ouMode the OrganisationUnitSelectionMode.
+ * @param lastUpdated the last updated for PI.
+ * @param program the Program identifier.
+ * @param programStatus the ProgramStatus in the given program.
+ * @param programStartDate the start date for enrollment in the given
+ * Program.
+ * @param programEndDate the end date for enrollment in the given Program.
+ * @param trackedEntity the TrackedEntity uid.
+ * @param trackedEntityInstance the TrackedEntityInstance uid.
+ * @param followUp indicates follow up status in the given Program.
+ * @param page the page number.
+ * @param pageSize the page size.
+ * @param totalPages indicates whether to include the total number of pages.
+ * @param skipPaging whether to skip paging.
+ * @return a ProgramInstanceQueryParams.
+ */
ProgramInstanceQueryParams getFromUrl( Set<String> ou, OrganisationUnitSelectionMode ouMode, Date lastUpdated, String program,
ProgramStatus programStatus, Date programStartDate, Date programEndDate, String trackedEntity, String trackedEntityInstance,
Boolean followUp, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging );
+ /**
+ * Returns a list with program instance values based on the given
+ * ProgramInstanceQueryParams.
+ *
+ * @param params the ProgramInstanceQueryParams.
+ * @return List of PIs matching the params
+ */
List<ProgramInstance> getProgramInstances( ProgramInstanceQueryParams params );
/**
+ * Returns the number of program instance matches based on the given
+ * ProgramInstanceQueryParams.
+ *
+ * @param params the ProgramInstanceQueryParams.
+ * @return Number of PIs matching the params
+ */
+ int countProgramInstances( ProgramInstanceQueryParams params );
+
+ /**
+ * Decides whether current user is authorized to perform the given query.
+ * IllegalQueryException is thrown if not.
+ *
+ * @param params the ProgramInstanceQueryParams.
+ */
+ void decideAccess( ProgramInstanceQueryParams params );
+
+ /**
+ * Validates the given ProgramInstanceQueryParams. The params is
+ * considered valid if no exception are thrown and the method returns
+ * normally.
+ *
+ * @param params the ProgramInstanceQueryParams.
+ * @throws IllegalQueryException if the given params is invalid.
+ */
+ void validate( ProgramInstanceQueryParams params )
+ throws IllegalQueryException;
+
+ /**
* Retrieve program instances on a program
*
* @param program Program
@@ -255,21 +311,6 @@
Collection<Integer> orgunitIds, Date startDate, Date endDate );
/**
- * Retrieve program instances with a certain status on a program and an
- * orgunit ids list for a period
- *
- * @param status of program-instance, include STATUS_ACTIVE,
- * STATUS_COMPLETED and STATUS_CANCELLED
- * @param program ProgramInstance
- * @param orgunitIds A list of orgunit ids
- * @param startDate The start date for retrieving on enrollment-date
- * @param endDate The end date for retrieving on enrollment-date
- * @return ProgramInstance list
- */
- List<ProgramInstance> getProgramInstancesByStatus( Integer status, Program program,
- Collection<Integer> orgunitIds, Date startDate, Date endDate, Integer min, Integer max );
-
- /**
* Get the number of program instances of a program which have a certain
* status and an orgunit ids list for a period
*
@@ -284,13 +325,12 @@
int countProgramInstancesByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate,
Date endDate );
-
/**
* Retrieve scheduled list of entityInstances registered
*
* @return A SchedulingProgramObject list
*/
- Collection<SchedulingProgramObject> getScheduleMesssages();
+ Collection<SchedulingProgramObject> getScheduledMessages();
/**
* Enroll a TrackedEntityInstance into a program. Must be run inside a transaction.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2015-05-01 14:30:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2015-07-08 03:26:22 +0000
@@ -64,6 +64,11 @@
public static final int DEFAULT_PAGE_SIZE = 50;
/**
+ * Last updated for TEI.
+ */
+ private Date lastUpdated;
+
+ /**
* Query value, will apply to all relevant attributes.
*/
private QueryFilter query;
@@ -525,6 +530,16 @@
// Getters and setters
// -------------------------------------------------------------------------
+ public Date getLastUpdated()
+ {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated( Date lastUpdated )
+ {
+ this.lastUpdated = lastUpdated;
+ }
+
public QueryFilter getQuery()
{
return query;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java 2015-07-03 08:41:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java 2015-07-08 03:26:22 +0000
@@ -94,13 +94,13 @@
{
String ID = TrackedEntityInstanceService.class.getName();
- final int ERROR_NONE = 0;
- final int ERROR_DUPLICATE_IDENTIFIER = 1;
- final int ERROR_ENROLLMENT = 2;
-
- final String SEPARATOR = "_";
-
- final String F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS = "F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS";
+ int ERROR_NONE = 0;
+ int ERROR_DUPLICATE_IDENTIFIER = 1;
+ int ERROR_ENROLLMENT = 2;
+
+ String SEPARATOR = "_";
+
+ String F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS = "F_TRACKED_ENTITY_INSTANCE_SEARCH_IN_ALL_ORGUNITS";
/**
* Returns a grid with tracked entity instance values based on the given
@@ -111,8 +111,22 @@
*/
Grid getTrackedEntityInstancesGrid( TrackedEntityInstanceQueryParams params );
+ /**
+ * Returns a list with tracked entity instance values based on the given
+ * TrackedEntityInstanceQueryParams.
+ *
+ * @param params the TrackedEntityInstanceQueryParams.
+ * @return List of TEIs matching the params
+ */
List<TrackedEntityInstance> getTrackedEntityInstances( TrackedEntityInstanceQueryParams params );
+ /**
+ * Returns the number of tracked entity instance matches based on the given
+ * TrackedEntityInstanceQueryParams.
+ *
+ * @param params the TrackedEntityInstanceQueryParams.
+ * @return Number of TEIs matching the params
+ */
int countTrackedEntityInstances( TrackedEntityInstanceQueryParams params );
/**
@@ -121,10 +135,10 @@
* @param query the query string.
* @param attribute the set of attributes.
* @param filter the set of filters.
- * @param ou the set of organisatio unit identifiers.
+ * @param ou the set of organisation unit identifiers.
* @param ouMode the OrganisationUnitSelectionMode.
* @param program the Program identifier.
- * @param programStatus the ProgramStatus in the given orogram.
+ * @param programStatus the ProgramStatus in the given program.
* @param followUp indicates follow up status in the given Program.
* @param programStartDate the start date for enrollment in the given
* Program.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-07-07 08:50:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-07-08 03:26:22 +0000
@@ -266,6 +266,9 @@
@Override
public List<ProgramInstance> getProgramInstances( ProgramInstanceQueryParams params )
{
+ decideAccess( params );
+ validate( params );
+
User user = currentUserService.getCurrentUser();
if ( user != null && params.isOrganisationUnitMode( OrganisationUnitSelectionMode.ACCESSIBLE ) )
@@ -303,6 +306,57 @@
}
@Override
+ public int countProgramInstances( ProgramInstanceQueryParams params )
+ {
+ decideAccess( params );
+ validate( params );
+
+ User user = currentUserService.getCurrentUser();
+
+ if ( user != null && params.isOrganisationUnitMode( OrganisationUnitSelectionMode.ACCESSIBLE ) )
+ {
+ params.setOrganisationUnits( user.getDataViewOrganisationUnitsWithFallback() );
+ params.setOrganisationUnitMode( OrganisationUnitSelectionMode.DESCENDANTS );
+ }
+ else if ( params.isOrganisationUnitMode( CHILDREN ) )
+ {
+ Set<OrganisationUnit> organisationUnits = new HashSet<>();
+ organisationUnits.addAll( params.getOrganisationUnits() );
+
+ for ( OrganisationUnit organisationUnit : params.getOrganisationUnits() )
+ {
+ organisationUnits.addAll( organisationUnit.getChildren() );
+ }
+
+ params.setOrganisationUnits( organisationUnits );
+ }
+
+ for ( OrganisationUnit organisationUnit : params.getOrganisationUnits() )
+ {
+ if ( !organisationUnit.hasLevel() )
+ {
+ organisationUnit.setLevel( organisationUnitService.getLevelOfOrganisationUnit( organisationUnit.getId() ) );
+ }
+ }
+
+ params.setSkipPaging( true );
+
+ return programInstanceStore.countProgramInstances( params );
+ }
+
+ @Override
+ public void decideAccess( ProgramInstanceQueryParams params )
+ {
+
+ }
+
+ @Override
+ public void validate( ProgramInstanceQueryParams params ) throws IllegalQueryException
+ {
+
+ }
+
+ @Override
public List<ProgramInstance> getProgramInstances( Program program )
{
return programInstanceStore.get( program );
@@ -382,30 +436,27 @@
@Override
public List<Grid> getProgramInstanceReport( TrackedEntityInstance instance, I18n i18n )
{
-
List<Grid> grids = new ArrayList<>();
// ---------------------------------------------------------------------
// Dynamic attributes
// ---------------------------------------------------------------------
- Collection<Program> programs = programService
- .getProgramsByCurrentUser( ProgramType.WITH_REGISTRATION );
+ Collection<Program> programs = programService.getProgramsByCurrentUser( ProgramType.WITH_REGISTRATION );
programs.addAll( programService.getProgramsByCurrentUser( ProgramType.WITH_REGISTRATION ) );
- Collection<TrackedEntityAttributeValue> attributeValues = attributeValueService
- .getTrackedEntityAttributeValues( instance );
+ Collection<TrackedEntityAttributeValue> attributeValues = attributeValueService.getTrackedEntityAttributeValues( instance );
Iterator<TrackedEntityAttributeValue> iterAttribute = attributeValues.iterator();
for ( Program program : programs )
{
- List<TrackedEntityAttribute> atttributes = program.getTrackedEntityAttributes();
+ List<TrackedEntityAttribute> attributes = program.getTrackedEntityAttributes();
while ( iterAttribute.hasNext() )
{
TrackedEntityAttributeValue attributeValue = iterAttribute.next();
- if ( !atttributes.contains( attributeValue.getAttribute() ) )
+ if ( !attributes.contains( attributeValue.getAttribute() ) )
{
iterAttribute.remove();
}
@@ -562,14 +613,7 @@
}
@Override
- public List<ProgramInstance> getProgramInstancesByStatus( Integer status, Program program,
- Collection<Integer> orgunitIds, Date startDate, Date endDate, Integer min, Integer max )
- {
- return programInstanceStore.getByStatus( status, program, orgunitIds, startDate, endDate, min, max );
- }
-
- @Override
- public Collection<SchedulingProgramObject> getScheduleMesssages()
+ public Collection<SchedulingProgramObject> getScheduledMessages()
{
Collection<SchedulingProgramObject> result = programInstanceStore
.getSendMesssageEvents( TrackedEntityInstanceReminder.ENROLLEMENT_DATE_TO_COMPARE );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-07-07 08:50:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2015-07-08 03:26:22 +0000
@@ -188,6 +188,8 @@
}
}
+ params.setSkipPaging( true );
+
return trackedEntityInstanceStore.countTrackedEntityInstances( params );
}
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/scheduling/SendScheduledMessageTask.java 2015-07-08 03:26:22 +0000
@@ -206,7 +206,7 @@
{
notifier.notify( taskId, "Start to prepare reminder messages for enrollements" );
- Collection<SchedulingProgramObject> schedulingProgramObjects = programInstanceService.getScheduleMesssages();
+ Collection<SchedulingProgramObject> schedulingProgramObjects = programInstanceService.getScheduledMessages();
for ( SchedulingProgramObject schedulingProgramObject : schedulingProgramObjects )
{