dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28508
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14232: tracker web-api refactor, wip
------------------------------------------------------------
revno: 14232
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 09:22:01 +0100
message:
tracker web-api refactor, wip
removed:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Identifier.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/JacksonTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstance.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstances.java
added:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Relationship.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstance.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstances.java
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java
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/DefaultEventStore.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/AttributeSchemaDescriptor.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.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/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2014-03-17 08:22:01 +0000
@@ -32,8 +32,8 @@
import java.util.Collection;
import java.util.List;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.i18n.I18nManager;
@@ -230,7 +230,7 @@
public ImportSummary saveEnrollment( Enrollment enrollment )
{
org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( enrollment.getPerson() );
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( entityInstance );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( entityInstance );
Program program = getProgram( enrollment.getProgram() );
Enrollments enrollments = getEnrollments( program, trackedEntityInstance, EnrollmentStatus.ACTIVE );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2014-03-17 08:22:01 +0000
@@ -32,7 +32,7 @@
import java.io.InputStream;
import java.util.Collection;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.organisationunit.OrganisationUnit;
=== 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-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-03-17 08:22:01 +0000
@@ -38,7 +38,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.dxf2.importsummary.ImportConflict;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -164,17 +164,17 @@
if ( program.isRegistration() )
{
- if ( event.getPerson() == null )
+ if ( event.getTrackedEntityInstance() == null )
{
return new ImportSummary( ImportStatus.ERROR,
- "No Event.person was provided for registration based program." );
+ "No Event.trackedEntityInstance was provided for registration based program." );
}
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( event.getPerson() );
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( event.getTrackedEntityInstance() );
if ( entityInstance == null )
{
- return new ImportSummary( ImportStatus.ERROR, "Event.person does not point to a valid person." );
+ return new ImportSummary( ImportStatus.ERROR, "Event.trackedEntityInstance does not point to a valid trackedEntityInstance." );
}
List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>(
@@ -182,12 +182,12 @@
if ( programInstances.isEmpty() )
{
- return new ImportSummary( ImportStatus.ERROR, "Person " + entityInstance.getUid()
+ return new ImportSummary( ImportStatus.ERROR, "TrackedEntityInstance " + entityInstance.getUid()
+ " is not enrolled in program " + program.getUid() );
}
else if ( programInstances.size() > 1 )
{
- return new ImportSummary( ImportStatus.ERROR, "Person " + entityInstance.getUid()
+ return new ImportSummary( ImportStatus.ERROR, "TrackedEntityInstance " + entityInstance.getUid()
+ " have multiple active enrollments into program " + program.getUid()
+ " please check and correct your database." );
}
@@ -201,12 +201,12 @@
if ( programStageInstances.isEmpty() )
{
- return new ImportSummary( ImportStatus.ERROR, "Person " + entityInstance.getUid()
+ return new ImportSummary( ImportStatus.ERROR, "TrackedEntityInstance " + entityInstance.getUid()
+ " is not enrolled in programStage " + programStage.getUid() );
}
else if ( programStageInstances.size() > 1 )
{
- return new ImportSummary( ImportStatus.ERROR, "Person " + entityInstance.getUid()
+ return new ImportSummary( ImportStatus.ERROR, "TrackedEntityInstance " + entityInstance.getUid()
+ " have multiple active enrollments into programStage " + programStage.getUid()
+ " please check and correct your database for multiple active stages." );
}
@@ -561,7 +561,7 @@
if ( programStageInstance.getProgramInstance().getEntityInstance() != null )
{
- event.setPerson( programStageInstance.getProgramInstance().getEntityInstance().getUid() );
+ event.setTrackedEntityInstance( programStageInstance.getProgramInstance().getEntityInstance().getUid() );
}
event.setStatus( EventStatus.fromInt( programStageInstance.getStatus() ) );
@@ -573,7 +573,7 @@
if ( programStageInstance.getProgramInstance().getEntityInstance() != null )
{
- event.setPerson( programStageInstance.getProgramInstance().getEntityInstance().getUid() );
+ event.setTrackedEntityInstance( programStageInstance.getProgramInstance().getEntityInstance().getUid() );
}
if ( programStageInstance.getProgramStage().getCaptureCoordinates() )
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/DefaultEventStore.java 2014-03-17 08:22:01 +0000
@@ -31,7 +31,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
@@ -168,7 +168,7 @@
{
List<Event> events = new ArrayList<Event>();
- Integer personId = null;
+ Integer trackedEntityInstanceId = null;
if ( trackedEntityInstance != null )
{
@@ -176,12 +176,12 @@
if ( entityInstance != null )
{
- personId = entityInstance.getId();
+ trackedEntityInstanceId = entityInstance.getId();
}
}
String sql = buildSql( getIdList( programs ), getIdList( programStages ), getIdList( organisationUnits ),
- personId, startDate, endDate );
+ trackedEntityInstanceId, startDate, endDate );
SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
@@ -195,7 +195,7 @@
event = new Event();
event.setEvent( rowSet.getString( "psi_uid" ) );
- event.setPerson( rowSet.getString( "pa_uid" ) );
+ event.setTrackedEntityInstance( rowSet.getString( "pa_uid" ) );
event.setStatus( EventStatus.fromInt( rowSet.getInt( "psi_status" ) ) );
event.setProgram( rowSet.getString( "p_uid" ) );
event.setProgramStage( rowSet.getString( "ps_uid" ) );
@@ -249,7 +249,7 @@
}
private String buildSql( List<Integer> programIds, List<Integer> programStageIds, List<Integer> orgUnitIds,
- Integer personId, Date startDate, Date endDate )
+ Integer trackedEntityInstanceId, Date startDate, Date endDate )
{
String sql = "select p.uid as p_uid, ps.uid as ps_uid, ps.capturecoordinates as ps_capturecoordinates, pa.uid as pa_uid, psi.uid as psi_uid, psi.status as psi_status, ou.uid as ou_uid, "
+ "psi.executiondate as psi_executiondate, psi.completeduser as psi_completeduser, psi.longitude as psi_longitude, psi.latitude as psi_latitude,"
@@ -265,15 +265,15 @@
boolean startedWhere = false;
- if ( personId != null )
+ if ( trackedEntityInstanceId != null )
{
if ( startedWhere )
{
- sql += " and pa.trackedentityinstanceid=" + personId;
+ sql += " and pa.trackedentityinstanceid=" + trackedEntityInstanceId;
}
else
{
- sql += " where pa.trackedentityinstanceid=" + personId;
+ sql += " where pa.trackedentityinstanceid=" + trackedEntityInstanceId;
startedWhere = true;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2014-01-02 13:45:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2014-03-17 08:22:01 +0000
@@ -32,7 +32,6 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -55,7 +54,7 @@
private String orgUnit;
- private String person;
+ private String trackedEntityInstance;
private String eventDate;
@@ -64,7 +63,7 @@
private Coordinate coordinate;
private List<DataValue> dataValues = new ArrayList<DataValue>();
-
+
private List<Note> notes = new ArrayList<Note>();
public Event()
@@ -133,15 +132,15 @@
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
- public String getPerson()
+ public String getTrackedEntityInstance()
{
- return person;
+ return trackedEntityInstance;
}
- public void setPerson( String person )
+ public void setTrackedEntityInstance( String trackedEntityInstance )
{
- this.person = person;
- }
+ this.trackedEntityInstance = trackedEntityInstance;
+ }
@JsonProperty( required = true )
@JacksonXmlProperty( isAttribute = true )
@@ -218,7 +217,8 @@
if ( event != null ? !event.equals( event1.event ) : event1.event != null ) return false;
if ( eventDate != null ? !eventDate.equals( event1.eventDate ) : event1.eventDate != null ) return false;
if ( orgUnit != null ? !orgUnit.equals( event1.orgUnit ) : event1.orgUnit != null ) return false;
- if ( person != null ? !person.equals( event1.person ) : event1.person != null ) return false;
+ if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( event1.trackedEntityInstance ) : event1.trackedEntityInstance != null )
+ return false;
if ( program != null ? !program.equals( event1.program ) : event1.program != null ) return false;
if ( programStage != null ? !programStage.equals( event1.programStage ) : event1.programStage != null ) return false;
if ( status != event1.status ) return false;
@@ -235,7 +235,7 @@
result = 31 * result + (program != null ? program.hashCode() : 0);
result = 31 * result + (programStage != null ? programStage.hashCode() : 0);
result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0);
- result = 31 * result + (person != null ? person.hashCode() : 0);
+ result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
result = 31 * result + (eventDate != null ? eventDate.hashCode() : 0);
result = 31 * result + (storedBy != null ? storedBy.hashCode() : 0);
result = 31 * result + (coordinate != null ? coordinate.hashCode() : 0);
@@ -252,7 +252,7 @@
", program='" + program + '\'' +
", programStage='" + programStage + '\'' +
", orgUnit='" + orgUnit + '\'' +
- ", person='" + person + '\'' +
+ ", trackedEntityInstance='" + trackedEntityInstance + '\'' +
", eventDate='" + eventDate + '\'' +
", storedBy='" + storedBy + '\'' +
", coordinate=" + coordinate +
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2014-03-17 08:22:01 +0000
@@ -33,7 +33,7 @@
import java.util.Date;
import java.util.List;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.dxf2.metadata.ImportOptions;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2014-03-17 08:22:01 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
=== removed directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person'
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractTrackedEntityInstanceService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractTrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
@@ -1,421 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.importsummary.ImportConflict;
-import org.hisp.dhis.dxf2.importsummary.ImportStatus;
-import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.relationship.Relationship;
-import org.hisp.dhis.relationship.RelationshipService;
-import org.hisp.dhis.relationship.RelationshipType;
-import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
-import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
-import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.Assert;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public abstract class AbstractTrackedEntityInstanceService
- implements TrackedEntityInstanceService
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private org.hisp.dhis.trackedentity.TrackedEntityInstanceService entityInstanceService;
-
- @Autowired
- private TrackedEntityAttributeValueService attributeValueService;
-
- @Autowired
- private RelationshipService relationshipService;
-
- @Autowired
- private IdentifiableObjectManager manager;
-
- // -------------------------------------------------------------------------
- // READ
- // -------------------------------------------------------------------------
-
- @Override
- public TrackedEntityInstances getPersons()
- {
- List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
- entityInstanceService.getAllTrackedEntityInstances() );
- return getPersons( entityInstances );
- }
-
- @Override
- public TrackedEntityInstances getPersons( OrganisationUnit organisationUnit )
- {
- List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
- entityInstanceService.getTrackedEntityInstances( organisationUnit, null, null ) );
- return getPersons( entityInstances );
- }
-
- @Override
- public TrackedEntityInstances getPersons( Program program )
- {
- List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
- entityInstanceService.getTrackedEntityInstances( program ) );
- return getPersons( entityInstances );
- }
-
- @Override
- public TrackedEntityInstances getPersons( OrganisationUnit organisationUnit, Program program )
- {
- List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
- entityInstanceService.getTrackedEntityInstances( organisationUnit, program ) );
- return getPersons( entityInstances );
- }
-
- @Override
- public TrackedEntityInstances getPersons( Collection<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances )
- {
- TrackedEntityInstances trackedEntityInstances = new TrackedEntityInstances();
-
- for ( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance : entityInstances )
- {
- trackedEntityInstances.getTrackedEntityInstances().add( getPerson( entityInstance ) );
- }
-
- return trackedEntityInstances;
- }
-
- @Override
- public TrackedEntityInstance getPerson( String uid )
- {
- return getPerson( entityInstanceService.getTrackedEntityInstance( uid ) );
- }
-
- @Override
- public TrackedEntityInstance getPerson( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
- {
- if ( entityInstance == null )
- {
- return null;
- }
-
- TrackedEntityInstance trackedEntityInstance = new TrackedEntityInstance();
- trackedEntityInstance.setTrackedEntityInstance( entityInstance.getUid() );
- trackedEntityInstance.setOrgUnit( entityInstance.getOrganisationUnit().getUid() );
-
- Collection<Relationship> relationships = relationshipService
- .getRelationshipsForTrackedEntityInstance( entityInstance );
-
- for ( Relationship entityRelationship : relationships )
- {
- org.hisp.dhis.dxf2.events.person.Relationship relationship = new org.hisp.dhis.dxf2.events.person.Relationship();
- relationship.setDisplayName( entityRelationship.getRelationshipType().getDisplayName() );
- relationship.setPerson( entityRelationship.getEntityInstanceA().getUid() );
- relationship.setType( entityRelationship.getRelationshipType().getUid() );
-
- trackedEntityInstance.getRelationships().add( relationship );
- }
-
- Collection<TrackedEntityAttributeValue> attributeValues = attributeValueService
- .getTrackedEntityAttributeValues( entityInstance );
-
- for ( TrackedEntityAttributeValue attributeValue : attributeValues )
- {
- Attribute attribute = new Attribute();
-
- attribute.setDisplayName( attributeValue.getAttribute().getDisplayName() );
- attribute.setAttribute( attributeValue.getAttribute().getUid() );
- attribute.setType( attributeValue.getAttribute().getValueType() );
- attribute.setCode( attributeValue.getAttribute().getCode() );
- attribute.setValue( attributeValue.getValue() );
-
- trackedEntityInstance.getAttributes().add( attribute );
- }
-
- return trackedEntityInstance;
- }
-
- public org.hisp.dhis.trackedentity.TrackedEntityInstance getTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
- {
- Assert.hasText( trackedEntityInstance.getOrgUnit() );
-
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = new org.hisp.dhis.trackedentity.TrackedEntityInstance();
-
- OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, trackedEntityInstance.getOrgUnit() );
- Assert.notNull( organisationUnit );
-
- entityInstance.setOrganisationUnit( organisationUnit );
-
- return entityInstance;
- }
-
- // -------------------------------------------------------------------------
- // CREATE
- // -------------------------------------------------------------------------
-
- @Override
- public ImportSummary savePerson( TrackedEntityInstance trackedEntityInstance )
- {
- ImportSummary importSummary = new ImportSummary();
- importSummary.setDataValueCount( null );
-
- List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
- importConflicts.addAll( checkAttributes( trackedEntityInstance ) );
-
- importSummary.setConflicts( importConflicts );
-
- if ( !importConflicts.isEmpty() )
- {
- importSummary.setStatus( ImportStatus.ERROR );
- importSummary.getImportCount().incrementIgnored();
- return importSummary;
- }
-
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( trackedEntityInstance );
- entityInstanceService.saveTrackedEntityInstance( entityInstance );
-
- updateAttributeValues( trackedEntityInstance, entityInstance );
- entityInstanceService.updateTrackedEntityInstance( entityInstance );
-
- importSummary.setStatus( ImportStatus.SUCCESS );
- importSummary.setReference( entityInstance.getUid() );
- importSummary.getImportCount().incrementImported();
-
- return importSummary;
- }
-
- // -------------------------------------------------------------------------
- // UPDATE
- // -------------------------------------------------------------------------
-
- @Override
- public ImportSummary updatePerson( TrackedEntityInstance trackedEntityInstance )
- {
- ImportSummary importSummary = new ImportSummary();
- importSummary.setDataValueCount( null );
-
- List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
- importConflicts.addAll( checkRelationships( trackedEntityInstance ) );
- importConflicts.addAll( checkAttributes( trackedEntityInstance ) );
-
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, trackedEntityInstance.getTrackedEntityInstance() );
-
- if ( entityInstance == null )
- {
- importConflicts.add( new ImportConflict( "Person", "person " + trackedEntityInstance.getTrackedEntityInstance()
- + " does not point to valid person" ) );
- }
-
- OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, trackedEntityInstance.getOrgUnit() );
-
- if ( organisationUnit == null )
- {
- importConflicts.add( new ImportConflict( "OrganisationUnit", "orgUnit " + trackedEntityInstance.getOrgUnit()
- + " does not point to valid organisation unit" ) );
- }
-
- importSummary.setConflicts( importConflicts );
-
- if ( !importConflicts.isEmpty() )
- {
- importSummary.setStatus( ImportStatus.ERROR );
- importSummary.getImportCount().incrementIgnored();
- return importSummary;
- }
-
- removeRelationships( entityInstance );
- removeAttributeValues( entityInstance );
- entityInstanceService.updateTrackedEntityInstance( entityInstance );
-
- updateRelationships( trackedEntityInstance, entityInstance );
- updateAttributeValues( trackedEntityInstance, entityInstance );
- entityInstanceService.updateTrackedEntityInstance( entityInstance );
-
- importSummary.setStatus( ImportStatus.SUCCESS );
- importSummary.setReference( entityInstance.getUid() );
- importSummary.getImportCount().incrementUpdated();
-
- return importSummary;
- }
-
- // -------------------------------------------------------------------------
- // DELETE
- // -------------------------------------------------------------------------
-
- @Override
- public void deletePerson( TrackedEntityInstance trackedEntityInstance )
- {
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( trackedEntityInstance.getTrackedEntityInstance() );
-
- if ( entityInstance != null )
- {
- entityInstanceService.deleteTrackedEntityInstance( entityInstance );
- }
- else
- {
- throw new IllegalArgumentException();
- }
- }
-
- // -------------------------------------------------------------------------
- // HELPERS
- // -------------------------------------------------------------------------
-
- private List<ImportConflict> checkAttributes( TrackedEntityInstance trackedEntityInstance )
- {
- List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
- Collection<TrackedEntityAttribute> entityAttributes = manager.getAll( TrackedEntityAttribute.class );
- Set<String> cache = new HashSet<String>();
-
- for ( Attribute attribute : trackedEntityInstance.getAttributes() )
- {
- if ( attribute.getValue() != null )
- {
- cache.add( attribute.getAttribute() );
- }
- }
-
- for ( TrackedEntityAttribute entityAttribute : entityAttributes )
- {
- if ( entityAttribute.isMandatory() )
- {
- if ( !cache.contains( entityAttribute.getUid() ) )
- {
- importConflicts.add( new ImportConflict( "Attribute.type", "Missing required attribute type "
- + entityAttribute.getUid() ) );
- }
- }
- }
-
- for ( Attribute attribute : trackedEntityInstance.getAttributes() )
- {
- TrackedEntityAttribute entityAttribute = manager.get( TrackedEntityAttribute.class,
- attribute.getAttribute() );
-
- if ( entityAttribute == null )
- {
- importConflicts
- .add( new ImportConflict( "Attribute.type", "Invalid type " + attribute.getAttribute() ) );
- }
- }
-
- return importConflicts;
- }
-
- private List<ImportConflict> checkRelationships( TrackedEntityInstance trackedEntityInstance )
- {
- List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
-
- for ( org.hisp.dhis.dxf2.events.person.Relationship relationship : trackedEntityInstance.getRelationships() )
- {
- RelationshipType relationshipType = manager.get( RelationshipType.class, relationship.getType() );
-
- if ( relationshipType == null )
- {
- importConflicts
- .add( new ImportConflict( "Relationship.type", "Invalid type " + relationship.getType() ) );
- }
-
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, relationship.getPerson() );
-
- if ( entityInstance == null )
- {
- importConflicts.add( new ImportConflict( "Relationship.person", "Invalid person "
- + relationship.getPerson() ) );
- }
- }
-
- return importConflicts;
- }
-
- private void updateAttributeValues( TrackedEntityInstance trackedEntityInstance, org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
- {
- for ( Attribute attribute : trackedEntityInstance.getAttributes() )
- {
- TrackedEntityAttribute entityAttribute = manager.get( TrackedEntityAttribute.class,
- attribute.getAttribute() );
-
- if ( entityAttribute != null )
- {
- TrackedEntityAttributeValue attributeValue = new TrackedEntityAttributeValue();
- attributeValue.setEntityInstance( entityInstance );
- attributeValue.setValue( attribute.getValue() );
- attributeValue.setAttribute( entityAttribute );
-
- attributeValueService.saveTrackedEntityAttributeValue( attributeValue );
- }
- }
- }
-
- private void updateRelationships( TrackedEntityInstance trackedEntityInstance, org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
- {
- for ( org.hisp.dhis.dxf2.events.person.Relationship relationship : trackedEntityInstance.getRelationships() )
- {
- org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstanceB = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, relationship.getPerson() );
- RelationshipType relationshipType = manager.get( RelationshipType.class, relationship.getType() );
-
- Relationship entityRelationship = new Relationship();
- entityRelationship.setEntityInstanceA( entityInstance );
- entityRelationship.setEntityInstanceB( entityInstanceB );
- entityRelationship.setRelationshipType( relationshipType );
-
- relationshipService.saveRelationship( entityRelationship );
- }
- }
-
- private void removeRelationships( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
- {
- Collection<Relationship> relationships = relationshipService
- .getRelationshipsForTrackedEntityInstance( entityInstance );
-
- for ( Relationship relationship : relationships )
- {
- relationshipService.deleteRelationship( relationship );
- }
- }
-
- private void removeAttributeValues( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
- {
- for ( TrackedEntityAttributeValue trackedEntityAttributeValue : entityInstance.getAttributeValues() )
- {
- attributeValueService.deleteTrackedEntityAttributeValue( trackedEntityAttributeValue );
- }
-
- entityInstanceService.updateTrackedEntityInstance( entityInstance );
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java 2014-01-28 10:01:16 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Attribute.java 1970-01-01 00:00:00 +0000
@@ -1,169 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "attribute", namespace = DxfNamespaces.DXF_2_0 )
-public class Attribute
-{
- private String displayName;
-
- private String attribute;
-
- private String type;
-
- private String code;
-
- private String value;
-
- public Attribute()
- {
- }
-
- public Attribute( String value )
- {
- this.value = value;
- }
-
- public Attribute( String attribute, String type, String value )
- {
- this.attribute = attribute;
- this.type = type;
- this.value = value;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getDisplayName()
- {
- return displayName;
- }
-
- public void setDisplayName( String name )
- {
- this.displayName = name;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getAttribute()
- {
- return attribute;
- }
-
- public void setAttribute( String attribute )
- {
- this.attribute = attribute;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getCode()
- {
- return code;
- }
-
- public void setCode( String code )
- {
- this.code = code;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getValue()
- {
- return value;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o )
- return true;
- if ( o == null || getClass() != o.getClass() )
- return false;
-
- Attribute attribute1 = (Attribute) o;
-
- if ( attribute != null ? !attribute.equals( attribute1.attribute ) : attribute1.attribute != null )
- return false;
- if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null )
- return false;
- if ( type != null ? !type.equals( attribute1.type ) : attribute1.type != null )
- return false;
- if ( code != null ? !code.equals( attribute1.code ) : attribute1.code != null )
- return false;
- if ( value != null ? !value.equals( attribute1.value ) : attribute1.value != null )
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = displayName != null ? displayName.hashCode() : 0;
- result = 31 * result + (attribute != null ? attribute.hashCode() : 0);
- result = 31 * result + (type != null ? type.hashCode() : 0);
- result = 31 * result + (code != null ? code.hashCode() : 0);
- result = 31 * result + (value != null ? value.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "Attribute{" + "displayName='" + displayName + '\'' + ", attribute='" + attribute + '\'' + ", type='"
- + type + '\'' + ", code='" + code + '\'' + ", value='" + value + '\'' + '}';
- }
-}
\ No newline at end of file
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Identifier.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Identifier.java 2013-12-27 13:33:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Identifier.java 1970-01-01 00:00:00 +0000
@@ -1,156 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "identifier", namespace = DxfNamespaces.DXF_2_0 )
-public class Identifier
-{
- private String displayName;
-
- private String identifier;
-
- private String type;
-
- private String value;
-
- public Identifier()
- {
- }
-
- public Identifier( String value )
- {
- this.value = value;
- }
-
- public Identifier( String identifier, String value )
- {
- this.identifier = identifier;
- this.value = value;
- }
-
- public Identifier( String identifier, String type, String value )
- {
- this.identifier = identifier;
- this.type = type;
- this.value = value;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getDisplayName()
- {
- return displayName;
- }
-
- public void setDisplayName( String name )
- {
- this.displayName = name;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getIdentifier()
- {
- return identifier;
- }
-
- public void setIdentifier( String identifier )
- {
- this.identifier = identifier;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getValue()
- {
- return value;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
-
- Identifier that = (Identifier) o;
-
- if ( displayName != null ? !displayName.equals( that.displayName ) : that.displayName != null ) return false;
- if ( identifier != null ? !identifier.equals( that.identifier ) : that.identifier != null ) return false;
- if ( type != null ? !type.equals( that.type ) : that.type != null ) return false;
- if ( value != null ? !value.equals( that.value ) : that.value != null ) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = displayName != null ? displayName.hashCode() : 0;
- result = 31 * result + (identifier != null ? identifier.hashCode() : 0);
- result = 31 * result + (type != null ? type.hashCode() : 0);
- result = 31 * result + (value != null ? value.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "Identifier{" +
- "displayName='" + displayName + '\'' +
- ", identifier='" + identifier + '\'' +
- ", type='" + type + '\'' +
- ", value='" + value + '\'' +
- '}';
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/JacksonTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/JacksonTrackedEntityInstanceService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/JacksonTrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
@@ -1,169 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
-import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.StreamUtils;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Transactional
-public class JacksonTrackedEntityInstanceService extends AbstractTrackedEntityInstanceService
-{
- // -------------------------------------------------------------------------
- // Implementation
- // -------------------------------------------------------------------------
-
- private final static ObjectMapper xmlMapper = new XmlMapper();
-
- private final static ObjectMapper jsonMapper = new ObjectMapper();
-
- @SuppressWarnings( "unchecked" )
- private static <T> T fromXml( InputStream inputStream, Class<?> clazz ) throws IOException
- {
- return (T) xmlMapper.readValue( inputStream, clazz );
- }
-
- @SuppressWarnings( "unchecked" )
- private static <T> T fromXml( String input, Class<?> clazz ) throws IOException
- {
- return (T) xmlMapper.readValue( input, clazz );
- }
-
- @SuppressWarnings( "unchecked" )
- private static <T> T fromJson( InputStream inputStream, Class<?> clazz ) throws IOException
- {
- return (T) jsonMapper.readValue( inputStream, clazz );
- }
-
- @SuppressWarnings( "unchecked" )
- private static <T> T fromJson( String input, Class<?> clazz ) throws IOException
- {
- return (T) jsonMapper.readValue( input, clazz );
- }
-
- static
- {
- xmlMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true );
- xmlMapper.configure( DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true );
- xmlMapper.configure( DeserializationFeature.WRAP_EXCEPTIONS, true );
- jsonMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true );
- jsonMapper.configure( DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true );
- jsonMapper.configure( DeserializationFeature.WRAP_EXCEPTIONS, true );
- }
-
- // -------------------------------------------------------------------------
- // CREATE
- // -------------------------------------------------------------------------
-
- @Override
- public ImportSummaries savePersonXml( InputStream inputStream ) throws IOException
- {
- ImportSummaries importSummaries = new ImportSummaries();
- String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
-
- try
- {
- TrackedEntityInstances trackedEntityInstances = fromXml( input, TrackedEntityInstances.class );
-
- for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
- {
- trackedEntityInstance.setTrackedEntityInstance( null );
- importSummaries.addImportSummary( savePerson( trackedEntityInstance ) );
- }
- }
- catch ( Exception ex )
- {
- TrackedEntityInstance trackedEntityInstance = fromXml( input, TrackedEntityInstance.class );
- trackedEntityInstance.setTrackedEntityInstance( null );
- importSummaries.addImportSummary( savePerson( trackedEntityInstance ) );
- }
-
- return importSummaries;
- }
-
- @Override
- public ImportSummaries savePersonJson( InputStream inputStream ) throws IOException
- {
- ImportSummaries importSummaries = new ImportSummaries();
- String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
-
- try
- {
- TrackedEntityInstances trackedEntityInstances = fromJson( input, TrackedEntityInstances.class );
-
- for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
- {
- trackedEntityInstance.setTrackedEntityInstance( null );
- importSummaries.addImportSummary( savePerson( trackedEntityInstance ) );
- }
- }
- catch ( Exception ex )
- {
- TrackedEntityInstance trackedEntityInstance = fromJson( input, TrackedEntityInstance.class );
- trackedEntityInstance.setTrackedEntityInstance( null );
- importSummaries.addImportSummary( savePerson( trackedEntityInstance ) );
- }
-
- return importSummaries;
- }
-
- // -------------------------------------------------------------------------
- // UPDATE
- // -------------------------------------------------------------------------
-
- @Override
- public ImportSummary updatePersonXml( String id, InputStream inputStream ) throws IOException
- {
- TrackedEntityInstance trackedEntityInstance = fromXml( inputStream, TrackedEntityInstance.class );
- trackedEntityInstance.setTrackedEntityInstance( id );
-
- return updatePerson( trackedEntityInstance );
- }
-
- @Override
- public ImportSummary updatePersonJson( String id, InputStream inputStream ) throws IOException
- {
- TrackedEntityInstance trackedEntityInstance = fromJson( inputStream, TrackedEntityInstance.class );
- trackedEntityInstance.setTrackedEntityInstance( id );
-
- return updatePerson( trackedEntityInstance );
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 2013-09-19 09:40:29 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Relationship.java 1970-01-01 00:00:00 +0000
@@ -1,121 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "relationship", namespace = DxfNamespaces.DXF_2_0 )
-public class Relationship
-{
- private String displayName;
-
- private String person;
-
- private String type;
-
- public Relationship()
- {
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getDisplayName()
- {
- return displayName;
- }
-
- public void setDisplayName( String name )
- {
- this.displayName = name;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getPerson()
- {
- return person;
- }
-
- public void setPerson( String person )
- {
- this.person = person;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getType()
- {
- return type;
- }
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
-
- Relationship that = (Relationship) o;
-
- if ( displayName != null ? !displayName.equals( that.displayName ) : that.displayName != null ) return false;
- if ( person != null ? !person.equals( that.person ) : that.person != null ) return false;
- if ( type != null ? !type.equals( that.type ) : that.type != null ) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = displayName != null ? displayName.hashCode() : 0;
- result = 31 * result + (person != null ? person.hashCode() : 0);
- result = 31 * result + (type != null ? type.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "Relationship{" +
- "displayName='" + displayName + '\'' +
- ", person='" + person + '\'' +
- ", type='" + type + '\'' +
- '}';
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstance.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstance.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstance.java 1970-01-01 00:00:00 +0000
@@ -1,176 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "trackedEntityInstance", namespace = DxfNamespaces.DXF_2_0 )
-public class TrackedEntityInstance
-{
- private String trackedEntity;
-
- private String trackedEntityInstance;
-
- private String orgUnit;
-
- private List<Relationship> relationships = new ArrayList<Relationship>();
-
- private List<Identifier> identifiers = new ArrayList<Identifier>();
-
- private List<Attribute> attributes = new ArrayList<Attribute>();
-
- public TrackedEntityInstance()
- {
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( isAttribute = true )
- public String getTrackedEntity()
- {
- return trackedEntity;
- }
-
- public void setTrackedEntity( String trackedEntity )
- {
- this.trackedEntity = trackedEntity;
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( isAttribute = true )
- public String getTrackedEntityInstance()
- {
- return trackedEntityInstance;
- }
-
- public void setTrackedEntityInstance( String trackedEntityInstance )
- {
- this.trackedEntityInstance = trackedEntityInstance;
- }
-
- @JsonProperty( required = true )
- @JacksonXmlProperty( isAttribute = true )
- public String getOrgUnit()
- {
- return orgUnit;
- }
-
- public void setOrgUnit( String orgUnit )
- {
- this.orgUnit = orgUnit;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public List<Relationship> getRelationships()
- {
- return relationships;
- }
-
- public void setRelationships( List<Relationship> relationships )
- {
- this.relationships = relationships;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public List<Identifier> getIdentifiers()
- {
- return identifiers;
- }
-
- public void setIdentifiers( List<Identifier> identifiers )
- {
- this.identifiers = identifiers;
- }
-
- @JsonProperty
- @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public List<Attribute> getAttributes()
- {
- return attributes;
- }
-
- public void setAttributes( List<Attribute> attributes )
- {
- this.attributes = attributes;
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
-
- TrackedEntityInstance that = (TrackedEntityInstance) o;
-
- if ( attributes != null ? !attributes.equals( that.attributes ) : that.attributes != null ) return false;
- if ( identifiers != null ? !identifiers.equals( that.identifiers ) : that.identifiers != null ) return false;
- if ( orgUnit != null ? !orgUnit.equals( that.orgUnit ) : that.orgUnit != null ) return false;
- if ( relationships != null ? !relationships.equals( that.relationships ) : that.relationships != null ) return false;
- if ( trackedEntity != null ? !trackedEntity.equals( that.trackedEntity ) : that.trackedEntity != null ) return false;
- if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( that.trackedEntityInstance ) : that.trackedEntityInstance != null )
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = trackedEntity != null ? trackedEntity.hashCode() : 0;
- result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
- result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0);
- result = 31 * result + (relationships != null ? relationships.hashCode() : 0);
- result = 31 * result + (identifiers != null ? identifiers.hashCode() : 0);
- result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "TrackedEntityInstance{" +
- "trackedEntity='" + trackedEntity + '\'' +
- ", trackedEntityInstance='" + trackedEntityInstance + '\'' +
- ", orgUnit='" + orgUnit + '\'' +
- ", relationships=" + relationships +
- ", identifiers=" + identifiers +
- ", attributes=" + attributes +
- '}';
- }
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstanceService.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
@@ -1,92 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-
-import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
-import org.hisp.dhis.dxf2.importsummary.ImportSummary;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.program.Program;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public interface TrackedEntityInstanceService
-{
- // -------------------------------------------------------------------------
- // READ
- // -------------------------------------------------------------------------
-
- TrackedEntityInstances getPersons();
-
- TrackedEntityInstances getPersons( OrganisationUnit organisationUnit );
-
- TrackedEntityInstances getPersons( Program program );
-
- TrackedEntityInstances getPersons( OrganisationUnit organisationUnit, Program program );
-
- TrackedEntityInstances getPersons( Collection<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances );
-
- TrackedEntityInstance getPerson( String uid );
-
- TrackedEntityInstance getPerson( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance );
-
- // -------------------------------------------------------------------------
- // CREATE
- // -------------------------------------------------------------------------
-
- ImportSummaries savePersonXml( InputStream inputStream )
- throws IOException;
-
- ImportSummaries savePersonJson( InputStream inputStream )
- throws IOException;
-
- ImportSummary savePerson( TrackedEntityInstance trackedEntityInstance );
-
- // -------------------------------------------------------------------------
- // UPDATE
- // -------------------------------------------------------------------------
-
- ImportSummary updatePersonXml( String id, InputStream inputStream )
- throws IOException;
-
- ImportSummary updatePersonJson( String id, InputStream inputStream )
- throws IOException;
-
- ImportSummary updatePerson( TrackedEntityInstance trackedEntityInstance );
-
- // -------------------------------------------------------------------------
- // DELETE
- // -------------------------------------------------------------------------
-
- void deletePerson( TrackedEntityInstance trackedEntityInstance );
-}
=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstances.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstances.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/TrackedEntityInstances.java 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
-package org.hisp.dhis.dxf2.events.person;
-
-/*
- * Copyright (c) 2004-2013, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.DxfNamespaces;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@JacksonXmlRootElement( localName = "trackedEntityInstances", namespace = DxfNamespaces.DXF_2_0 )
-public class TrackedEntityInstances
-{
- private List<TrackedEntityInstance> trackedEntityInstances = new ArrayList<TrackedEntityInstance>();
-
- public TrackedEntityInstances()
- {
- }
-
- @JsonProperty( "trackedEntityInstanceList" )
- @JacksonXmlElementWrapper( localName = "trackedEntityInstanceList", namespace = DxfNamespaces.DXF_2_0 )
- @JacksonXmlProperty( localName = "trackedEntityInstance", namespace = DxfNamespaces.DXF_2_0 )
- public List<TrackedEntityInstance> getTrackedEntityInstances()
- {
- return trackedEntityInstances;
- }
-
- public void setTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
- {
- this.trackedEntityInstances = trackedEntityInstances;
- }
-
- @Override
- public String toString()
- {
- return "TrackedEntityInstances{" +
- "trackedEntityInstances=" + trackedEntityInstances +
- '}';
- }
-}
=== added directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity'
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,421 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.dxf2.importsummary.ImportConflict;
+import org.hisp.dhis.dxf2.importsummary.ImportStatus;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.relationship.Relationship;
+import org.hisp.dhis.relationship.RelationshipService;
+import org.hisp.dhis.relationship.RelationshipType;
+import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
+import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
+import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public abstract class AbstractTrackedEntityInstanceService
+ implements TrackedEntityInstanceService
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private org.hisp.dhis.trackedentity.TrackedEntityInstanceService entityInstanceService;
+
+ @Autowired
+ private TrackedEntityAttributeValueService attributeValueService;
+
+ @Autowired
+ private RelationshipService relationshipService;
+
+ @Autowired
+ private IdentifiableObjectManager manager;
+
+ // -------------------------------------------------------------------------
+ // READ
+ // -------------------------------------------------------------------------
+
+ @Override
+ public TrackedEntityInstances getTrackedEntityInstances()
+ {
+ List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
+ entityInstanceService.getAllTrackedEntityInstances() );
+ return getTrackedEntityInstances( entityInstances );
+ }
+
+ @Override
+ public TrackedEntityInstances getTrackedEntityInstances( OrganisationUnit organisationUnit )
+ {
+ List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
+ entityInstanceService.getTrackedEntityInstances( organisationUnit, null, null ) );
+ return getTrackedEntityInstances( entityInstances );
+ }
+
+ @Override
+ public TrackedEntityInstances getTrackedEntityInstances( Program program )
+ {
+ List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
+ entityInstanceService.getTrackedEntityInstances( program ) );
+ return getTrackedEntityInstances( entityInstances );
+ }
+
+ @Override
+ public TrackedEntityInstances getTrackedEntityInstances( OrganisationUnit organisationUnit, Program program )
+ {
+ List<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances = new ArrayList<org.hisp.dhis.trackedentity.TrackedEntityInstance>(
+ entityInstanceService.getTrackedEntityInstances( organisationUnit, program ) );
+ return getTrackedEntityInstances( entityInstances );
+ }
+
+ @Override
+ public TrackedEntityInstances getTrackedEntityInstances( Collection<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances )
+ {
+ TrackedEntityInstances trackedEntityInstances = new TrackedEntityInstances();
+
+ for ( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance : entityInstances )
+ {
+ trackedEntityInstances.getTrackedEntityInstances().add( getTrackedEntityInstance( entityInstance ) );
+ }
+
+ return trackedEntityInstances;
+ }
+
+ @Override
+ public TrackedEntityInstance getTrackedEntityInstance( String uid )
+ {
+ return getTrackedEntityInstance( entityInstanceService.getTrackedEntityInstance( uid ) );
+ }
+
+ @Override
+ public TrackedEntityInstance getTrackedEntityInstance( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
+ {
+ if ( entityInstance == null )
+ {
+ return null;
+ }
+
+ TrackedEntityInstance trackedEntityInstance = new TrackedEntityInstance();
+ trackedEntityInstance.setTrackedEntityInstance( entityInstance.getUid() );
+ trackedEntityInstance.setOrgUnit( entityInstance.getOrganisationUnit().getUid() );
+
+ Collection<Relationship> relationships = relationshipService
+ .getRelationshipsForTrackedEntityInstance( entityInstance );
+
+ for ( Relationship entityRelationship : relationships )
+ {
+ org.hisp.dhis.dxf2.events.trackedentity.Relationship relationship = new org.hisp.dhis.dxf2.events.trackedentity.Relationship();
+ relationship.setDisplayName( entityRelationship.getRelationshipType().getDisplayName() );
+ relationship.setTrackedEntityInstance( entityRelationship.getEntityInstanceA().getUid() );
+ relationship.setType( entityRelationship.getRelationshipType().getUid() );
+
+ trackedEntityInstance.getRelationships().add( relationship );
+ }
+
+ Collection<TrackedEntityAttributeValue> attributeValues = attributeValueService
+ .getTrackedEntityAttributeValues( entityInstance );
+
+ for ( TrackedEntityAttributeValue attributeValue : attributeValues )
+ {
+ Attribute attribute = new Attribute();
+
+ attribute.setDisplayName( attributeValue.getAttribute().getDisplayName() );
+ attribute.setAttribute( attributeValue.getAttribute().getUid() );
+ attribute.setType( attributeValue.getAttribute().getValueType() );
+ attribute.setCode( attributeValue.getAttribute().getCode() );
+ attribute.setValue( attributeValue.getValue() );
+
+ trackedEntityInstance.getAttributes().add( attribute );
+ }
+
+ return trackedEntityInstance;
+ }
+
+ public org.hisp.dhis.trackedentity.TrackedEntityInstance getTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+ {
+ Assert.hasText( trackedEntityInstance.getOrgUnit() );
+
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = new org.hisp.dhis.trackedentity.TrackedEntityInstance();
+
+ OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, trackedEntityInstance.getOrgUnit() );
+ Assert.notNull( organisationUnit );
+
+ entityInstance.setOrganisationUnit( organisationUnit );
+
+ return entityInstance;
+ }
+
+ // -------------------------------------------------------------------------
+ // CREATE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummary saveTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+ {
+ ImportSummary importSummary = new ImportSummary();
+ importSummary.setDataValueCount( null );
+
+ List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
+ importConflicts.addAll( checkAttributes( trackedEntityInstance ) );
+
+ importSummary.setConflicts( importConflicts );
+
+ if ( !importConflicts.isEmpty() )
+ {
+ importSummary.setStatus( ImportStatus.ERROR );
+ importSummary.getImportCount().incrementIgnored();
+ return importSummary;
+ }
+
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = getTrackedEntityInstance( trackedEntityInstance );
+ entityInstanceService.saveTrackedEntityInstance( entityInstance );
+
+ updateAttributeValues( trackedEntityInstance, entityInstance );
+ entityInstanceService.updateTrackedEntityInstance( entityInstance );
+
+ importSummary.setStatus( ImportStatus.SUCCESS );
+ importSummary.setReference( entityInstance.getUid() );
+ importSummary.getImportCount().incrementImported();
+
+ return importSummary;
+ }
+
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+ {
+ ImportSummary importSummary = new ImportSummary();
+ importSummary.setDataValueCount( null );
+
+ List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
+ importConflicts.addAll( checkRelationships( trackedEntityInstance ) );
+ importConflicts.addAll( checkAttributes( trackedEntityInstance ) );
+
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, trackedEntityInstance.getTrackedEntityInstance() );
+
+ if ( entityInstance == null )
+ {
+ importConflicts.add( new ImportConflict( "TrackedEntityInstance", "trackedEntityInstance " + trackedEntityInstance.getTrackedEntityInstance()
+ + " does not point to valid trackedEntityInstance" ) );
+ }
+
+ OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, trackedEntityInstance.getOrgUnit() );
+
+ if ( organisationUnit == null )
+ {
+ importConflicts.add( new ImportConflict( "OrganisationUnit", "orgUnit " + trackedEntityInstance.getOrgUnit()
+ + " does not point to valid organisation unit" ) );
+ }
+
+ importSummary.setConflicts( importConflicts );
+
+ if ( !importConflicts.isEmpty() )
+ {
+ importSummary.setStatus( ImportStatus.ERROR );
+ importSummary.getImportCount().incrementIgnored();
+ return importSummary;
+ }
+
+ removeRelationships( entityInstance );
+ removeAttributeValues( entityInstance );
+ entityInstanceService.updateTrackedEntityInstance( entityInstance );
+
+ updateRelationships( trackedEntityInstance, entityInstance );
+ updateAttributeValues( trackedEntityInstance, entityInstance );
+ entityInstanceService.updateTrackedEntityInstance( entityInstance );
+
+ importSummary.setStatus( ImportStatus.SUCCESS );
+ importSummary.setReference( entityInstance.getUid() );
+ importSummary.getImportCount().incrementUpdated();
+
+ return importSummary;
+ }
+
+ // -------------------------------------------------------------------------
+ // DELETE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void deleteTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance )
+ {
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( trackedEntityInstance.getTrackedEntityInstance() );
+
+ if ( entityInstance != null )
+ {
+ entityInstanceService.deleteTrackedEntityInstance( entityInstance );
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // HELPERS
+ // -------------------------------------------------------------------------
+
+ private List<ImportConflict> checkAttributes( TrackedEntityInstance trackedEntityInstance )
+ {
+ List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
+ Collection<TrackedEntityAttribute> entityAttributes = manager.getAll( TrackedEntityAttribute.class );
+ Set<String> cache = new HashSet<String>();
+
+ for ( Attribute attribute : trackedEntityInstance.getAttributes() )
+ {
+ if ( attribute.getValue() != null )
+ {
+ cache.add( attribute.getAttribute() );
+ }
+ }
+
+ for ( TrackedEntityAttribute entityAttribute : entityAttributes )
+ {
+ if ( entityAttribute.isMandatory() )
+ {
+ if ( !cache.contains( entityAttribute.getUid() ) )
+ {
+ importConflicts.add( new ImportConflict( "Attribute.type", "Missing required attribute type "
+ + entityAttribute.getUid() ) );
+ }
+ }
+ }
+
+ for ( Attribute attribute : trackedEntityInstance.getAttributes() )
+ {
+ TrackedEntityAttribute entityAttribute = manager.get( TrackedEntityAttribute.class,
+ attribute.getAttribute() );
+
+ if ( entityAttribute == null )
+ {
+ importConflicts
+ .add( new ImportConflict( "Attribute.type", "Invalid type " + attribute.getAttribute() ) );
+ }
+ }
+
+ return importConflicts;
+ }
+
+ private List<ImportConflict> checkRelationships( TrackedEntityInstance trackedEntityInstance )
+ {
+ List<ImportConflict> importConflicts = new ArrayList<ImportConflict>();
+
+ for ( org.hisp.dhis.dxf2.events.trackedentity.Relationship relationship : trackedEntityInstance.getRelationships() )
+ {
+ RelationshipType relationshipType = manager.get( RelationshipType.class, relationship.getType() );
+
+ if ( relationshipType == null )
+ {
+ importConflicts
+ .add( new ImportConflict( "Relationship.type", "Invalid type " + relationship.getType() ) );
+ }
+
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, relationship.getTrackedEntityInstance() );
+
+ if ( entityInstance == null )
+ {
+ importConflicts.add( new ImportConflict( "Relationship.trackedEntityInstance", "Invalid trackedEntityInstance "
+ + relationship.getTrackedEntityInstance() ) );
+ }
+ }
+
+ return importConflicts;
+ }
+
+ private void updateAttributeValues( TrackedEntityInstance trackedEntityInstance, org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
+ {
+ for ( Attribute attribute : trackedEntityInstance.getAttributes() )
+ {
+ TrackedEntityAttribute entityAttribute = manager.get( TrackedEntityAttribute.class,
+ attribute.getAttribute() );
+
+ if ( entityAttribute != null )
+ {
+ TrackedEntityAttributeValue attributeValue = new TrackedEntityAttributeValue();
+ attributeValue.setEntityInstance( entityInstance );
+ attributeValue.setValue( attribute.getValue() );
+ attributeValue.setAttribute( entityAttribute );
+
+ attributeValueService.saveTrackedEntityAttributeValue( attributeValue );
+ }
+ }
+ }
+
+ private void updateRelationships( TrackedEntityInstance trackedEntityInstance, org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
+ {
+ for ( org.hisp.dhis.dxf2.events.trackedentity.Relationship relationship : trackedEntityInstance.getRelationships() )
+ {
+ org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstanceB = manager.get( org.hisp.dhis.trackedentity.TrackedEntityInstance.class, relationship.getTrackedEntityInstance() );
+ RelationshipType relationshipType = manager.get( RelationshipType.class, relationship.getType() );
+
+ Relationship entityRelationship = new Relationship();
+ entityRelationship.setEntityInstanceA( entityInstance );
+ entityRelationship.setEntityInstanceB( entityInstanceB );
+ entityRelationship.setRelationshipType( relationshipType );
+
+ relationshipService.saveRelationship( entityRelationship );
+ }
+ }
+
+ private void removeRelationships( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
+ {
+ Collection<Relationship> relationships = relationshipService
+ .getRelationshipsForTrackedEntityInstance( entityInstance );
+
+ for ( Relationship relationship : relationships )
+ {
+ relationshipService.deleteRelationship( relationship );
+ }
+ }
+
+ private void removeAttributeValues( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance )
+ {
+ for ( TrackedEntityAttributeValue trackedEntityAttributeValue : entityInstance.getAttributeValues() )
+ {
+ attributeValueService.deleteTrackedEntityAttributeValue( trackedEntityAttributeValue );
+ }
+
+ entityInstanceService.updateTrackedEntityInstance( entityInstance );
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Attribute.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,169 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "attribute", namespace = DxfNamespaces.DXF_2_0 )
+public class Attribute
+{
+ private String displayName;
+
+ private String attribute;
+
+ private String type;
+
+ private String code;
+
+ private String value;
+
+ public Attribute()
+ {
+ }
+
+ public Attribute( String value )
+ {
+ this.value = value;
+ }
+
+ public Attribute( String attribute, String type, String value )
+ {
+ this.attribute = attribute;
+ this.type = type;
+ this.value = value;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName( String name )
+ {
+ this.displayName = name;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getAttribute()
+ {
+ return attribute;
+ }
+
+ public void setAttribute( String attribute )
+ {
+ this.attribute = attribute;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getCode()
+ {
+ return code;
+ }
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue( String value )
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ return true;
+ if ( o == null || getClass() != o.getClass() )
+ return false;
+
+ Attribute attribute1 = (Attribute) o;
+
+ if ( attribute != null ? !attribute.equals( attribute1.attribute ) : attribute1.attribute != null )
+ return false;
+ if ( displayName != null ? !displayName.equals( attribute1.displayName ) : attribute1.displayName != null )
+ return false;
+ if ( type != null ? !type.equals( attribute1.type ) : attribute1.type != null )
+ return false;
+ if ( code != null ? !code.equals( attribute1.code ) : attribute1.code != null )
+ return false;
+ if ( value != null ? !value.equals( attribute1.value ) : attribute1.value != null )
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = displayName != null ? displayName.hashCode() : 0;
+ result = 31 * result + (attribute != null ? attribute.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (code != null ? code.hashCode() : 0);
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Attribute{" + "displayName='" + displayName + '\'' + ", attribute='" + attribute + '\'' + ", type='"
+ + type + '\'' + ", code='" + code + '\'' + ", value='" + value + '\'' + '}';
+ }
+}
\ No newline at end of file
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,169 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StreamUtils;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Transactional
+public class JacksonTrackedEntityInstanceService extends AbstractTrackedEntityInstanceService
+{
+ // -------------------------------------------------------------------------
+ // Implementation
+ // -------------------------------------------------------------------------
+
+ private final static ObjectMapper xmlMapper = new XmlMapper();
+
+ private final static ObjectMapper jsonMapper = new ObjectMapper();
+
+ @SuppressWarnings( "unchecked" )
+ private static <T> T fromXml( InputStream inputStream, Class<?> clazz ) throws IOException
+ {
+ return (T) xmlMapper.readValue( inputStream, clazz );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private static <T> T fromXml( String input, Class<?> clazz ) throws IOException
+ {
+ return (T) xmlMapper.readValue( input, clazz );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private static <T> T fromJson( InputStream inputStream, Class<?> clazz ) throws IOException
+ {
+ return (T) jsonMapper.readValue( inputStream, clazz );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private static <T> T fromJson( String input, Class<?> clazz ) throws IOException
+ {
+ return (T) jsonMapper.readValue( input, clazz );
+ }
+
+ static
+ {
+ xmlMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true );
+ xmlMapper.configure( DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true );
+ xmlMapper.configure( DeserializationFeature.WRAP_EXCEPTIONS, true );
+ jsonMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true );
+ jsonMapper.configure( DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true );
+ jsonMapper.configure( DeserializationFeature.WRAP_EXCEPTIONS, true );
+ }
+
+ // -------------------------------------------------------------------------
+ // CREATE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummaries saveTrackedEntityInstanceXml( InputStream inputStream ) throws IOException
+ {
+ ImportSummaries importSummaries = new ImportSummaries();
+ String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
+
+ try
+ {
+ TrackedEntityInstances trackedEntityInstances = fromXml( input, TrackedEntityInstances.class );
+
+ for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
+ {
+ trackedEntityInstance.setTrackedEntityInstance( null );
+ importSummaries.addImportSummary( saveTrackedEntityInstance( trackedEntityInstance ) );
+ }
+ }
+ catch ( Exception ex )
+ {
+ TrackedEntityInstance trackedEntityInstance = fromXml( input, TrackedEntityInstance.class );
+ trackedEntityInstance.setTrackedEntityInstance( null );
+ importSummaries.addImportSummary( saveTrackedEntityInstance( trackedEntityInstance ) );
+ }
+
+ return importSummaries;
+ }
+
+ @Override
+ public ImportSummaries saveTrackedEntityInstanceJson( InputStream inputStream ) throws IOException
+ {
+ ImportSummaries importSummaries = new ImportSummaries();
+ String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
+
+ try
+ {
+ TrackedEntityInstances trackedEntityInstances = fromJson( input, TrackedEntityInstances.class );
+
+ for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
+ {
+ trackedEntityInstance.setTrackedEntityInstance( null );
+ importSummaries.addImportSummary( saveTrackedEntityInstance( trackedEntityInstance ) );
+ }
+ }
+ catch ( Exception ex )
+ {
+ TrackedEntityInstance trackedEntityInstance = fromJson( input, TrackedEntityInstance.class );
+ trackedEntityInstance.setTrackedEntityInstance( null );
+ importSummaries.addImportSummary( saveTrackedEntityInstance( trackedEntityInstance ) );
+ }
+
+ return importSummaries;
+ }
+
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
+
+ @Override
+ public ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream ) throws IOException
+ {
+ TrackedEntityInstance trackedEntityInstance = fromXml( inputStream, TrackedEntityInstance.class );
+ trackedEntityInstance.setTrackedEntityInstance( id );
+
+ return updateTrackedEntityInstance( trackedEntityInstance );
+ }
+
+ @Override
+ public ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream ) throws IOException
+ {
+ TrackedEntityInstance trackedEntityInstance = fromJson( inputStream, TrackedEntityInstance.class );
+ trackedEntityInstance.setTrackedEntityInstance( id );
+
+ return updateTrackedEntityInstance( trackedEntityInstance );
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Relationship.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Relationship.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/Relationship.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,122 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "relationship", namespace = DxfNamespaces.DXF_2_0 )
+public class Relationship
+{
+ private String displayName;
+
+ private String trackedEntityInstance;
+
+ private String type;
+
+ public Relationship()
+ {
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName( String name )
+ {
+ this.displayName = name;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getTrackedEntityInstance()
+ {
+ return trackedEntityInstance;
+ }
+
+ public void setTrackedEntityInstance( String trackedEntityInstance )
+ {
+ this.trackedEntityInstance = trackedEntityInstance;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+
+ Relationship that = (Relationship) o;
+
+ if ( displayName != null ? !displayName.equals( that.displayName ) : that.displayName != null ) return false;
+ if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( that.trackedEntityInstance ) : that.trackedEntityInstance != null )
+ return false;
+ if ( type != null ? !type.equals( that.type ) : that.type != null ) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = displayName != null ? displayName.hashCode() : 0;
+ result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Relationship{" +
+ "displayName='" + displayName + '\'' +
+ ", trackedEntityInstance='" + trackedEntityInstance + '\'' +
+ ", type='" + type + '\'' +
+ '}';
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstance.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstance.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstance.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,159 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "trackedEntityInstance", namespace = DxfNamespaces.DXF_2_0 )
+public class TrackedEntityInstance
+{
+ private String trackedEntity;
+
+ private String trackedEntityInstance;
+
+ private String orgUnit;
+
+ private List<Relationship> relationships = new ArrayList<Relationship>();
+
+ private List<Attribute> attributes = new ArrayList<Attribute>();
+
+ public TrackedEntityInstance()
+ {
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( isAttribute = true )
+ public String getTrackedEntity()
+ {
+ return trackedEntity;
+ }
+
+ public void setTrackedEntity( String trackedEntity )
+ {
+ this.trackedEntity = trackedEntity;
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( isAttribute = true )
+ public String getTrackedEntityInstance()
+ {
+ return trackedEntityInstance;
+ }
+
+ public void setTrackedEntityInstance( String trackedEntityInstance )
+ {
+ this.trackedEntityInstance = trackedEntityInstance;
+ }
+
+ @JsonProperty( required = true )
+ @JacksonXmlProperty( isAttribute = true )
+ public String getOrgUnit()
+ {
+ return orgUnit;
+ }
+
+ public void setOrgUnit( String orgUnit )
+ {
+ this.orgUnit = orgUnit;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public List<Relationship> getRelationships()
+ {
+ return relationships;
+ }
+
+ public void setRelationships( List<Relationship> relationships )
+ {
+ this.relationships = relationships;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public List<Attribute> getAttributes()
+ {
+ return attributes;
+ }
+
+ public void setAttributes( List<Attribute> attributes )
+ {
+ this.attributes = attributes;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o ) return true;
+ if ( o == null || getClass() != o.getClass() ) return false;
+
+ TrackedEntityInstance that = (TrackedEntityInstance) o;
+
+ if ( attributes != null ? !attributes.equals( that.attributes ) : that.attributes != null ) return false;
+ if ( orgUnit != null ? !orgUnit.equals( that.orgUnit ) : that.orgUnit != null ) return false;
+ if ( relationships != null ? !relationships.equals( that.relationships ) : that.relationships != null ) return false;
+ if ( trackedEntity != null ? !trackedEntity.equals( that.trackedEntity ) : that.trackedEntity != null ) return false;
+ if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( that.trackedEntityInstance ) : that.trackedEntityInstance != null )
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = trackedEntity != null ? trackedEntity.hashCode() : 0;
+ result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
+ result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0);
+ result = 31 * result + (relationships != null ? relationships.hashCode() : 0);
+ result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TrackedEntityInstance{" +
+ "trackedEntity='" + trackedEntity + '\'' +
+ ", trackedEntityInstance='" + trackedEntityInstance + '\'' +
+ ", orgUnit='" + orgUnit + '\'' +
+ ", relationships=" + relationships +
+ ", attributes=" + attributes +
+ '}';
+ }
+}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,92 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
+import org.hisp.dhis.dxf2.importsummary.ImportSummary;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.program.Program;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface TrackedEntityInstanceService
+{
+ // -------------------------------------------------------------------------
+ // READ
+ // -------------------------------------------------------------------------
+
+ TrackedEntityInstances getTrackedEntityInstances();
+
+ TrackedEntityInstances getTrackedEntityInstances( OrganisationUnit organisationUnit );
+
+ TrackedEntityInstances getTrackedEntityInstances( Program program );
+
+ TrackedEntityInstances getTrackedEntityInstances( OrganisationUnit organisationUnit, Program program );
+
+ TrackedEntityInstances getTrackedEntityInstances( Collection<org.hisp.dhis.trackedentity.TrackedEntityInstance> entityInstances );
+
+ TrackedEntityInstance getTrackedEntityInstance( String uid );
+
+ TrackedEntityInstance getTrackedEntityInstance( org.hisp.dhis.trackedentity.TrackedEntityInstance entityInstance );
+
+ // -------------------------------------------------------------------------
+ // CREATE
+ // -------------------------------------------------------------------------
+
+ ImportSummaries saveTrackedEntityInstanceXml( InputStream inputStream )
+ throws IOException;
+
+ ImportSummaries saveTrackedEntityInstanceJson( InputStream inputStream )
+ throws IOException;
+
+ ImportSummary saveTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
+
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
+
+ ImportSummary updateTrackedEntityInstanceXml( String id, InputStream inputStream )
+ throws IOException;
+
+ ImportSummary updateTrackedEntityInstanceJson( String id, InputStream inputStream )
+ throws IOException;
+
+ ImportSummary updateTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
+
+ // -------------------------------------------------------------------------
+ // DELETE
+ // -------------------------------------------------------------------------
+
+ void deleteTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance );
+}
=== added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstances.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstances.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstances.java 2014-03-17 08:22:01 +0000
@@ -0,0 +1,72 @@
+package org.hisp.dhis.dxf2.events.trackedentity;
+
+/*
+ * Copyright (c) 2004-2013, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.DxfNamespaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@JacksonXmlRootElement( localName = "trackedEntityInstances", namespace = DxfNamespaces.DXF_2_0 )
+public class TrackedEntityInstances
+{
+ private List<TrackedEntityInstance> trackedEntityInstances = new ArrayList<TrackedEntityInstance>();
+
+ public TrackedEntityInstances()
+ {
+ }
+
+ @JsonProperty( "trackedEntityInstanceList" )
+ @JacksonXmlElementWrapper( localName = "trackedEntityInstanceList", namespace = DxfNamespaces.DXF_2_0 )
+ @JacksonXmlProperty( localName = "trackedEntityInstance", namespace = DxfNamespaces.DXF_2_0 )
+ public List<TrackedEntityInstance> getTrackedEntityInstances()
+ {
+ return trackedEntityInstances;
+ }
+
+ public void setTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
+ {
+ this.trackedEntityInstances = trackedEntityInstances;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TrackedEntityInstances{" +
+ "trackedEntityInstances=" + trackedEntityInstances +
+ '}';
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/AttributeSchemaDescriptor.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/AttributeSchemaDescriptor.java 2014-03-13 16:43:37 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/AttributeSchemaDescriptor.java 2014-03-17 08:22:01 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.dxf2.events.person.Attribute;
+import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.dxf2.schema.Schema;
import org.hisp.dhis.dxf2.schema.SchemaDescriptor;
import org.springframework.stereotype.Component;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2014-03-17 08:22:01 +0000
@@ -30,7 +30,7 @@
<bean id="org.hisp.dhis.dxf2.events.event.EventService" class="org.hisp.dhis.dxf2.events.event.JacksonEventService" />
- <bean id="org.hisp.dhis.dxf2.events.person.PersonService" class="org.hisp.dhis.dxf2.events.person.JacksonTrackedEntityInstanceService" />
+ <bean id="org.hisp.dhis.dxf2.events.person.PersonService" class="org.hisp.dhis.dxf2.events.trackedentity.JacksonTrackedEntityInstanceService" />
<bean id="org.hisp.dhis.dxf2.events.enrollment.EnrollmentService" class="org.hisp.dhis.dxf2.events.enrollment.JacksonEnrollmentService" />
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2014-03-17 08:22:01 +0000
@@ -42,8 +42,8 @@
import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.i18n.I18nFormat;
@@ -146,8 +146,8 @@
programInstanceService.enrollTrackedEntityInstance( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
programInstanceService.enrollTrackedEntityInstance( femaleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) );
- TrackedEntityInstance male = trackedEntityInstanceService.getPerson( maleA );
- TrackedEntityInstance female = trackedEntityInstanceService.getPerson( femaleA );
+ TrackedEntityInstance male = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
+ TrackedEntityInstance female = trackedEntityInstanceService.getTrackedEntityInstance( femaleA );
assertEquals( 1, enrollmentService.getEnrollments( male ).getEnrollments().size() );
assertEquals( 1, enrollmentService.getEnrollments( female ).getEnrollments().size() );
@@ -335,9 +335,9 @@
ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment );
assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( maleA );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
// person.setName( "Changed Name" );
- trackedEntityInstanceService.updatePerson( trackedEntityInstance );
+ trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance );
List<Enrollment> enrollments = enrollmentService.getEnrollments( trackedEntityInstance ).getEnrollments();
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2014-03-17 08:22:01 +0000
@@ -42,8 +42,8 @@
import org.hisp.dhis.dxf2.events.event.DataValue;
import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.events.event.EventService;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -119,7 +119,7 @@
identifiableObjectManager.save( femaleA );
identifiableObjectManager.save( femaleB );
- trackedEntityInstanceMaleA = trackedEntityInstanceService.getPerson( maleA );
+ trackedEntityInstanceMaleA = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
dataElementA = createDataElement( 'A' );
dataElementB = createDataElement( 'B' );
@@ -296,7 +296,7 @@
event.setProgram( program );
event.setProgramStage( programStage );
event.setOrgUnit( orgUnit );
- event.setPerson( person );
+ event.setTrackedEntityInstance( person );
event.setEventDate( "2013-01-01" );
event.getDataValues().add( new DataValue( dataElement, "10" ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2014-03-17 08:22:01 +0000
@@ -44,8 +44,8 @@
import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.events.event.EventService;
import org.hisp.dhis.dxf2.events.event.EventStatus;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -109,7 +109,7 @@
identifiableObjectManager.save( femaleA );
identifiableObjectManager.save( femaleB );
- trackedEntityInstanceMaleA = trackedEntityInstanceService.getPerson( maleA );
+ trackedEntityInstanceMaleA = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
dataElementA = createDataElement( 'A' );
dataElementA.setType( DataElement.VALUE_TYPE_INT );
@@ -230,7 +230,7 @@
Event event = new Event();
event.setProgram( program );
event.setOrgUnit( orgUnit );
- event.setPerson( person );
+ event.setTrackedEntityInstance( person );
event.setEventDate( "2013-01-01" );
event.getDataValues().add( new DataValue( dataElementA.getUid(), "10" ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/TrackedEntityInstanceServiceTest.java 2014-03-17 08:22:01 +0000
@@ -30,8 +30,8 @@
import org.hisp.dhis.DhisTest;
import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -108,58 +108,58 @@
@Test
public void testGetPersons()
{
- assertEquals( 4, trackedEntityInstanceService.getPersons().getTrackedEntityInstances().size() );
+ assertEquals( 4, trackedEntityInstanceService.getTrackedEntityInstances().getTrackedEntityInstances().size() );
}
@Test
public void testGetPersonByOrganisationUnit()
{
- assertEquals( 2, trackedEntityInstanceService.getPersons( organisationUnitA ).getTrackedEntityInstances().size() );
- assertEquals( 2, trackedEntityInstanceService.getPersons( organisationUnitB ).getTrackedEntityInstances().size() );
+ assertEquals( 2, trackedEntityInstanceService.getTrackedEntityInstances( organisationUnitA ).getTrackedEntityInstances().size() );
+ assertEquals( 2, trackedEntityInstanceService.getTrackedEntityInstances( organisationUnitB ).getTrackedEntityInstances().size() );
}
@Test
public void getPersonByPatients()
{
List<org.hisp.dhis.trackedentity.TrackedEntityInstance> patients = Arrays.asList( maleA, femaleB );
- assertEquals( 2, trackedEntityInstanceService.getPersons( patients ).getTrackedEntityInstances().size() );
+ assertEquals( 2, trackedEntityInstanceService.getTrackedEntityInstances( patients ).getTrackedEntityInstances().size() );
}
@Test
public void getPersonByUid()
{
- assertEquals( maleA.getUid(), trackedEntityInstanceService.getPerson( maleA.getUid() ).getTrackedEntityInstance() );
- assertEquals( femaleB.getUid(), trackedEntityInstanceService.getPerson( femaleB.getUid() ).getTrackedEntityInstance() );
- assertNotEquals( femaleA.getUid(), trackedEntityInstanceService.getPerson( femaleB.getUid() ).getTrackedEntityInstance() );
- assertNotEquals( maleA.getUid(), trackedEntityInstanceService.getPerson( maleB.getUid() ).getTrackedEntityInstance() );
+ assertEquals( maleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( maleA.getUid() ).getTrackedEntityInstance() );
+ assertEquals( femaleB.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( femaleB.getUid() ).getTrackedEntityInstance() );
+ assertNotEquals( femaleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( femaleB.getUid() ).getTrackedEntityInstance() );
+ assertNotEquals( maleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( maleB.getUid() ).getTrackedEntityInstance() );
}
@Test
public void getPersonByPatient()
{
- assertEquals( maleA.getUid(), trackedEntityInstanceService.getPerson( maleA ).getTrackedEntityInstance() );
- assertEquals( femaleB.getUid(), trackedEntityInstanceService.getPerson( femaleB ).getTrackedEntityInstance() );
- assertNotEquals( femaleA.getUid(), trackedEntityInstanceService.getPerson( femaleB ).getTrackedEntityInstance() );
- assertNotEquals( maleA.getUid(), trackedEntityInstanceService.getPerson( maleB ).getTrackedEntityInstance() );
+ assertEquals( maleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( maleA ).getTrackedEntityInstance() );
+ assertEquals( femaleB.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( femaleB ).getTrackedEntityInstance() );
+ assertNotEquals( femaleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( femaleB ).getTrackedEntityInstance() );
+ assertNotEquals( maleA.getUid(), trackedEntityInstanceService.getTrackedEntityInstance( maleB ).getTrackedEntityInstance() );
}
@Test
public void testGetPersonByProgram()
{
- assertEquals( 2, trackedEntityInstanceService.getPersons( programA ).getTrackedEntityInstances().size() );
+ assertEquals( 2, trackedEntityInstanceService.getTrackedEntityInstances( programA ).getTrackedEntityInstances().size() );
}
@Test
@Ignore
public void testUpdatePerson()
{
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( maleA.getUid() );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( maleA.getUid() );
// person.setName( "UPDATED_NAME" );
- ImportSummary importSummary = trackedEntityInstanceService.updatePerson( trackedEntityInstance );
+ ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance );
assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
- // assertEquals( "UPDATED_NAME", personService.getPerson( maleA.getUid() ).getName() );
+ // assertEquals( "UPDATED_NAME", personService.getTrackedEntityInstance( maleA.getUid() ).getName() );
}
@Test
@@ -170,19 +170,19 @@
// person.setName( "NAME" );
trackedEntityInstance.setOrgUnit( organisationUnitA.getUid() );
- ImportSummary importSummary = trackedEntityInstanceService.savePerson( trackedEntityInstance );
+ ImportSummary importSummary = trackedEntityInstanceService.saveTrackedEntityInstance( trackedEntityInstance );
assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
- // assertEquals( "NAME", personService.getPerson( importSummary.getReference() ).getName() );
+ // assertEquals( "NAME", personService.getTrackedEntityInstance( importSummary.getReference() ).getName() );
}
@Test
public void testDeletePerson()
{
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( maleA.getUid() );
- trackedEntityInstanceService.deletePerson( trackedEntityInstance );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( maleA.getUid() );
+ trackedEntityInstanceService.deleteTrackedEntityInstance( trackedEntityInstance );
- assertNull( trackedEntityInstanceService.getPerson( maleA.getUid() ) );
- assertNotNull( trackedEntityInstanceService.getPerson( maleB.getUid() ) );
+ assertNull( trackedEntityInstanceService.getTrackedEntityInstance( maleA.getUid() ) );
+ assertNotNull( trackedEntityInstanceService.getTrackedEntityInstance( maleB.getUid() ) );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java 2014-03-17 08:22:01 +0000
@@ -36,8 +36,8 @@
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
import org.hisp.dhis.dxf2.events.enrollment.Enrollments;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -273,7 +273,7 @@
private TrackedEntityInstance getPerson( String id ) throws NotFoundException
{
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( id );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( id );
if ( trackedEntityInstance == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-03-17 08:22:01 +0000
@@ -36,8 +36,8 @@
import org.hisp.dhis.dxf2.events.event.EventService;
import org.hisp.dhis.dxf2.events.event.Events;
import org.hisp.dhis.dxf2.events.event.ImportEventTask;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -136,7 +136,7 @@
if ( trackedEntityInstanceUid != null )
{
- trackedEntityInstance = trackedEntityInstanceService.getPerson( trackedEntityInstanceUid );
+ trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( trackedEntityInstanceUid );
if ( trackedEntityInstance == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java 2014-03-17 08:06:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java 2014-03-17 08:22:01 +0000
@@ -45,9 +45,9 @@
import org.hisp.dhis.api.controller.exception.NotFoundException;
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstance;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstanceService;
-import org.hisp.dhis.dxf2.events.person.TrackedEntityInstances;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
+import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstances;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
@@ -113,12 +113,12 @@
OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
Program program = getProgram( programUid );
- trackedEntityInstances = trackedEntityInstanceService.getPersons( organisationUnit, program );
+ trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances( organisationUnit, program );
}
else
{
OrganisationUnit organisationUnit = getOrganisationUnit( orgUnitUid );
- trackedEntityInstances = trackedEntityInstanceService.getPersons( organisationUnit );
+ trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances( organisationUnit );
}
}
else
@@ -231,7 +231,7 @@
criteria.addOrder( Order.desc( "lastUpdated" ) );
- return trackedEntityInstanceService.getPersons( criteria.list() );
+ return trackedEntityInstanceService.getTrackedEntityInstances( criteria.list() );
}
@RequestMapping( value = "/{id}", method = RequestMethod.GET )
@@ -257,7 +257,7 @@
public void postPersonXml( HttpServletRequest request, HttpServletResponse response )
throws IOException
{
- ImportSummaries importSummaries = trackedEntityInstanceService.savePersonXml( request.getInputStream() );
+ ImportSummaries importSummaries = trackedEntityInstanceService.saveTrackedEntityInstanceXml( request.getInputStream() );
if ( importSummaries.getImportSummaries().size() > 1 )
{
@@ -283,7 +283,7 @@
public void postPersonJson( HttpServletRequest request, HttpServletResponse response )
throws IOException
{
- ImportSummaries importSummaries = trackedEntityInstanceService.savePersonJson( request.getInputStream() );
+ ImportSummaries importSummaries = trackedEntityInstanceService.saveTrackedEntityInstanceJson( request.getInputStream() );
if ( importSummaries.getImportSummaries().size() > 1 )
{
@@ -314,7 +314,7 @@
public void updatePersonXml( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
throws IOException
{
- ImportSummary importSummary = trackedEntityInstanceService.updatePersonXml( id, request.getInputStream() );
+ ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceXml( id, request.getInputStream() );
JacksonUtils.toXml( response.getOutputStream(), importSummary );
}
@@ -324,7 +324,7 @@
public void updatePersonJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
throws IOException
{
- ImportSummary importSummary = trackedEntityInstanceService.updatePersonJson( id, request.getInputStream() );
+ ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceJson( id, request.getInputStream() );
JacksonUtils.toJson( response.getOutputStream(), importSummary );
}
@@ -339,7 +339,7 @@
throws NotFoundException
{
TrackedEntityInstance trackedEntityInstance = getPerson( id );
- trackedEntityInstanceService.deletePerson( trackedEntityInstance );
+ trackedEntityInstanceService.deleteTrackedEntityInstance( trackedEntityInstance );
}
// -------------------------------------------------------------------------
@@ -349,7 +349,7 @@
private TrackedEntityInstance getPerson( String id )
throws NotFoundException
{
- TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getPerson( id );
+ TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( id );
if ( trackedEntityInstance == null )
{