← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18762: add oneToMany, manyToOne fields on Property class, updated introspector to set values for these

 

------------------------------------------------------------
revno: 18762
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-31 11:45:20 +0700
message:
  add oneToMany, manyToOne fields on Property class, updated introspector to set values for these
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
  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/Jackson2PropertyIntrospectorService.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/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2015-03-30 02:47:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java	2015-03-31 04:45:20 +0000
@@ -208,6 +208,11 @@
     private boolean oneToMany;
 
     /**
+     * Is property many-to-one.
+     */
+    private boolean manyToOne;
+
+    /**
      * The hibernate role of the owning side.
      */
     private String owningRole;
@@ -587,6 +592,18 @@
 
     @JsonProperty
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public boolean isManyToOne()
+    {
+        return manyToOne;
+    }
+
+    public void setManyToOne( boolean manyToOne )
+    {
+        this.manyToOne = manyToOne;
+    }
+
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getOwningRole()
     {
         return owningRole;

=== 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-10 12:19:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java	2015-03-31 04:45:20 +0000
@@ -34,6 +34,8 @@
 import org.hibernate.engine.spi.SessionFactoryImplementor;
 import org.hibernate.mapping.Collection;
 import org.hibernate.mapping.Column;
+import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.OneToMany;
 import org.hibernate.mapping.PersistentClass;
 import org.hibernate.metadata.ClassMetadata;
 import org.hibernate.persister.collection.CollectionPersister;
@@ -51,6 +53,9 @@
 import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
@@ -239,6 +244,15 @@
                 }
             }
 
+            if ( ManyToOne.class.isInstance( type ) )
+            {
+                property.setManyToOne( true );
+            }
+            else if ( OneToMany.class.isInstance( type ) )
+            {
+                property.setOneToMany( true );
+            }
+
             if ( SingleColumnType.class.isInstance( type ) )
             {
                 Column column = (Column) hibernateProperty.getColumnIterator().next();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2015-03-23 07:10:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2015-03-31 04:45:20 +0000
@@ -124,6 +124,8 @@
                 property.setCascade( hibernateProperty.getCascade() );
                 property.setOwner( hibernateProperty.isOwner() );
                 property.setManyToMany( hibernateProperty.isManyToMany() );
+                property.setOneToMany( hibernateProperty.isOneToMany() );
+                property.setManyToOne( hibernateProperty.isManyToOne() );
                 property.setOwningRole( hibernateProperty.getOwningRole() );
                 property.setInverseRole( hibernateProperty.getInverseRole() );