dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29701
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15044: Removed obsolete methods
------------------------------------------------------------
revno: 15044
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-28 10:53:08 +0200
message:
Removed obsolete methods
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java
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/hibernate/HibernatePeriodStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.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 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java 2014-04-28 08:53:08 +0000
@@ -213,18 +213,6 @@
Collection<Period> getPeriodsByPeriodType( PeriodType periodType );
/**
- * Returns all intersecting Periods for the given Period which have associated DataValues for
- * the given collection of DataElements and Sources.
- *
- * @param period the Period.
- * @param dataElements the collection of DataElements.
- * @param sources the collection of Sources.
- * @return all intersecting Periods for the given Period which have associated DataValues for
- * the given collection of DataElements and Sources.
- */
- Collection<Period> getPeriods( Period period, Collection<DataElement> dataElements, Collection<OrganisationUnit> sources );
-
- /**
* Enforces that each Period in the given collection is loaded in the current
* session. Persists the Period if it does not exist.
*
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java 2014-04-28 08:53:08 +0000
@@ -28,13 +28,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.common.GenericStore;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-
import java.util.Collection;
import java.util.Date;
+import org.hisp.dhis.common.GenericStore;
+
/**
* Defines the functionality for persisting Periods and PeriodTypes.
*
@@ -137,18 +135,6 @@
Collection<Period> getPeriodsByPeriodType( PeriodType periodType );
/**
- * Returns all intersecting Periods for the given Period which have associated DataValues for
- * the given collection of DataElements and Sources.
- *
- * @param period the Period.
- * @param dataElements the collection of DataElements.
- * @param sources the collection of Sources.
- * @return all intersecting Periods for the given Period which have associated DataValues for
- * the given collection of DataElements and Sources.
- */
- Collection<Period> getPeriods( Period period, Collection<DataElement> dataElements, Collection<OrganisationUnit> sources );
-
- /**
* Checks if the given period is associated with the current session and loads
* it if not. Null is returned if the period does not exist.
*
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-14 10:12:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java 2014-04-28 08:53:08 +0000
@@ -260,13 +260,13 @@
public int addDataApprovalLevel( DataApprovalLevel newLevel )
{
- List<DataApprovalLevel> dataApprovalLevels = getAllDataApprovalLevels();
-
if ( newLevel.getOrgUnitLevel() <= 0 )
{
return -1;
}
+ List<DataApprovalLevel> dataApprovalLevels = getAllDataApprovalLevels();
+
int index = getInsertIndex( dataApprovalLevels, newLevel );
if ( index < 0 )
@@ -430,6 +430,7 @@
i--;
}
+
return i + 1;
}
=== 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 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2014-04-28 08:53:08 +0000
@@ -202,12 +202,6 @@
return immutablePeriods;
}
- public Collection<Period> getPeriods( Period period, Collection<DataElement> dataElements,
- Collection<OrganisationUnit> sources )
- {
- return periodStore.getPeriods( period, dataElements, sources );
- }
-
public List<Period> reloadPeriods( List<Period> periods )
{
List<Period> reloaded = new ArrayList<Period>();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java 2014-04-28 08:53:08 +0000
@@ -30,16 +30,11 @@
import java.util.Collection;
import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.period.PeriodType;
@@ -136,34 +131,6 @@
return criteria.list();
}
- @SuppressWarnings( "unchecked" )
- public Collection<Period> getPeriods( Period period, Collection<DataElement> dataElements,
- Collection<OrganisationUnit> sources )
- {
- Set<Period> periods = new HashSet<Period>();
-
- Session session = sessionFactory.getCurrentSession();
-
- Collection<Period> intersectingPeriods = getIntersectingPeriods( period.getStartDate(), period.getEndDate() );
-
- if ( intersectingPeriods != null && intersectingPeriods.size() > 0 )
- {
- Criteria criteria = session.createCriteria( DataValue.class );
- criteria.add( Restrictions.in( "dataElement", dataElements ) );
- criteria.add( Restrictions.in( "source", sources ) );
- criteria.add( Restrictions.in( "period", intersectingPeriods ) );
-
- Collection<DataValue> dataValues = criteria.list();
-
- for ( DataValue dataValue : dataValues )
- {
- periods.add( dataValue.getPeriod() );
- }
- }
-
- return periods;
- }
-
public Period getPeriodFromDates( Date startDate, Date endDate, PeriodType periodType )
{
Criteria criteria = getCriteria();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java 2014-04-28 08:20:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodServiceTest.java 2014-04-28 08:53:08 +0000
@@ -40,14 +40,6 @@
import java.util.Iterator;
import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.junit.Test;
/**
@@ -58,13 +50,7 @@
extends DhisSpringTest
{
private PeriodService periodService;
-
- private DataElementService dataElementService;
-
- private DataValueService dataValueService;
-
- private DataElementCategoryOptionCombo optionCombo;
-
+
// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@@ -73,18 +59,6 @@
public void setUpTest()
{
periodService = (PeriodService) getBean( PeriodService.ID );
-
- dataElementService = (DataElementService) getBean( DataElementService.ID );
-
- categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );
-
- organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
- dataValueService = (DataValueService) getBean( DataValueService.ID );
-
- optionCombo = new DataElementCategoryOptionCombo();
-
- categoryService.addDataElementCategoryOptionCombo( optionCombo );
}
// -------------------------------------------------------------------------
@@ -458,122 +432,6 @@
}
@Test
- public void testGetPeriodsWithAssociatedDataValues()
- throws Exception
- {
- DataElement dataElementA = createDataElement( 'A' );
- DataElement dataElementB = createDataElement( 'B' );
- DataElement dataElementC = createDataElement( 'C' );
-
- PeriodType quarterly = PeriodType.getPeriodTypeByName( QuarterlyPeriodType.NAME );
- PeriodType monthly = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
- PeriodType weekly = PeriodType.getPeriodTypeByName( WeeklyPeriodType.NAME );
-
- Period qu1 = new Period( quarterly, getDate( 2008, 1, 1 ), getDate( 2008, 3, 31 ) );
-
- Period jan = new Period( monthly, getDate( 2008, 1, 1 ), getDate( 2008, 1, 31 ) );
- Period feb = new Period( monthly, getDate( 2008, 2, 1 ), getDate( 2008, 2, 29 ) );
- Period mar = new Period( monthly, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
- Period apr = new Period( monthly, getDate( 2008, 4, 1 ), getDate( 2008, 4, 30 ) );
- Period may = new Period( monthly, getDate( 2008, 5, 1 ), getDate( 2008, 5, 31 ) );
-
- Period w01 = new Period( weekly, getDate( 2007, 12, 31 ), getDate( 2008, 1, 6 ) );
- Period w02 = new Period( weekly, getDate( 2008, 1, 7 ), getDate( 2008, 1, 13 ) );
- Period w03 = new Period( weekly, getDate( 2008, 1, 14 ), getDate( 2008, 1, 20 ) );
- Period w04 = new Period( weekly, getDate( 2008, 1, 21 ), getDate( 2008, 1, 27 ) );
- Period w05 = new Period( weekly, getDate( 2008, 1, 28 ), getDate( 2008, 2, 3 ) );
-
- OrganisationUnit sourceA = createOrganisationUnit( 'A' );
- OrganisationUnit sourceB = createOrganisationUnit( 'B' );
- OrganisationUnit sourceC = createOrganisationUnit( 'C' );
-
- DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo, optionCombo );
- dataValueA.setValue( "1" );
- DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo, optionCombo );
- dataValueB.setValue( "2" );
- DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo, optionCombo );
- dataValueC.setValue( "3" );
- DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo, optionCombo );
- dataValueD.setValue( "4" );
- DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo, optionCombo );
- dataValueE.setValue( "5" );
- DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo, optionCombo );
- dataValueF.setValue( "6" );
- DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo, optionCombo );
- dataValueG.setValue( "7" );
- DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo, optionCombo );
- dataValueH.setValue( "8" );
- DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo, optionCombo );
- dataValueI.setValue( "9" );
-
- dataElementService.addDataElement( dataElementA );
- dataElementService.addDataElement( dataElementB );
- dataElementService.addDataElement( dataElementC );
-
- organisationUnitService.addOrganisationUnit( sourceA, false );
- organisationUnitService.addOrganisationUnit( sourceB, false );
- organisationUnitService.addOrganisationUnit( sourceC, false );
-
- dataValueService.addDataValue( dataValueA );
- dataValueService.addDataValue( dataValueB );
- dataValueService.addDataValue( dataValueC );
- dataValueService.addDataValue( dataValueD );
- dataValueService.addDataValue( dataValueE );
- dataValueService.addDataValue( dataValueF );
- dataValueService.addDataValue( dataValueG );
- dataValueService.addDataValue( dataValueH );
- dataValueService.addDataValue( dataValueI );
-
- Collection<DataElement> dataElements1 = new ArrayList<DataElement>();
-
- dataElements1.add( dataElementA );
- dataElements1.add( dataElementB );
-
- Collection<DataElement> dataElements2 = new ArrayList<DataElement>();
-
- dataElements2.add( dataElementC );
-
- Collection<OrganisationUnit> sources1 = new ArrayList<OrganisationUnit>();
-
- sources1.add( sourceA );
- sources1.add( sourceB );
-
- Collection<OrganisationUnit> sources2 = new ArrayList<OrganisationUnit>();
-
- sources2.add( sourceC );
-
- Collection<Period> periods = periodService.getPeriods( jan, dataElements1, sources1 );
-
- assertEquals( periods.size(), 7 );
-
- periods = periodService.getPeriods( feb, dataElements1, sources1 );
-
- assertEquals( periods.size(), 3 );
-
- periods = periodService.getPeriods( mar, dataElements1, sources1 );
-
- assertEquals( periods.size(), 1 );
-
- periods = periodService.getPeriods( apr, dataElements1, sources1 );
-
- assertEquals( periods.size(), 1 );
-
- periods = periodService.getPeriods( may, dataElements1, sources1 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodService.getPeriods( jan, dataElements1, sources2 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodService.getPeriods( feb, dataElements2, sources1 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodService.getPeriods( mar, dataElements2, sources2 );
- }
-
- @Test
public void testGetBoundaryPeriods()
{
PeriodType periodType = periodService.getAllPeriodTypes().iterator().next();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java 2014-04-28 07:49:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java 2014-04-28 08:53:08 +0000
@@ -33,21 +33,12 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryService;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueStore;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.junit.Test;
/**
@@ -59,10 +50,6 @@
{
private PeriodStore periodStore;
- private DataValueStore dataValueStore;
-
- private DataElementCategoryOptionCombo optionCombo;
-
// -------------------------------------------------------------------------
// Set up/tear down
// -------------------------------------------------------------------------
@@ -72,16 +59,6 @@
throws Exception
{
periodStore = (PeriodStore) getBean( PeriodStore.ID );
-
- dataElementService = (DataElementService) getBean( DataElementService.ID );
-
- categoryService = (DataElementCategoryService) getBean( DataElementCategoryService.ID );
-
- organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
- dataValueStore = (DataValueStore) getBean( DataValueStore.ID );
-
- optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
}
// -------------------------------------------------------------------------
@@ -508,120 +485,4 @@
assertNotNull( periodsC );
assertEquals( 0, periodsC.size() );
}
-
- @Test
- public void testGetPeriodsWithAssociatedDataValues()
- throws Exception
- {
- DataElement dataElementA = createDataElement( 'A' );
- DataElement dataElementB = createDataElement( 'B' );
- DataElement dataElementC = createDataElement( 'C' );
-
- PeriodType quarterly = PeriodType.getPeriodTypeByName( QuarterlyPeriodType.NAME );
- PeriodType monthly = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
- PeriodType weekly = PeriodType.getPeriodTypeByName( WeeklyPeriodType.NAME );
-
- Period qu1 = new Period( quarterly, getDate( 2008, 1, 1 ), getDate( 2008, 3, 31 ) );
-
- Period jan = new Period( monthly, getDate( 2008, 1, 1 ), getDate( 2008, 1, 31 ) );
- Period feb = new Period( monthly, getDate( 2008, 2, 1 ), getDate( 2008, 2, 29 ) );
- Period mar = new Period( monthly, getDate( 2008, 3, 1 ), getDate( 2008, 3, 31 ) );
- Period apr = new Period( monthly, getDate( 2008, 4, 1 ), getDate( 2008, 4, 30 ) );
- Period may = new Period( monthly, getDate( 2008, 5, 1 ), getDate( 2008, 5, 31 ) );
-
- Period w01 = new Period( weekly, getDate( 2007, 12, 31 ), getDate( 2008, 1, 6 ) );
- Period w02 = new Period( weekly, getDate( 2008, 1, 7 ), getDate( 2008, 1, 13 ) );
- Period w03 = new Period( weekly, getDate( 2008, 1, 14 ), getDate( 2008, 1, 20 ) );
- Period w04 = new Period( weekly, getDate( 2008, 1, 21 ), getDate( 2008, 1, 27 ) );
- Period w05 = new Period( weekly, getDate( 2008, 1, 28 ), getDate( 2008, 2, 3 ) );
-
- OrganisationUnit sourceA = createOrganisationUnit( 'A' );
- OrganisationUnit sourceB = createOrganisationUnit( 'B' );
- OrganisationUnit sourceC = createOrganisationUnit( 'C' );
-
- DataValue dataValueA = new DataValue( dataElementA, jan, sourceA, optionCombo, optionCombo );
- dataValueA.setValue( "1" );
- DataValue dataValueB = new DataValue( dataElementA, feb, sourceB, optionCombo, optionCombo );
- dataValueB.setValue( "2" );
- DataValue dataValueC = new DataValue( dataElementA, apr, sourceB, optionCombo, optionCombo );
- dataValueC.setValue( "3" );
- DataValue dataValueD = new DataValue( dataElementA, qu1, sourceA, optionCombo, optionCombo );
- dataValueD.setValue( "4" );
- DataValue dataValueE = new DataValue( dataElementB, w01, sourceA, optionCombo, optionCombo );
- dataValueE.setValue( "5" );
- DataValue dataValueF = new DataValue( dataElementB, w02, sourceB, optionCombo, optionCombo );
- dataValueF.setValue( "6" );
- DataValue dataValueG = new DataValue( dataElementB, w03, sourceA, optionCombo, optionCombo );
- dataValueG.setValue( "7" );
- DataValue dataValueH = new DataValue( dataElementB, w04, sourceB, optionCombo, optionCombo );
- dataValueH.setValue( "8" );
- DataValue dataValueI = new DataValue( dataElementB, w05, sourceA, optionCombo, optionCombo );
- dataValueI.setValue( "9" );
-
- dataElementService.addDataElement( dataElementA );
- dataElementService.addDataElement( dataElementB );
- dataElementService.addDataElement( dataElementC );
-
- organisationUnitService.addOrganisationUnit( sourceA, false );
- organisationUnitService.addOrganisationUnit( sourceB, false );
- organisationUnitService.addOrganisationUnit( sourceC, false );
-
- dataValueStore.addDataValue( dataValueA );
- dataValueStore.addDataValue( dataValueB );
- dataValueStore.addDataValue( dataValueC );
- dataValueStore.addDataValue( dataValueD );
- dataValueStore.addDataValue( dataValueE );
- dataValueStore.addDataValue( dataValueF );
- dataValueStore.addDataValue( dataValueG );
- dataValueStore.addDataValue( dataValueH );
- dataValueStore.addDataValue( dataValueI );
-
- Collection<DataElement> dataElements1 = new ArrayList<DataElement>();
-
- dataElements1.add( dataElementA );
- dataElements1.add( dataElementB );
-
- Collection<DataElement> dataElements2 = new ArrayList<DataElement>();
-
- dataElements2.add( dataElementC );
-
- Collection<OrganisationUnit> sources1 = new ArrayList<OrganisationUnit>();
-
- sources1.add( sourceA );
- sources1.add( sourceB );
-
- Collection<OrganisationUnit> sources2 = new ArrayList<OrganisationUnit>();
-
- sources2.add( sourceC );
-
- Collection<Period> periods = periodStore.getPeriods( jan, dataElements1, sources1 );
-
- assertEquals( periods.size(), 7 );
-
- periods = periodStore.getPeriods( feb, dataElements1, sources1 );
-
- assertEquals( periods.size(), 3 );
-
- periods = periodStore.getPeriods( mar, dataElements1, sources1 );
-
- assertEquals( periods.size(), 1 );
-
- periods = periodStore.getPeriods( apr, dataElements1, sources1 );
-
- assertEquals( periods.size(), 1 );
-
- periods = periodStore.getPeriods( may, dataElements1, sources1 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodStore.getPeriods( jan, dataElements1, sources2 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodStore.getPeriods( feb, dataElements2, sources1 );
-
- assertEquals( periods.size(), 0 );
-
- periods = periodStore.getPeriods( mar, dataElements2, sources2 );
- }
}