dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36137
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18500: add utility methods to get getter/setter by role on Schema (only applicable to collection with ma...
------------------------------------------------------------
revno: 18500
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-06 13:57:45 +0700
message:
add utility methods to get getter/setter by role on Schema (only applicable to collection with many-to-many mapping)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.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/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2015-02-20 04:18:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2015-03-06 06:57:45 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.common.NameableObject;
import org.springframework.core.Ordered;
+import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
@@ -327,6 +328,32 @@
return getPropertyMap().containsKey( propertyName );
}
+ public Method getterByRole( String role )
+ {
+ for ( Property property : propertyMap.values() )
+ {
+ if ( property.isCollection() && property.isManyToMany() && (property.getOwningRole().equals( role ) || property.getInverseRole().equals( role )) )
+ {
+ return property.getGetterMethod();
+ }
+ }
+
+ return null;
+ }
+
+ public Method setterByRole( String role )
+ {
+ for ( Property property : propertyMap.values() )
+ {
+ if ( property.isCollection() && property.isManyToMany() && (property.getOwningRole().equals( role ) || property.getInverseRole().equals( role )) )
+ {
+ return property.getSetterMethod();
+ }
+ }
+
+ return null;
+ }
+
@JsonIgnore
public Map<String, Property> getPropertyMap()
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2015-03-06 05:37:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2015-03-06 06:57:45 +0000
@@ -221,7 +221,6 @@
if ( property.isCollection() )
{
-
CollectionType collectionType = (CollectionType) type;
Collection collection = sessionFactoryBean.getConfiguration().getCollectionMapping( collectionType.getRole() );
CollectionPersister collectionPersister = sessionFactoryImplementor.getCollectionPersister( collection.getRole() );