dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22554
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10865: validate that program is assigned to ou/ou-group
------------------------------------------------------------
revno: 10865
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-17 14:40:18 +0700
message:
validate that program is assigned to ou/ou-group
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java
dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.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/ProgramService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-05-15 09:14:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-05-17 07:40:18 +0000
@@ -65,7 +65,6 @@
Collection<Program> getPrograms( int type, OrganisationUnit orgunit );
Program getProgram( String uid );
-
- Collection<Program> getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit );
+ Collection<Program> getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit );
}
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 2013-05-17 07:16:31 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/event/BaseEventService.java 2013-05-17 07:40:18 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.i18n.I18nManager;
import org.hisp.dhis.i18n.I18nManagerException;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
@@ -119,6 +120,31 @@
{
return new ImportSummary( ImportStatus.ERROR, "Event organisationUnitId does not point to a valid organisation unit." );
}
+ else
+ {
+ boolean assignedToOrganisationUnit = false;
+
+ if ( program.getOrganisationUnits().contains( organisationUnit ) )
+ {
+ assignedToOrganisationUnit = true;
+ }
+ else
+ {
+ for ( OrganisationUnitGroup organisationUnitGroup : program.getOrganisationUnitGroups() )
+ {
+ if ( organisationUnitGroup.getMembers().contains( organisationUnit ) )
+ {
+ assignedToOrganisationUnit = true;
+ break;
+ }
+ }
+ }
+
+ if ( !assignedToOrganisationUnit )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Program is not assigned to this organisation unit." );
+ }
+ }
if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
{