dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08665
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2131: Finished Manpower Employee Post Deatils Report
------------------------------------------------------------
revno: 2131
committer: Bharath <chbharathk@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-22 12:58:23 +0530
message:
Finished Manpower Employee Post Deatils Report
added:
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/EmployeePostDetailsReportAction.java
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePostDetailsResult.vm
local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Department.java
modified:
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/llgroup/UpdateLineListGroupAction.java
local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.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/menu.vm
local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm
local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Employee.java
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/llgroup/UpdateLineListGroupAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/llgroup/UpdateLineListGroupAction.java 2010-11-03 13:40:15 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/llgroup/UpdateLineListGroupAction.java 2010-11-22 07:28:23 +0000
@@ -131,13 +131,6 @@
// -------------------------------------------------------------------------
public String execute()
{
-
- // ---------------------------------------------------------------------
- // Prepare values
- // ---------------------------------------------------------------------
-
- // System.out.println("Line List Group ID : "+id);
-
if ( description != null && description.trim().length() == 0 )
{
description = null;
@@ -151,31 +144,26 @@
LineListGroup lineListGroup = lineListService.getLineListGroup( id );
-
-
List<LineListElement> newElements = new ArrayList<LineListElement>();
List<LineListElement> oldElements = new ArrayList<LineListElement>( lineListGroup.getLineListElements() );
List<LineListElement> removeElementList = new ArrayList<LineListElement>();
Collection<LineListElement> updatedDataElementList = new ArrayList<LineListElement>();
- if ( selectedList == null )
+ if( selectedList == null )
{
System.out.println( "selectedList is null" );
- } else
+ }
+ else if( newElements.isEmpty() )
{
- if ( newElements.isEmpty() )
+ for( String elementId : selectedList )
{
- for ( String elementId : selectedList )
+ LineListElement element = lineListService.getLineListElement( Integer.parseInt( elementId ) );
+ if ( !( oldElements.contains( element ) ) )
{
-
- LineListElement element = lineListService.getLineListElement( Integer.parseInt( elementId ) );
- if ( !( oldElements.contains( element ) ) )
- {
- newElements.add( element );
- System.out.println( "New element that should be added is: " + element );
- }
- updatedDataElementList.add( element );
+ newElements.add( element );
+ System.out.println( "New element that should be added is: " + element );
}
+ updatedDataElementList.add( element );
}
}
@@ -183,7 +171,6 @@
{
if ( !( updatedDataElementList.contains( oldElements.get( i ) ) ) )
{
-
boolean doNotDelete = dataBaseManagerInterface.checkDataFromTable( lineListGroup.getShortName(), oldElements.get( i ) );
if ( !doNotDelete )
{
@@ -195,9 +182,7 @@
}
lineListGroup.getLineListElements().removeAll( updatedDataElementList );
-
lineListGroup.getLineListElements().retainAll( updatedDataElementList );
-
lineListGroup.getLineListElements().addAll( updatedDataElementList );
lineListGroup.setName( name );
@@ -209,8 +194,9 @@
lineListGroup.setPeriodType( periodService.getPeriodTypeByClass( periodType.getClass() ) );
lineListService.updateLineListGroup( lineListGroup );
-
+ dataBaseManagerInterface.updateTable( lineListGroup.getName(), removeElementList, newElements );
+
return SUCCESS;
}
}
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/EmployeePostDetailsReportAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/EmployeePostDetailsReportAction.java 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/EmployeePostDetailsReportAction.java 2010-11-22 07:28:23 +0000
@@ -0,0 +1,103 @@
+package org.hisp.dhis.ll.action.reports;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.dbmanager.DataBaseManagerInterface;
+import org.hisp.dhis.linelisting.LineListDataValue;
+import org.hisp.dhis.linelisting.LineListElement;
+import org.hisp.dhis.linelisting.LineListGroup;
+import org.hisp.dhis.linelisting.LineListOption;
+import org.hisp.dhis.linelisting.LineListService;
+import org.hisp.dhis.ll.action.lldataentry.SelectedStateManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+
+import com.opensymphony.xwork2.Action;
+
+public class EmployeePostDetailsReportAction implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private SelectedStateManager selectedStateManager;
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ private DataBaseManagerInterface dataBaseManagerInterface;
+
+ public void setDataBaseManagerInterface( DataBaseManagerInterface dataBaseManagerInterface )
+ {
+ this.dataBaseManagerInterface = dataBaseManagerInterface;
+ }
+
+ private LineListService lineListService;
+
+ public void setLineListService( LineListService lineListService )
+ {
+ this.lineListService = lineListService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private List<LineListDataValue> llDataValuesList;
+
+ public List<LineListDataValue> getLlDataValuesList()
+ {
+ return llDataValuesList;
+ }
+
+ private List<LineListElement> lineListElements;
+
+ public List<LineListElement> getLineListElements()
+ {
+ return lineListElements;
+ }
+
+ private String deptAndPostIds;
+
+ public void setDeptAndPostIds( String deptAndPostIds )
+ {
+ this.deptAndPostIds = deptAndPostIds;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ OrganisationUnit selOrgUnit = selectedStateManager.getSelectedOrganisationUnit();
+
+ System.out.println("deptAndPostNames: "+ deptAndPostIds );
+ String[] partsOfDeptAndPostNames = deptAndPostIds.split( ":" );
+
+ LineListGroup department = lineListService.getLineListGroup( Integer.parseInt( partsOfDeptAndPostNames[0] ) );
+ LineListOption lineListOption = lineListService.getLineListOption( Integer.parseInt( partsOfDeptAndPostNames[1] ) );
+
+ lineListElements = new ArrayList<LineListElement>( department.getLineListElements() );
+
+ llDataValuesList = new ArrayList<LineListDataValue>();
+
+ //HardCoding to get lastworkingdate linelist element
+ String postLineListElementName = lineListElements.iterator().next().getShortName();
+ 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" );
+
+ llDataValuesList = dataBaseManagerInterface.getLLValuesFilterByLLElements( department.getShortName(), llElementValueMap, selOrgUnit );
+
+ return SUCCESS;
+ }
+}
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java'
--- local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java 2010-11-19 09:33:44 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/java/org/hisp/dhis/ll/action/reports/SummaryReportAction.java 2010-11-22 07:28:23 +0000
@@ -74,6 +74,13 @@
return resultMap;
}
+ private Map<String, String> resultIdMap;
+
+ public Map<String, String> getResultIdMap()
+ {
+ return resultIdMap;
+ }
+
List<String> resultKeys;
public List<String> getResultKeys()
@@ -95,6 +102,7 @@
public String execute()
{
resultMap = new HashMap<String, String>();
+ resultIdMap = new HashMap<String, String>();
resultKeys = new ArrayList<String>();
Period dataValuePeriod = periodService.getPeriod( 0 );
OrganisationUnit selOrgUnit = selectedStateManager.getSelectedOrganisationUnit();
@@ -124,7 +132,7 @@
List<LineListDataElementMap> lineListDataElementMaps = lineListService.getLinelistDataelementMappings( postElement, postOption );
- if( lineListDataElementMaps != null )
+ if( lineListDataElementMaps != null && !lineListDataElementMaps.isEmpty() )
{
LineListDataElementMap lineListDataElementMap = lineListDataElementMaps.iterator().next();
DataValue dataValue = dataValueService.getDataValue( selOrgUnit, lineListDataElementMap.getDataElement(), dataValuePeriod, lineListDataElementMap.getDataElementOptionCombo() );
@@ -137,7 +145,8 @@
int filledPostsCount = dataBaseManagerInterface.getLLValueCountByLLElements( lineListGroup.getName(), llElementValueMap, selOrgUnit );
int vacantPostsCount = sanctionedPostsCount - filledPostsCount;
- resultMap.put( lineListGroup.getName()+" - "+postElement.getName(), sanctionedPostsCount + " - " + filledPostsCount + " - " + vacantPostsCount);
+ resultMap.put( lineListGroup.getName()+" - "+postOption.getName(), sanctionedPostsCount + " - " + filledPostsCount + " - " + vacantPostsCount );
+ resultIdMap.put( lineListGroup.getName()+" - "+postOption.getName(), lineListGroup.getId()+":"+postOption.getId() );
}
}
=== 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-20 12:16:50 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/META-INF/dhis/beans.xml 2010-11-22 07:28:23 +0000
@@ -794,5 +794,12 @@
<ref bean="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager"/>
</property>
</bean>
+
+ <bean id="org.hisp.dhis.ll.action.reports.EmployeePostDetailsReportAction"
+ class="org.hisp.dhis.ll.action.reports.EmployeePostDetailsReportAction" scope="prototype">
+ <property name="lineListService" ref="org.hisp.dhis.linelisting.LineListService" />
+ <property name="dataBaseManagerInterface" ref="org.hisp.dhis.dbmanager.DataBaseManagerInterface" />
+ <property name="selectedStateManager" ref="org.hisp.dhis.ll.action.lldataentry.SelectedStateManager" />
+ </bean>
</beans>
=== 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 12:52:40 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/resources/struts.xml 2010-11-22 07:28:23 +0000
@@ -578,6 +578,9 @@
<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js</param>
</action>
+ <action name="showEmployeePostDetails" class="org.hisp.dhis.ll.action.reports.EmployeePostDetailsReportAction">
+ <result name="success" type="velocity">/dhis-web-linelisting-mp/employeePostDetailsResult.vm</result>
+ </action>
</package>
</struts>
\ No newline at end of file
=== added file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePostDetailsResult.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePostDetailsResult.vm 1970-01-01 00:00:00 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/employeePostDetailsResult.vm 2010-11-22 07:28:23 +0000
@@ -0,0 +1,16 @@
+
+<table>
+ <tr>
+ #foreach( $lineListElement in $lineListElements)
+ <th>$lineListElement.name</th>
+ #end
+ </tr>
+ #foreach( $llDataValue in $llDataValuesList )
+ #set( $llValueMap = $llDataValue.lineListValues )
+ <tr>
+ #foreach( $lineListElement in $lineListElements )
+ <td>$llValueMap.get( $lineListElement.shortName )</td>
+ #end
+ </tr>
+ #end
+</table>
\ No newline at end of file
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm 2010-11-19 09:33:44 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/menu.vm 2010-11-22 07:28:23 +0000
@@ -12,7 +12,6 @@
<h2>Linelisting Reports</h2>
<ul>
<li><a href="summaryReport.action">Linelist Summary Report</a></li>
- <li><a href="#">Linelist Detailed Report</a></li>
</ul>
<!--
<h2>Linelisting Validation Rules</h2>
=== modified file 'local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm'
--- local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm 2010-11-19 09:33:44 +0000
+++ local/bd/dhis-web-linelisting-manpower/src/main/webapp/dhis-web-linelisting-mp/summaryReportResult.vm 2010-11-22 07:28:23 +0000
@@ -2,17 +2,36 @@
#if( $selOrgUnitName == "NONE" )
<h1>Please select OrganisationUnit</h1>
#else
- <h1>Summary Report Result for : $selOrgUnitName</h1>
- <table>
+ <h3>Summary Report Result for : $selOrgUnitName</h3>
+ <table align="center">
<tr>
<th>Department Name - Post Name</th>
- <th>Department Name - Post Name</th>
+ <th>Sanctioned - Filled - Vacant</th>
</tr>
#foreach( $resultKey in $resultKeys )
<tr>
<td>$resultKey</td>
- <td>$resultMap.get( $resultKey )</td>
+ <td align="center"><a href="#" onclick="javascript:showEmployeePostDetails('$resultIdMap.get( $resultKey )')">$resultMap.get( $resultKey )</a></td>
</tr>
#end
</table>
-#end
\ No newline at end of file
+#end
+
+<script>
+
+ function showEmployeePostDetails( deptAndPostIds )
+ {
+ var url = "showEmployeePostDetails.action?deptAndPostIds=" + deptAndPostIds;
+ $('#contentDataRecord').dialog('destroy').remove();
+ $('<div id="contentDataRecord" style="z-index: 1;">' ).load(url).dialog({
+ title: 'Employee Post Details',
+ maximize: true,
+ closable: true,
+ modal:true,
+ overlay:{background:'#000000', opacity:0.1},
+ width: 800,
+ height: 380
+ });
+ }
+
+</script>
\ No newline at end of file
=== added file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Department.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Department.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Department.java 2010-11-22 07:28:23 +0000
@@ -0,0 +1,12 @@
+package org.hisp.dhis.linelisting;
+
+public class Department
+{
+ public static final String POSTED_AS_COLUMN = "";
+ public static final String ADD_CHARGE_COLUMN = "";
+ public static final String DATE_OF_JOIN_TO_CURPOST_COLUMN = "";
+ public static final String CURRENT_PAYSCALE_COLUMN = "";
+ public static final String CURRENT_BASIC_PAY_COLUMN = "";
+ public static final String LAST_WORKING_DATE_COLUMN = "";
+ public static final String REASON_WHY_LEFT_COLUMN = "";
+}
=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Employee.java'
--- local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Employee.java 2010-11-17 10:49:09 +0000
+++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/linelisting/Employee.java 2010-11-22 07:28:23 +0000
@@ -26,7 +26,6 @@
*/
package org.hisp.dhis.linelisting;
-import java.io.Serializable;
import java.util.Date;
/**
=== 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-19 12:52:40 +0000
+++ local/in/dhis-in-services/dhis-in-service-dbmanager/src/main/java/org/hisp/dhis/dbmanager/mysql/MySQLDataBaseManager.java 2010-11-22 07:28:23 +0000
@@ -70,7 +70,7 @@
}
// -------------------------------------------------------------------------
- // Implementation
+ // Create Table
// -------------------------------------------------------------------------
public boolean createTable( String tableName, List<String> columnNames, List<String> autoIncrement,
List<String> dataTypes, List<Integer> sizeOfColumns )
@@ -79,8 +79,7 @@
PreparedStatement preparedStatement = null;
- String columnDefinition = "create table " + tableName + " ( ";
- // System.out.println(columnDefinition);
+ String columnDefinition = "CREATE TABLE " + tableName + " ( ";
for ( int i = 0; i < columnNames.size(); i++ )
{
@@ -89,16 +88,19 @@
if ( i < ( columnNames.size() - 1 ) )
{
columnDefinition += columnNames.get( i ) + " " + dataTypes.get( i ) + ",";
- } else
+ }
+ else
{
columnDefinition += columnNames.get( i ) + " " + dataTypes.get( i );
}
- } else
+ }
+ else
{
if ( i < ( columnNames.size() - 1 ) )
{
columnDefinition += columnNames.get( i ) + " " + dataTypes.get( i ) + "(" + sizeOfColumns.get( i ) + ") " + autoIncrement.get( i ) + ",";
- } else
+ }
+ else
{
columnDefinition += columnNames.get( i ) + " " + dataTypes.get( i ) + "(" + sizeOfColumns.get( i ) + ") " + autoIncrement.get( i );
}
@@ -106,7 +108,7 @@
}
columnDefinition += ");";
- // System.out.println(columnDefinition);
+
try
{
Connection connection = jdbcTemplate.getDataSource().getConnection();
@@ -116,7 +118,8 @@
preparedStatement.execute();
preparedStatement.close();
- } catch ( SQLException e )
+ }
+ catch ( SQLException e )
{
tableCreated = false;
@@ -126,81 +129,69 @@
return tableCreated;
}
+ // -------------------------------------------------------------------------
+ // Drop Table
+ // -------------------------------------------------------------------------
+
public void dropTable( String tableName )
{
+ PreparedStatement preparedStatement = null;
+
try
{
Connection connection = jdbcTemplate.getDataSource().getConnection();
String columnDefinition = "";
- PreparedStatement preparedStatement = null;
-
- columnDefinition += "drop table " + tableName + " ;";
+ columnDefinition += "DROP TABLE " + tableName + " ;";
preparedStatement = connection.prepareStatement( columnDefinition );
preparedStatement.execute();
- preparedStatement.close();
- } catch ( SQLException e )
+ }
+ catch ( SQLException e )
{
e.printStackTrace();
}
+ finally
+ {
+ try
+ {
+ if( preparedStatement != null ) preparedStatement.close();
+ }
+ catch( Exception e )
+ {
+
+ }
+ }
}
+ // -------------------------------------------------------------------------
+ // Check if any data exists in Table
+ // -------------------------------------------------------------------------
+
public boolean checkDataFromTable( String tableName, LineListElement lineListElement )
{
boolean doNotDelete = false;
-
- //Statement statement = null;
-
+ int recordCount = 0;
try
{
- //Connection connection = jdbcTemplate.getDataSource().getConnection();
- //statement = connection.createStatement();
- String columnDefinition = "select " + lineListElement.getShortName() + " from " + tableName;
- //ResultSet rs = statement.executeQuery( query );
+ String columnDefinition = "SELECT COUNT(" + lineListElement.getShortName() + ") FROM " + tableName;
SqlRowSet rs = jdbcTemplate.queryForRowSet( columnDefinition );
- if ( rs != null )
- {
- while ( rs.next() )
- {
-
- if ( lineListElement.getDataType().equalsIgnoreCase( "string" ) )
- {
- if ( rs.getString( lineListElement.getShortName() ) != null )
- {
- doNotDelete = true;
- break;
- }
- } else
- {
- if ( lineListElement.getDataType().equalsIgnoreCase( "date" ) )
- {
- if ( rs.getDate( lineListElement.getShortName() ) != null )
- {
- doNotDelete = true;
- break;
- }
- } else
- {
- if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
- {
-
- if ( rs.getInt( lineListElement.getShortName() ) != 0 )
- {
- doNotDelete = true;
- break;
- }
- } else
- {
- }
- }
- }
- }
- }
+
+ if( rs != null && rs.next() )
+ {
+ recordCount = rs.getInt( 1 );
+ }
+
+ if( recordCount > 0 )
+ {
+ doNotDelete = true;
+ }
+
log.debug( tableName + ", " + lineListElement.getShortName() + (doNotDelete ? " has data" : " can be deleted") );
- } catch ( Exception e )
+ }
+ catch ( Exception e )
{
log.error( "Caught exception while checking " + tableName + ", " + lineListElement.getShortName() + ". Won't delete.", e );
doNotDelete = false;
@@ -209,8 +200,9 @@
return doNotDelete;
}
-
- // function to get max row number
+ // -------------------------------------------------------------------------
+ // Get Max Record Number from Department table
+ // -------------------------------------------------------------------------
public int getMaxRecordNumber( String tableName )
{
int maxRecordNumber = 0;
@@ -1140,8 +1132,6 @@
PreparedStatement preparedStatement = null;
- // System.out.println(" llDataValuesList size = " +
- // llDataValuesList.size());
for ( LineListDataValue llDataValue : llDataValuesList )
{
@@ -1229,6 +1219,90 @@
return valueUpdated;
}
+
+ public boolean updateSingleLLValue( LineListDataValue llDataValue, String tableName )
+ {
+ boolean valueUpdated = false;
+
+ String columnDefinition = "";
+
+ columnDefinition = "UPDATE " + tableName + " SET ";
+
+ Map<String, String> elementValues = llDataValue.getLineListValues();
+
+ Set<String> elements = elementValues.keySet();
+ System.out.println("In Update recordnumber = " + llDataValue.getRecordNumber());
+ int size = elements.size();
+ int i = 1;
+ java.util.Date today = llDataValue.getTimestamp();
+ long t = today.getTime();
+ java.sql.Date date = new java.sql.Date( t );
+ String whereClause = " WHERE recordnumber = " + llDataValue.getRecordNumber();
+ for ( String elementName : elements )
+ {
+ LineListElement lineListElement = lineListService.getLineListElementByShortName( elementName );
+ if ( i == size )
+ {
+ if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
+ {
+ try
+ {
+ columnDefinition += elementName + " = " + Integer.parseInt( elementValues.get( elementName ) ) + ",";
+ llDataValue.getSource().getId();
+ columnDefinition += "periodid = '" + llDataValue.getPeriod().getId() + "', sourceid = '" + llDataValue.getSource().getId() + "', storedby = '" + llDataValue.getStoredBy() + "', lastupdated = '" + date + "' ";
+
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "Exception: "+ e.getMessage() );
+ }
+ }
+ else
+ {
+ columnDefinition += elementName + " = '" + elementValues.get( elementName ) + "'" + ",";
+ columnDefinition += "periodid = '" + llDataValue.getPeriod().getId() + "', sourceid = '" + llDataValue.getSource().getId() + "', storedby = '" + llDataValue.getStoredBy() + "', lastupdated = '" + date + "' ";
+ }
+ }
+ else
+ {
+ if ( lineListElement.getDataType().equalsIgnoreCase( "int" ) )
+ {
+ try
+ {
+ columnDefinition += elementName + " = " + Integer.parseInt( elementValues.get( elementName ) ) + ",";
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "Exception: "+ e.getMessage() );
+ }
+ } else
+ {
+ columnDefinition += elementName + " = '" + elementValues.get( elementName ) + "'" + ",";
+ }
+ i++;
+ }
+
+ }
+
+ columnDefinition += whereClause;
+ System.out.println("Update Definition = " + columnDefinition);
+
+ try
+ {
+ int sqlResult = jdbcTemplate.update( columnDefinition );
+ valueUpdated = true;
+ columnDefinition = "";
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ valueUpdated = false;
+ }
+
+ return valueUpdated;
+ }
+
+
public Period getRecentPeriodForOnChangeData( String tableName, String llElementName, String llElementValue, Source source )
{
String columnDefinition = "";