=== removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/AbstractPersonService.java 2013-09-10 13:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/AbstractPersonService.java 1970-01-01 00:00:00 +0000 @@ -1,192 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.i18n.I18nFormat; -import org.hisp.dhis.i18n.I18nManager; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.patient.PatientService; -import org.hisp.dhis.program.Program; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty; - -/** - * @author Morten Olav Hansen - */ -@Transactional -public abstract class AbstractPersonService implements PersonService -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - @Autowired - private PatientService patientService; - - @Autowired - private I18nManager i18nManager; - - private I18nFormat format; - - // ------------------------------------------------------------------------- - // Implementation - // ------------------------------------------------------------------------- - - @Override - public Persons getPersons() - { - List patients = new ArrayList( patientService.getAllPatients() ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( OrganisationUnit organisationUnit ) - { - List patients = new ArrayList( patientService.getPatients( organisationUnit ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( Gender gender ) - { - List patients = new ArrayList( patientService.getPatiensByGender( gender.getValue() ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( Program program ) - { - List patients = new ArrayList( patientService.getPatients( program ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( Program program, Gender gender ) - { - List patients = new ArrayList( patientService.getPatients( program, gender.getValue() ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( OrganisationUnit organisationUnit, Program program ) - { - List patients = new ArrayList( patientService.getPatients( organisationUnit, program ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( OrganisationUnit organisationUnit, Gender gender ) - { - List patients = new ArrayList( patientService.getPatients( organisationUnit, gender.getValue() ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( OrganisationUnit organisationUnit, Program program, Gender gender ) - { - List patients = new ArrayList( patientService.getPatients( organisationUnit, program, gender.getValue() ) ); - return getPersons( patients ); - } - - @Override - public Persons getPersons( Collection patients ) - { - Persons persons = new Persons(); - - for ( Patient patient : patients ) - { - persons.getPersons().add( getPerson( patient ) ); - } - - return persons; - } - - @Override - public Person getPerson( String uid ) - { - return getPerson( patientService.getPatient( uid ) ); - } - - @Override - public Person getPerson( Patient patient ) - { - Person person = new Person(); - person.setPerson( patient.getUid() ); - person.setOrgUnit( patient.getOrganisationUnit().getUid() ); - - person.setName( patient.getFullName() ); - person.setGender( Gender.fromString( patient.getGender() ) ); - - person.setDeceased( patient.getIsDead() ); - person.setDateOfDeath( patient.getDeathDate() ); - - Contact contact = new Contact(); - contact.setPhoneNumber( nullIfEmpty( patient.getPhoneNumber() ) ); - - if ( contact.getPhoneNumber() != null ) - { - person.setContact( contact ); - } - - DateOfBirth dateOfBirth = new DateOfBirth( patient.getBirthDate(), - DateOfBirthType.fromString( String.valueOf( patient.getDobType() ) ) ); - - person.setDateOfBirth( dateOfBirth ); - person.setDateOfRegistration( patient.getRegistrationDate() ); - - return person; - } - - @Override - public void updatePerson( Person person ) - { - } - - @Override - public void deletePerson( Person person ) - { - Patient patient = patientService.getPatient( person.getPerson() ); - - if ( patient != null ) - { - patientService.deletePatient( patient ); - } - else - { - throw new IllegalArgumentException(); - } - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Contact.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Contact.java 2013-09-10 10:46:59 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Contact.java 1970-01-01 00:00:00 +0000 @@ -1,59 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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 - */ -@JacksonXmlRootElement( localName = "contact", namespace = DxfNamespaces.DXF_2_0 ) -public class Contact -{ - private String phoneNumber; - - public Contact() - { - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getPhoneNumber() - { - return phoneNumber; - } - - public void setPhoneNumber( String phoneNumber ) - { - this.phoneNumber = phoneNumber; - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirth.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirth.java 2013-09-10 10:46:59 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirth.java 1970-01-01 00:00:00 +0000 @@ -1,77 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.Date; - -/** - * @author Morten Olav Hansen - */ -@JacksonXmlRootElement( localName = "dateOfBirth", namespace = DxfNamespaces.DXF_2_0 ) -public class DateOfBirth -{ - private Date date; - - private DateOfBirthType type; - - public DateOfBirth() - { - } - - public DateOfBirth( Date date ) - { - this.date = date; - this.type = DateOfBirthType.VERIFIED; - } - - public DateOfBirth( Date date, DateOfBirthType type ) - { - this.date = date; - this.type = type; - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( isAttribute = true ) - public Date getDate() - { - return date; - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( isAttribute = true ) - public DateOfBirthType getType() - { - return type; - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirthType.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirthType.java 2013-09-10 12:18:56 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DateOfBirthType.java 1970-01-01 00:00:00 +0000 @@ -1,64 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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. - */ - -/** - * @author Morten Olav Hansen - */ -public enum DateOfBirthType -{ - VERIFIED( "V" ), - DECLARED( "D" ), - APPROXIMATE( "A" ); - - private final String value; - - private DateOfBirthType( String value ) - { - this.value = value; - } - - public String getValue() - { - return value; - } - - public static DateOfBirthType fromString( String text ) - { - for ( DateOfBirthType dateOfBirthType : DateOfBirthType.values() ) - { - if ( text.equals( dateOfBirthType.getValue() ) ) - { - return dateOfBirthType; - } - } - - throw new IllegalArgumentException(); - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Gender.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Gender.java 2013-09-10 12:18:56 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Gender.java 1970-01-01 00:00:00 +0000 @@ -1,66 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.dataformat.xml.annotation.JacksonXmlRootElement; -import org.hisp.dhis.common.DxfNamespaces; - -/** - * @author Morten Olav Hansen - */ -@JacksonXmlRootElement( localName = "gender", namespace = DxfNamespaces.DXF_2_0 ) -public enum Gender -{ - MALE( "M" ), FEMALE( "F" ), TRANSGENDER( "T" ); - - private final String value; - - private Gender( String value ) - { - this.value = value; - } - - public String getValue() - { - return value; - } - - public static Gender fromString( String text ) - { - for ( Gender gender : Gender.values() ) - { - if ( text.equals( gender.getValue() ) ) - { - return gender; - } - } - - throw new IllegalArgumentException(); - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonPersonService.java 2013-09-06 09:34:21 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/JacksonPersonService.java 1970-01-01 00:00:00 +0000 @@ -1,88 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.hisp.dhis.system.notification.Notifier; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Morten Olav Hansen - */ -public class JacksonPersonService extends AbstractPersonService -{ - @Autowired - private Notifier notifier; - - // ------------------------------------------------------------------------- - // Implementation - // ------------------------------------------------------------------------- - - private static ObjectMapper xmlMapper = new XmlMapper(); - private static ObjectMapper jsonMapper = new ObjectMapper(); - - @SuppressWarnings( "unchecked" ) - private static T fromXml( InputStream inputStream, Class clazz ) throws IOException - { - return (T) xmlMapper.readValue( inputStream, clazz ); - } - - @SuppressWarnings( "unchecked" ) - private static T fromXml( String input, Class clazz ) throws IOException - { - return (T) xmlMapper.readValue( input, clazz ); - } - - @SuppressWarnings( "unchecked" ) - private static T fromJson( InputStream inputStream, Class clazz ) throws IOException - { - return (T) jsonMapper.readValue( inputStream, clazz ); - } - - @SuppressWarnings( "unchecked" ) - private static 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 ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Person.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Person.java 2013-09-10 11:41:45 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Person.java 1970-01-01 00:00:00 +0000 @@ -1,200 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.Date; - -/** - * @author Morten Olav Hansen - */ -@JacksonXmlRootElement(localName = "person", namespace = DxfNamespaces.DXF_2_0) -public class Person -{ - private String person; - - private String orgUnit; - - private String name; - - private Gender gender; - - private DateOfBirth dateOfBirth; - - private boolean deceased; - - private Date dateOfDeath; - - private Date dateOfRegistration; - - private Contact contact; - - public Person() - { - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( isAttribute = true ) - public String getPerson() - { - return person; - } - - public void setPerson( String person ) - { - this.person = person; - } - - @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 String getName() - { - return name; - } - - public void setName( String name ) - { - this.name = name; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Gender getGender() - { - return gender; - } - - public void setGender( Gender gender ) - { - this.gender = gender; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public DateOfBirth getDateOfBirth() - { - return dateOfBirth; - } - - public void setDateOfBirth( DateOfBirth dateOfBirth ) - { - this.dateOfBirth = dateOfBirth; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public boolean isDeceased() - { - return deceased; - } - - public void setDeceased( boolean deceased ) - { - this.deceased = deceased; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getDateOfDeath() - { - return dateOfDeath; - } - - public void setDateOfDeath( Date dateOfDeath ) - { - this.dateOfDeath = dateOfDeath; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getDateOfRegistration() - { - return dateOfRegistration; - } - - public void setDateOfRegistration( Date dateOfRegistration ) - { - this.dateOfRegistration = dateOfRegistration; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Contact getContact() - { - return contact; - } - - public void setContact( Contact contact ) - { - this.contact = contact; - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) return true; - if ( o == null || getClass() != o.getClass() ) return false; - - Person person = (Person) o; - - if ( person != null ? !person.equals( person.person ) : person.person != null ) return false; - - return true; - } - - @Override - public int hashCode() - { - return person != null ? person.hashCode() : 0; - } - - @Override - public String toString() - { - return "Person{" + - "person='" + person + '\'' + - '}'; - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/PersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/PersonService.java 2013-09-10 13:10:10 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/PersonService.java 1970-01-01 00:00:00 +0000 @@ -1,67 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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.organisationunit.OrganisationUnit; -import org.hisp.dhis.patient.Patient; -import org.hisp.dhis.program.Program; - -import java.util.Collection; - -/** - * @author Morten Olav Hansen - */ -public interface PersonService -{ - Persons getPersons(); - - Persons getPersons( OrganisationUnit organisationUnit ); - - Persons getPersons( Gender gender ); - - Persons getPersons( Program program ); - - Persons getPersons( Program program, Gender gender ); - - Persons getPersons( OrganisationUnit organisationUnit, Program program ); - - Persons getPersons( OrganisationUnit organisationUnit, Gender gender ); - - Persons getPersons( OrganisationUnit organisationUnit, Program program, Gender gender ); - - Persons getPersons( Collection patients ); - - Person getPerson( String uid ); - - Person getPerson( Patient patient ); - - void updatePerson( Person person ); - - void deletePerson( Person person ); -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Persons.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Persons.java 2013-09-06 09:34:21 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/Persons.java 1970-01-01 00:00:00 +0000 @@ -1,72 +0,0 @@ -package org.hisp.dhis.dxf2.event; - -/* - * 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 - */ -@JacksonXmlRootElement( localName = "persons", namespace = DxfNamespaces.DXF_2_0 ) -public class Persons -{ - private List persons = new ArrayList(); - - public Persons() - { - } - - @JsonProperty( "personList" ) - @JacksonXmlElementWrapper( localName = "personList", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "person", namespace = DxfNamespaces.DXF_2_0 ) - public List getPersons() - { - return persons; - } - - public void setPersons( List persons ) - { - this.persons = persons; - } - - @Override - public String toString() - { - return "Persons{" + - "persons=" + persons + - '}'; - } -} === added directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person' === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,192 @@ +package org.hisp.dhis.dxf2.event.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.i18n.I18nFormat; +import org.hisp.dhis.i18n.I18nManager; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.program.Program; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty; + +/** + * @author Morten Olav Hansen + */ +@Transactional +public abstract class AbstractPersonService implements PersonService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private PatientService patientService; + + @Autowired + private I18nManager i18nManager; + + private I18nFormat format; + + // ------------------------------------------------------------------------- + // Implementation + // ------------------------------------------------------------------------- + + @Override + public Persons getPersons() + { + List patients = new ArrayList( patientService.getAllPatients() ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( OrganisationUnit organisationUnit ) + { + List patients = new ArrayList( patientService.getPatients( organisationUnit ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( Gender gender ) + { + List patients = new ArrayList( patientService.getPatiensByGender( gender.getValue() ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( Program program ) + { + List patients = new ArrayList( patientService.getPatients( program ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( Program program, Gender gender ) + { + List patients = new ArrayList( patientService.getPatients( program, gender.getValue() ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( OrganisationUnit organisationUnit, Program program ) + { + List patients = new ArrayList( patientService.getPatients( organisationUnit, program ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( OrganisationUnit organisationUnit, Gender gender ) + { + List patients = new ArrayList( patientService.getPatients( organisationUnit, gender.getValue() ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( OrganisationUnit organisationUnit, Program program, Gender gender ) + { + List patients = new ArrayList( patientService.getPatients( organisationUnit, program, gender.getValue() ) ); + return getPersons( patients ); + } + + @Override + public Persons getPersons( Collection patients ) + { + Persons persons = new Persons(); + + for ( Patient patient : patients ) + { + persons.getPersons().add( getPerson( patient ) ); + } + + return persons; + } + + @Override + public Person getPerson( String uid ) + { + return getPerson( patientService.getPatient( uid ) ); + } + + @Override + public Person getPerson( Patient patient ) + { + Person person = new Person(); + person.setPerson( patient.getUid() ); + person.setOrgUnit( patient.getOrganisationUnit().getUid() ); + + person.setName( patient.getFullName() ); + person.setGender( Gender.fromString( patient.getGender() ) ); + + person.setDeceased( patient.getIsDead() ); + person.setDateOfDeath( patient.getDeathDate() ); + + Contact contact = new Contact(); + contact.setPhoneNumber( nullIfEmpty( patient.getPhoneNumber() ) ); + + if ( contact.getPhoneNumber() != null ) + { + person.setContact( contact ); + } + + DateOfBirth dateOfBirth = new DateOfBirth( patient.getBirthDate(), + DateOfBirthType.fromString( String.valueOf( patient.getDobType() ) ) ); + + person.setDateOfBirth( dateOfBirth ); + person.setDateOfRegistration( patient.getRegistrationDate() ); + + return person; + } + + @Override + public void updatePerson( Person person ) + { + } + + @Override + public void deletePerson( Person person ) + { + Patient patient = patientService.getPatient( person.getPerson() ); + + if ( patient != null ) + { + patientService.deletePatient( patient ); + } + else + { + throw new IllegalArgumentException(); + } + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Contact.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Contact.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Contact.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,59 @@ +package org.hisp.dhis.dxf2.event.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 + */ +@JacksonXmlRootElement( localName = "contact", namespace = DxfNamespaces.DXF_2_0 ) +public class Contact +{ + private String phoneNumber; + + public Contact() + { + } + + @JsonProperty( required = true ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public String getPhoneNumber() + { + return phoneNumber; + } + + public void setPhoneNumber( String phoneNumber ) + { + this.phoneNumber = phoneNumber; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirth.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,77 @@ +package org.hisp.dhis.dxf2.event.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.Date; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement( localName = "dateOfBirth", namespace = DxfNamespaces.DXF_2_0 ) +public class DateOfBirth +{ + private Date date; + + private DateOfBirthType type; + + public DateOfBirth() + { + } + + public DateOfBirth( Date date ) + { + this.date = date; + this.type = DateOfBirthType.VERIFIED; + } + + public DateOfBirth( Date date, DateOfBirthType type ) + { + this.date = date; + this.type = type; + } + + @JsonProperty( required = true ) + @JacksonXmlProperty( isAttribute = true ) + public Date getDate() + { + return date; + } + + @JsonProperty( required = true ) + @JacksonXmlProperty( isAttribute = true ) + public DateOfBirthType getType() + { + return type; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirthType.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirthType.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/DateOfBirthType.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,64 @@ +package org.hisp.dhis.dxf2.event.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. + */ + +/** + * @author Morten Olav Hansen + */ +public enum DateOfBirthType +{ + VERIFIED( "V" ), + DECLARED( "D" ), + APPROXIMATE( "A" ); + + private final String value; + + private DateOfBirthType( String value ) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + public static DateOfBirthType fromString( String text ) + { + for ( DateOfBirthType dateOfBirthType : DateOfBirthType.values() ) + { + if ( text.equals( dateOfBirthType.getValue() ) ) + { + return dateOfBirthType; + } + } + + throw new IllegalArgumentException(); + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Gender.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Gender.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Gender.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,66 @@ +package org.hisp.dhis.dxf2.event.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.dataformat.xml.annotation.JacksonXmlRootElement; +import org.hisp.dhis.common.DxfNamespaces; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement( localName = "gender", namespace = DxfNamespaces.DXF_2_0 ) +public enum Gender +{ + MALE( "M" ), FEMALE( "F" ), TRANSGENDER( "T" ); + + private final String value; + + private Gender( String value ) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + public static Gender fromString( String text ) + { + for ( Gender gender : Gender.values() ) + { + if ( text.equals( gender.getValue() ) ) + { + return gender; + } + } + + throw new IllegalArgumentException(); + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/JacksonPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/JacksonPersonService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/JacksonPersonService.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,89 @@ +package org.hisp.dhis.dxf2.event.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.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import org.hisp.dhis.dxf2.event.person.AbstractPersonService; +import org.hisp.dhis.system.notification.Notifier; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author Morten Olav Hansen + */ +public class JacksonPersonService extends AbstractPersonService +{ + @Autowired + private Notifier notifier; + + // ------------------------------------------------------------------------- + // Implementation + // ------------------------------------------------------------------------- + + private static ObjectMapper xmlMapper = new XmlMapper(); + private static ObjectMapper jsonMapper = new ObjectMapper(); + + @SuppressWarnings( "unchecked" ) + private static T fromXml( InputStream inputStream, Class clazz ) throws IOException + { + return (T) xmlMapper.readValue( inputStream, clazz ); + } + + @SuppressWarnings( "unchecked" ) + private static T fromXml( String input, Class clazz ) throws IOException + { + return (T) xmlMapper.readValue( input, clazz ); + } + + @SuppressWarnings( "unchecked" ) + private static T fromJson( InputStream inputStream, Class clazz ) throws IOException + { + return (T) jsonMapper.readValue( inputStream, clazz ); + } + + @SuppressWarnings( "unchecked" ) + private static 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 ); + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Person.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,200 @@ +package org.hisp.dhis.dxf2.event.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.Date; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement(localName = "person", namespace = DxfNamespaces.DXF_2_0) +public class Person +{ + private String person; + + private String orgUnit; + + private String name; + + private Gender gender; + + private DateOfBirth dateOfBirth; + + private boolean deceased; + + private Date dateOfDeath; + + private Date dateOfRegistration; + + private Contact contact; + + public Person() + { + } + + @JsonProperty( required = true ) + @JacksonXmlProperty( isAttribute = true ) + public String getPerson() + { + return person; + } + + public void setPerson( String person ) + { + this.person = person; + } + + @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 String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Gender getGender() + { + return gender; + } + + public void setGender( Gender gender ) + { + this.gender = gender; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public DateOfBirth getDateOfBirth() + { + return dateOfBirth; + } + + public void setDateOfBirth( DateOfBirth dateOfBirth ) + { + this.dateOfBirth = dateOfBirth; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public boolean isDeceased() + { + return deceased; + } + + public void setDeceased( boolean deceased ) + { + this.deceased = deceased; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Date getDateOfDeath() + { + return dateOfDeath; + } + + public void setDateOfDeath( Date dateOfDeath ) + { + this.dateOfDeath = dateOfDeath; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Date getDateOfRegistration() + { + return dateOfRegistration; + } + + public void setDateOfRegistration( Date dateOfRegistration ) + { + this.dateOfRegistration = dateOfRegistration; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Contact getContact() + { + return contact; + } + + public void setContact( Contact contact ) + { + this.contact = contact; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) return true; + if ( o == null || getClass() != o.getClass() ) return false; + + Person person = (Person) o; + + if ( person != null ? !person.equals( person.person ) : person.person != null ) return false; + + return true; + } + + @Override + public int hashCode() + { + return person != null ? person.hashCode() : 0; + } + + @Override + public String toString() + { + return "Person{" + + "person='" + person + '\'' + + '}'; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/PersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/PersonService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/PersonService.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,70 @@ +package org.hisp.dhis.dxf2.event.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.dxf2.event.person.Gender; +import org.hisp.dhis.dxf2.event.person.Person; +import org.hisp.dhis.dxf2.event.person.Persons; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.program.Program; + +import java.util.Collection; + +/** + * @author Morten Olav Hansen + */ +public interface PersonService +{ + Persons getPersons(); + + Persons getPersons( OrganisationUnit organisationUnit ); + + Persons getPersons( Gender gender ); + + Persons getPersons( Program program ); + + Persons getPersons( Program program, Gender gender ); + + Persons getPersons( OrganisationUnit organisationUnit, Program program ); + + Persons getPersons( OrganisationUnit organisationUnit, Gender gender ); + + Persons getPersons( OrganisationUnit organisationUnit, Program program, Gender gender ); + + Persons getPersons( Collection patients ); + + Person getPerson( String uid ); + + Person getPerson( Patient patient ); + + void updatePerson( Person person ); + + void deletePerson( Person person ); +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Persons.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Persons.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/Persons.java 2013-09-10 14:11:48 +0000 @@ -0,0 +1,72 @@ +package org.hisp.dhis.dxf2.event.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 + */ +@JacksonXmlRootElement( localName = "persons", namespace = DxfNamespaces.DXF_2_0 ) +public class Persons +{ + private List persons = new ArrayList(); + + public Persons() + { + } + + @JsonProperty( "personList" ) + @JacksonXmlElementWrapper( localName = "personList", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "person", namespace = DxfNamespaces.DXF_2_0 ) + public List getPersons() + { + return persons; + } + + public void setPersons( List persons ) + { + this.persons = persons; + } + + @Override + public String toString() + { + return "Persons{" + + "persons=" + persons + + '}'; + } +} === 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 2013-09-06 09:34:21 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2013-09-10 14:11:48 +0000 @@ -18,7 +18,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java 2013-09-10 13:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java 2013-09-10 14:11:48 +0000 @@ -30,10 +30,10 @@ import org.hisp.dhis.api.controller.WebOptions; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.event.Gender; -import org.hisp.dhis.dxf2.event.Person; -import org.hisp.dhis.dxf2.event.PersonService; -import org.hisp.dhis.dxf2.event.Persons; +import org.hisp.dhis.dxf2.event.person.Gender; +import org.hisp.dhis.dxf2.event.person.Person; +import org.hisp.dhis.dxf2.event.person.PersonService; +import org.hisp.dhis.dxf2.event.person.Persons; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; import org.springframework.beans.factory.annotation.Autowired; === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java 2013-09-10 14:11:48 +0000 @@ -28,9 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import com.opensymphony.xwork2.Action; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.patient.Patient; @@ -40,7 +38,9 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.util.SessionUtils; -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; public class GetSingleEventBeneficiaryAction implements Action @@ -155,10 +155,11 @@ { //delete previous data value of other single event form SessionUtils.removeSessionVar( "prevDataValues" ); - + OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); Program program = programService.getProgram( programId ); - Collection allPatient = patientService.getPatients( orgUnit, null, null ); + Collection allPatient = patientService.getPatients( orgUnit, 0, Integer.MAX_VALUE ); + for ( Patient patient : allPatient ) { if ( programInstanceService.getProgramInstances( patient, program ).size() == 0 )