dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25822
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12826: add more link for mobile orgunit, fix bugs of SMS command
------------------------------------------------------------
revno: 12826
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-29 17:27:23 +0700
message:
add more link for mobile orgunit, fix bugs of SMS command
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java
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/MobileOrgUnitLinks.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/DefaultProgramService.java
dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java
dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.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-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-10-22 04:01:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-10-29 10:27:23 +0000
@@ -390,26 +390,37 @@
{
OrganisationUnit orgunit = null;
User user = null;
+
+ //-------------------------> Need to be edit
for ( User u : userService.getUsersByPhoneNumber( sender ) )
{
OrganisationUnit ou = u.getOrganisationUnit();
- // Might be undefined if the user has more than one org units
- if ( orgunit == null )
- {
- orgunit = ou;
- }
- else if ( orgunit.getId() == ou.getId() )
- {
- // Same org unit
- }
- else
- {
- throw new SMSParserException(
- "User is associated with more than one orgunit. Please contact your supervisor." );
+ if ( ou != null )
+ {
+ // Might be undefined if the user has more than one org units
+ if ( orgunit == null )
+ {
+ orgunit = ou;
+ }
+ else if ( orgunit.getId() == ou.getId() )
+ {
+ // Same org unit
+ }
+ else
+ {
+ throw new SMSParserException(
+ "User is associated with more than one orgunit. Please contact your supervisor." );
+ }
}
user = u;
}
+ // <-------------------------------------
+ if ( user == null)
+ {
+ throw new SMSParserException(
+ "User is not associated with any orgunit. Please contact your supervisor." );
+ }
return user;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java 2013-10-04 09:09:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsPublisher.java 2013-10-29 10:27:23 +0000
@@ -124,6 +124,7 @@
}
catch ( Exception e )
{
+ e.printStackTrace();
log.error( e );
smsSender.sendMessage( e.getMessage(), message.getOriginator() );
}
=== 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-09-07 12:47:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/ProgramStage.java 2013-10-29 10:27:23 +0000
@@ -53,6 +53,8 @@
private boolean isCompleted;
private boolean isSingleEvent;
+
+ private Integer standardInterval;
private List<Section> sections;
@@ -138,31 +140,42 @@
this.reportDateDescription = reportDateDescription;
}
+ public Integer getStandardInterval()
+ {
+ return standardInterval;
+ }
+
+ public void setStandardInterval( Integer standardInterval )
+ {
+ this.standardInterval = standardInterval;
+ }
+
@Override
public void serialize( DataOutputStream dout )
throws IOException
{
super.serialize( dout );
- if ( this.reportDate == null )
+ if ( reportDate == null )
{
reportDate = "";
}
- dout.writeUTF( this.reportDate );
- dout.writeUTF( this.reportDateDescription );
- dout.writeBoolean( this.isRepeatable() );
- dout.writeBoolean( this.isCompleted() );
- dout.writeBoolean( this.isSingleEvent );
+ dout.writeUTF( reportDate );
+ dout.writeUTF( reportDateDescription );
+ dout.writeBoolean( isRepeatable );
+ dout.writeInt( standardInterval );
+ dout.writeBoolean( isCompleted() );
+ dout.writeBoolean( isSingleEvent );
- dout.writeInt( this.dataElements.size() );
- for ( int i = 0; i < this.dataElements.size(); i++ )
+ dout.writeInt( dataElements.size() );
+ for ( int i = 0; i < dataElements.size(); i++ )
{
- this.dataElements.get( i ).serialize( dout );
+ dataElements.get( i ).serialize( dout );
}
- dout.writeInt( this.sections.size() );
- for ( int i = 0; i < this.sections.size(); i++ )
+ dout.writeInt( sections.size() );
+ for ( int i = 0; i < sections.size(); i++ )
{
- this.sections.get( i ).serialize( dout );
+ sections.get( i ).serialize( dout );
}
}
@@ -171,11 +184,12 @@
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() );
+ setReportDate( dint.readUTF() );
+ setReportDateDescription( dint.readUTF() );
+ setRepeatable( dint.readBoolean() );
+ setStandardInterval( dint.readInt() );
+ setCompleted( dint.readBoolean() );
+ setSingleEvent( dint.readBoolean() );
int dataElementSize = dint.readInt();
if ( dataElementSize > 0 )
{
@@ -183,7 +197,7 @@
{
ProgramStageDataElement de = new ProgramStageDataElement();
de.deSerialize( dint );
- this.dataElements.add( de );
+ dataElements.add( de );
}
}
else
@@ -198,7 +212,7 @@
sections = new ArrayList<Section>();
Section se = new Section();
se.deSerialize( dint );
- this.sections.add( se );
+ sections.add( se );
}
}
else
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2013-10-09 03:02:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/MobileOrgUnitLinks.java 2013-10-29 10:27:23 +0000
@@ -88,6 +88,8 @@
private String findLostToFollowUpUrl;
private String handleLostToFollowUpUrl;
+
+ private String generateRepeatableEventUrl;
@XmlAttribute
public int getId()
@@ -331,6 +333,16 @@
this.handleLostToFollowUpUrl = handleLostToFollowUpUrl;
}
+ public String getGenerateRepeatableEventUrl()
+ {
+ return generateRepeatableEventUrl;
+ }
+
+ public void setGenerateRepeatableEventUrl( String generateRepeatableEventUrl )
+ {
+ this.generateRepeatableEventUrl = generateRepeatableEventUrl;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
throws IOException
@@ -358,6 +370,7 @@
dataOutputStream.writeUTF( this.findPatientInAdvancedUrl );
dataOutputStream.writeUTF( this.findLostToFollowUpUrl );
dataOutputStream.writeUTF( this.handleLostToFollowUpUrl );
+ dataOutputStream.writeUTF( this.generateRepeatableEventUrl );
}
public void deSerialize( DataInputStream dataInputStream )
@@ -386,6 +399,7 @@
this.findPatientInAdvancedUrl = dataInputStream.readUTF();
this.findLostToFollowUpUrl = dataInputStream.readUTF();
this.handleLostToFollowUpUrl = dataInputStream.readUTF();
+ this.generateRepeatableEventUrl = dataInputStream.readUTF();
}
@Override
@@ -447,5 +461,6 @@
dataOutputStream.writeUTF( this.findPatientInAdvancedUrl );
dataOutputStream.writeUTF( this.findLostToFollowUpUrl );
dataOutputStream.writeUTF( this.handleLostToFollowUpUrl );
+ dataOutputStream.writeUTF( this.generateRepeatableEventUrl );
}
}
=== 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-10-28 09:53:18 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-10-29 10:27:23 +0000
@@ -766,7 +766,16 @@
programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
programInstanceService.updateProgramInstance( programInstance );
}
- return PROGRAM_STAGE_UPLOADED;
+ if ( mobileProgramStage.isRepeatable() )
+ {
+ Date nextDate = DateUtils.getDateAfterAddition( new Date(), mobileProgramStage.getStandardInterval() );
+
+ return PROGRAM_STAGE_UPLOADED+"$"+PeriodUtil.dateToString( nextDate );
+ }
+ else
+ {
+ return PROGRAM_STAGE_UPLOADED;
+ }
}
}
}
@@ -1178,10 +1187,6 @@
{
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage>();
- /*
- * for ( ProgramStage eachProgramStage :
- * programInstance.getProgram().getProgramStages() )
- */
for ( ProgramStageInstance eachProgramStageInstance : programInstance.getProgramStageInstances() )
{
// only for Mujhu database, because there is null program stage
@@ -1207,18 +1212,25 @@
mobileProgramStage.setReportDate( "" );
}
- if ( eachProgramStageInstance.getProgramStage().getReportDateDescription() == null )
+ if ( programStage.getReportDateDescription() == null )
{
mobileProgramStage.setReportDateDescription( "Report Date" );
}
else
{
- mobileProgramStage.setReportDateDescription( eachProgramStageInstance.getProgramStage()
- .getReportDateDescription() );
+ mobileProgramStage.setReportDateDescription( programStage.getReportDateDescription() );
}
// is repeatable
mobileProgramStage.setRepeatable( programStage.getIrregular() );
+ if ( programStage.getStandardInterval() == null )
+ {
+ mobileProgramStage.setStandardInterval( 0 );
+ }
+ else
+ {
+ mobileProgramStage.setStandardInterval( programStage.getStandardInterval() );
+ }
// is completed
/*
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/DefaultProgramService.java 2013-10-29 10:27:23 +0000
@@ -210,6 +210,15 @@
prStg.setRepeatable( programStage.getIrregular() );
+ if ( programStage.getStandardInterval() == null )
+ {
+ prStg.setStandardInterval( 0 );
+ }
+ else
+ {
+ prStg.setStandardInterval( programStage.getStandardInterval() );
+ }
+
prStg.setCompleted( false );
prStg.setSingleEvent( program.isSingleEvent() );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2013-10-09 03:02:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitTest.java 2013-10-29 10:27:23 +0000
@@ -71,6 +71,7 @@
unit.setFindPatientInAdvancedUrl( "findPatientInAdvanced" );
unit.setFindLostToFollowUpUrl( "findLostToFollowUpUrl" );
unit.setHandleLostToFollowUpUrl( "handleLostToFollowUpUrl" );
+ unit.setGenerateRepeatableEventUrl( "generateRepeatableEventUrl" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream( baos );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2013-10-09 03:02:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/api/model/OrgUnitsTest.java 2013-10-29 10:27:23 +0000
@@ -96,6 +96,7 @@
unit.setFindPatientInAdvancedUrl( "findPatientInAdvancedUrl" );
unit.setFindLostToFollowUpUrl( "findLostToFollowUpUrl" );
unit.setHandleLostToFollowUpUrl( "handleLostToFollowUpUrl" );
+ unit.setGenerateRepeatableEventUrl( "generateRepeatableEventUrl" );
return unit;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-10-09 03:02:54 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileClientController.java 2013-10-29 10:27:23 +0000
@@ -159,6 +159,7 @@
orgUnit.setFindPatientInAdvancedUrl( getUrl( request, unit.getId(), "findPatientInAdvanced" ) );
orgUnit.setFindLostToFollowUpUrl( getUrl( request, unit.getId(), "findLostToFollowUp" ) );
orgUnit.setHandleLostToFollowUpUrl( getUrl( request, unit.getId(), "handleLostToFollowUpUrl" ) );
+ orgUnit.setGenerateRepeatableEventUrl( getUrl( request, unit.getId(), "generateRepeatableEventUrl" ) );
// generate URL for download new version
String full = UrlUtils.buildFullRequestUrl( request );