dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17148
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6735: local vn - Supported a new export item type as text for normal report. And fixed the attribute re...
------------------------------------------------------------
revno: 6735
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-25 16:59:24 +0700
message:
local vn - Supported a new export item type as text for normal report. And fixed the attribute report.
added:
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm
modified:
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java
local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/filemanager/action/ExcelTemplateListAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.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
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attribute.ajax.js
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.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 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java 2011-12-22 07:43:18 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java 2012-04-25 09:59:24 +0000
@@ -144,6 +144,8 @@
public static class TYPE
{
public static final String DATAELEMENT = "dataelement";
+
+ public static final String DATAELEMENT_VALUETYPE_TEXT = "dataelement_valuetype_text";
public static final String ORGANISATION = "organisation";
@@ -161,6 +163,7 @@
{
List<String> list = new ArrayList<String>();
list.add( DATAELEMENT );
+ list.add( DATAELEMENT_VALUETYPE_TEXT );
list.add( ORGANISATION );
list.add( INDICATOR );
list.add( DATAELEMENT_CODE );
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportReport.hbm.xml 2012-04-25 09:59:24 +0000
@@ -65,7 +65,7 @@
<joined-subclass name="org.hisp.dhis.reportsheet.ExportReportOrganizationGroupListing" table="reportexcels_organizationgrouplisting">
<key column="reportexcelid"/>
- <list name="organisationUnitGroups" table="reportexcel_organisationgroup">
+ <list name="organisationUnitGroups" table="reportexcel_organisationgroup">
<key column="reportexcelid" />
<list-index column="grouporder" base="0"/>
<many-to-many class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" column="oganisationunitgroupid"
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java 2012-04-25 09:59:24 +0000
@@ -60,4 +60,9 @@
{
return dataElementStore.getByAttributeValue( attribute, value );
}
+
+ public int getDataElementCount( Integer dataElementId, Integer attributeId, String value )
+ {
+ return dataElementStore.getDataElementCount( dataElementId, attributeId, value );
+ }
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java 2012-04-25 09:59:24 +0000
@@ -33,10 +33,12 @@
/**
* @author Chau Thu Tran
- *
+ *
* @version $LocalDataElementService.java Mar 23, 2012 4:05:32 PM$
*/
public interface LocalDataElementService
{
Collection<DataElement> getDataElementsByAttribute( Attribute attribute, String value );
+
+ int getDataElementCount( Integer dataElementId, Integer attributeId, String value );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java 2012-03-24 01:29:01 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java 2012-04-25 09:59:24 +0000
@@ -33,10 +33,12 @@
/**
* @author Chau Thu Tran
- *
+ *
* @version $LocalDataElementStore.java Mar 23, 2012 4:10:24 PM$
*/
public interface LocalDataElementStore
{
Collection<DataElement> getByAttributeValue( Attribute attribute, String value );
+
+ int getDataElementCount( Integer dataElementId, Integer attributeId, String value );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-03-30 04:49:55 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-04-25 09:59:24 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
+import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
@@ -51,4 +52,17 @@
Restrictions.eq( "attributeValue.attribute", attribute ) ).add(
Restrictions.eq( "attributeValue.value", value ).ignoreCase() ).list();
}
+
+ @Override
+ public int getDataElementCount( Integer dataElementId, Integer attributeId, String value )
+ {
+ Number rs = (Number) getCriteria()
+ .add( Restrictions.eq( "id", dataElementId ) )
+ .createAlias( "attributeValues", "attributeValue" )
+ .add( Restrictions.eq( "attributeValue.attribute.id", attributeId ) )
+ .add( Restrictions.eq( "attributeValue.value", value ).ignoreCase() )
+ .setProjection( Projections.rowCount() ).uniqueResult();
+
+ return rs != null ? rs.intValue() : 0;
+ }
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java 2011-11-03 04:26:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/AbstractGenerateExcelReportSupport.java 2012-04-25 09:59:24 +0000
@@ -49,8 +49,12 @@
import org.apache.poi.ss.usermodel.Sheet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.DailyPeriodType;
+import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.period.QuarterlyPeriodType;
+import org.hisp.dhis.period.YearlyPeriodType;
import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
import org.hisp.dhis.reportsheet.utils.ExcelUtils;
@@ -204,6 +208,31 @@
// DataElement Value
// -------------------------------------------------------------------------
+ protected String getTextValue( ExportItem exportItem, OrganisationUnit organisationUnit )
+ {
+ Period p = null;
+
+ if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
+ {
+ p = periodService.getPeriod( startDate, startDate, new DailyPeriodType() );
+ }
+ else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
+ {
+ p = periodService.getPeriod( startDate, endDate, new MonthlyPeriodType() );
+ }
+ else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
+ {
+ p = periodService.getPeriod( startQuaterly, endQuaterly, new QuarterlyPeriodType() );
+ }
+ else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
+ {
+ p = periodService.getPeriod( firstDayOfYear, endDateOfYear, new YearlyPeriodType() );
+ }
+
+ return generateExpression( exportItem, p, organisationUnit, dataElementService, categoryService,
+ dataValueService );
+ }
+
protected double getDataValue( ExportItem exportItem, OrganisationUnit organisationUnit )
{
double value = 0.0;
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-04-25 02:57:38 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-04-25 09:59:24 +0000
@@ -27,13 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.expression.Expression.SEPARATOR;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import static org.hisp.dhis.expression.Expression.SEPARATOR;
-
import org.apache.poi.ss.usermodel.Sheet;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -95,7 +95,6 @@
for ( AttributeValueGroupOrder avgOrder : exportReport.getAttributeValueOrders() )
{
int serial = 1;
- DataElement de = null;
List<DataElement> dataElements = null;
flag = true;
@@ -135,18 +134,24 @@
}
else
{
- ExportItem newExportItem = new ExportItem();
-
- de = dataElements.get( Integer.parseInt( exportItem.getExtraExpression() ) - 1 );
-
- if ( de != null )
+ int id = Integer.parseInt( exportItem.getExpression().split( "@" )[0] );
+ String value = exportItem.getExpression().split( "@" )[1];
+
+ for ( DataElement de : dataElements )
{
- newExportItem.setExpression( de.getId() + SEPARATOR + optionCombo.getId() );
-
- double value = this.getDataValue( newExportItem, organisationUnit );
-
- ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), value + "",
- ExcelUtils.NUMBER, sheet, this.csNumber );
+ if ( localDataElementService.getDataElementCount( de.getId(), id, value ) > 0 )
+ {
+ ExportItem newExportItem = new ExportItem();
+
+ newExportItem.setExpression( de.getId() + SEPARATOR + optionCombo.getId() );
+
+ double result = this.getDataValue( newExportItem, organisationUnit );
+
+ ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), result + "",
+ ExcelUtils.NUMBER, sheet, this.csNumber );
+
+ break;
+ }
}
}
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2011-11-09 07:34:53 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2012-04-25 09:59:24 +0000
@@ -83,6 +83,13 @@
ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), String.valueOf( value ),
ExcelUtils.NUMBER, sheet, this.csNumber );
}
+ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ) )
+ {
+ String value = getTextValue( reportItem, organisationUnit );
+
+ ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), value, ExcelUtils.NUMBER,
+ sheet, this.csText );
+ }
else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
{
double value = getIndicatorValue( reportItem, organisationUnit );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/filemanager/action/ExcelTemplateListAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/filemanager/action/ExcelTemplateListAction.java 2011-08-04 08:39:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/filemanager/action/ExcelTemplateListAction.java 2012-04-25 09:59:24 +0000
@@ -148,6 +148,7 @@
public List<String> getReportTypes()
{
this.reportTypes.add( ExportReport.TYPE.NORMAL );
+ this.reportTypes.add( ExportReport.TYPE.ATTRIBUTE );
this.reportTypes.add( ExportReport.TYPE.CATEGORY );
this.reportTypes.add( ExportReport.TYPE.PERIOD_COLUMN_LISTING );
this.reportTypes.add( ExportReport.TYPE.ORGANIZATION_GROUP_LISTING );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java 2012-02-03 08:38:42 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java 2012-04-25 09:59:24 +0000
@@ -38,9 +38,11 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datavalue.DataValueService;
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.ExportItem;
/**
@@ -62,6 +64,54 @@
*
* @return The generated expression
*/
+ public static String generateExpression( ExportItem reportItem, Period period, OrganisationUnit organisationUnit,
+ DataElementService dataElementService, DataElementCategoryService categoryService,
+ DataValueService dataValueService )
+ {
+ try
+ {
+ Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+ Matcher matcher = pattern.matcher( reportItem.getExpression() );
+ StringBuffer buffer = new StringBuffer();
+
+ while ( matcher.find() )
+ {
+ String replaceString = matcher.group();
+
+ replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+
+ String dataElementIdString = replaceString.substring( 0, replaceString.indexOf( SEPARATOR ) );
+ String optionComboIdString = replaceString.substring( replaceString.indexOf( SEPARATOR ) + 1,
+ replaceString.length() );
+
+ int dataElementId = Integer.parseInt( dataElementIdString );
+ int optionComboId = Integer.parseInt( optionComboIdString );
+
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( optionComboId );
+
+ {
+ replaceString = getValue( dataElement, optionCombo, organisationUnit, period, dataValueService )
+ + "";
+
+ matcher.appendReplacement( buffer, replaceString );
+ }
+ }
+
+ // Finally
+ matcher.appendTail( buffer );
+
+ return buffer.toString();
+ }
+ catch ( NumberFormatException ex )
+ {
+ throw new RuntimeException( "Illegal DataElement id", ex );
+ }
+ }
+
public static String generateExpression( ExportItem reportItem, Date startDate, Date endDate,
OrganisationUnit organisationUnit, DataElementService dataElementService,
DataElementCategoryService categoryService, AggregationService aggregationService )
@@ -91,7 +141,6 @@
DataElementCategoryOptionCombo optionCombo = categoryService
.getDataElementCategoryOptionCombo( optionComboId );
- // Normal
{
replaceString = getValue( dataElement, optionCombo, organisationUnit, startDate, endDate,
aggregationService )
@@ -163,6 +212,15 @@
// Supporting method(s)
// -------------------------------------------------------------------------
+ private static String getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
+ OrganisationUnit organisationUnit, Period period, DataValueService dataValueService )
+ {
+ String aggregatedValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo )
+ .getValue();
+
+ return (aggregatedValue == null) ? "" : aggregatedValue;
+ }
+
private static double getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
OrganisationUnit organisationUnit, Date startDate, Date endDate, AggregationService aggregationService )
{
@@ -171,11 +229,6 @@
// aggregatedDataValueService.getAggregatedValue( dataElement,
// optionCombo, startDate, endDate, );
- if ( aggregatedValue == null )
- {
- aggregatedValue = 0.0;
- }
-
- return aggregatedValue;
+ return (aggregatedValue == null) ? 0.0 : aggregatedValue;
}
}
=== 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 2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2012-04-25 09:59:24 +0000
@@ -113,6 +113,7 @@
dataelements = Data Elements
temp_place = Temp Place
update_sorted_dataelement = Update Sorted Data Element
+dataelement_valuetype_text = Data Element Text Type
dataelement_name = Data Element Name
dataelement_code = Data Element Code
available_dataelementgroups = Available Data Element Groups
=== 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 2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2012-04-25 09:59:24 +0000
@@ -40,6 +40,7 @@
rename_successful=T\u00ean t\u1eadp tin \u0111\u00e3 \u0111\u1ed5i
i18n_name_is_null=H\u00e3y nh\u1eadp t\u00ean!
no_item=Kh\u00f4ng c\u00f3 ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn
+dataelement_valuetype_text = Ph\u1ea7n t\u1eed d\u1eef li\u1ec7u ki\u1ec3u chu\u1ed7i
dataelement_code=M\u00e3 ph\u1ea7n t\u1eed d\u1eef li\u1ec7u
selected_dataelementgroups=Nh\u00f3m d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c ch\u1ecdn
cannot_write_file_being_used=Kh\u00f4ng th\u1ec3 ghi l\u00ean t\u1eadp tin n\u00e0y v\u00ec \u0111ang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng b\u1edfi m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh kh\u00e1c
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attribute.ajax.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attribute.ajax.js 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/attribute.ajax.js 2012-04-25 09:59:24 +0000
@@ -45,11 +45,15 @@
this.loadAttributeValuesByAttribute = function( id, curItems, sourceList, destList, isFirstLoad )
{
- var target = jQuery( "#" + sourceList );
+ var source = jQuery( "#" + sourceList );
var dest = jQuery( "#" + destList );
- target.empty();
+
+ if ( source )
+ {
+ source.empty();
+ }
- if ( !isFirstLoad )
+ if ( dest && !isFirstLoad )
{
dest.empty();
}
@@ -67,7 +71,7 @@
jQuery.each( json.values, function( i, item )
{
valueList.push( new AttributeValue( item.value ) );
- target.append( '<option value="' + item.value + '">' + item.value + '</option>' );
+ source.append( '<option value="' + item.value + '">' + item.value + '</option>' );
} );
attributeValueMap[ id ] = valueList;
@@ -77,7 +81,7 @@
{
jQuery.each( valueList, function( i, item )
{
- target.append( '<option value="' + item.value + '">' + item.value + '</option>' );
+ source.append( '<option value="' + item.value + '">' + item.value + '</option>' );
} );
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/exportItems.js 2012-04-25 09:59:24 +0000
@@ -56,10 +56,7 @@
if( value == 'dataelement' )
{
if ( attribute ) {
- disable( 'expression-button' );
- setFieldValue( 'exportItem input[id=expression]', value );
- removeValidatorRulesById( 'exportItem input[id=expression]' );
- removeValidatorRulesById( 'dataelement textarea[id=formula]' );
+ byId('expression-button' ).onclick = avExpressionBuilderForm;
} else {
byId('expression-button' ).onclick = deExpressionBuilderForm;
}
@@ -92,11 +89,22 @@
function insertExpression()
{
- if( category ) var expression = "[*." + getFieldValue("elementSelect")+ "]";
- else var expression = getFieldValue("elementSelect");
- setFieldValue( 'formula', getFieldValue( 'formula') + expression );
-
- getExpression();
+ var expression = '';
+
+ if ( attribute ) {
+ expression = "[" + getFieldValue( "groupSelect" ) + "@" + getFieldValue( "elementSelect" ) + "]";
+ }
+ else if ( category ) {
+ expression = "[*." + getFieldValue( "elementSelect" )+ "]";
+ }
+ else {
+ expression = getFieldValue( "elementSelect" );
+ alert(expression);
+ }
+
+ setFieldValue( 'formula', getFieldValue( 'formula' ) + expression );
+
+ if ( !attribute ) { getExpression(); }
}
function getExpression()
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2012-04-25 09:59:24 +0000
@@ -1,3 +1,4 @@
+<script type="text/javascript" src="javascript/attribute.ajax.js"></script>
<script>
jQuery(document).ready(function(){
validation( 'exportItem', function( form ){
@@ -98,6 +99,8 @@
<!-- EXPRESSION FORM -->
+#parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" )
+
#parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" )
#parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" )
=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm 2012-04-25 09:59:24 +0000
@@ -0,0 +1,73 @@
+<script>
+
+ jQuery(document).ready(function(){
+ avExpressionValidator = validation( 'attributevalue-form', function(){
+ updateAVExpression();
+ });
+
+ avExpressionDialog = setUpDialog( 'attributevalue', i18n_expression, 800, 430 );
+
+ //remoteValidate( jQuery( "#attributevalue textarea[id=formula]" ), 'checkAttributeValueValid.action' );
+
+ changeItemType();
+ });
+
+ var avExpressionValidator = null;
+ var avExpressionDialog = null;
+ var i18n_no_attribute = '$encoder.jsEscape( $i18n.getString( "no_attribute" ) , "'")';;
+ var i18n_label = '$encoder.jsEscape($i18n.getString( 'select_attribute' ) , "'")';
+</script>
+
+<div id="attributevalue" style="display:none">
+ <form id="attributevalue-form">
+ <table width="100%">
+ <tr>
+ <th>$i18n.getString( "formula" )</th>
+ <th id="attributeOrderHeader">$i18n.getString( "attributevalue" )</th>
+ </tr>
+ <tr valign="top">
+ <td height="139">
+ <textarea id="formula" name="expression" cols="40" rows="5" class="{validate:{required:true}}"></textarea><br/>
+ </td>
+ <td>
+ <select id="groupSelect" style="width:500px" onchange="attributeLib.loadAttributeValuesByAttribute( this.value, null, 'attributevalue select[id=elementSelect]', '', false )"></select>
+ <select id="elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="2">$i18n.getString( "description" )</th>
+ <tr>
+ <tr>
+ <td colspan="2">
+ <div id="expression-description" style="width:750px;height:30px;overflow:auto"></div>
+ </td>
+ </th>
+ </table>
+ <br/>
+ <br/>
+ <center>
+ <input type="submit" value="$i18n.getString('ok')" style="width:100px"/>
+ <input type="button" value="$i18n.getString('clean')" onclick="cleanFormula()" style="width:100px"/>
+ <input type="button" value="$i18n.getString('cancel')" onclick="closeDialog( avExpressionDialog )" style="width:100px"/>
+ </center>
+ </form>
+</div>
+
+<script>
+ function avExpressionBuilderForm()
+ {
+ attributeLib.loadAttributes( "attributevalue select[id=groupSelect]" );
+
+ setFieldValue( 'attributevalue textarea[id=formula]', getFieldValue('expression') );
+ getExpression();
+
+ openDialog( avExpressionDialog );
+ }
+
+ function updateAVExpression()
+ {
+ expression = jQuery( '#attributevalue textarea[id=formula]' ).val();
+ setFieldValue( 'expression', expression );
+ closeDialog( avExpressionDialog );
+ }
+</script>
\ No newline at end of file
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm 2012-04-05 07:39:23 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm 2012-04-25 09:59:24 +0000
@@ -90,7 +90,7 @@
function getDataElements( id, target )
{
#if($exportReport.isCategory())
- dataDictionary.loadDataElementsByGroup( id, target);
+ dataDictionary.loadDataElementsByGroup( id, target );
#else
dataDictionary.loadOperands( target, {id:id} );
#end
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2012-04-19 03:58:49 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2012-04-25 09:59:24 +0000
@@ -1,4 +1,5 @@
-<script>
+<script type="text/javascript" src="javascript/attribute.ajax.js"></script>
+<script>
jQuery(document).ready(function(){
validation( 'exportItem', function( form ){
validateUpdateExportItem( form );
@@ -99,6 +100,8 @@
<!-- EXPRESSION FORM -->
+#parse( "/dhis-web-spreadsheet-reporting/report/attributeValueExpressionBuilderForm.vm" )
+
#parse( "/dhis-web-spreadsheet-reporting/report/dataelementExpressionBuilderForm.vm" )
#parse( "/dhis-web-spreadsheet-reporting/report/indicatorExpressionBuilderForm.vm" )