dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03005
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1003: fixed validate update/add report excel items
------------------------------------------------------------
revno: 1003
committer: Tran Thanh Tri <Tran Thanh Tri@TranThanhTri-PC>
branch nick: trunk
timestamp: Mon 2009-11-09 14:03:05 +0700
message:
fixed validate update/add report excel items
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcel.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateAddReportExcelItemAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.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/reportexcel/ReportExcel.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcel.java 2009-10-27 15:12:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcel.java 2009-11-09 07:03:05 +0000
@@ -96,11 +96,11 @@
this.organisationAssocitions = new HashSet<OrganisationUnit>();
}
- public ReportExcelItem getReportExcelItem( String name )
+ public ReportExcelItem getReportExcelItem( String name, int sheetNo )
{
for ( ReportExcelItem reportExcelItem : this.reportExcelItems )
{
- if ( reportExcelItem.getName().equalsIgnoreCase( name ) )
+ if ( reportExcelItem.getName().equalsIgnoreCase( name ) && reportExcelItem.getSheetNo()== sheetNo )
{
return reportExcelItem;
}
@@ -281,11 +281,8 @@
{
this.excelTemplateFile = excelTemplateFile;
}
-
- public abstract Document createDocument() throws ParserConfigurationException;
-
-
-
+ public abstract Document createDocument()
+ throws ParserConfigurationException;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java 2009-11-09 07:03:05 +0000
@@ -80,9 +80,7 @@
public Collection<ReportExcelItem> getALLReportExcelItem();
- public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
-
- public ReportExcelItem getReportExcelItem(ReportExcel reportExcel, int sheetNo, String name);
+ public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
public Collection<Integer> getSheets( Integer reportId );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java 2009-11-09 07:03:05 +0000
@@ -77,9 +77,7 @@
public Collection<ReportExcelItem> getALLReportExcelItem();
- public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
-
- public ReportExcelItem getReportExcelItem( ReportExcel reportExcel, int sheetNo, String name );
+ public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
public Collection<Integer> getSheets( Integer reportId );
=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java 2009-11-09 07:03:05 +0000
@@ -151,13 +151,8 @@
public Collection<ReportExcelItem> getReportExcelItem(int sheetNo,
Integer reportId) {
return reportStore.getReportExcelItem(sheetNo, reportId);
- }
+ }
- public ReportExcelItem getReportExcelItem(
- ReportExcel reportExcel, int sheetNo, String name) {
- return reportStore.getReportExcelItem( reportExcel, sheetNo, name );
- }
-
public Collection<Integer> getSheets(Integer reportId) {
return reportStore.getSheets(reportId);
}
=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java 2009-11-09 07:03:05 +0000
@@ -202,20 +202,8 @@
+ sheetNo + " and reportexcel_items.reportexcelid=" + reportId.intValue() );
sqlQuery.addEntity( ReportExcelItem.class );
return sqlQuery.list();
- }
-
- @Override
- public ReportExcelItem getReportExcelItem( ReportExcel reportExcel, int sheetNo, String name )
- {
- Session session = sessionFactory.getCurrentSession();
-
- Criteria criteria = session.createCriteria( ReportExcelItem.class );
- criteria.add( Restrictions.eq( "reportExcel", reportExcel ) );
- criteria.add( Restrictions.eq( "sheetNo", sheetNo ) );
- criteria.add( Restrictions.eq( "name", name ) );
-
- return (ReportExcelItem) criteria.uniqueResult();
- }
+ }
+
@SuppressWarnings( "unchecked" )
public Collection<Integer> getSheets( Integer reportId )
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateAddReportExcelItemAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateAddReportExcelItemAction.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateAddReportExcelItemAction.java 2009-11-09 07:03:05 +0000
@@ -132,7 +132,7 @@
}
ReportExcel reportExcel = reportService.getReportExcel( reportId );
- ReportExcelItem reportItem = reportService.getReportExcelItem( reportExcel, sheetNo, name );
+ ReportExcelItem reportItem = reportExcel.getReportExcelItem( name, sheetNo );
if ( reportItem != null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java 2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java 2009-11-09 07:03:05 +0000
@@ -26,6 +26,8 @@
*/
package org.hisp.dhis.reportexcel.item.action;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.reportexcel.ReportExcel;
import org.hisp.dhis.reportexcel.ReportExcelItem;
import org.hisp.dhis.reportexcel.ReportExcelService;
@@ -38,6 +40,7 @@
public class ValidateUpdateReportExcelItemAction
extends ActionSupport
{
+ private static final Log log = LogFactory.getLog( ValidateUpdateReportExcelItemAction.class );
// -------------------------------------------
// Dependency
// -------------------------------------------
@@ -135,12 +138,13 @@
ReportExcel reportExcel = reportService.getReportExcel( reportId );
- ReportExcelItem reportItem = reportService.getReportExcelItem( reportExcel, sheetNo, name );
-
- ReportExcelItem temp = reportService.getReportExcelItem( reportItemId );
-
- if ( (!temp.equals( reportItem )) )
- {
+ ReportExcelItem reportItem = reportExcel.getReportExcelItem( name, sheetNo );
+
+ ReportExcelItem temp = reportService.getReportExcelItem( reportItemId );
+
+
+ if ( reportItem!=null && !reportItem.equals( temp ))
+ {
message = i18n.getString( "name_ready_exist" );
return ERROR;
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm 2009-11-09 06:59:22 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/reportItems.vm 2009-11-09 07:03:05 +0000
@@ -26,6 +26,7 @@
<th>$i18n.getString('row')</th>
<th>$i18n.getString('column')</th>
<th>$i18n.getString('expression')</th>
+ <th>$i18n.getString('sheet_no')</th>
<th width="70px">$i18n.getString('operations')</th>
</tr>
#set( $mark = false )
@@ -38,7 +39,7 @@
<td>$encoder.htmlEncode( $reportItem.row )</td>
<td>$encoder.htmlEncode( $reportItem.column )</td>
<td>$encoder.htmlEncode( $reportItem.expression )</td>
-
+ <td>$encoder.htmlEncode( $reportItem.sheetNo )</td>
<td align="center">
<a href="javascript:deleteReportExcelItem('$reportItem.id');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
<a href="javascript:openUpdateReportItem( '$reportItem.id' );" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>