=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/parse/ParserType.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/parse/ParserType.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/parse/ParserType.java 2014-07-30 04:28:22 +0000 @@ -34,5 +34,6 @@ J2ME_PARSER, ALERT_PARSER, UNREGISTERED_PARSER, - ANONYMOUS_PROGRAM_PARSER + ANONYMOUS_PROGRAM_PARSER, + TRACKED_ENTITY_REGISTRATION_PARSER } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCode.java 2014-07-30 04:28:22 +0000 @@ -29,6 +29,7 @@ */ import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; public class SMSCode { @@ -37,6 +38,8 @@ private String code; private DataElement dataElement; + + private TrackedEntityAttribute trackedEntityAttribute; private int optionId; @@ -46,6 +49,14 @@ this.dataElement = dataElement; this.optionId = optionId; } + + public SMSCode( String code, TrackedEntityAttribute trackedEntityAttribute) + { + this.code = code; + this.trackedEntityAttribute = trackedEntityAttribute; + } + + public SMSCode() { @@ -91,4 +102,16 @@ { this.optionId = optionId; } + + public TrackedEntityAttribute getTrackedEntityAttribute() + { + return trackedEntityAttribute; + } + + public void setTrackedEntityAttribute( TrackedEntityAttribute trackedEntityAttribute ) + { + this.trackedEntityAttribute = trackedEntityAttribute; + } + + } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2014-06-27 11:45:23 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java 2014-07-30 04:28:22 +0000 @@ -29,6 +29,7 @@ */ import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.program.Program; import org.hisp.dhis.sms.parse.ParserType; import org.hisp.dhis.user.UserGroup; @@ -61,14 +62,22 @@ private ParserType parserType; private String separator; + + //Dataset private DataSet dataset; private Set codes; private String codeSeparator; + + //Usergroup private UserGroup userGroup; + + //Program + + private Program program; private Set specialCharacters; @@ -89,6 +98,7 @@ private String moreThanOneOrgUnitMessage; private String successMessage; + public SMSCommand( String name, String parser, ParserType parserType, String separator, DataSet dataset, Set codes, String codeSeparator, String defaultMessage, UserGroup userGroup, String receivedMessage, Set specialCharacters ) @@ -373,4 +383,14 @@ { this.successMessage = successMessage; } + + public Program getProgram() + { + return program; + } + + public void setProgram( Program program ) + { + this.program = program; + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml 2013-08-29 17:04:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml 2014-07-30 04:28:22 +0000 @@ -14,6 +14,9 @@ + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml 2014-06-27 11:45:23 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml 2014-07-30 04:28:22 +0000 @@ -45,6 +45,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/CreateSMSCommandForm.java 2014-07-30 04:28:22 +0000 @@ -30,6 +30,8 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.sms.parse.ParserType; import org.hisp.dhis.smscommand.SMSCommand; import org.hisp.dhis.smscommand.SMSCommandService; @@ -66,12 +68,12 @@ this.userGroupService = userGroupService; } - // private ProgramService programService; - // - // public void setProgramService( ProgramService programService ) - // { - // this.programService = programService; - // } + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } // ------------------------------------------------------------------------- // Input && Output @@ -104,11 +106,25 @@ { this.userGroupID = userGroupID; } + + private Integer selectedProgramId; + + public Integer getSelectedProgramId() + { + return selectedProgramId; + } + public void setSelectedProgramId( Integer selectedProgramId ) + { + this.selectedProgramId = selectedProgramId; + } + + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- + @Override public String execute() throws Exception @@ -128,6 +144,11 @@ userGroup = userGroupService.getUserGroup( userGroupID ); command.setUserGroup( userGroup ); } + else if ( parserType.equals( ParserType.TRACKED_ENTITY_REGISTRATION_PARSER ) ) + { + Program program = programService.getProgram( selectedProgramId ); + command.setProgram( program ); + } else if ( parserType.equals( ParserType.ANONYMOUS_PROGRAM_PARSER ) ) { === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java 2014-06-27 11:45:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java 2014-07-30 04:28:22 +0000 @@ -40,10 +40,12 @@ import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.sms.parse.ParserType; import org.hisp.dhis.smscommand.SMSCode; import org.hisp.dhis.smscommand.SMSCommand; import org.hisp.dhis.smscommand.SMSCommandService; import org.hisp.dhis.smscommand.SMSSpecialCharacter; +import org.hisp.dhis.trackedentity.TrackedEntityAttributeService; import org.hisp.dhis.user.UserGroupService; import com.opensymphony.xwork2.Action; @@ -82,6 +84,18 @@ this.userGroupService = userGroupService; } + private TrackedEntityAttributeService trackedEntityAttributeService; + + public TrackedEntityAttributeService getTrackedEntityAttributeService() + { + return trackedEntityAttributeService; + } + + public void setTrackedEntityAttributeService( TrackedEntityAttributeService trackedEntityAttributeService ) + { + this.trackedEntityAttributeService = trackedEntityAttributeService; + } + // ------------------------------------------------------------------------- // Input && Output // ------------------------------------------------------------------------- @@ -96,6 +110,8 @@ private String specialCharactersInfo; + private String trackedEntityAttributeCodes; + private String separator; private String codeSeparator; @@ -152,48 +168,66 @@ } smsCommandService.saveSpecialCharacterSet( specialCharacterSet ); + SMSCommand command = getSMSCommand(); + + if ( selectedDataSetID > -1 && command != null ) + { + if ( command.getParserType() == ParserType.TRACKED_ENTITY_REGISTRATION_PARSER ) + { + @SuppressWarnings( "unchecked" ) + List jsonRegistrationCodes = (List) JSONObject.fromObject( + trackedEntityAttributeCodes ).get( "trackedEntityAttributeCodes" ); + for ( JSONObject x : jsonRegistrationCodes ) + { + SMSCode c = new SMSCode(); + c.setCode( x.getString( "code" ) ); + c.setTrackedEntityAttribute( trackedEntityAttributeService.getTrackedEntityAttribute( x + .getInt( "trackedEntityAttributeId" ) ) ); + codeSet.add( c ); + } + } + } + if ( codeSet.size() > 0 ) { smsCommandService.save( codeSet ); } - SMSCommand c = getSMSCommand(); - - if ( selectedDataSetID > -1 && c != null ) + if ( selectedDataSetID > -1 && command != null ) { - c.setCurrentPeriodUsedForReporting( currentPeriodUsedForReporting ); - c.setName( name ); - c.setSeparator( separator ); + command.setCurrentPeriodUsedForReporting( currentPeriodUsedForReporting ); + command.setName( name ); + command.setSeparator( separator ); if ( completenessMethod != null ) { - c.setCompletenessMethod( completenessMethod ); + command.setCompletenessMethod( completenessMethod ); } // remove codes - Set toRemoveCodes = c.getCodes(); + Set toRemoveCodes = command.getCodes(); smsCommandService.deleteCodeSet( toRemoveCodes ); // remove special characters - Set toRemoveCharacters = c.getSpecialCharacters(); + Set toRemoveCharacters = command.getSpecialCharacters(); smsCommandService.deleteSpecialCharacterSet( toRemoveCharacters ); - c.setCodes( codeSet ); + command.setCodes( codeSet ); // message - c.setDefaultMessage( defaultMessage ); - c.setReceivedMessage( receivedMessage ); - c.setMoreThanOneOrgUnitMessage( moreThanOneOrgUnitMessage ); - c.setNoUserMessage( noUserMessage ); - c.setWrongFormatMessage( wrongFormatMessage ); - c.setSuccessMessage( successMessage ); + command.setDefaultMessage( defaultMessage ); + command.setReceivedMessage( receivedMessage ); + command.setMoreThanOneOrgUnitMessage( moreThanOneOrgUnitMessage ); + command.setNoUserMessage( noUserMessage ); + command.setWrongFormatMessage( wrongFormatMessage ); + command.setSuccessMessage( successMessage ); if ( userGroupID != null && userGroupID > -1 ) { - c.setUserGroup( userGroupService.getUserGroup( userGroupID ) ); + command.setUserGroup( userGroupService.getUserGroup( userGroupID ) ); } - c.setSpecialCharacters( specialCharacterSet ); - smsCommandService.save( c ); + command.setSpecialCharacters( specialCharacterSet ); + smsCommandService.save( command ); } return SUCCESS; @@ -376,4 +410,14 @@ this.successMessage = successMessage; } + public String getTrackedEntityAttributeCodes() + { + return trackedEntityAttributeCodes; + } + + public void setTrackedEntityAttributeCodes( String trackedEntityAttributeCodes ) + { + this.trackedEntityAttributeCodes = trackedEntityAttributeCodes; + } + } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/SMSCommandAction.java 2014-07-30 04:28:22 +0000 @@ -41,10 +41,12 @@ import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramTrackedEntityAttribute; import org.hisp.dhis.sms.parse.ParserType; import org.hisp.dhis.smscommand.SMSCode; import org.hisp.dhis.smscommand.SMSCommand; import org.hisp.dhis.smscommand.SMSCommandService; +import org.hisp.dhis.trackedentity.TrackedEntityAttribute; import org.hisp.dhis.user.UserGroup; import org.hisp.dhis.user.UserGroupService; @@ -101,7 +103,19 @@ return userGroupList; } - public List anonymousProgramList; + private List programList; + + public List getProgramList() + { + return programList; + } + + public void setProgramList( List programList ) + { + this.programList = programList; + } + + private List trackedEntityAttributeList; private int selectedCommandID = -1; @@ -148,12 +162,19 @@ { for ( SMSCode x : smsCommand.getCodes() ) { - codes.put( "" + x.getDataElement().getId() + x.getOptionId(), x.getCode() ); + if ( smsCommand.getParserType() == ParserType.TRACKED_ENTITY_REGISTRATION_PARSER ) + { + codes.put( "" + x.getTrackedEntityAttribute().getId(), x.getCode() ); + } + else + { + codes.put( "" + x.getDataElement().getId() + x.getOptionId(), x.getCode() ); + } + } } userGroupList = new ArrayList( userGroupService.getAllUserGroups() ); - anonymousProgramList = new ArrayList( - programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) ); + programList = new ArrayList( programService.getPrograms( Program.MULTIPLE_EVENTS_WITH_REGISTRATION ) ); return SUCCESS; } @@ -190,4 +211,28 @@ { return smsCommand; } + + public List getTrackedEntityAttributeList() + { + if ( smsCommand != null ) + { + Program program = smsCommand.getProgram(); + if ( program != null ) + { + trackedEntityAttributeList = new ArrayList(); + for ( ProgramTrackedEntityAttribute programAttribute : program.getProgramAttributes() ) + { + trackedEntityAttributeList.add( programAttribute.getAttribute() ); + } + return trackedEntityAttributeList; + } + + } + return null; + } + + public void setTrackedEntityAttributeList( List trackedEntityAttributeList ) + { + this.trackedEntityAttributeList = trackedEntityAttributeList; + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2014-05-21 09:48:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2014-07-30 04:28:22 +0000 @@ -133,7 +133,7 @@ - + + #end + + #if( $smsCommand.parserType == 'TRACKED_ENTITY_REGISTRATION_PARSER' ) + + + + + + + + + #set($index = 0) + #foreach($attribute in $trackedEntityAttributeList) + + #set ($index = $index + 1) + + + + + + #end +
$i18n.getString( "tracked_entity_attribute")$i18n.getString( "code" )
$attribute.name
+ #end
+ + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/new-sms-command.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/new-sms-command.vm 2014-01-07 10:08:24 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/new-sms-command.vm 2014-07-30 04:28:22 +0000 @@ -70,6 +70,19 @@ + + + $i18n.getString( "program" ) + + + + + +