=== 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 2015-09-16 14:49:50 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2015-09-21 12:17:42 +0000 @@ -84,22 +84,6 @@ * @param dataValue the DataValue to delete. */ void deleteDataValue( DataValue dataValue ); - - /** - * Deletes all DataValues connected to a Source. - * - * @param source the Source for which the DataValues should be deleted. - * @return the number of deleted DataValues. - */ - int deleteDataValuesBySource( OrganisationUnit source ); - - /** - * Deletes all DataValues registered for the given DataElement. - * - * @param dataElement the DataElement for which the DataValues should be deleted. - * @return the number of deleted DataValues. - */ - int deleteDataValuesByDataElement( DataElement dataElement ); /** * Returns a DataValue. @@ -107,7 +91,7 @@ * @param dataElement the DataElement of the DataValue. * @param period the Period of the DataValue. * @param source the Source of the DataValue. - * @param categoryOptionCombo the category option combo. + * @param optionCombo the category option combo. * @return the DataValue which corresponds to the given parameters, or null * if no match. */ @@ -134,7 +118,6 @@ * @param periodId period id * @param sourceId source id * @param categoryOptionComboId category option combo id - * @param attributeOptionComboId attribute option combo id */ DataValue getDataValue( int dataElementId, int periodId, int sourceId, int categoryOptionComboId ); === 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 2015-09-16 14:49:50 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2015-09-21 12:17:42 +0000 @@ -79,22 +79,6 @@ void deleteDataValue( DataValue dataValue ); /** - * Deletes all DataValues registered for the given Source. - * - * @param source the Source for which the DataValues should be deleted. - * @return the number of deleted DataValues. - */ - int deleteDataValuesBySource( OrganisationUnit source ); - - /** - * Deletes all DataValues registered for the given DataElement. - * - * @param dataElement the DataElement for which the DataValues should be deleted. - * @return the number of deleted DataValues. - */ - int deleteDataValuesByDataElement( DataElement dataElement ); - - /** * Returns a DataValue. * * @param dataElement the DataElement of the DataValue. === 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 2015-09-18 16:41:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2015-09-21 12:17:42 +0000 @@ -186,7 +186,6 @@ if ( dataValue.getDataElement().isFileType() ) { - // TODO Consider for deleteDataValuesBySource and deleteDataValuesByDataElement fileResourceService.deleteFileResource( dataValue.getValue() ); } @@ -194,20 +193,6 @@ } @Override - @Transactional - public int deleteDataValuesBySource( OrganisationUnit source ) - { - return dataValueStore.deleteDataValuesBySource( source ); - } - - @Override - @Transactional - public int deleteDataValuesByDataElement( DataElement dataElement ) - { - return dataValueStore.deleteDataValuesByDataElement( dataElement ); - } - - @Override public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo ) { DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); === 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 2015-07-03 01:33:37 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2015-09-21 12:17:42 +0000 @@ -133,28 +133,6 @@ } @Override - public int deleteDataValuesBySource( OrganisationUnit source ) - { - Session session = sessionFactory.getCurrentSession(); - - Query query = session.createQuery( "delete DataValue where source = :source" ); - query.setEntity( "source", source ); - - return query.executeUpdate(); - } - - @Override - public int deleteDataValuesByDataElement( DataElement dataElement ) - { - Session session = sessionFactory.getCurrentSession(); - - Query query = session.createQuery( "delete DataValue where dataElement = :dataElement" ); - query.setEntity( "dataElement", dataElement ); - - return query.executeUpdate(); - } - - @Override public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java 2015-09-13 17:45:53 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java 2015-09-21 12:17:42 +0000 @@ -257,100 +257,6 @@ assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); } - @Test - public void testDeleteDataValuesBySource() - { - DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ); - dataValueA.setValue( "1" ); - DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ); - dataValueB.setValue( "2" ); - DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ); - dataValueC.setValue( "3" ); - DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ); - dataValueD.setValue( "4" ); - - dataValueService.addDataValue( dataValueA ); - dataValueService.addDataValue( dataValueB ); - dataValueService.addDataValue( dataValueC ); - dataValueService.addDataValue( dataValueD ); - - assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesBySource( sourceA ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesBySource( sourceB ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesBySource( sourceC ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesBySource( sourceD ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - } - - @Test - public void testDeleteDataValuesByDataElement() - { - DataValue dataValueA = new DataValue( dataElementA, periodA, sourceA, optionCombo, optionCombo ); - dataValueA.setValue( "1" ); - DataValue dataValueB = new DataValue( dataElementB, periodA, sourceA, optionCombo, optionCombo ); - dataValueB.setValue( "2" ); - DataValue dataValueC = new DataValue( dataElementC, periodC, sourceD, optionCombo, optionCombo ); - dataValueC.setValue( "3" ); - DataValue dataValueD = new DataValue( dataElementD, periodC, sourceB, optionCombo, optionCombo ); - dataValueD.setValue( "4" ); - - dataValueService.addDataValue( dataValueA ); - dataValueService.addDataValue( dataValueB ); - dataValueService.addDataValue( dataValueC ); - dataValueService.addDataValue( dataValueD ); - - assertNotNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesByDataElement( dataElementA ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesByDataElement( dataElementB ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesByDataElement( dataElementC ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNotNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - - dataValueService.deleteDataValuesByDataElement( dataElementD ); - assertNull( dataValueService.getDataValue( dataElementA, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementB, periodA, sourceA, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementC, periodC, sourceD, optionCombo ) ); - assertNull( dataValueService.getDataValue( dataElementD, periodC, sourceB, optionCombo ) ); - } - // ------------------------------------------------------------------------- // Collections of DataValues // -------------------------------------------------------------------------