dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05721
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1812: Merge with trunk.
Merge authors:
Tran Thanh Tri <Tran Thanh Tri@TranThanhTri-PC>
------------------------------------------------------------
revno: 1812 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: gis
timestamp: Wed 2010-04-28 17:30:28 +0200
message:
Merge with trunk.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/tallysheet/DefaultTallySheetService.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2010-04-28 15:14:05 +0000
@@ -31,7 +31,9 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
/**
@@ -254,4 +256,19 @@
* @return a collection of all DataValues which mach the given collection of DataElements.
*/
Collection<DataValue> getDataValues( DataElement dataElement );
+
+ /**
+ * Returns Latest DataValues for a given DataElement, PeriodType and OrganisationUnit
+ *
+ * @param dataElement the DataElements of the DataValue.
+ * @param periodType the Period Type of period of the DataValue
+ * @param organisationUnit the Organisation Unit of the DataValue
+ * @return a Latest DataValue
+ */
+
+ DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType, OrganisationUnit organisationUnit );
+
+
}
+
+
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2010-04-28 15:14:05 +0000
@@ -31,7 +31,9 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
/**
@@ -246,4 +248,15 @@
* @return a collection of all DataValues which mach the given collection of DataElements.
*/
Collection<DataValue> getDataValues( DataElement dataElement );
+
+ /**
+ * Returns Latest DataValues for a given DataElement, PeriodType and OrganisationUnit
+ *
+ * @param dataElement the DataElements of the DataValue.
+ * @param periodType the Period Type of period of the DataValue
+ * @param organisationUnit the Organisation Unit of the DataValue
+ * @return a Latest DataValue
+ */
+
+ DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType, OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2010-04-21 14:32:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2010-04-28 15:14:05 +0000
@@ -35,7 +35,9 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
import org.springframework.transaction.annotation.Transactional;
@@ -49,7 +51,7 @@
implements DataValueService
{
private static final Log log = LogFactory.getLog( DefaultDataValueService.class );
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -60,9 +62,9 @@
{
this.dataValueStore = dataValueStore;
}
-
+
private DataValueAuditService dataValueAuditService;
-
+
public void setDataValueAuditService( DataValueAuditService dataValueAuditService )
{
this.dataValueAuditService = dataValueAuditService;
@@ -76,10 +78,11 @@
{
if ( !dataValue.isNullValue() )
{
- if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant() &&
- !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
+ if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant()
+ && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
{
- log.info( "DataValue was ignored as zero values are insignificant for this data element: " + dataValue.getDataElement() );
+ log.info( "DataValue was ignored as zero values are insignificant for this data element: "
+ + dataValue.getDataElement() );
}
else
{
@@ -96,10 +99,11 @@
}
else
{
- if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant() &&
- !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
+ if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant()
+ && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
{
- log.info( "DataValue was ignored as zero values are insignificant for this data element: " + dataValue.getDataElement() );
+ log.info( "DataValue was ignored as zero values are insignificant for this data element: "
+ + dataValue.getDataElement() );
}
else
{
@@ -211,4 +215,13 @@
{
return dataValueStore.getDataValues( dataElement );
}
+
+ @Override
+ public DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType,
+ OrganisationUnit organisationUnit )
+ {
+ return dataValueStore.getLatestDataValues( dataElement, periodType, organisationUnit );
+ }
+
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2010-04-21 12:14:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2010-04-28 15:14:05 +0000
@@ -43,8 +43,10 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueStore;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodStore;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.source.Source;
/**
@@ -79,7 +81,7 @@
{
this.periodStore = periodStore;
}
-
+
// -------------------------------------------------------------------------
// Support methods for reloading periods
// -------------------------------------------------------------------------
@@ -135,24 +137,24 @@
public void deleteDataValue( DataValue dataValue )
{
Session session = sessionFactory.getCurrentSession();
-
+
session.delete( dataValue );
}
-
+
public int deleteDataValuesBySource( Source source )
{
Session session = sessionFactory.getCurrentSession();
-
+
Query query = session.createQuery( "delete DataValue where source = :source" );
query.setEntity( "source", source );
-
+
return query.executeUpdate();
}
public int deleteDataValuesByDataElement( DataElement dataElement )
{
Session session = sessionFactory.getCurrentSession();
-
+
Query query = session.createQuery( "delete DataValue where dataElement = :dataElement" );
query.setEntity( "dataElement", dataElement );
@@ -425,4 +427,26 @@
return criteria.list();
}
+
+
+ @Override
+ public DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType,
+ OrganisationUnit organisationUnit )
+ {
+ final String hsql = "SELECT v FROM DataValue v, Period p WHERE v.dataElement =:dataElement "
+ + " AND v.period=p AND p.periodType=:periodType AND v.source=:source ORDER BY p.endDate DESC";
+
+ Session session = sessionFactory.getCurrentSession();
+
+ Query query = session.createQuery( hsql );
+
+ query.setParameter( "dataElement", dataElement );
+ query.setParameter( "periodType", periodType );
+ query.setParameter( "source", organisationUnit );
+
+ query.setFirstResult( 0 );
+ query.setMaxResults( 1 );
+
+ return (DataValue) query.uniqueResult();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/tallysheet/DefaultTallySheetService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/tallysheet/DefaultTallySheetService.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/tallysheet/DefaultTallySheetService.java 2010-04-28 15:14:05 +0000
@@ -28,8 +28,8 @@
*/
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import org.hisp.dhis.dataelement.DataElement;
@@ -37,14 +37,11 @@
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.tallysheet.TallySheet;
-import org.hisp.dhis.tallysheet.TallySheetService;
-import org.hisp.dhis.tallysheet.TallySheetTuple;
/**
- * @author Haavard Tegelsrud, Oddmund Stroemme, Joergen Froeysadal, Ruben Wangberg
+ * @author Haavard Tegelsrud, Oddmund Stroemme, Joergen Froeysadal, Ruben
+ * Wangberg
* @version $Id$
*/
public class DefaultTallySheetService
@@ -53,77 +50,84 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private DataValueService dataValueService;
public void setDataValueService( DataValueService dataValueService )
{
this.dataValueService = dataValueService;
}
-
+
// -------------------------------------------------------------------------
// TallySheetService implementation
// -------------------------------------------------------------------------
-
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
-
- public TallySheet createTallySheet( OrganisationUnit organisationUnit, List<DataElement> dataElements, boolean a3Format,
- boolean displayFacilityName, DataSet selectedDataSet, String tallySheetName )
+
+ public TallySheet createTallySheet( OrganisationUnit organisationUnit, List<DataElement> dataElements,
+ boolean a3Format, boolean displayFacilityName, DataSet selectedDataSet, String tallySheetName )
{
- PeriodType periodType = selectedDataSet.getPeriodType();
-
- Calendar calendar = Calendar.getInstance();
- int thisYear = calendar.get( Calendar.YEAR );
- int lastYear = thisYear - 1;
- calendar.set( Calendar.YEAR, lastYear );
-
- Period period = periodType.createPeriod( calendar.getTime() );
-
- Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements );
-
- return internalCreateTallySheet( organisationUnit, dataElements, dataValues, period, a3Format, displayFacilityName, tallySheetName );
+ PeriodType periodType = selectedDataSet.getPeriodType();
+
+ Collection<DataValue> dataValues = new HashSet<DataValue>();
+
+ for ( DataElement dataElement : dataElements )
+ {
+
+ DataValue dataValue = dataValueService.getLatestDataValues( dataElement, periodType, organisationUnit );
+
+ if ( dataValue != null )
+ {
+ dataValues.add( dataValue );
+ }
+
+ }
+
+ return internalCreateTallySheet( organisationUnit, dataElements, dataValues, a3Format,
+ displayFacilityName, tallySheetName );
}
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
+
private TallySheet internalCreateTallySheet( OrganisationUnit organisationUnit, List<DataElement> dataElements,
- Collection<DataValue> dataValues, Period period, boolean a3Format, boolean displayFacilityName, String tallySheetName )
+ Collection<DataValue> dataValues, boolean a3Format, boolean displayFacilityName,
+ String tallySheetName )
{
TallySheet tallySheet = new TallySheet();
-
+
tallySheet.setTallySheetName( tallySheetName );
tallySheet.setA3Format( a3Format );
tallySheet.setDisplayFacilityName( displayFacilityName );
tallySheet.setOrganisationUnit( organisationUnit );
List<TallySheetTuple> tallySheetTuples = new ArrayList<TallySheetTuple>();
-
+
for ( DataElement dataElement : dataElements )
{
int calculatedNumberOfElements = 0;
for ( DataValue dataValue : dataValues )
{
- if ( dataValue.getPeriod().equals( period ) && dataValue.getSource().equals( organisationUnit )
+ if ( dataValue.getSource().equals( organisationUnit )
&& dataValue.getDataElement().equals( dataElement ) )
{
calculatedNumberOfElements = Integer.parseInt( dataValue.getValue() );
-
+
break;
}
}
-
+
TallySheetTuple tallySheetTuple = new TallySheetTuple();
tallySheetTuple.setTallySheetTuple( calculatedNumberOfElements, dataElement, tallySheet.getRowWidth() );
tallySheetTuples.add( tallySheetTuple );
}
tallySheet.setTallySheetTuples( tallySheetTuples );
-
+
return tallySheet;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-04-27 07:20:12 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-04-28 15:14:05 +0000
@@ -218,4 +218,10 @@
template_using = File is using
template_pending = File is pending
expression_not_well_formed = Expression is not well formed
-print = Print template...
\ No newline at end of file
+basic = Basic
+advanced = Advanced
+update_reportexcel_userrole = User role
+available = Available
+selected = Selected
+expression_not_well_formed = Expression is not well formed
+print = Print template...
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-04-27 07:20:12 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-04-28 15:14:05 +0000
@@ -211,4 +211,9 @@
intro_clean_up = Ch\u1ee9c n\u0103ng n\u00e0y cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng x\u00f3a c\u00e1c t\u1eadp tin t\u1ea1m sinh ra trong qu\u00e1 tr\u00ecnh sinh b\u00e1o c\u00e1o ho\u1eb7c xem tr\u01b0\u1edbc b\u00e1o c\u00e1o.
intro_excel_item = T\u1ea1o m\u1edbi, c\u1eadp nh\u1eadt, xem v\u00e0o x\u00f3a c\u00e1c ph\u1ea7n t\u1eed excel cho qu\u00e1 tr\u00ecnh import d\u1eef li\u1ec7u t\u1eeb t\u1eadp tin excel. Ph\u1ea7n t\u1eed excel n\u00e0y c\u00f3 ch\u1ee9c n\u0103ng g\u1ea7n gi\u1ed1ng v\u1edbi ph\u1ea7n t\u1eed excel trong m\u1ed9t b\u00e1o c\u00e1o excel.
intro_excel_template_management = T\u1ea3i ,\u0111\u1ed5i t\u00ean, t\u00ecm ki\u1ebfm, t\u1ea3i v\u1ec1 v\u00e0 x\u00f3a c\u00e1c t\u1eadp tin c\u00f3 \u0111u\u00f4i m\u1edf r\u1ed9ng .xls ho\u1eb7c .xlsx. Ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 nh\u1eadn bi\u1ebft t\u1eadp tin n\u00e0o \u0111ang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng v\u00e0 t\u1eadp tin n\u00e0o ch\u01b0a d\u00f9ng \u0111\u1ebfn. Cho ph\u00e9p t\u1ef1 \u0111\u1ed9ng c\u1eadp nh\u1eadt l\u1ea1i h\u1ec7 th\u1ed1ng b\u00e1o c\u00e1o excel khi t\u00ean t\u1eadp tin \u0111ang s\u1eed d\u1ee5ng thay \u0111\u1ed5i.
-print = In th\u1eed...
\ No newline at end of file
+basic = C\u01a1 b\u1ea3n
+advanced = N\u00e2ng cao
+update_reportexcel_userrole = G\u00e1n quy\u1ec1n truy xu\u1ea5t tr\u00ean b\u00e1o c\u00e1o
+available = Hi\u1ec7n c\u00f3
+selected = \u0110\u01b0\u1ee3c ch\u1ecdn
+print = In th\u1eed..