dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41778
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21314: support attribute scheme in AbstractEventService
------------------------------------------------------------
revno: 21314
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-04 14:02:34 +0700
message:
support attribute scheme in AbstractEventService
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.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-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 2015-12-04 05:41:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-12-04 07:02:34 +0000
@@ -249,17 +249,17 @@
protected ImportSummary addEvent( Event event, User user, ImportOptions importOptions )
{
- Program program = getProgram( event.getProgram() );
- ProgramStage programStage = getProgramStage( event.getProgramStage() );
+ if ( importOptions == null )
+ {
+ importOptions = new ImportOptions();
+ }
+
+ Program program = getProgram( importOptions.getIdSchemes().getProgramIdScheme(), event.getProgram() );
+ ProgramStage programStage = getProgramStage( importOptions.getIdSchemes().getProgramStageIdScheme(), event.getProgramStage() );
ProgramInstance programInstance;
ProgramStageInstance programStageInstance = null;
- if ( importOptions == null )
- {
- importOptions = new ImportOptions();
- }
-
if ( program == null )
{
return new ImportSummary( ImportStatus.ERROR, "Event.program does not point to a valid program" ).incrementIgnored();
@@ -741,7 +741,7 @@
for ( DataValue value : event.getDataValues() )
{
- DataElement dataElement = getDataElement( value.getDataElement() );
+ DataElement dataElement = getDataElement( importOptions.getIdSchemes().getDataElementIdScheme(), value.getDataElement() );
TrackedEntityDataValue dataValue = dataValueService.getTrackedEntityDataValue( programStageInstance, dataElement );
if ( !validateDataValue( dataElement, value.getValue(), importSummary ) )
@@ -1164,7 +1164,13 @@
ImportSummary importSummary = new ImportSummary();
importSummary.setStatus( ImportStatus.SUCCESS );
- boolean dryRun = importOptions != null && importOptions.isDryRun();
+
+ if ( importOptions == null )
+ {
+ importOptions = new ImportOptions();
+ }
+
+ boolean dryRun = importOptions.isDryRun();
Date eventDate = DateUtils.parseDate( event.getEventDate() );
@@ -1215,7 +1221,7 @@
}
else
{
- dataElement = getDataElement( dataValue.getDataElement() );
+ dataElement = getDataElement( importOptions.getIdSchemes().getDataElementIdScheme(), dataValue.getDataElement() );
}
if ( dataElement != null )
@@ -1322,18 +1328,18 @@
return organisationUnit;
}
- private Program getProgram( String programId )
- {
- return programCache.get( programId, new IdentifiableObjectCallable<>( manager, Program.class, programId ) );
- }
-
- private ProgramStage getProgramStage( String programStageId )
- {
- return programStageCache.get( programStageId, new IdentifiableObjectCallable<>( manager, ProgramStage.class, programStageId ) );
- }
-
- private DataElement getDataElement( String dataElementId )
- {
- return dataElementCache.get( dataElementId, new IdentifiableObjectCallable<>( manager, DataElement.class, dataElementId ) );
+ private Program getProgram( IdScheme idScheme, String id )
+ {
+ return programCache.get( id, new IdentifiableObjectCallable<>( manager, Program.class, idScheme, id ) );
+ }
+
+ private ProgramStage getProgramStage( IdScheme idScheme, String id )
+ {
+ return programStageCache.get( id, new IdentifiableObjectCallable<>( manager, ProgramStage.class, idScheme, id ) );
+ }
+
+ private DataElement getDataElement( IdScheme idScheme, String id )
+ {
+ return dataElementCache.get( id, new IdentifiableObjectCallable<>( manager, DataElement.class, idScheme, id ) );
}
}