dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19344
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8395: Fix bug an exception thrown if resource tables not generated yet.
------------------------------------------------------------
revno: 8395
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-10-06 11:54:55 +0700
message:
Fix bug an exception thrown if resource tables not generated yet.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonSingleEventPrograms.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-07-24 07:37:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-10-06 04:54:55 +0000
@@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Set;
+import org.hibernate.exception.SQLGrammarException;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
@@ -262,6 +263,13 @@
return mapSuggestedValues;
}
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
// -------------------------------------------------------------------------
// Implementation Action
// -------------------------------------------------------------------------
@@ -301,7 +309,8 @@
}
else
{
- organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunitId ));
+ organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+ orgunitId ) );
}
}
}
@@ -321,27 +330,33 @@
// ---------------------------------------------------------------------
// Generate tabular report
// ---------------------------------------------------------------------
-
- if ( type == null ) // Tabular report
- {
- totalRecords = programStageInstanceService.getTabularReportCount( programStage, columns, organisationUnits,
- level, startValue, endValue );
-
- total = getNumberOfPages( totalRecords );
-
- this.paging = createPaging( totalRecords );
- // total = paging.getTotal(); //TODO
-
- grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
- startValue, endValue, !orderByOrgunitAsc, paging.getStartPos(), paging.getPageSize() );
- }
- else
- // Download as Excel
- {
- grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
- startValue, endValue, !orderByOrgunitAsc, null, null );
- }
-
+ try
+ {
+ if ( type == null ) // Tabular report
+ {
+ totalRecords = programStageInstanceService.getTabularReportCount( programStage, columns,
+ organisationUnits, level, startValue, endValue );
+
+ total = getNumberOfPages( totalRecords );
+
+ this.paging = createPaging( totalRecords );
+ // total = paging.getTotal(); //TODO
+
+ grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
+ startValue, endValue, !orderByOrgunitAsc, paging.getStartPos(), paging.getPageSize() );
+ }
+ else
+ // Download as Excel
+ {
+ grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
+ startValue, endValue, !orderByOrgunitAsc, null, null );
+ }
+ }
+ catch ( SQLGrammarException ex )
+ {
+ message = i18n.getString("failed_to_get_events");
+ }
+
return type == null ? SUCCESS : type;
}
@@ -364,26 +379,26 @@
for ( String searchValue : searchingValues )
{
String[] values = searchValue.split( "_" );
-
+
if ( values != null && values.length >= 3 )
{
String prefix = values[0];
-
+
TabularReportColumn column = new TabularReportColumn();
column.setPrefix( prefix );
column.setIdentifier( values[1] );
column.setHidden( Boolean.parseBoolean( values[2] ) );
column.setQuery( values.length == 4 ? TextUtils.lower( values[3] ) : null );
-
+
if ( PREFIX_FIXED_ATTRIBUTE.equals( prefix ) )
{
column.setName( values[1] );
}
else if ( PREFIX_IDENTIFIER_TYPE.equals( prefix ) )
{
- PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( column
- .getIdentifierAsInt() );
-
+ PatientIdentifierType identifierType = patientIdentifierTypeService
+ .getPatientIdentifierType( column.getIdentifierAsInt() );
+
column.setName( identifierType.getName() );
}
else if ( PREFIX_PATIENT_ATTRIBUTE.equals( prefix ) )
@@ -391,10 +406,10 @@
int objectId = Integer.parseInt( values[1] );
PatientAttribute attribute = patientAttributeService.getPatientAttribute( objectId );
patientAttributes.add( attribute );
-
+
valueTypes.add( attribute.getValueType() );
mapSuggestedValues.put( index, getSuggestedAttributeValues( attribute ) );
-
+
column.setName( attribute.getName() );
}
else if ( PREFIX_DATA_ELEMENT.equals( prefix ) )
@@ -402,16 +417,17 @@
int objectId = Integer.parseInt( values[1] );
DataElement dataElement = dataElementService.getDataElement( objectId );
dataElements.add( dataElement );
-
- String valueType = dataElement.getOptionSet() != null ? VALUE_TYPE_OPTION_SET : dataElement.getType();
+
+ String valueType = dataElement.getOptionSet() != null ? VALUE_TYPE_OPTION_SET : dataElement
+ .getType();
valueTypes.add( valueType );
mapSuggestedValues.put( index, getSuggestedDataElementValues( dataElement ) );
-
+
column.setName( dataElement.getName() );
}
-
+
columns.add( column );
-
+
index++;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-10-05 03:50:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-10-06 04:54:55 +0000
@@ -462,4 +462,5 @@
location = Location
some_data_element_not_exist = Some data elements not exist
guardian=Guardian/caretaker
-of = of
\ No newline at end of file
+of = of
+failed_to_get_events = Failed to get events. Please generate resource tables before.
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2012-09-21 07:44:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2012-10-06 04:54:55 +0000
@@ -34,7 +34,7 @@
</td>
<td>
<select type="text" id="programId" name="programId" onchange='getDataElements();' class='stage-object-selected'>
- <option value="" psid="">[$i18n.getString("please_select")]</option>
+ <option value="" psid="" reportDateDes="$i18n.getString('report_date')">[$i18n.getString("please_select")]</option>
#foreach( $program in $programs )
#foreach( $programStage in $program.programStages )
<option value='$program.id' psid='$programStage.id' reportDateDes="$programStage.reportDateDescription">$program.name</option>
@@ -77,29 +77,25 @@
</td>
</tr>
<tr>
- <td><span id="reportDateDescriptionField"></span> $i18n.getString('from_to')</td>
- <td><input type="text" id='startDate' name='startDate' style='width:240px'></td>
- <td><input type="text" id='endDate' name='endDate' style='width:240px'></td>
+ <td><span id="reportDateDescriptionField">$i18n.getString('report_date')</span> $i18n.getString('from_to')</td>
+ <td>
+ <input type="text" id='startDate' name='startDate' style='width:105px'>
+ <input type="text" id='endDate' name='endDate' style='width:105px'>
+ </td>
<td><input type="button" id='searchBtn' value='$i18n.getString( "search" )' onclick='setFieldValue("isShowEventList", false);validateSearchEvents( false )'></td>
</tr>
- <tr>
- <td valign="top">$i18n.getString('data_elements')</td>
- <td colspan='2'>
- <table id='advancedSearchTB'>
- <tbody>
- <tr id='advSearchBox0'>
- <td id='searchingAttributeIdTD' style="width:298px">
- <select id="searchObjectId" name="searchObjectId" style='margin-right:18px;' onchange='dataElementOnChange(this);'></select>
- </td>
- <td>
- <input type="text" id="searchText" name="searchText" value="$!searchText">
- <input type="button" id='addSearchOptionBtn' name='addSearchOptionBtn' class='small-button' value='+' onclick='addAttributeOption()'>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
+
+ <tbody id='advancedSearchTB'>
+ <tr id='advSearchBox0'>
+ <td id='searchingAttributeIdTD'>
+ <select id="searchObjectId" name="searchObjectId" onchange='dataElementOnChange(this);'></select>
+ </td>
+ <td>
+ <input type="text" id="searchText" name="searchText" value="$!searchText">
+ <input type="button" id='addSearchOptionBtn' name='addSearchOptionBtn' class='small-button' value='+' onclick='addAttributeOption()'>
+ </td>
+ </tr>
+ </tbody>
</table>
</div>
</div>
@@ -160,6 +156,8 @@
var i18n_no_compulsary_data_elements = '$encoder.jsEscape( $i18n.getString( "no_compulsary_data_elements" ) , "'")';
var i18n_remove_empty_events_success = '$encoder.jsEscape( $i18n.getString( "remove_empty_events_success" ) , "'")';
var i18n_confirm_remove_empty_events = '$encoder.jsEscape( $i18n.getString( "confirm_remove_empty_events" ) , "'")';
+ var i18n_report_date = '$encoder.jsEscape( $i18n.getString( "report_date" ) , "'")';
+
isAjax = true;
contentDiv = '';
var unSave = false;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-08-02 20:08:19 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-10-06 04:54:55 +0000
@@ -742,42 +742,48 @@
params: this.getParams(),
success: function(r) {
var json = Ext.JSON.decode(r.responseText);
- TR.state.total = json.total;
- TR.value.columns = json.columns;
- TR.value.values = json.items;
-
- // Get fields
- var fields = [];
- fields[0] = 'id';
- var record = new Array();
- for( var index=1; index < TR.value.columns.length; index++ )
- {
- fields[index] = 'col' + index;
- record.push('');
- }
- TR.value.fields = fields;
- TR.value.values.unshift(record);
-
- // Set data for grid
- TR.store.getDataTableStore();
- TR.datatable.getDataTable();
- if ( json.items.length > 1 )
- {
- TR.datatable.setPagingToolbarStatus();
- Ext.getCmp('btnClean').enable();
- Ext.getCmp('btnSortBy').enable();
- }
- else
- {
- Ext.getCmp('currentPage').setValue('');
- Ext.getCmp('currentPage').disable();
- Ext.getCmp('firstPageBtn').disable();
- Ext.getCmp('previousPageBtn').disable();
- Ext.getCmp('nextPageBtn').disable();
- Ext.getCmp('lastPageBtn').disable();
-
- Ext.getCmp('btnClean').disable();
- Ext.getCmp('btnSortBy').disable();
+ if(json.message!=""){
+ //TR.util.notification.warning(json.message);
+ TR.util.notification.error(TR.i18n.error, json.message);
+ }
+ else{
+ TR.state.total = json.total;
+ TR.value.columns = json.columns;
+ TR.value.values = json.items;
+
+ // Get fields
+ var fields = [];
+ fields[0] = 'id';
+ var record = new Array();
+ for( var index=1; index < TR.value.columns.length; index++ )
+ {
+ fields[index] = 'col' + index;
+ record.push('');
+ }
+ TR.value.fields = fields;
+ TR.value.values.unshift(record);
+
+ // Set data for grid
+ TR.store.getDataTableStore();
+ TR.datatable.getDataTable();
+ if ( json.items.length > 1 )
+ {
+ TR.datatable.setPagingToolbarStatus();
+ Ext.getCmp('btnClean').enable();
+ Ext.getCmp('btnSortBy').enable();
+ }
+ else
+ {
+ Ext.getCmp('currentPage').setValue('');
+ Ext.getCmp('currentPage').disable();
+ Ext.getCmp('firstPageBtn').disable();
+ Ext.getCmp('previousPageBtn').disable();
+ Ext.getCmp('nextPageBtn').disable();
+ Ext.getCmp('lastPageBtn').disable();
+
+ Ext.getCmp('btnClean').disable();
+ Ext.getCmp('btnSortBy').disable();
+ }
}
TR.util.mask.hideMask();
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2012-07-24 07:37:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2012-10-06 04:54:55 +0000
@@ -91,5 +91,6 @@
false_value:'$encoder.jsEscape($i18n.getString( 'false_value' ) , "'")',
value_is_invalid:'$encoder.jsEscape($i18n.getString( 'value_is_invalid' ) , "'")',
value_is_valid:'$encoder.jsEscape($i18n.getString( 'value_is_valid' ) , "'")',
-em_no_program_stage: '$encoder.jsEscape($i18n.getString( 'em_no_program_stage' ) , "'")'
+em_no_program_stage: '$encoder.jsEscape($i18n.getString( 'em_no_program_stage' ) , "'")',
+error: '$encoder.jsEscape($i18n.getString( 'error' ) , "'")'
};
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-09-14 13:48:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2012-10-06 04:54:55 +0000
@@ -11,9 +11,9 @@
clearListById('compulsoryDE');
clearListById('programId');
- jQuery( '#programId').append( '<option value="" psid="">[' + i18n_please_select + ']</option>' );
+ jQuery( '#programId').append( '<option value="" psid="" reportDateDes="' + i18n_report_date + '">[' + i18n_please_select + ']</option>' );
for ( i in json.programs ) {
- jQuery( '#programId').append( '<option value="' + json.programs[i].id +'" psid="' + json.programs[i].programStageId + '">' + json.programs[i].name + '</option>' );
+ jQuery( '#programId').append( '<option value="' + json.programs[i].id +'" psid="' + json.programs[i].programStageId + '" reportDateDes="' + json.programs[i].reportDateDescription + '">' + json.programs[i].name + '</option>' );
}
disableCriteriaDiv();
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonSingleEventPrograms.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonSingleEventPrograms.vm 2012-06-27 05:12:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonSingleEventPrograms.vm 2012-10-06 04:54:55 +0000
@@ -6,10 +6,10 @@
"id": ${program.id} ,
"name": "$!encoder.jsonEncode( ${program.name} )",
"type": "$program.type",
- "programStageId":
- #foreach( $programStage in $program.programStages )
- "$programStage.id"
- #end
+ #foreach( $programStage in $program.programStages )
+ "reportDateDescription": "$programStage.reportDateDescription",
+ "programStageId": "$programStage.id"
+ #end
}#if( $velocityCount < $size ),#end
#end]
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm 2012-07-12 02:49:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm 2012-10-06 04:54:55 +0000
@@ -3,6 +3,7 @@
{
#set( $noHeader = $grid.getHeaders().size() )
#set( $metaData = $noHeader - $valueTypes.size() )
+"message": "$!message",
"total": "$total",
"columns":[
#set($index = 0)
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm 2012-08-01 18:20:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageInstancesList.vm 2012-10-06 04:54:55 +0000
@@ -1,78 +1,82 @@
-<table>
- <tr>
- <td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
- <td> </td>
- <td> </td>
- <td id='searchInforTD'></td>
- </tr>
-
- <tr>
- <td class='text-column'>$i18n.getString( "total_result" )</td>
- <td> </td>
- <td> </td>
- <td>$!totalRecords</td>
- </tr>
-</table>
+#if($!message)
+ <span id='message' style="display:block;">$message</span>
+#else
+ <table>
+ <tr>
+ <td class='text-column' >$i18n.getString( "search_result_matching_the_search_criteria" ):</td>
+ <td> </td>
+ <td> </td>
+ <td id='searchInforTD'></td>
+ </tr>
+
+ <tr>
+ <td class='text-column'>$i18n.getString( "total_result" )</td>
+ <td> </td>
+ <td> </td>
+ <td>$!totalRecords</td>
+ </tr>
+ </table>
-<table class="mainPageTable">
- <tr>
- <td>
- <table class="listTable">
- <thead>
- <tr>
- <th>#</th>
- #set($index = 0)
- #foreach( $col in $grid.getHeaders() )
- #if( $index > 0 )
- <th>$col.name</th>
+ <table class="mainPageTable">
+ <tr>
+ <td>
+ <table class="listTable">
+ <thead>
+ <tr>
+ <th>#</th>
+ #set($index = 0)
+ #foreach( $col in $grid.getHeaders() )
+ #if( $index > 0 )
+ <th>$col.name</th>
+ #end
+ #set($index = $index + 1)
#end
- #set($index = $index + 1)
+ <th style="width:70px">$i18n.getString( "operations" )</th>
+ </tr>
+ </thead>
+
+ <tbody id="list">
+ #set($noCols = $grid.getHeaders().size())
+ #foreach( $row in $grid.getRows() )
+ #set($index = 0)
+ <tr id="row" #alternate( $mark )>
+ <td>
+ #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount )
+ $nr
+ </td>
+
+ #foreach( $col in $row )
+ #if( $index == 0 )
+ #set($psid = $col)
+ #elseif( $index < $noCols )
+ <td>$!col</td>
+ #end
+ #set($index = $index + 1)
+ #end
+
+ <td>
+ <a href="javascript:showUpdateEvent( $psid )" title='$i18n.getString( "data_entry" )'><img src="images/data_entry.png" alt='$i18n.getString( "data_entry" )'></a>
+ <a href="javascript:removeEvent( $psid )" title='$i18n.getString( "remove" )'><img src="../images/delete.png" alt='$i18n.getString( "remove" )'></a>
+ </td>
+ #set( $mark = !$mark)
+ <script>
+ jQuery('#row').attr('id','tr' + "$psid");
+ </script>
+ </tr>
#end
- <th style="width:70px">$i18n.getString( "operations" )</th>
- </tr>
- </thead>
-
- <tbody id="list">
- #set($noCols = $grid.getHeaders().size())
- #foreach( $row in $grid.getRows() )
- #set($index = 0)
- <tr id="row" #alternate( $mark )>
- <td>
- #set( $nr = ( ( $paging.getCurrentPage() - 1 ) * $paging.pageSize ) + $velocityCount )
- $nr
- </td>
-
- #foreach( $col in $row )
- #if( $index == 0 )
- #set($psid = $col)
- #elseif( $index < $noCols )
- <td>$!col</td>
- #end
- #set($index = $index + 1)
- #end
-
- <td>
- <a href="javascript:showUpdateEvent( $psid )" title='$i18n.getString( "data_entry" )'><img src="images/data_entry.png" alt='$i18n.getString( "data_entry" )'></a>
- <a href="javascript:removeEvent( $psid )" title='$i18n.getString( "remove" )'><img src="../images/delete.png" alt='$i18n.getString( "remove" )'></a>
- </td>
- #set( $mark = !$mark)
- <script>
- jQuery('#row').attr('id','tr' + "$psid");
- </script>
- </tr>
- #end
- </tbody>
- </table>
- </td>
- </tr>
- <tr>
- #set( $noCol = $grid.getHeaders().size() + 3 )
- <td colspan="$noCol">
- <p></p>
- <div class="paging-container">
- #parse( "/dhis-web-commons/paging/paging.vm" )
- </div>
- </td>
- <td></td>
- </tr>
-</table>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ #set( $noCol = $grid.getHeaders().size() + 3 )
+ <td colspan="$noCol">
+ <p></p>
+ <div class="paging-container">
+ #parse( "/dhis-web-commons/paging/paging.vm" )
+ </div>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+#end