dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08946
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2266: Centralized method
------------------------------------------------------------
revno: 2266
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-02 23:05:55 +0100
message:
Centralized method
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
--
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/period/PeriodService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java 2010-10-22 07:47:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java 2010-12-02 22:05:55 +0000
@@ -182,6 +182,15 @@
Collection<Period> getIntersectingPeriods( Date startDate, Date endDate );
/**
+ * Returns Periods where at least one its days are between each of the Periods
+ * start date and end date in the given collection.
+ *
+ * @param periods the collection of Periods.
+ * @return a collection of Periods.
+ */
+ Collection<Period> getIntersectionPeriods( Collection<Period> periods );
+
+ /**
* Returns all Periods from the given collection of Periods which span the border of either the
* start date OR end date of the given Period.
*
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2010-10-22 07:47:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2010-12-02 22:05:55 +0000
@@ -31,8 +31,10 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.i18n.I18nFormat;
@@ -149,6 +151,18 @@
{
return periodStore.getIntersectingPeriods( startDate, endDate );
}
+
+ public Collection<Period> getIntersectionPeriods( Collection<Period> periods )
+ {
+ Set<Period> intersecting = new HashSet<Period>();
+
+ for ( Period period : periods )
+ {
+ intersecting.addAll( getIntersectingPeriods( period.getStartDate(), period.getEndDate() ) );
+ }
+
+ return intersecting;
+ }
public Collection<Period> getBoundaryPeriods( Period period, Collection<Period> periods )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2010-12-02 21:52:11 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2010-12-02 22:05:55 +0000
@@ -287,8 +287,10 @@
Collection<Integer> childrenIds = organisationUnitService.getOrganisationUnitHierarchy().getChildren(
organisationUnitIds );
+ Collection<Integer> intersectingPeriodIds = ConversionUtils.getIdentifiers( Period.class, periodService.getIntersectionPeriods( periods ) );
+
final Collection<DataElementOperand> emptyOperands = crossTabService.populateCrossTabTable(
- allDataElementOperands, getIntersectingIds( periodIds ), childrenIds, key );
+ allDataElementOperands, intersectingPeriodIds, childrenIds, key );
log.info( "Populated crosstab table: " + TimeUtils.getHMS() );
@@ -456,27 +458,6 @@
}
/**
- * Returns the identifiers of the periods in the given collection including
- * all intersecting periods.
- */
- private Collection<Integer> getIntersectingIds( final Collection<Integer> periodIds )
- {
- final Set<Integer> identifiers = new HashSet<Integer>( periodIds.size() );
-
- for ( final Integer id : periodIds )
- {
- final Period period = periodService.getPeriod( id );
-
- final Collection<Period> periods = periodService.getIntersectingPeriods( period.getStartDate(), period
- .getEndDate() );
-
- identifiers.addAll( ConversionUtils.getIdentifiers( Period.class, periods ) );
- }
-
- return identifiers;
- }
-
- /**
* Filters the data element operands based on the value type.
*/
private Collection<DataElementOperand> filterOperands( Collection<DataElementOperand> operands, String valueType,