dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23628
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11510: Add annotation for new properties of Program object.
------------------------------------------------------------
revno: 11510
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-07-25 10:58:14 +0700
message:
Add annotation for new properties of Program object.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.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-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-07-25 02:32:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2013-07-25 03:58:14 +0000
@@ -181,6 +181,58 @@
}
// -------------------------------------------------------------------------
+ // Logic methods
+ // -------------------------------------------------------------------------
+
+ public ProgramStage getProgramStageByStage( int stage )
+ {
+ int count = 1;
+
+ for ( ProgramStage programStage : programStages )
+ {
+ if ( count == stage )
+ {
+ return programStage;
+ }
+
+ count++;
+ }
+
+ return null;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public ValidationCriteria isValid( Patient patient )
+ {
+ try
+ {
+ for ( ValidationCriteria criteria : patientValidationCriteria )
+ {
+ Object propertyValue = getValueFromPatient( StringUtils.capitalize( criteria.getProperty() ), patient );
+
+ // Compare property value with compare value
+
+ int i = ((Comparable<Object>) propertyValue).compareTo( criteria.getValue() );
+
+ // Return validation criteria if criteria is not met
+
+ if ( i != criteria.getOperator() )
+ {
+ return criteria;
+ }
+ }
+
+ // Return null if all criteria are met
+
+ return null;
+ }
+ catch ( Exception ex )
+ {
+ throw new RuntimeException( ex );
+ }
+ }
+
+ // -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
@@ -377,6 +429,9 @@
this.displayIncidentDate = displayIncidentDate;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
private Object getValueFromPatient( String property, Patient patient )
throws Exception
{
@@ -422,58 +477,6 @@
this.blockEntryForm = blockEntryForm;
}
- // -------------------------------------------------------------------------
- // Logic methods
- // -------------------------------------------------------------------------
-
- public ProgramStage getProgramStageByStage( int stage )
- {
- int count = 1;
-
- for ( ProgramStage programStage : programStages )
- {
- if ( count == stage )
- {
- return programStage;
- }
-
- count++;
- }
-
- return null;
- }
-
- @SuppressWarnings( "unchecked" )
- public ValidationCriteria isValid( Patient patient )
- {
- try
- {
- for ( ValidationCriteria criteria : patientValidationCriteria )
- {
- Object propertyValue = getValueFromPatient( StringUtils.capitalize( criteria.getProperty() ), patient );
-
- // Compare property value with compare value
-
- int i = ((Comparable<Object>) propertyValue).compareTo( criteria.getValue() );
-
- // Return validation criteria if criteria is not met
-
- if ( i != criteria.getOperator() )
- {
- return criteria;
- }
- }
-
- // Return null if all criteria are met
-
- return null;
- }
- catch ( Exception ex )
- {
- throw new RuntimeException( ex );
- }
- }
-
@JsonProperty
@JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -517,6 +520,9 @@
this.onlyEnrollOnce = onlyEnrollOnce;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Set<PatientReminder> getPatientReminders()
{
return patientReminders;
@@ -577,6 +583,9 @@
this.useBirthDateAsEnrollmentDate = useBirthDateAsEnrollmentDate;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Boolean getSelectEnrollmentDatesInFuture()
{
return selectEnrollmentDatesInFuture;