dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #09311
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2432: [DHIS Mobile] Add "version" to program
------------------------------------------------------------
revno: 2432
committer: Long <thanhlongngo1988>
branch nick: dhis2
timestamp: Mon 2010-12-27 10:17:34 +0700
message:
[DHIS Mobile] Add "version" to program
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm
--
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 2010-11-09 02:09:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java 2010-12-27 03:17:34 +0000
@@ -48,6 +48,8 @@
private String name;
private String description;
+
+ private Integer version;
/**
* Description of Date of Enrollment This description is differ from each
@@ -158,6 +160,17 @@
{
this.organisationUnits = organisationUnits;
}
+
+
+ public Integer getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( Integer version )
+ {
+ this.version = version;
+ }
public Set<OrganisationUnit> getOrganisationUnits()
{
=== 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 2010-11-26 11:02:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2010-12-27 03:17:34 +0000
@@ -60,6 +60,7 @@
public ProgramStage()
{
+
}
public ProgramStage( String name, Program program )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2010-02-22 09:19:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java 2010-12-27 03:17:34 +0000
@@ -32,27 +32,28 @@
/**
* @author Viet Nguyen
- *
+ *
* @version $Id$
*/
-public class ProgramStageDataElement implements Serializable
+public class ProgramStageDataElement
+ implements Serializable
{
-
+
/**
* Part of composite key
*/
private ProgramStage programStage;
-
+
/**
* Part of composite key
*/
private DataElement dataElement;
-
+
/*
- * True if this dataElement is mandatory in the dataEntryForm for this programStage
+ * True if this dataElement is mandatory in the dataEntryForm for this
+ * programStage
*/
private boolean compulsory = false;
-
public ProgramStageDataElement( ProgramStage programStage, DataElement dataElement, boolean compulsory )
{
@@ -60,12 +61,11 @@
this.dataElement = dataElement;
this.compulsory = compulsory;
}
-
+
public ProgramStageDataElement()
{
-
}
-
+
public ProgramStage getProgramStage()
{
return programStage;
@@ -122,7 +122,8 @@
final ProgramStageDataElement other = (ProgramStageDataElement) object;
- return dataElement.getId() == other.getDataElement().getId() && programStage.getId() == other.getProgramStage().getId();
+ return dataElement.getId() == other.getDataElement().getId()
+ && programStage.getId() == other.getProgramStage().getId();
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2010-12-27 03:17:34 +0000
@@ -43,7 +43,8 @@
*
* @version TableAlteror.java Sep 9, 2010 10:22:29 PM
*/
-public class TableAlteror extends AbstractStartupRoutine
+public class TableAlteror
+ extends AbstractStartupRoutine
{
private static final Log log = LogFactory.getLog( TableAlteror.class );
@@ -57,6 +58,7 @@
{
this.statementManager = statementManager;
}
+
// -------------------------------------------------------------------------
// Execute
// -------------------------------------------------------------------------
@@ -66,22 +68,27 @@
throws Exception
{
updatePatientOrgunitAssociation();
-
+
updateDOBType();
-
- updateDataSetMobileAttribute();
-
- updateDataSetVersionAttribute();
-
- executeSql("UPDATE patientidentifiertype SET type='" + PatientIdentifierType.VALUE_TYPE_TEXT +"' WHERE type IS NULL");
-
- executeSql("UPDATE program SET minDaysAllowedInputData=0 WHERE minDaysAllowedInputData IS NULL");
-
- executeSql("UPDATE program SET maxDaysAllowedInputData=0 WHERE maxDaysAllowedInputData IS NULL");
+
+ executeSql( "UPDATE program SET version = 1 WHERE version is NULL" );
+
+ updateDataSetMobileAttribute();
+
+ updateDataSetVersionAttribute();
+
+ executeSql( "UPDATE patientidentifiertype SET type='" + PatientIdentifierType.VALUE_TYPE_TEXT
+ + "' WHERE type IS NULL" );
+
+ executeSql( "UPDATE program SET minDaysAllowedInputData=0 WHERE minDaysAllowedInputData IS NULL" );
+
+ executeSql( "UPDATE program SET maxDaysAllowedInputData=0 WHERE maxDaysAllowedInputData IS NULL" );
+
}
- private void updatePatientOrgunitAssociation(){
-
+ private void updatePatientOrgunitAssociation()
+ {
+
StatementHolder holder = statementManager.getHolder();
try
@@ -101,7 +108,7 @@
executeSql( "UPDATE patient SET organisationunitid=" + resultSet.getInt( 2 ) + " WHERE patientid="
+ resultSet.getInt( 1 ) );
}
-
+
executeSql( "ALTER TABLE patientidentifier DROP COLUMN organisationunitid" );
}
}
@@ -114,62 +121,65 @@
holder.close();
}
}
-
- private void updateDOBType(){
- StatementHolder holder = statementManager.getHolder();
-
- try
- {
- executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true");
-
- executeSql("ALTER TABLE patient drop column birthdateestimated");
-
- executeSql("DELETE FROM validationcriteria where property='birthdateestimated'");
- }
- catch ( Exception ex )
- {
- log.error( ex );
- }
- finally
- {
- holder.close();
- }
- }
-
- private void updateDataSetMobileAttribute(){
- StatementHolder holder = statementManager.getHolder();
-
- try
- {
- executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null");
- }
- catch ( Exception ex )
- {
- log.error( ex );
- }
- finally
- {
- holder.close();
- }
- }
-
- private void updateDataSetVersionAttribute(){
- StatementHolder holder = statementManager.getHolder();
-
- try
- {
- executeSql( "UPDATE dataset SET version = 1 WHERE version is null");
- }
- catch ( Exception ex )
- {
- log.error( ex );
- }
- finally
- {
- holder.close();
- }
- }
-
+
+ private void updateDOBType()
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ executeSql( "UPDATE patient SET dobType='A' WHERE birthdateestimated=true" );
+
+ executeSql( "ALTER TABLE patient drop column birthdateestimated" );
+
+ executeSql( "DELETE FROM validationcriteria where property='birthdateestimated'" );
+ }
+ catch ( Exception ex )
+ {
+ log.error( ex );
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+ private void updateDataSetMobileAttribute()
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ executeSql( "UPDATE dataset SET mobile = false WHERE mobile is null" );
+ }
+ catch ( Exception ex )
+ {
+ log.error( ex );
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+ private void updateDataSetVersionAttribute()
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ executeSql( "UPDATE dataset SET version = 1 WHERE version is null" );
+ }
+ catch ( Exception ex )
+ {
+ log.error( ex );
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
private int executeSql( String sql )
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml 2010-12-27 03:17:34 +0000
@@ -12,7 +12,9 @@
<property name="name" not-null="true" unique="true" length="160"/>
- <property name="description" type="text"/>
+ <property name="description" type="text"/>
+
+ <property name="version"/>
<property name="dateOfEnrollmentDescription" type="text" not-null="true"/>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java 2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/OrgUnit.java 2010-12-27 03:17:34 +0000
@@ -48,8 +48,11 @@
private String uploadActivityReportUrl;
+ private String updateProgramUrl;
+
private String updateDataSetUrl;
+
@XmlAttribute
public int getId()
{
@@ -122,6 +125,16 @@
this.updateDataSetUrl = updateDataSetUrl;
}
+ public String getUpdateProgramUrl()
+ {
+ return updateProgramUrl;
+ }
+
+ public void setUpdateProgramUrl( String updateProgramUrl )
+ {
+ this.updateProgramUrl = updateProgramUrl;
+ }
+
public void serialize( DataOutputStream dataOutputStream )
throws IOException
{
@@ -131,6 +144,7 @@
dataOutputStream.writeUTF( this.downloadActivityPlanUrl );
dataOutputStream.writeUTF( this.uploadFacilityReportUrl );
dataOutputStream.writeUTF( this.uploadActivityReportUrl );
+ dataOutputStream.writeUTF( this.updateProgramUrl );
dataOutputStream.writeUTF( this.updateDataSetUrl );
}
@@ -143,6 +157,7 @@
this.downloadActivityPlanUrl = dataInputStream.readUTF();
this.uploadFacilityReportUrl = dataInputStream.readUTF();
this.uploadActivityReportUrl = dataInputStream.readUTF();
+ this.updateProgramUrl = dataInputStream.readUTF();
this.updateDataSetUrl = dataInputStream.readUTF();
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java 2010-11-16 16:28:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Program.java 2010-12-27 03:17:34 +0000
@@ -36,6 +36,18 @@
extends Model
{
+ private int version;
+
+ public int getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( int version )
+ {
+ this.version = version;
+ }
+
private List<ProgramStage> programStages;
public List<ProgramStage> getProgramStages()
@@ -54,6 +66,7 @@
{
dout.writeInt( this.getId() );
dout.writeUTF( this.getName() );
+ dout.writeInt( this.getVersion() );
dout.writeInt( programStages.size() );
for ( int i = 0; i < programStages.size(); i++ )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java 2010-11-20 08:35:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/model/Task.java 2010-12-27 03:17:34 +0000
@@ -37,6 +37,8 @@
private int programStageId;
+ private int programId;
+
private boolean completed;
public int getId()
@@ -59,6 +61,16 @@
this.programStageId = programStageId;
}
+ public int getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( int programId )
+ {
+ this.programId = programId;
+ }
+
public boolean isCompleted()
{
return completed;
@@ -74,7 +86,8 @@
throws IOException
{
dout.writeInt(this.getId());
- dout.writeInt(this.getProgramStageId());
+ dout.writeInt(this.getProgramStageId());
+ dout.writeInt( this.getProgramId() );
dout.writeBoolean(this.isCompleted());
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java 2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/MobileResource.java 2010-12-27 03:17:34 +0000
@@ -118,6 +118,8 @@
.build( unit.getId() ).toString() );
orgUnit.setUploadActivityReportUrl( uriInfo.getBaseUriBuilder().path( "/orgUnits/{id}" ).path( "activities" )
.build( unit.getId() ).toString() );
+ orgUnit.setUpdateProgramUrl( uriInfo.getBaseUriBuilder().path( "/orgUnits/{id}" ).path( "programs" )
+ .build( unit.getId() ).toString() );
orgUnit.setUpdateDataSetUrl( uriInfo.getBaseUriBuilder().path( "/orgUnits/{id}" ).path( "updateDataSets" )
.build( unit.getId() ).toString() );
return orgUnit;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2010-12-22 04:05:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2010-12-27 03:17:34 +0000
@@ -21,6 +21,7 @@
import org.hisp.dhis.web.api.model.DataSetList;
import org.hisp.dhis.web.api.model.DataSetValue;
import org.hisp.dhis.web.api.model.MobileModel;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.service.ActivityReportingService;
import org.hisp.dhis.web.api.service.ActivityReportingServiceImpl;
import org.hisp.dhis.web.api.service.FacilityReportingService;
@@ -175,6 +176,15 @@
activityReportingService.saveActivityReport( unit, activityValue );
}
+ @POST
+ @Path( "programs" )
+ public MobileModel updatePrograms( @HeaderParam( "accept-language" ) String locale, ModelList programsFromClient )
+ {
+ MobileModel model = new MobileModel();
+ model.setPrograms( programService.updateProgram(programsFromClient, locale, unit) );
+ return model;
+ }
+
@Required
public void setProgramService( IProgramService programService )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java 2010-12-02 10:53:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/ActivityReportingServiceImpl.java 2010-12-27 03:17:34 +0000
@@ -109,21 +109,21 @@
List<org.hisp.dhis.web.api.model.Activity> items = new ArrayList<org.hisp.dhis.web.api.model.Activity>();
- if (DEBUG)
+ if ( DEBUG )
log.debug( "Filtering through " + allActivities.size() + " activities" );
for ( Activity activity : allActivities )
{
long dueTime = activity.getDueDate().getTime();
-
+
if ( to.isBefore( dueTime ) )
{
continue;
}
-
- if (DEBUG)
- log.debug( "Activity " + activity.getBeneficiary().getFirstName() + ", " + activity.getTask().getProgramStage().getName() );
+ if ( DEBUG )
+ log.debug( "Activity " + activity.getBeneficiary().getFirstName() + ", "
+ + activity.getTask().getProgramStage().getName() );
if ( from.isBefore( dueTime ) )
{
@@ -135,12 +135,12 @@
a.setLate( true );
items.add( a );
}
-
- if (items.size() > 10)
+
+ if ( items.size() > 10 )
break;
}
- if (DEBUG)
+ if ( DEBUG )
log.debug( "Found " + items.size() + " current activities" );
if ( items.isEmpty() )
@@ -181,6 +181,7 @@
task.setCompleted( stageInstance.isCompleted() );
task.setId( stageInstance.getId() );
task.setProgramStageId( stageInstance.getProgramStage().getId() );
+ task.setProgramId( stageInstance.getProgramInstance().getProgram().getId() );
return task;
}
@@ -196,7 +197,7 @@
beneficiary.setLastName( patient.getLastName() );
beneficiary.setMiddleName( patient.getMiddleName() );
- Period period = new Period( new DateTime(patient.getBirthDate()), new DateTime());
+ Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() );
beneficiary.setAge( period.getYears() );
PatientMobileSetting setting = getSettings();
@@ -290,7 +291,8 @@
// -------------------------------------------------------------------------
@Override
- public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue ) throws NotAllowedException
+ public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue )
+ throws NotAllowedException
{
ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( activityValue
@@ -298,7 +300,7 @@
if ( programStageInstance == null )
{
- throw new NotAllowedException( "INVALID_PROGRAM_STAGE");
+ throw new NotAllowedException( "INVALID_PROGRAM_STAGE" );
}
programStageInstance.getProgramStage();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-12-02 11:58:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/DefaultProgramService.java 2010-12-27 03:17:34 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.web.api.model.DataElement;
+import org.hisp.dhis.web.api.model.Model;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.Program;
import org.hisp.dhis.web.api.model.ProgramStage;
import org.hisp.dhis.web.api.utils.LocaleUtil;
@@ -67,6 +69,40 @@
return programs;
}
+ public List<Program> updateProgram( ModelList programsFromClient, String localeString, OrganisationUnit unit )
+ {
+ List<Program> programs = new ArrayList<Program>();
+ boolean isExisted = false;
+
+ //Get all Program belong to this OrgUnit
+ List<Program> serverPrograms = this.getPrograms( unit, localeString );
+ for ( int i = 0; i < serverPrograms.size(); i++ )
+ {
+ Program program = serverPrograms.get( i );
+
+ //Loop thought the list of program from client
+ for ( int j = 0; j < programsFromClient.getModels().size(); j++ )
+ {
+ Model model = programsFromClient.getModels().get( j );
+ if ( program.getId() == model.getId() )
+ {
+ //Version is different
+ if ( program.getVersion() != Integer.parseInt( model.getName() ) )
+ {
+ programs.add( program );
+ isExisted = true;
+ }
+ }
+ }
+ //Server has more program than client
+ if ( isExisted = false )
+ {
+ programs.add( program );
+ }
+ }
+ return programs;
+ }
+
public Program getProgram( int programId, String localeString )
{
Locale locale = LocaleUtil.getLocale( localeString );
@@ -79,6 +115,7 @@
pr.setId( program.getId() );
pr.setName( program.getName() );
+ pr.setVersion( program.getVersion() );
List<ProgramStage> prStgs = new ArrayList<ProgramStage>();
@@ -89,7 +126,6 @@
ProgramStage prStg = new ProgramStage();
prStg.setId( programStage.getId() );
prStg.setName( programStage.getName() );
-
List<DataElement> des = new ArrayList<DataElement>();
for ( org.hisp.dhis.program.ProgramStageDataElement programStagedataElement : programStage
@@ -128,5 +164,4 @@
{
this.i18nService = i18nService;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java 2010-11-18 06:08:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/service/IProgramService.java 2010-12-27 03:17:34 +0000
@@ -3,12 +3,15 @@
import java.util.List;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.web.api.model.ModelList;
import org.hisp.dhis.web.api.model.Program;
-public interface IProgramService {
-
- public List<Program> getPrograms( OrganisationUnit unit, String localeString );
-
- public Program getProgram( int programId, String localeString );
+public interface IProgramService
+{
+ public List<Program> getPrograms( OrganisationUnit unit, String localeString );
+
+ public Program getProgram( int programId, String localeString );
+
+ public List<Program> updateProgram( ModelList programsFromClient, String localeString, OrganisationUnit unit );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/AddProgramAction.java 2010-12-27 03:17:34 +0000
@@ -67,6 +67,13 @@
{
this.description = description;
}
+
+ private Integer version;
+
+ public void setVersion( Integer version )
+ {
+ this.version = version;
+ }
/**
* Description of Date of Enrollment This description is differ from each
@@ -115,6 +122,7 @@
program.setName( name );
program.setDescription( description );
+ program.setVersion( new Integer( 1 ) );
program.setDateOfEnrollmentDescription( dateOfEnrollmentDescription );
program.setDateOfIncidentDescription( dateOfIncidentDescription );
program.setMinDaysAllowedInputData( minDaysAllowedInputData );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2010-12-27 03:17:34 +0000
@@ -74,6 +74,18 @@
{
this.description = description;
}
+
+ private Integer version;
+
+ public Integer getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( Integer version )
+ {
+ this.version = version;
+ }
/**
* Description of Date of Enrollment This description is differ from each
@@ -119,9 +131,9 @@
throws Exception
{
Program program = programService.getProgram( id );
-
program.setName( name );
program.setDescription( description );
+ program.setVersion(version);
program.setDateOfEnrollmentDescription( dateOfEnrollmentDescription );
program.setDateOfIncidentDescription( dateOfIncidentDescription );
program.setMinDaysAllowedInputData( minDaysAllowedInputData );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2010-12-27 03:17:34 +0000
@@ -24,7 +24,11 @@
<td><input type="text" id="description" name="description" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>
<td></td>
</tr>
-
+ <tr>
+ <td><label>$i18n.getString( "version" )</label></td>
+ <td>1</td>
+ <td></td>
+ </tr>
<tr>
<td><label>$i18n.getString( "dateOfEnrollmentDescription" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td><input type="text" id="dateOfEnrollmentDescription" name="dateOfEnrollmentDescription" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2010-12-27 03:17:34 +0000
@@ -34,7 +34,12 @@
<td><label>$i18n.getString( "description" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td><input type="text" id="description" name="description" value="$encoder.htmlEncode( $program.description )" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>
<td></td>
- </tr>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString( "version" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><input type="text" id="version" name="version" value="$program.version" style="width:30em" class="{validate:{required:true,number:true}}"></td>
+ <td></td>
+ </tr>
<tr>
<td><label>$i18n.getString( "dateOfEnrollmentDescription" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td><input type="text" id="dateOfEnrollmentDescription" name="dateOfEnrollmentDescription" value="$!program.dateOfEnrollmentDescription" style="width:30em" class="{validate:{required:true,minlength:4}}"></td>