dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32193
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16446: changes to web api so that it is possible to create event with valid uid
------------------------------------------------------------
revno: 16446
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-19 14:59:01 +0200
message:
changes to web api so that it is possible to create event with valid uid
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js
--
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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-08-15 12:54:04 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-08-19 12:59:01 +0000
@@ -53,6 +53,7 @@
import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.ValidationUtils;
+import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.trackedentitycomment.TrackedEntityComment;
import org.hisp.dhis.trackedentitycomment.TrackedEntityCommentService;
@@ -186,8 +187,8 @@
"Event.trackedEntityInstance does not point to a valid trackedEntityInstance." );
}
- List<ProgramInstance> programInstances = new ArrayList<>(
- programInstanceService.getProgramInstances( entityInstance, program, ProgramInstance.STATUS_ACTIVE ) );
+ List<ProgramInstance> programInstances = new ArrayList<>( programInstanceService.getProgramInstances(
+ entityInstance, program, ProgramInstance.STATUS_ACTIVE ) );
if ( programInstances.isEmpty() )
{
@@ -237,7 +238,11 @@
if ( programStageInstance == null )
{
- return new ImportSummary( ImportStatus.ERROR, "Event.event did not point to a valid event" );
+ if ( !CodeGenerator.isValidCode( event.getEvent() ) )
+ {
+ return new ImportSummary( ImportStatus.ERROR,
+ "Event.event did not point to a valid event" );
+ }
}
}
}
@@ -245,8 +250,8 @@
}
else
{
- List<ProgramInstance> programInstances = new ArrayList<>(
- programInstanceService.getProgramInstances( program, ProgramInstance.STATUS_ACTIVE ) );
+ List<ProgramInstance> programInstances = new ArrayList<>( programInstanceService.getProgramInstances(
+ program, ProgramInstance.STATUS_ACTIVE ) );
if ( programInstances.isEmpty() )
{
@@ -269,7 +274,10 @@
if ( programStageInstance == null )
{
- return new ImportSummary( ImportStatus.ERROR, "Event.event did not point to a valid event" );
+ if ( !CodeGenerator.isValidCode( event.getEvent() ) )
+ {
+ return new ImportSummary( ImportStatus.ERROR, "Event.event did not point to a valid event" );
+ }
}
}
}
@@ -715,11 +723,16 @@
private ProgramStageInstance createProgramStageInstance( ProgramStage programStage,
- ProgramInstance programInstance, OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status,
- Coordinate coordinate, String storedBy )
+ ProgramInstance programInstance, OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status,
+ Coordinate coordinate, String storedBy, String programStageInstanceUid )
{
ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ if ( programStageInstanceUid != null )
+ {
+ programStageInstance.setUid( programStageInstanceUid );
+ }
+
updateProgramStageInstance( programStage, programInstance, organisationUnit, dueDate, executionDate, status,
coordinate, storedBy, programStageInstance );
@@ -728,7 +741,7 @@
private void updateProgramStageInstance( ProgramStage programStage, ProgramInstance programInstance,
- OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status, Coordinate coordinate,
+ OrganisationUnit organisationUnit, Date dueDate, Date executionDate, int status, Coordinate coordinate,
String storedBy, ProgramStageInstance programStageInstance )
{
programStageInstance.setProgramInstance( programInstance );
@@ -777,11 +790,6 @@
Date eventDate = DateUtils.getMediumDate( event.getEventDate() );
- /*
- * if ( eventDate == null ) { return new ImportSummary(
- * ImportStatus.ERROR, "Event.eventDate is not in a valid format." ); }
- */
-
Date dueDate = DateUtils.getMediumDate( event.getDueDate() );
String storedBy = getStoredBy( event, importSummary );
@@ -791,7 +799,7 @@
if ( programStageInstance == null )
{
programStageInstance = createProgramStageInstance( programStage, programInstance, organisationUnit,
- dueDate, eventDate, event.getStatus().getValue(), event.getCoordinate(), storedBy );
+ dueDate, eventDate, event.getStatus().getValue(), event.getCoordinate(), storedBy, event.getEvent() );
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-08-19 11:45:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-08-19 12:59:01 +0000
@@ -217,7 +217,7 @@
var attributes = {};
$(inputElement[0].attributes).each(function() {
- attributes[this.nodeName] = this.nodeValue;
+ attributes[this.nodeName] = this.value;
});
var deId = '', newInputField;