dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02993
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 993: Implemented DataElementStore.getDataElementsWithGroupSets and IndicatorStore.getIndicatorsWithGro...
------------------------------------------------------------
revno: 993
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-11-07 14:03:26 +0100
message:
Implemented DataElementStore.getDataElementsWithGroupSets and IndicatorStore.getIndicatorsWithGroupSets
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/pom.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.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2009-11-06 10:50:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2009-11-07 13:03:26 +0000
@@ -221,6 +221,13 @@
* @return all DataElements with the given category combo.
*/
Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
+
+ /**
+ * Returns all DataElements which are associated with one or more DataElementGroupSets.
+ *
+ * @return all DataElements which are associated with one or more DataElementGroupSets.
+ */
+ Collection<DataElement> getDataElementsWithGroupSets();
// -------------------------------------------------------------------------
// Calculated Data Elements
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2009-11-06 10:50:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2009-11-07 13:03:26 +0000
@@ -179,6 +179,13 @@
* @return all DataElements with the given category combo.
*/
Collection<DataElement> getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo );
+
+ /**
+ * Returns all DataElements which are associated with one or more DataElementGroupSets.
+ *
+ * @return all DataElements which are associated with one or more DataElementGroupSets.
+ */
+ Collection<DataElement> getDataElementsWithGroupSets();
// -------------------------------------------------------------------------
// Calculated Data Elements
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2009-11-01 20:57:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2009-11-07 13:03:26 +0000
@@ -62,6 +62,8 @@
Indicator getIndicatorByAlternativeName( String alternativeName );
Indicator getIndicatorByCode( String code );
+
+ Collection<Indicator> getIndicatorsWithGroupSets();
// -------------------------------------------------------------------------
// IndicatorType
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java 2009-10-27 17:41:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java 2009-11-07 13:03:26 +0000
@@ -56,4 +56,6 @@
Indicator getIndicatorByAlternativeName( String alternativeName );
Indicator getIndicatorByCode( String code );
+
+ Collection<Indicator> getIndicatorsWithGroupSets();
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2009-11-06 10:50:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2009-11-07 13:03:26 +0000
@@ -259,6 +259,11 @@
return dataElementStore.getDataElementByCategoryCombo( categoryCombo );
}
+ public Collection<DataElement> getDataElementsWithGroupSets()
+ {
+ return dataElementStore.getDataElementsWithGroupSets();
+ }
+
// -------------------------------------------------------------------------
// CalculatedDataElement
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2009-11-06 10:50:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2009-11-07 13:03:26 +0000
@@ -32,6 +32,7 @@
import java.util.Set;
import org.hibernate.Criteria;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
@@ -227,6 +228,16 @@
return criteria.list();
}
+ @SuppressWarnings( "unchecked" )
+ public Collection<DataElement> getDataElementsWithGroupSets()
+ {
+ final String sql = "from DataElement d where d.groupSets.size > 0";
+
+ Query query = sessionFactory.getCurrentSession().createQuery( sql );
+
+ return query.list();
+ }
+
// -------------------------------------------------------------------------
// CalculatedDataElement
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2009-11-03 11:04:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2009-11-07 13:03:26 +0000
@@ -172,6 +172,11 @@
return indicatorStore.getIndicatorByCode( code );
}
+ public Collection<Indicator> getIndicatorsWithGroupSets()
+ {
+ return indicatorStore.getIndicatorsWithGroupSets();
+ }
+
// -------------------------------------------------------------------------
// IndicatorType
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java 2009-10-27 17:41:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/hibernate/HibernateIndicatorStore.java 2009-11-07 13:03:26 +0000
@@ -34,6 +34,7 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorStore;
@@ -42,7 +43,7 @@
* @version $Id: HibernateIndicatorStore.java 3287 2007-05-08 00:26:53Z larshelg $
*/
public class HibernateIndicatorStore
- implements IndicatorStore
+ extends HibernateGenericStore<Indicator> implements IndicatorStore
{
// -------------------------------------------------------------------------
// Dependencies
@@ -151,4 +152,14 @@
return (Indicator) query.uniqueResult();
}
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<Indicator> getIndicatorsWithGroupSets()
+ {
+ final String sql = "from Indicator d where d.groupSets.size > 0";
+
+ Query query = sessionFactory.getCurrentSession().createQuery( sql );
+
+ return query.list();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml 2009-11-06 10:21:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml 2009-11-07 13:03:26 +0000
@@ -65,5 +65,12 @@
<many-to-many class="org.hisp.dhis.indicator.IndicatorGroup" column="indicatorgroupid"/>
</set>
+ <list name="groupSets" table="indicator_indicatorgroupsetmembers">
+ <key column="indicatorid"/>
+ <list-index column="sort_order" base="0"/>
+ <many-to-many class="org.hisp.dhis.indicator.IndicatorGroupSet"
+ column="indicatorgroupsetid" foreign-key="fk_indicator_indicatorgroupsetid"/>
+ </list>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2009-11-03 14:25:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2009-11-07 13:03:26 +0000
@@ -9,9 +9,9 @@
<generator class="native"/>
</id>
- <property name="uuid">
- <column name="uuid" length="40"/>
- </property>
+ <property name="uuid">
+ <column name="uuid" length="40"/>
+ </property>
<property name="name">
<column name="name" not-null="true" unique="true" length="230"/>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java 2009-11-06 10:50:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java 2009-11-07 13:03:26 +0000
@@ -54,7 +54,7 @@
extends DhisSpringTest
{
private DataElementStore dataElementStore;
-
+
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@@ -64,6 +64,8 @@
throws Exception
{
dataElementStore = (DataElementStore) getBean( DataElementStore.ID );
+
+ dataElementService = (DataElementService) getBean( DataElementService.ID );
}
// -------------------------------------------------------------------------
@@ -474,6 +476,33 @@
assertEquals( 2, dataElementStore.getDataElement( idA ).getAggregationLevels().size() );
assertEquals( aggregationLevels, dataElementStore.getDataElement( idA ).getAggregationLevels() );
}
+
+ @Test
+ public void testGetDataElementsWithGroupSets()
+ {
+ DataElementGroupSet groupSetA = createDataElementGroupSet( 'A' );
+
+ dataElementService.addDataElementGroupSet( groupSetA );
+
+ DataElement dataElementA = createDataElement( 'A' );
+ DataElement dataElementB = createDataElement( 'B' );
+ DataElement dataElementC = createDataElement( 'C' );
+ DataElement dataElementD = createDataElement( 'D' );
+
+ dataElementB.getGroupSets().add( groupSetA );
+ dataElementD.getGroupSets().add( groupSetA );
+
+ dataElementStore.addDataElement( dataElementA );
+ dataElementStore.addDataElement( dataElementB );
+ dataElementStore.addDataElement( dataElementC );
+ dataElementStore.addDataElement( dataElementD );
+
+ Collection<DataElement> dataElements = dataElementStore.getDataElementsWithGroupSets();
+
+ assertEquals( 2, dataElements.size() );
+ assertTrue( dataElements.contains( dataElementB ) );
+ assertTrue( dataElements.contains( dataElementD ) );
+ }
// -------------------------------------------------------------------------
// CalculatedDataElements
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java 2009-10-27 17:41:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/indicator/IndicatorStoreTest.java 2009-11-07 13:03:26 +0000
@@ -63,6 +63,8 @@
indicatorStore = (IndicatorStore) getBean( IndicatorStore.ID );
indicatorTypeStore = (GenericIdentifiableObjectStore<IndicatorType>) getBean( "org.hisp.dhis.indicator.IndicatorTypeStore" );
+
+ indicatorService = (IndicatorService) getBean( IndicatorService.ID );
}
// -------------------------------------------------------------------------
@@ -414,5 +416,37 @@
Indicator indicatorC = indicatorStore.getIndicatorByCode( "CodeC" );
assertNull( indicatorC );
+ }
+
+ @Test
+ public void testGetIndicatorsWithGroupSets()
+ throws Exception
+ {
+ IndicatorGroupSet groupSetA = createIndicatorGroupSet( 'A' );
+
+ indicatorService.addIndicatorGroupSet( groupSetA );
+
+ IndicatorType type = new IndicatorType( "IndicatorType", 100 );
+
+ indicatorTypeStore.save( type );
+
+ Indicator indicatorA = createIndicator( 'A', type );
+ Indicator indicatorB = createIndicator( 'B', type );
+ Indicator indicatorC = createIndicator( 'C', type );
+ Indicator indicatorD = createIndicator( 'D', type );
+
+ indicatorB.getGroupSets().add( groupSetA );
+ indicatorD.getGroupSets().add( groupSetA );
+
+ indicatorStore.addIndicator( indicatorA );
+ indicatorStore.addIndicator( indicatorB );
+ indicatorStore.addIndicator( indicatorC );
+ indicatorStore.addIndicator( indicatorD );
+
+ Collection<Indicator> indicators = indicatorStore.getIndicatorsWithGroupSets();
+
+ assertEquals( 2, indicators.size() );
+ assertTrue( indicators.contains( indicatorB ) );
+ assertTrue( indicators.contains( indicatorD ) );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/pom.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/pom.xml 2009-11-03 14:24:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/pom.xml 2009-11-07 13:03:26 +0000
@@ -31,6 +31,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-web-commons</artifactId>
</dependency>
<dependency>