← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9953: Moved class DataMartTask to data mart project, where it fits better

 

------------------------------------------------------------
revno: 9953
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-03-03 23:51:24 +0100
message:
  Moved class DataMartTask to data mart project, where it fits better
removed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling/
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling/TaskTest.java
added:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling/
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling/DataMartTask.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling/
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling/TaskTest.java
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml


--
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
=== added directory 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling'
=== added file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling/DataMartTask.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling/DataMartTask.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/scheduling/DataMartTask.java	2013-03-03 22:51:24 +0000
@@ -0,0 +1,159 @@
+package org.hisp.dhis.datamart.scheduling;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_PERIOD_TYPES;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.completeness.DataSetCompletenessEngine;
+import org.hisp.dhis.datamart.DataMartEngine;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.util.ConversionUtils;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class DataMartTask
+    implements Runnable
+{
+    private static final Log log = LogFactory.getLog( DataMartTask.class );
+    
+    private DataMartEngine dataMartEngine;
+
+    private DataSetCompletenessEngine completenessEngine;
+    
+    private PeriodService periodService;
+        
+    private SystemSettingManager systemSettingManager;
+    
+    // -------------------------------------------------------------------------
+    // Params
+    // -------------------------------------------------------------------------
+
+    private TaskId taskId;
+
+    public void setTaskId( TaskId taskId )
+    {
+        this.taskId = taskId;
+    }
+
+    private List<Period> periods;
+    
+    public void setPeriods( List<Period> periods )
+    {
+        this.periods = periods;
+    }
+    
+    private boolean last6Months;
+
+    public void setLast6Months( boolean last6Months )
+    {
+        this.last6Months = last6Months;
+    }
+
+    private boolean last6To12Months;
+
+    public void setLast6To12Months( boolean last6To12Months )
+    {
+        this.last6To12Months = last6To12Months;
+    }
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public DataMartTask()
+    {
+    }
+    
+    public DataMartTask( DataMartEngine dataMartEngine, DataSetCompletenessEngine completenessEngine, 
+        PeriodService periodService, SystemSettingManager systemSettingManager )
+    {
+        this.dataMartEngine = dataMartEngine;
+        this.completenessEngine = completenessEngine;
+        this.periodService = periodService;
+        this.systemSettingManager = systemSettingManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Runnable implementation
+    // -------------------------------------------------------------------------
+
+    @Override  
+    @SuppressWarnings("unchecked")  
+    public void run()
+    {
+        Set<String> periodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
+        
+        List<Period> periods = getPeriods( periodTypes );
+        
+        log.info( "Using periods: " + periods );
+        
+        Collection<Integer> periodIds = ConversionUtils.getIdentifiers( Period.class, periodService.reloadPeriods( periods ) );
+        
+        dataMartEngine.export( periodIds, taskId );
+        completenessEngine.exportDataSetCompleteness( periodIds, taskId ); 
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    public List<Period> getPeriods( Set<String> periodTypes )
+    {
+        if ( periods != null && periods.size() > 0 )
+        {
+            return periods;
+        }
+        
+        List<Period> relatives =  new ArrayList<Period>();
+        
+        if  ( last6Months )
+        {
+            relatives.addAll( new RelativePeriods().getLast6Months( periodTypes ) );
+        }
+        
+        if ( last6To12Months )
+        {
+            relatives.addAll( new RelativePeriods().getLast6To12Months( periodTypes ) );
+        }
+        
+        return relatives;
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2013-03-03 22:51:24 +0000
@@ -102,6 +102,28 @@
 	<property name="statementManager" ref="inMemoryStatementManager" />
   </bean>
       
+  <!-- Scheduling  -->      
+      
+  <bean id="abstractDataMartTask" class="org.hisp.dhis.datamart.scheduling.DataMartTask" scope="prototype">
+    <constructor-arg ref="org.hisp.dhis.datamart.DataMartEngine" />
+    <constructor-arg ref="org.hisp.dhis.completeness.DataSetCompletenessEngine" />
+    <constructor-arg ref="org.hisp.dhis.period.PeriodService" />
+    <constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
+  </bean>
+  
+  <bean id="dataMartLast12MonthsTask" class="org.hisp.dhis.datamart.scheduling.DataMartTask" parent="abstractDataMartTask">
+    <property name="last6Months" value="true"/>
+    <property name="last6To12Months" value="true"/>
+  </bean>
+    
+  <bean id="dataMartLast6MonthsTask" class="org.hisp.dhis.datamart.scheduling.DataMartTask" parent="abstractDataMartTask">
+    <property name="last6Months" value="true"/>
+  </bean>
+  
+  <bean id="dataMartFrom6To12MonthsTask" class="org.hisp.dhis.datamart.scheduling.DataMartTask" parent="abstractDataMartTask">
+    <property name="last6To12Months" value="true"/>
+  </bean>      
+      
   <!-- Deletion AOP definitions -->
 
   <aop:config>

=== added directory 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling'
=== added file 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling/TaskTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling/TaskTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/scheduling/TaskTest.java	2013-03-03 22:51:24 +0000
@@ -0,0 +1,87 @@
+package org.hisp.dhis.datamart.scheduling;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.period.BiMonthlyPeriodType;
+import org.hisp.dhis.period.FinancialJulyPeriodType;
+import org.hisp.dhis.period.MonthlyPeriodType;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.QuarterlyPeriodType;
+import org.hisp.dhis.period.SixMonthlyPeriodType;
+import org.hisp.dhis.period.YearlyPeriodType;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class TaskTest
+{
+    @Test
+    public void testGetPeriods()
+    {
+        Set<String> periodTypes = new HashSet<String>();
+        periodTypes.add( MonthlyPeriodType.NAME );
+        periodTypes.add( BiMonthlyPeriodType.NAME );
+        periodTypes.add( QuarterlyPeriodType.NAME );
+        periodTypes.add( SixMonthlyPeriodType.NAME );
+        periodTypes.add( YearlyPeriodType.NAME );
+        periodTypes.add( FinancialJulyPeriodType.NAME );
+        
+        DataMartTask dataMartTask = new DataMartTask();
+
+        dataMartTask.setLast6Months( true );
+        dataMartTask.setLast6To12Months( true );
+
+        List<Period> periods = dataMartTask.getPeriods( periodTypes );
+        
+        assertNotNull( periods );
+        assertEquals( 28, periods.size() ); // 12 + 6 + 4 + 2 + 1 + 1 
+        
+        dataMartTask.setLast6Months( true );
+        dataMartTask.setLast6To12Months( false );
+        
+        periods = dataMartTask.getPeriods( periodTypes );
+
+        assertNotNull( periods );
+        assertEquals( 14, periods.size() ); // 6 + 3 + 2 + 1 + 1 + 1
+        
+        dataMartTask.setLast6Months( false );
+        dataMartTask.setLast6To12Months( true );
+
+        periods = dataMartTask.getPeriods( periodTypes );
+        
+        assertNotNull( periods );
+        assertEquals( 14, periods.size() ); // 6 + 3 + 2 + 1 + 1 + 1
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-03-03 21:30:24 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2013-03-03 22:51:24 +0000
@@ -253,26 +253,6 @@
     </property>
   </bean>
 
-  <bean id="abstractDataMartTask" class="org.hisp.dhis.system.scheduling.DataMartTask" scope="prototype">
-    <constructor-arg ref="org.hisp.dhis.datamart.DataMartEngine" />
-    <constructor-arg ref="org.hisp.dhis.completeness.DataSetCompletenessEngine" />
-	<constructor-arg ref="org.hisp.dhis.period.PeriodService" />
-	<constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
-  </bean>
-  
-  <bean id="dataMartLast12MonthsTask" class="org.hisp.dhis.system.scheduling.DataMartTask" parent="abstractDataMartTask">
-	<property name="last6Months" value="true"/>
-	<property name="last6To12Months" value="true"/>
-  </bean>
-    
-  <bean id="dataMartLast6MonthsTask" class="org.hisp.dhis.system.scheduling.DataMartTask" parent="abstractDataMartTask">
-	<property name="last6Months" value="true"/>
-  </bean>
-  
-  <bean id="dataMartFrom6To12MonthsTask" class="org.hisp.dhis.system.scheduling.DataMartTask" parent="abstractDataMartTask">
-	<property name="last6To12Months" value="true"/>
-  </bean>  
-
   <!-- DeletionHandler -->
 
   <bean id="org.hisp.dhis.report.ReportDeletionHandler" class="org.hisp.dhis.report.ReportDeletionHandler">

=== removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java	2013-03-03 21:30:24 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java	1970-01-01 00:00:00 +0000
@@ -1,159 +0,0 @@
-package org.hisp.dhis.system.scheduling;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_PERIOD_TYPES;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.completeness.DataSetCompletenessEngine;
-import org.hisp.dhis.datamart.DataMartEngine;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.scheduling.TaskId;
-import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.system.util.ConversionUtils;
-
-/**
- * @author Lars Helge Overland
- */
-public class DataMartTask
-    implements Runnable
-{
-    private static final Log log = LogFactory.getLog( DataMartTask.class );
-    
-    private DataMartEngine dataMartEngine;
-
-    private DataSetCompletenessEngine completenessEngine;
-    
-    private PeriodService periodService;
-        
-    private SystemSettingManager systemSettingManager;
-    
-    // -------------------------------------------------------------------------
-    // Params
-    // -------------------------------------------------------------------------
-
-    private TaskId taskId;
-
-    public void setTaskId( TaskId taskId )
-    {
-        this.taskId = taskId;
-    }
-
-    private List<Period> periods;
-    
-    public void setPeriods( List<Period> periods )
-    {
-        this.periods = periods;
-    }
-    
-    private boolean last6Months;
-
-    public void setLast6Months( boolean last6Months )
-    {
-        this.last6Months = last6Months;
-    }
-
-    private boolean last6To12Months;
-
-    public void setLast6To12Months( boolean last6To12Months )
-    {
-        this.last6To12Months = last6To12Months;
-    }
-
-    // -------------------------------------------------------------------------
-    // Constructors
-    // -------------------------------------------------------------------------
-
-    public DataMartTask()
-    {
-    }
-    
-    public DataMartTask( DataMartEngine dataMartEngine, DataSetCompletenessEngine completenessEngine, 
-        PeriodService periodService, SystemSettingManager systemSettingManager )
-    {
-        this.dataMartEngine = dataMartEngine;
-        this.completenessEngine = completenessEngine;
-        this.periodService = periodService;
-        this.systemSettingManager = systemSettingManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // Runnable implementation
-    // -------------------------------------------------------------------------
-
-    @Override  
-    @SuppressWarnings("unchecked")  
-    public void run()
-    {
-        Set<String> periodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
-        
-        List<Period> periods = getPeriods( periodTypes );
-        
-        log.info( "Using periods: " + periods );
-        
-        Collection<Integer> periodIds = ConversionUtils.getIdentifiers( Period.class, periodService.reloadPeriods( periods ) );
-        
-        dataMartEngine.export( periodIds, taskId );
-        completenessEngine.exportDataSetCompleteness( periodIds, taskId ); 
-    }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    public List<Period> getPeriods( Set<String> periodTypes )
-    {
-        if ( periods != null && periods.size() > 0 )
-        {
-            return periods;
-        }
-        
-        List<Period> relatives =  new ArrayList<Period>();
-        
-        if  ( last6Months )
-        {
-            relatives.addAll( new RelativePeriods().getLast6Months( periodTypes ) );
-        }
-        
-        if ( last6To12Months )
-        {
-            relatives.addAll( new RelativePeriods().getLast6To12Months( periodTypes ) );
-        }
-        
-        return relatives;
-    }
-}

=== removed directory 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling'
=== removed file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling/TaskTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling/TaskTest.java	2012-05-08 15:55:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/scheduling/TaskTest.java	1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-package org.hisp.dhis.system.scheduling;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hisp.dhis.period.BiMonthlyPeriodType;
-import org.hisp.dhis.period.FinancialJulyPeriodType;
-import org.hisp.dhis.period.MonthlyPeriodType;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.QuarterlyPeriodType;
-import org.hisp.dhis.period.SixMonthlyPeriodType;
-import org.hisp.dhis.period.YearlyPeriodType;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Lars Helge Overland
- */
-public class TaskTest
-{
-    @Test
-    public void testGetPeriods()
-    {
-        Set<String> periodTypes = new HashSet<String>();
-        periodTypes.add( MonthlyPeriodType.NAME );
-        periodTypes.add( BiMonthlyPeriodType.NAME );
-        periodTypes.add( QuarterlyPeriodType.NAME );
-        periodTypes.add( SixMonthlyPeriodType.NAME );
-        periodTypes.add( YearlyPeriodType.NAME );
-        periodTypes.add( FinancialJulyPeriodType.NAME );
-        
-        DataMartTask dataMartTask = new DataMartTask();
-
-        dataMartTask.setLast6Months( true );
-        dataMartTask.setLast6To12Months( true );
-
-        List<Period> periods = dataMartTask.getPeriods( periodTypes );
-        
-        assertNotNull( periods );
-        assertEquals( 28, periods.size() ); // 12 + 6 + 4 + 2 + 1 + 1 
-        
-        dataMartTask.setLast6Months( true );
-        dataMartTask.setLast6To12Months( false );
-        
-        periods = dataMartTask.getPeriods( periodTypes );
-
-        assertNotNull( periods );
-        assertEquals( 14, periods.size() ); // 6 + 3 + 2 + 1 + 1 + 1
-        
-        dataMartTask.setLast6Months( false );
-        dataMartTask.setLast6To12Months( true );
-
-        periods = dataMartTask.getPeriods( periodTypes );
-        System.out.println( periods );
-        assertNotNull( periods );
-        assertEquals( 14, periods.size() ); // 6 + 3 + 2 + 1 + 1 + 1
-    }
-}