dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41448
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21124: attributeValueStore, get all by attribute
------------------------------------------------------------
revno: 21124
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-19 12:37:09 +0700
message:
attributeValueStore, get all by attribute
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeValueStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.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/attribute/AttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2015-11-18 05:35:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeService.java 2015-11-19 05:37:09 +0000
@@ -273,6 +273,8 @@
*/
List<AttributeValue> getAllAttributeValues();
+ List<AttributeValue> getAllAttributeValuesByAttribute( Attribute attribute );
+
/**
* Gets the number of attribute values.
*
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValueStore.java 2015-11-17 04:18:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValueStore.java 2015-11-19 05:37:09 +0000
@@ -30,10 +30,13 @@
import org.hisp.dhis.common.GenericStore;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
public interface AttributeValueStore
extends GenericStore<AttributeValue>
{
+ List<AttributeValue> getAllByAttribute( Attribute attribute );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2015-11-19 04:58:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/DefaultAttributeService.java 2015-11-19 05:37:09 +0000
@@ -297,6 +297,12 @@
}
@Override
+ public List<AttributeValue> getAllAttributeValuesByAttribute( Attribute attribute )
+ {
+ return attributeValueStore.getAllByAttribute( attribute );
+ }
+
+ @Override
public int getAttributeValueCount()
{
return attributeValueStore.getCount();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeValueStore.java 2015-11-17 04:18:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeValueStore.java 2015-11-19 05:37:09 +0000
@@ -28,10 +28,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.attribute.AttributeValueStore;
import org.hisp.dhis.hibernate.HibernateGenericStore;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -39,4 +43,10 @@
extends HibernateGenericStore<AttributeValue>
implements AttributeValueStore
{
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public List<AttributeValue> getAllByAttribute( Attribute attribute )
+ {
+ return getCriteria().add( Restrictions.eq( "attribute", attribute ) ).list();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java 2015-11-17 11:55:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/attribute/AttributeValueStoreTest.java 2015-11-19 05:37:09 +0000
@@ -89,4 +89,10 @@
assertNotNull( av );
assertEquals( "value 1", av.getValue() );
}
+
+ @Test
+ public void testGetAllByAttribute()
+ {
+ assertEquals( 2, attributeValueStore.getAllByAttribute( atA ).size() );
+ }
}