dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08638
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2109: Work in Progress for Bangladesh Manpower Module
------------------------------------------------------------
revno: 2109
committer: Neeraj <neeraj.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-11-19 18:22:40 +0530
message:
Work in Progress for Bangladesh Manpower Module
added:
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/UpdateEmployeePostAction.java
modified:
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/UpdateEmployeeAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/FormAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowUpdateEmployeePostFormAction.java
local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml
local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/updateEmployeePostForm.vm
local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.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 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/UpdateEmployeeAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/UpdateEmployeeAction.java 2010-10-28 11:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/employee/UpdateEmployeeAction.java 2010-11-19 12:52:40 +0000
@@ -8,132 +8,128 @@
import com.opensymphony.xwork2.Action;
-public class UpdateEmployeeAction
-implements Action
+public class UpdateEmployeeAction
+ implements Action
{
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
- private EmployeeService employeeService;
+ private EmployeeService employeeService;
- public void setEmployeeService(EmployeeService employeeService)
- {
- this.employeeService = employeeService;
- }
+ public void setEmployeeService( EmployeeService employeeService )
+ {
+ this.employeeService = employeeService;
+ }
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
- private I18nFormat format;
+ private I18nFormat format;
public void setFormat( I18nFormat format )
{
this.format = format;
}
-
- private String pdscode;
-
- public String getPdscode()
- {
- return pdscode;
- }
-
- public void setPdscode(String pdscode)
- {
- this.pdscode = pdscode;
- }
-
- private String name;
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- private String dob;
-
- public void setDob(String dob)
- {
- this.dob = dob;
- }
-
- private String lprDate;
-
- public void setLprDate(String lprDate)
- {
- this.lprDate = lprDate;
- }
-
- private String govtSerJoinDate;
-
- public void setGovtSerJoinDate(String govtSerJoinDate)
- {
- this.govtSerJoinDate = govtSerJoinDate;
- }
-
- private String sex;
-
- public void setSex(String sex)
- {
- this.sex = sex;
- }
-
- private String resAdd;
-
- public void setResAdd(String resAdd)
- {
- this.resAdd = resAdd;
- }
-
- private String contactNo;
-
- public void setContactNo(String contactNo)
- {
- this.contactNo = contactNo;
- }
-
- private String emerContactNo;
-
- public void setEmerContactNo(String emerContactNo)
- {
- this.emerContactNo = emerContactNo;
- }
-
-
- public String execute()
- {
- Employee employee = employeeService.getEmployeeByPDSCode( pdscode );
-
- Date dateOfBirth = format.parseDate( dob );
-
- Date lpRetirementDate = format.parseDate( lprDate );
-
- Date joinDate = format.parseDate( govtSerJoinDate );
-
- employee.setPdsCode( pdscode );
-
- employee.setName( name );
-
- employee.setDateOfBirth( dateOfBirth );
-
- employee.setLprDate( lpRetirementDate );
-
- employee.setSex( sex );
-
- employee.setJoinDateToGovtService( joinDate );
-
- employee.setResAddress( resAdd );
-
- employee.setContactNumber( contactNo );
-
- employee.setEmergencyContactNumber( emerContactNo );
-
- employeeService.updateEmployee( employee );
-
- return SUCCESS;
- }
-
-
-
+
+ private String pdscode;
+
+ public String getPdscode()
+ {
+ return pdscode;
+ }
+
+ public void setPdscode( String pdscode )
+ {
+ this.pdscode = pdscode;
+ }
+
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ private String dob;
+
+ public void setDob( String dob )
+ {
+ this.dob = dob;
+ }
+
+ private String lprDate;
+
+ public void setLprDate( String lprDate )
+ {
+ this.lprDate = lprDate;
+ }
+
+ private String govtSerJoinDate;
+
+ public void setGovtSerJoinDate( String govtSerJoinDate )
+ {
+ this.govtSerJoinDate = govtSerJoinDate;
+ }
+
+ private String sex;
+
+ public void setSex( String sex )
+ {
+ this.sex = sex;
+ }
+
+ private String resAdd;
+
+ public void setResAdd( String resAdd )
+ {
+ this.resAdd = resAdd;
+ }
+
+ private String contactNo;
+
+ public void setContactNo( String contactNo )
+ {
+ this.contactNo = contactNo;
+ }
+
+ private String emerContactNo;
+
+ public void setEmerContactNo( String emerContactNo )
+ {
+ this.emerContactNo = emerContactNo;
+ }
+
+ public String execute()
+ {
+ Employee employee = employeeService.getEmployeeByPDSCode( pdscode );
+
+ Date dateOfBirth = format.parseDate( dob );
+
+ Date lpRetirementDate = format.parseDate( lprDate );
+
+ Date joinDate = format.parseDate( govtSerJoinDate );
+
+ employee.setPdsCode( pdscode );
+
+ employee.setName( name );
+
+ employee.setDateOfBirth( dateOfBirth );
+
+ employee.setLprDate( lpRetirementDate );
+
+ employee.setSex( sex );
+
+ employee.setJoinDateToGovtService( joinDate );
+
+ employee.setResAddress( resAdd );
+
+ employee.setContactNumber( contactNo );
+
+ employee.setEmergencyContactNumber( emerContactNo );
+
+ employeeService.updateEmployee( employee );
+
+ return SUCCESS;
+ }
}
\ No newline at end of file
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/FormAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/FormAction.java 2010-11-17 10:49:09 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/FormAction.java 2010-11-19 12:52:40 +0000
@@ -84,39 +84,39 @@
}
private LineListService lineListService;
-
+
public void setLineListService( LineListService lineListService )
{
this.lineListService = lineListService;
}
private DataValueService dataValueService;
-
+
public void setDataValueService( DataValueService dataValueService )
{
this.dataValueService = dataValueService;
}
-
+
private EmployeeService employeeService;
-
+
public void setEmployeeService( EmployeeService employeeService )
{
this.employeeService = employeeService;
}
-
- // --------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
// Parameters
- // --------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
private Map<String, DataValue> dataValueMap;
-
+
public Map<String, DataValue> getDataValueMap()
{
return dataValueMap;
}
private Map<String, String> dataelementMap;
-
+
public Map<String, String> getDataelementMap()
{
return dataelementMap;
@@ -142,7 +142,7 @@
}
private String selectedLineListOptionId;
-
+
public String getSelectedLineListOptionId()
{
return selectedLineListOptionId;
@@ -152,7 +152,7 @@
{
this.selectedLineListOptionId = selectedLineListOptionId;
}
-
+
private Integer selectedPeriodIndex;
public void setSelectedPeriodIndex( Integer selectedPeriodIndex )
@@ -192,7 +192,7 @@
}
private List<Employee> employeeList;
-
+
public List<Employee> getEmployeeList()
{
return employeeList;
@@ -200,25 +200,30 @@
private Collection<LineListOption> lineListOptions;
- public String execute() throws Exception
+ //--------------------------------------------------------------------------
+ // Action Implementation
+ //--------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
{
employeeList = new ArrayList<Employee>();
OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
LineListGroup lineListGroup = selectedStateManager.getSelectedLineListGroup();
-
+
LineListOption lineListOption = selectedStateManager.getSelectedLineListOption();
llElementOptionsMap = new HashMap<String, Collection<LineListOption>>();
List<Integer> recordNumbers = new ArrayList<Integer>();
-
+
lineListElements = new ArrayList<LineListElement>( lineListGroup.getLineListElements() );
if ( lineListElements.size() == 0 )
{
return SUCCESS;
- }
+ }
else
{
Iterator<LineListElement> it2 = lineListElements.iterator();
@@ -230,26 +235,25 @@
llElementOptionsMap.put( element.getShortName(), lineListOptions );
}
}
-
+
// Removing POST linelist element from the list
String postLineListElementName = lineListGroup.getLineListElements().iterator().next().getShortName();
lineListElements.remove( 0 );
-
- //HardCoding to get lastworkingdate linelist element
- String lastWorkingDateLLElementName = "lastworkingdate";
-
- //preparing map to filter records from linelist table
+
+ // HardCoding to get lastworkingdate linelist element
+ String lastWorkingDateLLElementName = "lastworkingdate";
+
+ // preparing map to filter records from linelist table
Map<String, String> llElementValueMap = new HashMap<String, String>();
llElementValueMap.put( postLineListElementName, lineListOption.getName() );
llElementValueMap.put( lastWorkingDateLLElementName, "null" );
-
-
+
Period period;
- if( lineListGroup != null && lineListGroup.getPeriodType().getName().equalsIgnoreCase( "OnChange" ) )
- {
- period = dataBaseManagerInterface.getRecentPeriodForOnChangeData( lineListGroup.getShortName(), postLineListElementName, lineListOption.getName(), organisationUnit );
-
+ if ( lineListGroup != null && lineListGroup.getPeriodType().getName().equalsIgnoreCase( "OnChange" ) )
+ {
+ period = dataBaseManagerInterface.getRecentPeriodForOnChangeData( lineListGroup.getShortName(),
+ postLineListElementName, lineListOption.getName(), organisationUnit );
}
else
{
@@ -257,65 +261,73 @@
period = periodService.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
}
-
+
if ( period != null )
{
- //To get datavalues from datavalue table for normal dataelements
-
+ // To get datavalues from datavalue table for normal dataelements
+
+ Period dataValuePeriod = periodService.getPeriod( 0 );
dataValueMap = new HashMap<String, DataValue>();
-
+
dataelementMap = new HashMap<String, String>();
-
+
LineListElement lineListElement = lineListService.getLineListElementByShortName( postLineListElementName );
-
- List<LineListDataElementMap> lineListDataElementMaps = lineListService.getLinelistDataelementMappings( lineListElement, lineListOption );
-
- System.out.println("Agg De size : "+lineListDataElementMaps.size() + " :: "+ lineListElement.getId() + " :: " + lineListOption.getId() );
+
+ List<LineListDataElementMap> lineListDataElementMaps = lineListService.getLinelistDataelementMappings(
+ lineListElement, lineListOption );
+
+ System.out.println( "Agg De size : " + lineListDataElementMaps.size() + " :: " + lineListElement.getId()
+ + " :: " + lineListOption.getId() );
Iterator<LineListDataElementMap> lineListDEMapIterator = lineListDataElementMaps.iterator();
-
- while( lineListDEMapIterator.hasNext() )
+
+ while ( lineListDEMapIterator.hasNext() )
{
LineListDataElementMap lineListDataElementMap = lineListDEMapIterator.next();
-
- DataValue dataValue = dataValueService.getDataValue( organisationUnit, lineListDataElementMap.getDataElement(), period, lineListDataElementMap.getDataElementOptionCombo() );
-
- System.out.println(organisationUnit.getId() + " : " + lineListDataElementMap.getDataElement().getId() + " : " + period.getId() + " : " + lineListDataElementMap.getDataElementOptionCombo().getId() );
-
- String mapName = "DE:"+lineListDataElementMap.getDataElement().getId() + ":" + lineListDataElementMap.getDataElementOptionCombo().getId();
-
- if(lineListDataElementMap.getDataElement().getName().contains( "Sanctioned Post"))
+
+ DataValue dataValue = dataValueService.getDataValue( organisationUnit, lineListDataElementMap
+ .getDataElement(), dataValuePeriod, lineListDataElementMap.getDataElementOptionCombo() );
+
+ System.out.println( organisationUnit.getId() + " : " + lineListDataElementMap.getDataElement().getId()
+ + " : " + dataValuePeriod.getId() + " : " + lineListDataElementMap.getDataElementOptionCombo().getId() );
+
+ String mapName = "DE:" + lineListDataElementMap.getDataElement().getId() + ":"
+ + lineListDataElementMap.getDataElementOptionCombo().getId();
+
+ if ( lineListDataElementMap.getDataElement().getName().contains( "Sanctioned Post" ) )
{
sactionedPostdataelement = mapName;
}
dataValueMap.put( mapName, dataValue );
-
- dataelementMap.put( mapName, lineListDataElementMap.getDataElement().getName() + " : " + lineListDataElementMap.getDataElementOptionCombo().getName() );
+
+ dataelementMap.put( mapName, lineListDataElementMap.getDataElement().getName() + " : "
+ + lineListDataElementMap.getDataElementOptionCombo().getName() );
}
llDataValuesList = new ArrayList<LineListDataValue>();
- llDataValuesList = dataBaseManagerInterface.getLLValuesFilterByLLElements( lineListGroup.getShortName(), llElementValueMap, organisationUnit, period );
-
+ llDataValuesList = dataBaseManagerInterface.getLLValuesFilterByLLElements( lineListGroup.getShortName(),
+ llElementValueMap, organisationUnit );
+
// HardCoding Column Name
-
+
String pdsCodeColName = "pdscode";
if ( llDataValuesList == null || llDataValuesList.isEmpty() )
{
return SUCCESS;
- }
+ }
else
{
for ( LineListDataValue llDataValue : llDataValuesList )
{
Map<String, String> llValueMap = llDataValue.getLineListValues();
- if ( llValueMap != null)
+ if ( llValueMap != null )
{
String pdsCode = llValueMap.get( pdsCodeColName );
- if( pdsCode != null )
+ if ( pdsCode != null )
{
Employee employee = employeeService.getEmployeeByPDSCode( pdsCode );
- if( employee != null )
+ if ( employee != null )
{
employeeList.add( employee );
}
@@ -324,7 +336,7 @@
recordNumbers.add( Integer.valueOf( llDataValue.getRecordNumber() ) );
}
}
-
+
}
return SUCCESS;
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java 2010-11-17 10:49:09 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/GetValidatePostVacantAction.java 2010-11-19 12:52:40 +0000
@@ -165,7 +165,8 @@
{
OrganisationUnit organisationunit = selectedStateManager.getSelectedOrganisationUnit();
- Period historyPeriod = getHistoryPeriod();
+ //Period historyPeriod = getHistoryPeriod();
+ Period period = periodService.getPeriod( 0 );
storedBy = currentUserService.getCurrentUsername();
@@ -189,7 +190,7 @@
dataValue = dataValue.trim();
}
- DataValue dataValueObj = dataValueService.getDataValue( organisationunit, dataElement, historyPeriod, optionCombo );
+ DataValue dataValueObj = dataValueService.getDataValue( organisationunit, dataElement, period, optionCombo );
if ( storedBy == null )
{
@@ -200,7 +201,7 @@
{
if ( dataValue != null )
{
- dataValueObj = new DataValue( dataElement, historyPeriod, organisationunit, dataValue, storedBy, new Date(), null,
+ dataValueObj = new DataValue( dataElement, period, organisationunit, dataValue, storedBy, new Date(), null,
optionCombo );
dataValueService.addDataValue( dataValueObj );
}
@@ -214,7 +215,7 @@
dataValueService.updateDataValue( dataValueObj );
}
}
-
+
private Period getHistoryPeriod( )
{
//lineListGroup = selectedStateManager.getSelectedLineListGroup();
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java 2010-11-17 10:49:09 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/SaveEmplyeePostAction.java 2010-11-19 12:52:40 +0000
@@ -169,12 +169,20 @@
for ( LineListElement linelistElement : linelistElements )
{
String linelistElementValue = request.getParameter( linelistElement.getShortName() );
+
+ System.out.println("Linelist Em=lement name is :" + linelistElement.getShortName() + " And Linlelist Value is:" + linelistElementValue );
+ if( linelistElementValue == null )
+ {
+ continue;
+ }
+
if ( linelistElementValue != null && linelistElementValue.trim().equals( "" ) )
{
- linelistElementValue = "";
+ linelistElementValue = "";
}
llElementValuesMap.put( linelistElement.getShortName(), linelistElementValue );
+
}
String postColumnId = linelistElements.iterator().next().getShortName();
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java 2010-11-17 10:49:09 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowEmployeePostFormAction.java 2010-11-19 12:52:40 +0000
@@ -104,6 +104,10 @@
}
private Collection<LineListOption> lineListOptions;
+
+ //--------------------------------------------------------------------------
+ //Action Implementation
+ //--------------------------------------------------------------------------
public String execute()
{
@@ -112,6 +116,7 @@
llElementOptionsMap = new HashMap<String, Collection<LineListOption>>();
lineListElements = new ArrayList<LineListElement>( lineListGroup.getLineListElements() );
+
if ( lineListElements.size() == 0 )
{
return SUCCESS;
@@ -129,6 +134,12 @@
}
lineListElements.remove( 0 );
+ // Hardcoding to remove lastWorkingDate and reasonWhyLeft
+
+ lineListElements.remove( lineListElements.size()-1 );
+ lineListElements.remove( lineListElements.size()-1 );
+
+
linelistGroupName = selectedStateManager.getSelectedLineListGroup().getName();
linelistOptionName = selectedStateManager.getSelectedLineListOption().getName();
linelistGroupId = selectedStateManager.getSelectedLineListGroup().getId();
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowUpdateEmployeePostFormAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowUpdateEmployeePostFormAction.java 2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/ShowUpdateEmployeePostFormAction.java 2010-11-19 12:52:40 +0000
@@ -45,6 +45,20 @@
this.id = id;
}
+ private String linelistGroupName;
+
+ public String getLinelistGroupName()
+ {
+ return linelistGroupName;
+ }
+
+ private String linelistOptionName;
+
+ public String getLinelistOptionName()
+ {
+ return linelistOptionName;
+ }
+
private Map<String, String> llDataValuesMap;
public Map<String, String> getLlDataValuesMap()
@@ -58,6 +72,26 @@
{
return lineListElements;
}
+
+ public String reportingDate;
+
+ public String getReportingDate()
+ {
+ return reportingDate;
+ }
+
+ public void setReportingDate( String reportingDate )
+ {
+ this.reportingDate = reportingDate;
+ }
+
+ private Integer linelistGroupId;
+
+ public Integer getLinelistGroupId()
+ {
+ return linelistGroupId;
+ }
+
//--------------------------------------------------------------------------
// Action Implementation
@@ -69,6 +103,7 @@
OrganisationUnit orgUnit = selectedStateManager.getSelectedOrganisationUnit();
LineListGroup llGroup = selectedStateManager.getSelectedLineListGroup();
lineListElements = new ArrayList<LineListElement>( llGroup.getLineListElements() );
+ lineListElements.remove( 0 );
List<LineListDataValue> llDataValuesList = new ArrayList<LineListDataValue>();
Map<String, String> llDataValueMap = new HashMap<String, String>();
@@ -79,15 +114,24 @@
llDataValueMap.put( pdsCodeColName, id );
llDataValueMap.put( lastWorkingDateColumnName, "null" );
+ System.out.println("The entered PDSCODE IS ***************" + id );
llDataValuesList = dataBaseManagerInterface.getLLValuesFilterByLLElements( llGroup.getShortName(), llDataValueMap, orgUnit );
- if ( llDataValuesList != null)
+ if ( llDataValuesList != null && llDataValuesList.size() > 0 )
{
+ System.out.println("************************************************" );
+ System.out.println("LineList Value is----------" + llDataValuesList );
LineListDataValue llDataValue;
llDataValue = llDataValuesList.get( 0 );
llDataValuesMap = llDataValue.getLineListValues();
}
+ System.out.println("::::::::::::" + llDataValuesMap );
+
+ linelistGroupName = selectedStateManager.getSelectedLineListGroup().getName();
+ linelistOptionName = selectedStateManager.getSelectedLineListOption().getName();
+ linelistGroupId = selectedStateManager.getSelectedLineListGroup().getId();
+
return SUCCESS;
}
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/UpdateEmployeePostAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/UpdateEmployeePostAction.java 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/lldataentry/UpdateEmployeePostAction.java 2010-11-19 12:52:40 +0000
@@ -0,0 +1,241 @@
+package org.hisp.dhis.ll.action.lldataentry;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.dbmanager.DataBaseManagerInterface;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.linelisting.LineListDataValue;
+import org.hisp.dhis.linelisting.LineListElement;
+import org.hisp.dhis.linelisting.LineListGroup;
+import org.hisp.dhis.linelisting.LineListService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.DailyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.CurrentUserService;
+
+import com.opensymphony.xwork2.Action;
+
+public class UpdateEmployeePostAction
+ implements Action
+{
+ //--------------------------------------------------------------------------
+ // Dependencies
+ //--------------------------------------------------------------------------
+
+ private LineListService lineListService;
+
+ public void setLineListService( LineListService lineListService )
+ {
+ this.lineListService = lineListService;
+ }
+
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
+ private DataBaseManagerInterface dbManagerInterface;
+
+ public void setDbManagerInterface( DataBaseManagerInterface dbManagerInterface )
+ {
+ this.dbManagerInterface = dbManagerInterface;
+ }
+
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ //--------------------------------------------------------------------------
+ // Input/Output
+ //--------------------------------------------------------------------------
+
+ private String department;
+
+ public void setDepartment( String department )
+ {
+ this.department = department;
+ }
+
+ private String post;
+
+ public void setPost( String post )
+ {
+ this.post = post;
+ }
+
+ private String storedBy;
+
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public String reportingDate;
+
+ public void setReportingDate( String reportingDate )
+ {
+ this.reportingDate = reportingDate;
+ }
+
+ public String getReportingDate()
+ {
+ return reportingDate;
+ }
+
+ private Integer groupid;
+
+ public void setGroupid( Integer groupid )
+ {
+ this.groupid = groupid;
+ }
+
+ private LineListGroup lineListGroup;
+
+ //--------------------------------------------------------------------------
+ // Action Impplementation
+ //--------------------------------------------------------------------------
+
+ public String execute()
+ {
+ HttpServletRequest request = ServletActionContext.getRequest();
+
+ System.out.println( "GroupId id :::::" + groupid );
+
+ Collection<LineListElement> linelistElements = lineListService.getLineListGroup( groupid )
+ .getLineListElements();
+
+ lineListGroup = selectedStateManager.getSelectedLineListGroup();
+
+ OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ Period historyPeriod = getHistoryPeriod();
+
+ Map<String, String> llElementValuesMap = new HashMap<String, String>();
+ LineListDataValue llDataValue = new LineListDataValue();
+ for ( LineListElement linelistElement : linelistElements )
+ {
+ String linelistElementValue = request.getParameter( linelistElement.getShortName() );
+
+ if ( linelistElementValue != null && linelistElementValue.trim().equals( "" ) )
+ {
+ linelistElementValue = "";
+ }
+ llElementValuesMap.put( linelistElement.getShortName(), linelistElementValue );
+ }
+
+ String postColumnId = linelistElements.iterator().next().getShortName();
+ llElementValuesMap.put( postColumnId, post );
+ System.out.println( "*********" + postColumnId + " ------ " + post + "**********" );
+
+ // add map in linelist data value
+ llDataValue.setLineListValues( llElementValuesMap );
+
+ // add period and source to row
+ llDataValue.setPeriod( historyPeriod );
+ llDataValue.setSource( organisationUnit );
+
+ // add stored by, timestamp in linelist data value
+ storedBy = currentUserService.getCurrentUsername();
+
+ if ( storedBy == null )
+ {
+ storedBy = "[unknown]";
+ }
+
+ llDataValue.setStoredBy( storedBy );
+ List<LineListDataValue> llDataValuesList = new ArrayList<LineListDataValue>();
+
+ llDataValuesList.add( llDataValue );
+
+ boolean valueUpdated = dbManagerInterface.updateLLValue( llDataValuesList, department );
+
+ if ( valueUpdated )
+ {
+ System.out.println( "Values Successfully Updated in DB" );
+ }
+
+ return SUCCESS;
+ }
+
+ private Period getHistoryPeriod()
+ {
+ Date historyDate = format.parseDate( reportingDate );
+ System.out.println( "Report Date is :::::::" + reportingDate );
+
+ Period period;
+ period = periodService.getPeriod( 0 );
+ Period historyPeriod;
+
+ if ( lineListGroup != null && lineListGroup.getPeriodType().getName().equalsIgnoreCase( "OnChange" ) )
+ {
+ PeriodType dailyPeriodType = new DailyPeriodType();
+ historyPeriod = dailyPeriodType.createPeriod( historyDate );
+
+ System.out.println( reportingDate + " : " + historyPeriod );
+ if ( historyPeriod == null )
+ {
+ System.out.println( "historyPeriod is null" );
+ }
+ historyPeriod = reloadPeriodForceAdd( historyPeriod );
+ }
+ else
+ {
+ period = selectedStateManager.getSelectedPeriod();
+
+ period = reloadPeriodForceAdd( period );
+
+ historyPeriod = period;
+ }
+
+ return historyPeriod;
+ }
+
+ private final Period reloadPeriod( Period period )
+ {
+ return periodService.getPeriod( period.getStartDate(), period.getEndDate(), period.getPeriodType() );
+ }
+
+ private final Period reloadPeriodForceAdd( Period period )
+ {
+ Period storedPeriod = reloadPeriod( period );
+
+ if ( storedPeriod == null )
+ {
+ periodService.addPeriod( period );
+
+ return period;
+ }
+
+ return storedPeriod;
+ }
+
+}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-11-19 09:33:44 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-11-19 12:52:40 +0000
@@ -571,6 +571,25 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.ll.action.lldataentry.UpdateEmployeePostAction"
+ class="org.hisp.dhis.ll.action.lldataentry.UpdateEmployeePostAction" scope="prototype">
+ <property name="selectedStateManager">
+ <ref bean="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager"/>
+ </property>
+ <property name="lineListService">
+ <ref bean="org.hisp.dhis.linelisting.LineListService"/>
+ </property>
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService"/>
+ </property>
+ <property name="dbManagerInterface">
+ <ref bean="org.hisp.dhis.dbmanager.DataBaseManagerInterface"/>
+ </property>
+ <property name="periodService">
+ <ref bean="org.hisp.dhis.period.PeriodService"/>
+ </property>
+ </bean>
+
<!-- 15/10/2010 Start -->
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml'
--- local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-11-19 09:33:44 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-11-19 12:52:40 +0000
@@ -405,12 +405,11 @@
</action>
<action name="saveValueAction" class="org.hisp.dhis.ll.action.lldataentry.SaveValueAction">
- <result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-linelisting-mp/select.vm</param>
+ <result name="success" type="redirect">select.action</result>
</action>
<action name="saveEmployeePost" class="org.hisp.dhis.ll.action.lldataentry.SaveEmplyeePostAction">
- <result name="success" type="velocity">/main.vm</result>
+ <result name="success" type="redirect">select.action</result>
</action>
<action name="updateLineListEntry"
@@ -441,8 +440,10 @@
<result name="success" type="velocity">/dhis-web-linelisting-mp/updateEmployeePostForm.vm</result>
</action>
-
-
+ <action name="updateEmployeePost"
+ class="org.hisp.dhis.ll.action.lldataentry.UpdateEmployeePostAction">
+ <result name="success" type="redirect">select.action</result>
+ </action>
<!-- Org unit -->
<action name="getOrgUnitDetails"
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm 2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePost.vm 2010-11-19 12:52:40 +0000
@@ -37,17 +37,17 @@
</td>
#elseif($lineListElement.PresentationType == 'combobox')
<td>
- <select name="$element" id="$element" onkeypress="return keyPress(event, this)">
- <option name="SelectOption" value="" selected>--Select--</option>
- #set($lineListOptions = $llElementOptionsMap.get($lineListElement.shortName))
+ <select name="$lineListElement.shortName" id="$lineListElement.shortName" onkeypress="return keyPress(event, this)">
+ <option name="SelectOption" value="" selected>--Select--</option>
+ ##set($lineListOptions = $llElementOptionsMap.get($lineListElement.shortName))
+ #set( $lineListOptions = $lineListElement.lineListElementOptions )
#foreach( $lineListOption in $lineListOptions )
<option name="$lineListOption.name" value="$lineListOption.name" #if($lineListOption.name == $llElementValuesMap.get($element)) selected #end>$lineListOption.name</option>
#end
</select>
</td>
#elseif($lineListElement.PresentationType == 'calender')
- #set($fordate = $lineListElement.shortName)
-
+ #set($fordate = $lineListElement.shortName)
<td>
<input type="text" id="$fordate" name="$fordate" style="width:10em" onkeypress="return keyPress(event, this)">
<script>datePickerValid( '$fordate', false );</script>
@@ -56,12 +56,13 @@
</tr>
#set ($count=$count+1)
#end
+
+ <tr><td></td><td></td></tr>
<tr>
-
- <td colspan="2" align="centre">
+ <td align="centre">
<input type="submit" value="Save">
- <input type="hidden" id="reportedDate" name="reportedDate">
+ <input type="hidden" id="reportedDate" name="reportedDate">
</td>
<td>
<input type="button" value="Reset">
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm 2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/form.vm 2010-11-19 12:52:40 +0000
@@ -60,7 +60,6 @@
<tr id="tr${employee.pdsCode}">
<td#alternate( $mark )>$encoder.htmlEncode( $employee.name ) - $encoder.htmlEncode( $employee.pdsCode )</td>
<td style="text-align:center"#alternate( $mark )><a href="javascript:showUpdateEmployeePostForm( '$employee.pdsCode' )" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a></td>
- <td style="text-align:center"#alternate( $mark )><a href="javascript:showEmployeePostDetails( '$employee.pdsCode' )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a></td>
#end
<tbody>
@@ -164,22 +163,4 @@
return true;
}
- function showUpdateEmployeePostForm( pdsCode )
- {
- var url = 'showEmployeePostForm.action?id=' + pdsCode;
- //var url = 'showEmployeePostForm.action';
- $('#contentDataRecord1').dialog('destroy').remove();
- $('<div id="contentDataRecord1" style="z-index: 1;">' ).load(url).dialog({
- title: 'Edit Employee Post Detail',
- maximize: true,
- closable: true,
- modal:true,
- overlay:{background:'#000000', opacity:0.1},
- width: 420,
- height: 380
- });
- }
-
-
-
</script>
\ No newline at end of file
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js 2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/javascript/form.js 2010-11-19 12:52:40 +0000
@@ -55,7 +55,11 @@
{
if( confirm( employeeElement.firstChild.nodeValue ) )
{
- alert("Edit Employee");
+
+ var field = document.getElementById( currentPDSCode );
+ document.getElementById('contentDataRecord').style.display="none";
+ showUpdateEmployeePostForm( field.value );
+
}
else
{
@@ -174,6 +178,57 @@
overlay:{background:'#000000', opacity:0.1},
width: 420,
height: 380
-});
-
-}
\ No newline at end of file
+ });
+}
+
+function showUpdateEmployeePostForm( pdsCode )
+{
+ var reportingDate = document.getElementById( "reportingDate" ).value;
+ var url = 'showEditEmployeePostForm.action?id=' + pdsCode + '&reportingDate=' + reportingDate;
+ $('#contentDataRecord').dialog('destroy').remove();
+ $('<div id="contentDataRecord" style="z-index: 1;">' ).load(url).dialog({
+ title: 'Edit Employee Post Detail',
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 420,
+ height: 380
+ });
+}
+
+function keyPress( event, field )
+{
+ var key = 0;
+ if ( event.charCode )
+ {
+ key = event.charCode; /* Safari2 (Mac) (and probably Konqueror on Linux, untested) */
+ }
+ else
+ {
+ if ( event.keyCode )
+ {
+ key = event.keyCode; /* Firefox1.5 (Mac/Win), Opera9 (Mac/Win), IE6, IE7Beta2, Netscape7.2 (Mac) */
+ }
+ else
+ {
+ if ( event.which )
+ {
+ key = event.which; /* Older Netscape? (No browsers triggered yet) */
+ }
+ }
+ }
+
+ if ( key == 13 ) /* CR */
+ {
+ nextField = getNextEntryField( field );
+ if ( nextField )
+ {
+ nextField.focus(); /* Does not seem to actually work in Safari, unless you also have an Alert in between */
+ }
+ return true;
+ }
+
+ /* Illegal characters can be removed with a new if-block and return false */
+ return true;
+}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/updateEmployeePostForm.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/updateEmployeePostForm.vm 2010-11-17 13:56:10 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/updateEmployeePostForm.vm 2010-11-19 12:52:40 +0000
@@ -1,7 +1,7 @@
<script type="text/javascript" src="../"></script>
-<form id="employeePostForm" action="saveEmployeePost.action" method="post" >
+<form id="employeePostForm" action="updateEmployeePost.action" method="post" >
<table align="centre">
<tr>
<td><label for="department"><Strong>Department</Strong> </label></td>
@@ -15,7 +15,12 @@
<td>
<input id="post" name="post" type="text" readonly="readonly" value="$linelistOptionName" style="min-width:200px">
</td>
+ <td>
+ <input type="hidden" name="groupid" id="groupid" value="$linelistGroupId">
+ <input type="hidden" name="reportingDate" id="reportingDate" value="$reportingDate">
+ </td>
</tr>
+ <tr><td></td></tr>
#set( $count = 0 )
#foreach( $lineListElement in $lineListElements )
<tr>
@@ -26,12 +31,12 @@
</td>
#elseif($lineListElement.PresentationType == 'combobox')
<td>
- <select name="$element" id="$element" onkeypress="return keyPress(event, this)">
+ <select name="$lineListElement.shortName" id="$lineListElement.shortName" onkeypress="return keyPress(event, this)">
<option name="SelectOption" value="" selected>--Select--</option>
##set($lineListOptions = $llElementOptionsMap.get($lineListElement.shortName))
#set($lineListOptions = $lineListElement.lineListElementOptions)
#foreach( $lineListOption in $lineListOptions )
- <option name="$lineListOption.name" value="$lineListOption.name" #if($lineListOption.name == $llElementValuesMap.get($element)) selected #end>$lineListOption.name</option>
+ <option value="$lineListOption.name" name="$llDataValuesMap.get($lineListElement.shortName)" #if($lineListOption.name == $llDataValuesMap.get($lineListElement.shortName)) selected #end>$lineListOption.name</option>
#end
</select>
</td>
@@ -39,15 +44,24 @@
#set($fordate = $lineListElement.shortName)
<td>
- <input type="text" id="$fordate" name="$fordate" style="width:10em" onkeypress="return keyPress(event, this)">
+ <input type="text" id="$fordate" name="$fordate" style="width:10em" onkeypress="return keyPress(event, this)" value=$llDataValuesMap.get($lineListElement.shortName)>
<script>datePickerValid( '$fordate', false );</script>
</td>
#end
</tr>
#set ($count=$count+1)
#end
-
-
+ <tr><td></td><td></td></tr>
+
+ <tr>
+ <td align="centre">
+ <input type="submit" value="Save">
+ <input type="hidden" id="reportedDate" name="reportedDate">
+ </td>
+ <td>
+ <input type="button" value="Reset">
+ </td>
+ </tr>
</table>
</form>
\ No newline at end of file
=== modified file 'local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java'
--- local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-11-17 13:56:10 +0000
+++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-11-19 12:52:40 +0000
@@ -163,7 +163,6 @@
SqlRowSet rs = jdbcTemplate.queryForRowSet( columnDefinition );
if ( rs != null )
{
- int i = 0;
while ( rs.next() )
{
@@ -258,59 +257,48 @@
public boolean updateTable( String tableName, List<LineListElement> removeList, List<LineListElement> addList )
{
-
String columnDefinition = "";
Statement statement = null;
- columnDefinition += "alter table " + tableName;
+ columnDefinition += "ALTER TABLE " + tableName;
int columnAffected = 0;
boolean rowUpdated = false;
boolean columnAdded = false;
- if ( addList != null )
+ if ( addList != null && !addList.isEmpty() )
{
- if ( !( addList.isEmpty() ) )
+ int i = 1;
+ Iterator<LineListElement> addListItr = addList.iterator();
+ int size = addList.size();
+ while ( addListItr.hasNext() )
{
- int i = 1;
- Iterator addListItr = addList.iterator();
- int size = addList.size();
- while ( addListItr.hasNext() )
- {
- LineListElement lineListElement = (LineListElement) addListItr.next();
- if ( lineListElement.getDataType().equalsIgnoreCase( "string" ) )
- {
- columnDefinition += " add column " + lineListElement.getShortName() + " VARCHAR (255)";
- columnAdded = true;
- } else
- {
- if ( lineListElement.getDataType().equalsIgnoreCase( "bool" ) )
- {
- columnDefinition += " add column " + lineListElement.getShortName() + "BIT (1)";
- columnAdded = true;
- } else
- {
- if ( lineListElement.getDataType().equalsIgnoreCase( "date" ) )
- {
- columnDefinition += " add column " + lineListElement.getShortName() + " DATE";
- columnAdded = true;
- } else
- {
- if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
- {
- columnDefinition += " add column " + lineListElement.getShortName() + " int (11)";
- columnAdded = true;
- } else
- {
- }
- }
- }
- }
- if ( i < size )
- {
- columnDefinition += " ,";
- i++;
- }
+ LineListElement lineListElement = (LineListElement) addListItr.next();
+ if ( lineListElement.getDataType().equalsIgnoreCase( "string" ) )
+ {
+ columnDefinition += " ADD COLUMN " + lineListElement.getShortName() + " VARCHAR (255)";
+ columnAdded = true;
+ }
+ else if ( lineListElement.getDataType().equalsIgnoreCase( "bool" ) )
+ {
+ columnDefinition += " ADD COLUMN " + lineListElement.getShortName() + "BIT (1)";
+ columnAdded = true;
+ }
+ else if ( lineListElement.getDataType().equalsIgnoreCase( "date" ) )
+ {
+ columnDefinition += " ADD COLUMN " + lineListElement.getShortName() + " DATE";
+ columnAdded = true;
+ }
+ else if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
+ {
+ columnDefinition += " ADD COLUMN " + lineListElement.getShortName() + " int (11)";
+ columnAdded = true;
+ }
+
+ if ( i < size )
+ {
+ columnDefinition += " ,";
+ i++;
}
}
}
@@ -322,7 +310,7 @@
{
int j = 1;
- Iterator removeListItr = removeList.iterator();
+ Iterator<LineListElement> removeListItr = removeList.iterator();
int size = removeList.size();
while ( removeListItr.hasNext() )
@@ -1010,10 +998,12 @@
}
columnDefinition += values + ")";
+
+ System.out.println("ColimnDefination in LLSingleDatavalue " + columnDefinition );
try
{
- int sqlResult = jdbcTemplate.update( columnDefinition );
+ int sqlResult = jdbcTemplate.update( columnDefinition );
updateLLValue = true;
columnDefinition = "";
}
@@ -1032,10 +1022,6 @@
String columnDefinition = "";
- PreparedStatement preparedStatement = null;
-
- // System.out.println(" llDataValuesList size = " +
- // llDataValuesList.size());
for ( LineListDataValue llDataValue : llDataValuesList )
{