dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24412
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11961: [mobile] change model to support user select report date on J2ME
------------------------------------------------------------
revno: 11961
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Sat 2013-09-07 19:47:54 +0700
message:
[mobile] change model to support user select report date on J2ME
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.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-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java 2013-09-07 12:47:54 +0000
@@ -44,6 +44,10 @@
{
private String clientVersion;
+ private String reportDate;
+
+ private String reportDateDescription;
+
private boolean isRepeatable;
private boolean isCompleted;
@@ -114,11 +118,37 @@
this.isSingleEvent = isSingleEvent;
}
+ public String getReportDate()
+ {
+ return reportDate;
+ }
+
+ public void setReportDate( String reportDate )
+ {
+ this.reportDate = reportDate;
+ }
+
+ public String getReportDateDescription()
+ {
+ return reportDateDescription;
+ }
+
+ public void setReportDateDescription( String reportDateDescription )
+ {
+ this.reportDateDescription = reportDateDescription;
+ }
+
@Override
public void serialize( DataOutputStream dout )
throws IOException
{
super.serialize( dout );
+ if ( this.reportDate == null )
+ {
+ reportDate = "";
+ }
+ dout.writeUTF( this.reportDate );
+ dout.writeUTF( this.reportDateDescription );
dout.writeBoolean( this.isRepeatable() );
dout.writeBoolean( this.isCompleted() );
dout.writeBoolean( this.isSingleEvent );
@@ -141,6 +171,8 @@
throws IOException
{
super.deSerialize( dint );
+ this.setReportDate( dint.readUTF() );
+ this.setReportDateDescription( dint.readUTF() );
this.setRepeatable( dint.readBoolean() );
this.setCompleted( dint.readBoolean() );
this.setSingleEvent( dint.readBoolean() );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-03 18:28:38 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-07 12:47:54 +0000
@@ -605,7 +605,14 @@
}
- programStageInstance.setExecutionDate( new Date() );
+ if ( PeriodUtil.stringToDate( mobileProgramStage.getReportDate() ) != null )
+ {
+ programStageInstance.setExecutionDate( PeriodUtil.stringToDate( mobileProgramStage.getReportDate() ) );
+ }
+ else
+ {
+ programStageInstance.setExecutionDate( new Date() );
+ }
if ( programStageInstance.getProgramStage().getProgramStageDataElements().size() > dataElements.size() )
{
@@ -1046,6 +1053,18 @@
mobileProgramStage.setId( programStageInstance.getId() );
mobileProgramStage.setName( eachProgramStage.getName() );
+ // get report date
+ if ( programStageInstance.getExecutionDate() != null )
+ {
+ mobileProgramStage.setReportDate( PeriodUtil.dateToString( programStageInstance.getExecutionDate() ) );
+ }
+ else
+ {
+ mobileProgramStage.setReportDate( "" );
+ }
+
+ mobileProgramStage.setReportDateDescription( programStageInstance.getProgramStage()
+ .getReportDateDescription() );
// is repeatable
mobileProgramStage.setRepeatable( eachProgramStage.getIrregular() );
@@ -1113,7 +1132,20 @@
{
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement();
mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
- mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
+
+ String dataElementName;
+
+ if ( programStageDataElement.getDataElement().getFormName() != null
+ || !programStageDataElement.getDataElement().getFormName().trim().equals( "" ) )
+ {
+ dataElementName = programStageDataElement.getDataElement().getFormName();
+ }
+ else
+ {
+ dataElementName = programStageDataElement.getDataElement().getName();
+ }
+
+ mobileDataElement.setName( dataElementName );
mobileDataElement.setType( programStageDataElement.getDataElement().getType() );
// problem
@@ -1800,21 +1832,24 @@
patientIdentifierSet.add( systemGenerateIdentifier );
}
- for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : patientAttributesMobile )
+ if ( patientAttributesMobile != null )
{
-
- org.hisp.dhis.patient.PatientAttribute patientAttribute = patientAttributeService
- .getPatientAttributeByName( paAtt.getName() );
-
- patientAttributeSet.add( patientAttribute );
-
- PatientAttributeValue patientAttributeValue = new PatientAttributeValue();
-
- patientAttributeValue.setPatient( patientWeb );
- patientAttributeValue.setPatientAttribute( patientAttribute );
- patientAttributeValue.setValue( paAtt.getValue() );
- patientAttributeValues.add( patientAttributeValue );
-
+ for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : patientAttributesMobile )
+ {
+
+ org.hisp.dhis.patient.PatientAttribute patientAttribute = patientAttributeService
+ .getPatientAttributeByName( paAtt.getName() );
+
+ patientAttributeSet.add( patientAttribute );
+
+ PatientAttributeValue patientAttributeValue = new PatientAttributeValue();
+
+ patientAttributeValue.setPatient( patientWeb );
+ patientAttributeValue.setPatientAttribute( patientAttribute );
+ patientAttributeValue.setValue( paAtt.getValue() );
+ patientAttributeValues.add( patientAttributeValue );
+
+ }
}
patientWeb.setIdentifiers( patientIdentifierSet );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/PeriodUtil.java 2013-09-07 12:47:54 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -161,4 +162,26 @@
+ periodName );
}
+ public static String dateToString( Date date )
+ {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+ return dateFormat.format( date );
+ }
+
+ public static Date stringToDate( String dateString )
+ {
+ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
+ Date date = null;
+ try
+ {
+ date = dateFormat.parse( dateString );
+ }
+ catch ( Exception e )
+ {
+ return null;
+ }
+
+ return date;
+ }
+
}