dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42000
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21456: made it more clear that manager.getByAttributeValue is only applicable for unique attribute value...
------------------------------------------------------------
revno: 21456
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-15 11:01:19 +0100
message:
made it more clear that manager.getByAttributeValue is only applicable for unique attribute values (renamed getByUniqueAttributeValue)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.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/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2015-12-03 03:12:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2015-12-15 10:01:19 +0000
@@ -81,7 +81,7 @@
*/
T getByCode( String code );
- T getByAttributeValue( Attribute attribute, String value );
+ T getByUniqueAttributeValue( Attribute attribute, String value );
/**
* Retrieves a List of all objects (sorted on name).
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2015-12-04 05:41:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2015-12-15 10:01:19 +0000
@@ -67,7 +67,7 @@
<T extends IdentifiableObject> T getByName( Class<T> clazz, String name );
- <T extends IdentifiableObject> T getByAttributeValue( Class<T> clazz, Attribute attribute, String value );
+ <T extends IdentifiableObject> T getByUniqueAttributeValue( Class<T> clazz, Attribute attribute, String value );
<T extends IdentifiableObject> T search( Class<T> clazz, String query );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2015-12-04 05:41:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2015-12-15 10:01:19 +0000
@@ -242,7 +242,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public <T extends IdentifiableObject> T getByAttributeValue( Class<T> clazz, Attribute attribute, String value )
+ public <T extends IdentifiableObject> T getByUniqueAttributeValue( Class<T> clazz, Attribute attribute, String value )
{
GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -251,7 +251,7 @@
return null;
}
- return (T) store.getByAttributeValue( attribute, value );
+ return (T) store.getByUniqueAttributeValue( attribute, value );
}
@Override
@@ -848,7 +848,7 @@
}
if ( idScheme.is( IdentifiableProperty.ATTRIBUTE ) )
{
- return store.getByAttributeValue( attribute, value );
+ return store.getByUniqueAttributeValue( attribute, value );
}
else if ( idScheme.is( IdentifiableProperty.ID ) )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-12-03 04:18:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java 2015-12-15 10:01:19 +0000
@@ -175,7 +175,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public T getByAttributeValue( Attribute attribute, String value )
+ public T getByUniqueAttributeValue( Attribute attribute, String value )
{
if ( attribute == null || StringUtils.isEmpty( value ) || !attribute.isUnique() )
{
=== 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 2015-12-03 03:21:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java 2015-12-15 10:01:19 +0000
@@ -534,15 +534,15 @@
dataElementStore.update( dataElementB );
dataElementStore.update( dataElementC );
- assertNotNull( dataElementStore.getByAttributeValue( attribute, "CID1" ) );
- assertNotNull( dataElementStore.getByAttributeValue( attribute, "CID2" ) );
- assertNotNull( dataElementStore.getByAttributeValue( attribute, "CID3" ) );
- assertNull( dataElementStore.getByAttributeValue( attribute, "CID4" ) );
- assertNull( dataElementStore.getByAttributeValue( attribute, "CID5" ) );
+ assertNotNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID1" ) );
+ assertNotNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID2" ) );
+ assertNotNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID3" ) );
+ assertNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID4" ) );
+ assertNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID5" ) );
- assertEquals( "DataElementA", dataElementStore.getByAttributeValue( attribute, "CID1" ).getName() );
- assertEquals( "DataElementB", dataElementStore.getByAttributeValue( attribute, "CID2" ).getName() );
- assertEquals( "DataElementC", dataElementStore.getByAttributeValue( attribute, "CID3" ).getName() );
+ assertEquals( "DataElementA", dataElementStore.getByUniqueAttributeValue( attribute, "CID1" ).getName() );
+ assertEquals( "DataElementB", dataElementStore.getByUniqueAttributeValue( attribute, "CID2" ).getName() );
+ assertEquals( "DataElementC", dataElementStore.getByUniqueAttributeValue( attribute, "CID3" ).getName() );
}
@Test
@@ -572,8 +572,8 @@
dataElementStore.update( dataElementB );
dataElementStore.update( dataElementC );
- assertNull( dataElementStore.getByAttributeValue( attribute, "CID1" ) );
- assertNull( dataElementStore.getByAttributeValue( attribute, "CID2" ) );
- assertNull( dataElementStore.getByAttributeValue( attribute, "CID3" ) );
+ assertNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID1" ) );
+ assertNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID2" ) );
+ assertNull( dataElementStore.getByUniqueAttributeValue( attribute, "CID3" ) );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-12-14 08:58:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-12-15 10:01:19 +0000
@@ -1315,7 +1315,7 @@
else if ( idScheme.is( IdentifiableProperty.ATTRIBUTE ) )
{
Attribute attribute = manager.get( Attribute.class, idScheme.getAttribute() );
- organisationUnit = manager.getByAttributeValue( OrganisationUnit.class, attribute, value );
+ organisationUnit = manager.getByUniqueAttributeValue( OrganisationUnit.class, attribute, value );
}
else
{