=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2015-02-26 15:21:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2015-03-14 07:57:45 +0000 @@ -30,18 +30,24 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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.IdentifiableObject; import org.hisp.dhis.common.MergeStrategy; +import org.hisp.dhis.common.adapter.JacksonPeriodTypeDeserializer; +import org.hisp.dhis.common.adapter.JacksonPeriodTypeSerializer; import org.hisp.dhis.common.annotation.Scanned; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; +import org.hisp.dhis.common.view.WithoutOrganisationUnitsView; import org.hisp.dhis.dataentryform.DataEntryForm; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.schema.annotation.PropertyRange; import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder; @@ -118,6 +124,8 @@ private String reportDateToUse; private Integer sortOrder; + + private PeriodType periodType; // ------------------------------------------------------------------------- // Constructors @@ -471,6 +479,22 @@ this.sortOrder = sortOrder; } + @JsonProperty + @JsonSerialize( using = JacksonPeriodTypeSerializer.class ) + @JsonDeserialize( using = JacksonPeriodTypeDeserializer.class ) + @JsonView( { DetailedView.class, ExportView.class, WithoutOrganisationUnitsView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public PeriodType getPeriodType() + { + return periodType; + } + + public void setPeriodType( PeriodType periodType ) + { + this.periodType = periodType; + } + + @Override public void mergeWith( IdentifiableObject other, MergeStrategy strategy ) { === modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml' --- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2014-10-06 10:11:29 +0000 +++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2015-03-14 07:57:45 +0000 @@ -80,6 +80,9 @@ - + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2015-02-16 11:46:32 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/GetProgramAction.java 2015-03-14 07:57:45 +0000 @@ -38,6 +38,8 @@ import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramIndicator; import org.hisp.dhis.program.ProgramIndicatorService; @@ -72,17 +74,31 @@ { this.selectionTreeManager = selectionTreeManager; } - + private UserGroupService userGroupService; - + public void setUserGroupService( UserGroupService userGroupService ) { this.userGroupService = userGroupService; } - + + private List periodTypes = new ArrayList<>(); + + public List getPeriodTypes() + { + return periodTypes; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + @Autowired private ProgramIndicatorService programIndicatorService; - + @Autowired private ConstantService constantService; @@ -134,21 +150,21 @@ { this.level = level; } - + private List userGroups; - + public List getUserGroups() { return userGroups; } - + private List programIndicators; public List getProgramIndicators() { return programIndicators; } - + private List constants; public List getConstants() @@ -164,20 +180,22 @@ public String execute() throws Exception { + periodTypes = periodService.getAllPeriodTypes(); + program = programService.getProgram( id ); - + selectionTreeManager.setSelectedOrganisationUnits( program.getOrganisationUnits() ); - + userGroups = new ArrayList<>( userGroupService.getAllUserGroups() ); - + programIndicators = new ArrayList<>( programIndicatorService.getProgramIndicators( program ) ); Collections.sort( programIndicators, IdentifiableObjectNameComparator.INSTANCE ); - constants = new ArrayList<>(constantService.getAllConstants()); - + constants = new ArrayList<>( constantService.getAllConstants() ); + Collections.sort( constants, IdentifiableObjectNameComparator.INSTANCE ); - + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/AddProgramStageAction.java 2015-03-14 07:57:45 +0000 @@ -35,6 +35,8 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramIndicator; import org.hisp.dhis.program.ProgramIndicatorService; @@ -97,6 +99,13 @@ this.userGroupService = userGroupService; } + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + @Autowired private ProgramIndicatorService programIndicatorService; @@ -326,6 +335,13 @@ this.preGenerateUID = preGenerateUID; } + private String periodTypeName; + + public void setPeriodTypeName( String periodTypeName ) + { + this.periodTypeName = periodTypeName; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -346,7 +362,8 @@ remindCompleted = (remindCompleted == null) ? false : remindCompleted; allowGenerateNextVisit = (allowGenerateNextVisit == null) ? false : allowGenerateNextVisit; openAfterEnrollment = (openAfterEnrollment == null) ? false : openAfterEnrollment; - preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID; + preGenerateUID = (preGenerateUID == null) ? false : preGenerateUID; + ProgramStage programStage = new ProgramStage(); Program program = programService.getProgram( id ); @@ -360,6 +377,13 @@ programStage.setMinDaysFromStart( minDaysFromStart ); programStage.setDisplayGenerateEventBox( displayGenerateEventBox ); programStage.setValidCompleteOnly( validCompleteOnly ); + if( periodTypeName != null ) + { + + PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName ); + programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) ); + } + if ( program.isSingleEvent() ) { programStage.setAutoGenerateEvent( true ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/GetProgramStageAction.java 2015-03-14 07:57:45 +0000 @@ -32,6 +32,8 @@ import java.util.Collection; import java.util.List; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.ProgramIndicator; import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramStage; @@ -69,6 +71,13 @@ this.userGroupService = userGroupService; } + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + @Autowired private ProgramIndicatorService programIndicatorService; @@ -120,6 +129,13 @@ { return programIndicators; } + + private List periodTypes = new ArrayList<>(); + + public List getPeriodTypes() + { + return periodTypes; + } // ------------------------------------------------------------------------- // Action implementation @@ -129,6 +145,8 @@ public String execute() throws Exception { + periodTypes = periodService.getAllPeriodTypes(); + programStage = programStageService.getProgramStage( id ); programStageDataElements = programStage.getProgramStageDataElements(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2015-03-14 07:57:45 +0000 @@ -35,6 +35,8 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.ProgramIndicator; import org.hisp.dhis.program.ProgramIndicatorService; import org.hisp.dhis.program.ProgramService; @@ -89,9 +91,19 @@ this.userGroupService = userGroupService; } + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + @Autowired private ProgramService programService; - + + @Autowired + private ProgramIndicatorService programIndicatorService; + // ------------------------------------------------------------------------- // Input/Output // ------------------------------------------------------------------------- @@ -320,9 +332,13 @@ this.preGenerateUID = preGenerateUID; } - @Autowired - private ProgramIndicatorService programIndicatorService; + private String periodTypeName; + public void setPeriodTypeName( String periodTypeName ) + { + this.periodTypeName = periodTypeName; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -362,7 +378,13 @@ programStage.setOpenAfterEnrollment( openAfterEnrollment ); programStage.setReportDateToUse( reportDateToUse ); programStage.setPreGenerateUID( preGenerateUID ); - + + if( periodTypeName != null ) + { + PeriodType periodType = PeriodType.getPeriodTypeByName( periodTypeName ); + programStage.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) ); + } + if ( programStage.getProgram().isSingleEvent() ) { programStage.setAutoGenerateEvent( true ); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-02-18 13:48:37 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/META-INF/dhis/beans.xml 2015-03-14 07:57:45 +0000 @@ -200,6 +200,7 @@ + + + + + + + + + + + + + + + + #end $i18n.getString( "form_details" ) === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2014-08-06 15:20:54 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addProgramStageForm.js 2015-03-14 07:57:45 +0000 @@ -9,6 +9,14 @@ { selectAllById('selectedIndicators'); + var customStandardInterval = byId('customStandardInterval').checked; + if( customStandardInterval ){ + setFieldValue('periodTypeName',''); + } + else{ + setFieldValue('standardInterval',''); + } + var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); selectedDataElementsValidator.empty(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js 2014-08-18 14:21:48 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/programStage.js 2015-03-14 07:57:45 +0000 @@ -265,13 +265,31 @@ var checked = byId('irregular').checked; if( checked ) { + enable('displayGenerateEventBox'); + enable('customStandardInterval'); + enable('periodTypeName'); + } + else + { + disable('displayGenerateEventBox'); + disabled('customStandardInterval'); + disabled('periodTypeName'); + } + customStandardIntervalOnChange(); +} + +function customStandardIntervalOnChange() +{ + var checked = byId('customStandardInterval').checked; + if( checked ) + { enable('standardInterval'); - enable('displayGenerateEventBox'); + disable('periodTypeName'); } else { disable('standardInterval'); - disable('displayGenerateEventBox'); + enable('periodTypeName'); } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2014-08-06 15:20:54 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateProgramStageForm.js 2015-03-14 07:57:45 +0000 @@ -10,7 +10,15 @@ 'beforeValidateHandler' : function() { selectAllById('selectedIndicators'); - + + var customStandardInterval = byId('customStandardInterval').checked; + if( customStandardInterval ){ + setFieldValue('periodTypeName',''); + } + else{ + setFieldValue('standardInterval',''); + } + var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" ); selectedDataElementsValidator.empty(); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2015-01-06 14:51:29 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateProgramStageForm.vm 2015-03-14 07:57:45 +0000 @@ -52,12 +52,29 @@ - + + + + + + - + + + + + + + + #end