=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2012-05-16 09:54:13 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2012-05-28 22:32:37 +0000 @@ -71,6 +71,16 @@ Collection getBetween( int first, int max ); /** + * Retrieves the objects determined by the given first result and max result. + * The returned list is ordered by the last updated property descending. + * + * @param first the first result object to return. + * @param max the max number of result objects to return. + * @return collection of objects. + */ + List getBetweenOrderderByLastUpdated( int first, int max ); + + /** * Retrieves the objects determined by the given first result and max result * which name is like the given name. * === added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation' === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-28 22:32:37 +0000 @@ -0,0 +1,70 @@ +package org.hisp.dhis.interpretation; + +/* + * 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 org.hisp.dhis.chart.Chart; +import org.hisp.dhis.common.BaseIdentifiableObject; + +/** + * @author Lars Helge Overland + */ +public class Interpretation + extends BaseIdentifiableObject +{ + private Chart chart; + + private String text; + + public Interpretation() + { + } + + public Interpretation( Chart chart, String text ) + { + } + + public Chart getChart() + { + return chart; + } + + public void setChart( Chart chart ) + { + this.chart = chart; + } + + public String getText() + { + return text; + } + + public void setText( String text ) + { + this.text = text; + } +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java 2012-05-28 22:32:37 +0000 @@ -0,0 +1,46 @@ +package org.hisp.dhis.interpretation; + +/* + * 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.List; + +/** + * @author Lars Helge Overland + */ +public interface InterpretationService +{ + int saveInterpretation( Interpretation interpretation ); + + Interpretation getInterpretation( int id ); + + Interpretation getInterpretation( String uid ); + + void deleteInterpretation( Interpretation interpretation ); + + List getInterpretations( int first, int max ); +} === added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation' === added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl' === added file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java 2012-05-28 22:32:37 +0000 @@ -0,0 +1,81 @@ +package org.hisp.dhis.interpretation.impl; + +/* + * 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.List; + +import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.interpretation.Interpretation; +import org.hisp.dhis.interpretation.InterpretationService; + +/** + * @author Lars Helge Overland + */ +public class DefaultInterpretationService + implements InterpretationService +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private GenericIdentifiableObjectStore interpretationStore; + + public void setInterpretationStore( GenericIdentifiableObjectStore interpretationStore ) + { + this.interpretationStore = interpretationStore; + } + + // ------------------------------------------------------------------------- + // InterpretationService implementation + // ------------------------------------------------------------------------- + + public int saveInterpretation( Interpretation interpretation ) + { + return interpretationStore.save( interpretation ); + } + + public Interpretation getInterpretation( int id ) + { + return interpretationStore.get( id ); + } + + public Interpretation getInterpretation( String uid ) + { + return interpretationStore.getByUid( uid ); + } + + public void deleteInterpretation( Interpretation interpretation ) + { + interpretationStore.delete( interpretation ); + } + + public List getInterpretations( int first, int max ) + { + return interpretationStore.getBetweenOrderderByLastUpdated( first, max ); + } +} === 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 2012-05-08 15:55:59 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-05-28 22:32:37 +0000 @@ -247,6 +247,18 @@ + + + + + + + + + + + + === added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation' === added directory 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate' === added file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-28 22:32:37 +0000 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === added directory 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation' === added file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/interpretation/InterpretationServiceTest.java 2012-05-28 22:32:37 +0000 @@ -0,0 +1,129 @@ +package org.hisp.dhis.interpretation; + +/* + * 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 junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; +import static junit.framework.Assert.assertTrue; + +import java.util.List; + +import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.chart.Chart; +import org.hisp.dhis.chart.ChartService; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Lars Helge Overland + */ +public class InterpretationServiceTest + extends DhisSpringTest +{ + @Autowired + private ChartService chartService; + + @Autowired + private InterpretationService interpretationService; + + private Chart chartA; + + private Interpretation interpretationA; + private Interpretation interpretationB; + private Interpretation interpretationC; + + @Before + public void beforeTest() + { + chartA = new Chart( "ChartA" ); + chartService.saveChart( chartA ); + + interpretationA = new Interpretation( chartA, "Interpration of chart A" ); + interpretationB = new Interpretation( chartA, "Interpration of chart B" ); + interpretationC = new Interpretation( chartA, "Interpration of chart C" ); + } + + @Test + public void testSaveGet() + { + int idA = interpretationService.saveInterpretation( interpretationA ); + int idB = interpretationService.saveInterpretation( interpretationB ); + int idC = interpretationService.saveInterpretation( interpretationC ); + + assertEquals( interpretationA, interpretationService.getInterpretation( idA ) ); + assertEquals( interpretationB, interpretationService.getInterpretation( idB ) ); + assertEquals( interpretationC, interpretationService.getInterpretation( idC ) ); + } + + @Test + public void testDelete() + { + int idA = interpretationService.saveInterpretation( interpretationA ); + int idB = interpretationService.saveInterpretation( interpretationB ); + int idC = interpretationService.saveInterpretation( interpretationC ); + + assertNotNull( interpretationService.getInterpretation( idA ) ); + assertNotNull( interpretationService.getInterpretation( idB ) ); + assertNotNull( interpretationService.getInterpretation( idC ) ); + + interpretationService.deleteInterpretation( interpretationB ); + + assertNotNull( interpretationService.getInterpretation( idA ) ); + assertNull( interpretationService.getInterpretation( idB ) ); + assertNotNull( interpretationService.getInterpretation( idC ) ); + + interpretationService.deleteInterpretation( interpretationA ); + + assertNull( interpretationService.getInterpretation( idA ) ); + assertNull( interpretationService.getInterpretation( idB ) ); + assertNotNull( interpretationService.getInterpretation( idC ) ); + + interpretationService.deleteInterpretation( interpretationC ); + + assertNull( interpretationService.getInterpretation( idA ) ); + assertNull( interpretationService.getInterpretation( idB ) ); + assertNull( interpretationService.getInterpretation( idC ) ); + } + + @Test + public void testGetLast() + { + interpretationService.saveInterpretation( interpretationA ); + interpretationService.saveInterpretation( interpretationB ); + interpretationService.saveInterpretation( interpretationC ); + + List interpretations = interpretationService.getInterpretations( 0, 50 ); + + assertEquals( 3, interpretations.size() ); + assertTrue( interpretations.contains( interpretationA ) ); + assertTrue( interpretations.contains( interpretationB ) ); + assertTrue( interpretations.contains( interpretationC ) ); + } +} === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java 2011-12-22 15:07:07 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/orgunitdistribution/OrgUnitDistributionServiceTest.java 2012-05-28 22:32:37 +0000 @@ -1,5 +1,32 @@ package org.hisp.dhis.orgunitdistribution; +/* + * 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 junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; @@ -12,6 +39,9 @@ import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.junit.Test; +/** + * @author Lars Helge Overland + */ public class OrgUnitDistributionServiceTest extends DhisSpringTest { === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java 2012-05-28 22:32:37 +0000 @@ -42,7 +42,6 @@ /** * @author Lars Helge Overland - * @version $Id$ */ @SuppressWarnings( "unchecked" ) public class ReportStoreTest === modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2012-05-15 09:15:16 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2012-05-28 22:32:37 +0000 @@ -288,6 +288,17 @@ @Override @SuppressWarnings( "unchecked" ) + public List getBetweenOrderderByLastUpdated( int first, int max ) + { + Criteria criteria = getCriteria(); + criteria.addOrder( Order.desc( "lastUpdated" ) ); + criteria.setFirstResult( first ); + criteria.setMaxResults( max ); + return criteria.list(); + } + + @Override + @SuppressWarnings( "unchecked" ) public Collection getBetweenByName( String name, int first, int max ) { Criteria criteria = getCriteria();