=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2014-01-07 08:22:52 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2014-01-07 10:07:23 +0000 @@ -28,12 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +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.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.view.DetailedView; @@ -50,17 +50,16 @@ import org.hisp.dhis.user.UserAuthorityGroup; import org.hisp.dhis.validation.ValidationCriteria; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -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 java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * @author Abyot Asalefew */ -@JacksonXmlRootElement( localName = "program", namespace = DxfNamespaces.DXF_2_0 ) +@JacksonXmlRootElement(localName = "program", namespace = DxfNamespaces.DXF_2_0) public class Program extends BaseIdentifiableObject { @@ -240,8 +239,8 @@ // ------------------------------------------------------------------------- @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getDescription() { return description; @@ -253,8 +252,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Integer getVersion() { return version; @@ -265,11 +264,11 @@ this.version = version; } - @JsonProperty( value = "organisationUnits" ) - @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 ) + @JsonProperty(value = "organisationUnits") + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class }) + @JacksonXmlElementWrapper(localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0) public Set getOrganisationUnits() { return organisationUnits; @@ -280,10 +279,10 @@ this.organisationUnits = organisationUnits; } - @JsonProperty( value = "programInstances" ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "programInstances", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "programInstance", namespace = DxfNamespaces.DXF_2_0 ) + @JsonProperty(value = "programInstances") + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "programInstances", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "programInstance", namespace = DxfNamespaces.DXF_2_0) public Set getProgramInstances() { return programInstances; @@ -294,11 +293,11 @@ this.programInstances = programInstances; } - @JsonProperty( value = "programStages" ) - @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "programStages", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "programStage", namespace = DxfNamespaces.DXF_2_0 ) + @JsonProperty(value = "programStages") + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "programStages", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "programStage", namespace = DxfNamespaces.DXF_2_0) public Set getProgramStages() { return programStages; @@ -310,8 +309,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getDateOfEnrollmentDescription() { return dateOfEnrollmentDescription; @@ -323,8 +322,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getDateOfIncidentDescription() { return dateOfIncidentDescription; @@ -336,14 +335,14 @@ } @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getKind() { return TYPE_LOOKUP.get( type ); } @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Integer getType() { return type; @@ -354,11 +353,11 @@ this.type = type; } - @JsonProperty( value = "validationCriterias" ) - @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0 ) + @JsonProperty(value = "validationCriterias") + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "validationCriterias", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "validationCriteria", namespace = DxfNamespaces.DXF_2_0) public Set getPatientValidationCriteria() { return patientValidationCriteria; @@ -369,10 +368,10 @@ this.patientValidationCriteria = patientValidationCriteria; } - @JsonProperty( value = "identifierTypes" ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "identifierTypes", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "identifierType", namespace = DxfNamespaces.DXF_2_0 ) + @JsonProperty(value = "identifierTypes") + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "identifierTypes", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "identifierType", namespace = DxfNamespaces.DXF_2_0) public List getPatientIdentifierTypes() { return patientIdentifierTypes; @@ -384,8 +383,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getDisplayIncidentDate() { return displayIncidentDate; @@ -397,8 +396,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) private Object getValueFromPatient( String property, Patient patient ) throws Exception { @@ -406,8 +405,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getIgnoreOverdueEvents() { return ignoreOverdueEvents; @@ -419,26 +418,26 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public boolean isSingleEvent() { return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || SINGLE_EVENT_WITHOUT_REGISTRATION == type); } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public boolean isRegistration() { return type != null && (SINGLE_EVENT_WITH_REGISTRATION == type || MULTIPLE_EVENTS_WITH_REGISTRATION == type); } @JsonProperty - @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "userRoles", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "userRole", namespace = DxfNamespaces.DXF_2_0 ) + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "userRoles", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "userRole", namespace = DxfNamespaces.DXF_2_0) public Set getUserRoles() { return userRoles; @@ -450,8 +449,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getOnlyEnrollOnce() { return onlyEnrollOnce; @@ -463,8 +462,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Set getPatientReminders() { return patientReminders; @@ -476,10 +475,10 @@ } @JsonProperty - @JsonSerialize( contentAs = BaseIdentifiableObject.class ) - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0 ) - @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0 ) + @JsonSerialize(contentAs = BaseIdentifiableObject.class) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlElementWrapper(localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty(localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0) public Set getOrganisationUnitGroups() { return organisationUnitGroups; @@ -491,8 +490,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getDisplayOnAllOrgunit() { return displayOnAllOrgunit; @@ -504,8 +503,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getSelectEnrollmentDatesInFuture() { return selectEnrollmentDatesInFuture; @@ -517,8 +516,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getSelectIncidentDatesInFuture() { return selectIncidentDatesInFuture; @@ -530,8 +529,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public String getRelationshipText() { return relationshipText; @@ -543,8 +542,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public RelationshipType getRelationshipType() { return relationshipType; @@ -556,8 +555,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Program getRelatedProgram() { return relatedProgram; @@ -569,8 +568,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getRelationshipFromA() { return relationshipFromA; @@ -582,8 +581,8 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + @JsonView({ DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class }) + @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) public Boolean getDataEntryMethod() { return dataEntryMethod; @@ -594,6 +593,10 @@ this.dataEntryMethod = dataEntryMethod; } + @JsonProperty( value = "programPersonAttributes" ) + @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) + @JacksonXmlElementWrapper(localName = "programPersonAttributes", namespace = DxfNamespaces.DXF_2_0) + @JacksonXmlProperty( localName = "programPersonAttribute", namespace = DxfNamespaces.DXF_2_0 ) public List getProgramPatientAttributes() { return programPatientAttributes;