dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14899
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5184: local vn - Added a new validation on checking the unexisting dataelement, indicator and option co...
------------------------------------------------------------
revno: 5184
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-11-18 11:24:39 +0700
message:
local vn - Added a new validation on checking the unexisting dataelement, indicator and option combo which being referenced in item's expression.
modified:
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java
local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties
local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties
--
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/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReport.java 2011-11-18 04:24:39 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -193,6 +194,24 @@
return null;
}
+ public Collection<ExportItem> getExportItemsByItemType( String... types )
+ {
+ List<ExportItem> items = new ArrayList<ExportItem>();
+
+ for ( ExportItem e : this.exportItems )
+ {
+ for ( String type : types )
+ {
+ if ( e.getItemType().equalsIgnoreCase( type ) )
+ {
+ items.add( e );
+ }
+ }
+ }
+
+ return items;
+ }
+
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java 2011-08-04 08:39:55 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportReportService.java 2011-11-18 04:24:39 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.reportsheet.status.DataEntryStatus;
@@ -123,4 +124,6 @@
public PeriodColumn getPeriodColumn( Integer id );
public void updatePeriodColumn( PeriodColumn periodColumn );
+
+ public String validateEmportItems( ExportReport exportReport, I18n i18n );
}
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java 2011-08-04 08:39:55 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/impl/DefaultExportReportService.java 2011-11-18 04:24:39 +0000
@@ -31,15 +31,28 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.reportsheet.DataElementGroupOrder;
import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
+import org.hisp.dhis.reportsheet.ExportReportCategory;
import org.hisp.dhis.reportsheet.ExportReportService;
import org.hisp.dhis.reportsheet.ExportReportStore;
import org.hisp.dhis.reportsheet.PeriodColumn;
@@ -62,6 +75,20 @@
// Dependency
// -------------------------------------------------------------------------
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
private ExportReportStore exportReportStore;
public void setExportReportStore( ExportReportStore exportReportStore )
@@ -69,6 +96,13 @@
this.exportReportStore = exportReportStore;
}
+ private ExpressionService expressionService;
+
+ public void setExpressionService( ExpressionService expressionService )
+ {
+ this.expressionService = expressionService;
+ }
+
private UserStore userStore;
public void setUserStore( UserStore userStore )
@@ -76,6 +110,13 @@
this.userStore = userStore;
}
+ private IndicatorService indicatorService;
+
+ public void setIndicatorService( IndicatorService indicatorService )
+ {
+ this.indicatorService = indicatorService;
+ }
+
private I18nService i18nService;
public void setI18nService( I18nService i18nService )
@@ -175,7 +216,7 @@
{
return exportReportStore.getExportReportsByReportType( reportType );
}
-
+
public Collection<String> getAllExportReportTemplates()
{
return exportReportStore.getAllExportReportTemplates();
@@ -277,7 +318,7 @@
{
return exportReportStore.getDataEntryStatusByDataSets( arg0 );
}
-
+
public Collection<DataEntryStatus> getDataEntryStatusDefaultByDataSets( Collection<DataSet> arg0 )
{
return exportReportStore.getDataEntryStatusDefaultByDataSets( arg0 );
@@ -297,4 +338,88 @@
{
exportReportStore.updatePeriodColumn( periodColumn );
}
+
+ public String validateEmportItems( ExportReport exportReport, I18n i18n )
+ {
+ Set<ExportItem> items = new HashSet<ExportItem>( exportReport.getExportItemsByItemType(
+ ExportItem.TYPE.DATAELEMENT, ExportItem.TYPE.INDICATOR ) );
+
+ if ( exportReport.getReportType().equalsIgnoreCase( ExportReport.TYPE.CATEGORY ) )
+ {
+ for ( DataElementGroupOrder groupOrder : ((ExportReportCategory) exportReport).getDataElementOrders() )
+ {
+ if ( groupOrder.getDataElements() == null || groupOrder.getDataElements().isEmpty() )
+ {
+ return i18n.getString( "group_order" ) + ": " + groupOrder.getName() + " "
+ + i18n.getString( "has_no_element" );
+ }
+ }
+
+ String optionComboId = null;
+ List<String> optionComboIds = new ArrayList<String>();
+
+ for ( ExportItem item : items )
+ {
+ optionComboId = item.getExpression().split( "\\" + DataElementOperand.SEPARATOR )[1].replace( "]", "" );
+
+ if ( !optionComboIds.contains( optionComboId ) )
+ {
+ optionComboIds.add( optionComboId );
+
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( Integer.parseInt( optionComboId ) );
+
+ if ( optionCombo == null )
+ {
+ return i18n.getString( "cate_option_combo_with_id" ) + ": " + optionComboId + " "
+ + i18n.getString( "does_not_exist" );
+ }
+ }
+ }
+ }
+ else
+ {
+ Set<DataElementOperand> operands = new HashSet<DataElementOperand>();
+
+ for ( ExportItem item : items )
+ {
+ operands = expressionService.getOperandsInExpression( item.getExpression() );
+
+ for ( DataElementOperand operand : operands )
+ {
+ if ( operand.getOptionComboId() == 0 )
+ {
+ Indicator indicator = indicatorService.getIndicator( operand.getDataElementId() );
+
+ if ( indicator == null )
+ {
+ return i18n.getString( "indicator_with_id" ) + ": " + operand.getDataElementId() + " "
+ + i18n.getString( "does_not_exist" );
+ }
+ }
+ else
+ {
+ DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() );
+
+ if ( dataElement == null )
+ {
+ return i18n.getString( "dataelement_with_id" ) + ": " + operand.getDataElementId() + " "
+ + i18n.getString( "does_not_exist" );
+ }
+
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( operand.getOptionComboId() );
+
+ if ( optionCombo == null )
+ {
+ return i18n.getString( "cate_option_combo_with_id" ) + ": " + operand.getOptionComboId()
+ + " " + i18n.getString( "does_not_exist" );
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
}
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-08-03 08:38:38 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-11-18 04:24:39 +0000
@@ -16,6 +16,10 @@
<bean id="org.hisp.dhis.reportsheet.ExportReportService"
class="org.hisp.dhis.reportsheet.impl.DefaultExportReportService">
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
+ <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="exportReportStore" ref="org.hisp.dhis.reportsheet.ExportReportStore" />
<property name="userStore" ref="org.hisp.dhis.user.UserStore" />
<property name="i18nService" ref="org.hisp.dhis.i18n.I18nService" />
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2011-10-13 03:03:58 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2011-11-18 04:24:39 +0000
@@ -93,16 +93,23 @@
throws Exception
{
Integer reportId = Integer.parseInt( exportReportId.split( "_" )[0] );
-
+
ExportReport exportReport = exportReportService.getExportReport( reportId );
-
+
if ( exportReport == null )
{
message = i18n.getString( "the_specified_report_is_not_exist" );
return ERROR;
}
-
+
+ message = exportReportService.validateEmportItems( exportReport, i18n );
+
+ if ( message != null )
+ {
+ return ERROR;
+ }
+
File templateDirectory = reportLocationManager.getExportReportTemplateDirectory();
if ( templateDirectory == null || !templateDirectory.exists() )
@@ -120,7 +127,7 @@
return ERROR;
}
-
+
selectionManager.setSelectedPeriodIndex( periodIndex );
selectionManager.setSelectedReportId( reportId );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2011-11-03 09:28:41 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2011-11-18 04:24:39 +0000
@@ -299,4 +299,10 @@
file_format_structure_broken= Warning! File format structure is broken.
number_of_members = Number of members
edit_excel_template = Edit name of excel template
-no_group_order_created_for_category = No group order created for this category report
\ No newline at end of file
+no_group_order_created_for_category = No group order created for this category report
+group_order = Data element group order
+has_no_element = has no element
+indicator_with_id = Indicator with id
+dataelement_with_id = Dataelement with id
+cate_option_combo_with_id = Option combo with id
+does_not_exist = does not exist
\ No newline at end of file
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2011-11-03 09:28:41 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2011-11-18 04:24:39 +0000
@@ -331,3 +331,10 @@
PERIOD_COLUMN_LISTING=Li\u1ec7t k\u00ea th\u1eddi \u0111i\u1ec3m theo c\u1ed9t
upload_successful=T\u1ea3i t\u1eadp tin th\u00e0nh c\u00f4ng \!
override_confirm=B\u1ea3ng m\u1eabu \u0111\u00e3 t\u1ed3n t\u1ea1i. B\u1ea1n c\u00f3 mu\u1ed1n ghi \u0111\u00e8 hay kh\u00f4ng ?
+no_group_order_created_for_category = No group order created for this category report
+group_order=Nh\u00f3m ph\u1ea7n t\u1eed d\u1eef li\u1ec7u s\u1eafp x\u1ebfp (Category)
+has_no_element=kh\u00f4ng c\u00f3 t\u1eadp con
+indicator_with_id=Ch\u1ec9 s\u1ed1 c\u00f3 m\u00e3
+dataelement_with_id=Ph\u1ea7n t\u1eed d\u1eef li\u1ec7u c\u00f3 m\u00e3
+cate_option_combo_with_id=T\u1eadp m\u1ee5c ch\u1ecdn ph\u00e2n lo\u1ea1i c\u00f3 m\u00e3
+does_not_exist=kh\u00f4ng t\u1ed3n t\u1ea1i
\ No newline at end of file