← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17787: program attributes, wip (not reflected in UI)

 

------------------------------------------------------------
revno: 17787
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-12-23 18:19:20 +0100
message:
  program attributes, wip (not reflected in UI)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm


--
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/Attribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2014-12-19 15:41:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java	2014-12-23 17:19:20 +0000
@@ -75,6 +75,8 @@
 
     private boolean userGroupAttribute;
 
+    private boolean programAttribute;
+
     private boolean mandatory;
 
     private Integer sortOrder;
@@ -248,6 +250,19 @@
         this.userGroupAttribute = userGroupAttribute;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public boolean isProgramAttribute()
+    {
+        return programAttribute;
+    }
+
+    public void setProgramAttribute( boolean programAttribute )
+    {
+        this.programAttribute = programAttribute;
+    }
+
     public Set<AttributeValue> getAttributeValues()
     {
         return attributeValues;
@@ -291,6 +306,7 @@
             organisationUnitGroupSetAttribute = attribute.isOrganisationUnitGroupSetAttribute();
             userAttribute = attribute.isUserAttribute();
             userGroupAttribute = attribute.isUserGroupAttribute();
+            programAttribute = attribute.isProgramAttribute();
             mandatory = attribute.isMandatory();
             sortOrder = attribute.getSortOrder() == null ? sortOrder : attribute.getSortOrder();
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-12-19 16:13:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2014-12-23 17:19:20 +0000
@@ -34,6 +34,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -120,6 +121,11 @@
 
     private TrackedEntity trackedEntity;
 
+    /**
+     * Set of the dynamic attributes values that belong to this data element.
+     */
+    private Set<AttributeValue> attributeValues = new HashSet<>();
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -540,6 +546,20 @@
         this.trackedEntity = trackedEntity;
     }
 
+    @JsonProperty( "attributeValues" )
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "attributeValues", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "attributeValue", namespace = DxfNamespaces.DXF_2_0 )
+    public Set<AttributeValue> getAttributeValues()
+    {
+        return attributeValues;
+    }
+
+    public void setAttributeValues( Set<AttributeValue> attributeValues )
+    {
+        this.attributeValues = attributeValues;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other )
     {
@@ -583,6 +603,9 @@
 
             instanceReminders.clear();
             instanceReminders.addAll( program.getInstanceReminders() );
+
+            attributeValues.clear();
+            attributeValues.addAll( program.getAttributeValues() );
         }
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-12-20 13:06:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2014-12-23 17:19:20 +0000
@@ -736,6 +736,7 @@
         executeSql( "UPDATE attribute SET userattribute=false WHERE userattribute IS NULL" );
         executeSql( "UPDATE attribute SET usergroupattribute=false WHERE usergroupattribute IS NULL" );
         executeSql( "UPDATE attribute SET datasetattribute=false WHERE datasetattribute IS NULL" );
+        executeSql( "UPDATE attribute SET programattribute=false WHERE programattribute IS NULL" );
 
         executeSql( "ALTER TABLE trackedentityattributedimension DROP COLUMN operator" );
         executeSql( "ALTER TABLE trackedentitydataelementdimension DROP COLUMN operator" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml	2014-01-19 05:14:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/attribute/hibernate/Attribute.hbm.xml	2014-12-23 17:19:20 +0000
@@ -41,6 +41,8 @@
 
     <property name="userGroupAttribute" not-null="false" />
 
+    <property name="programAttribute" not-null="false" />
+
     <property name="sortOrder" />
 
     <set name="attributeValues" inverse="true" lazy="true">

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-10-06 10:11:29 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-12-23 17:19:20 +0000
@@ -86,6 +86,14 @@
     <many-to-one name="trackedEntity" class="org.hisp.dhis.trackedentity.TrackedEntity"
       column="trackedentityid" foreign-key="fk_program_trackedentityid" />
 
+    <!-- Dynamic attribute values -->
+
+    <set name="attributeValues" table="programattributevalues">
+      <cache usage="read-write" />
+      <key column="programid" />
+      <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
+    </set>
+
     <!-- Access properties -->
 
     <many-to-one name="user" class="org.hisp.dhis.user.User"

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/AddAttributeAction.java	2014-12-23 17:19:20 +0000
@@ -152,6 +152,13 @@
         this.userGroupAttribute = userGroupAttribute;
     }
 
+    private boolean programAttribute;
+
+    public void setProgramAttribute( boolean programAttribute )
+    {
+        this.programAttribute = programAttribute;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -172,6 +179,7 @@
         attribute.setOrganisationUnitGroupSetAttribute( organisationUnitGroupSetAttribute );
         attribute.setUserAttribute( userAttribute );
         attribute.setUserGroupAttribute( userGroupAttribute );
+        attribute.setProgramAttribute( programAttribute );
 
         attributeService.addAttribute( attribute );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/attribute/UpdateAttributeAction.java	2014-12-23 17:19:20 +0000
@@ -160,6 +160,13 @@
         this.userGroupAttribute = userGroupAttribute;
     }
     
+    private boolean programAttribute;
+
+    public void setProgramAttribute( boolean programAttribute )
+    {
+        this.programAttribute = programAttribute;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -185,6 +192,7 @@
             attribute.setOrganisationUnitGroupSetAttribute( organisationUnitGroupSetAttribute );
             attribute.setUserAttribute( userAttribute );
             attribute.setUserGroupAttribute( userGroupAttribute );
+            attribute.setProgramAttribute( programAttribute );
 
             attributeService.updateAttribute( attribute );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2014-11-16 10:31:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties	2014-12-23 17:19:20 +0000
@@ -261,6 +261,7 @@
 organisation_unit_group_set=Organisation Unit Group Set
 user=User
 user_group=User Group
+program=Program
 integer=Integer
 positive_integer=Positive Integer
 negative_integer=Negative Integer

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2014-01-20 10:20:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addAttributeForm.vm	2014-12-23 17:19:20 +0000
@@ -59,6 +59,7 @@
             <input type="checkbox" id="organisationUnitGroupSetAttribute" name="organisationUnitGroupSetAttribute" value="true" /><label for="organisationUnitGroupSetAttribute">$i18n.getString( 'organisation_unit_group_set' )</label> <br />
             <input type="checkbox" id="userAttribute" name="userAttribute" value="true" /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
             <input type="checkbox" id="userGroupAttribute" name="userGroupAttribute" value="true" /><label for="userGroupAttribute">$i18n.getString( 'user_group' )</label> <br />
+            <input type="checkbox" id="programAttribute" name="programAttribute" value="true" /><label for="programAttribute">$i18n.getString( 'program' )</label> <br />
 		</td>
 	</tr>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2014-01-20 10:20:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateAttributeForm.vm	2014-12-23 17:19:20 +0000
@@ -60,6 +60,7 @@
             <input type="checkbox" id="organisationUnitGroupSetAttribute" name="organisationUnitGroupSetAttribute" value="true" #if( $attribute.organisationUnitGroupSetAttribute ) checked="checked" #end /><label for="organisationUnitGroupSetAttribute">$i18n.getString( 'organisation_unit_group_set' )</label> <br />
             <input type="checkbox" id="userAttribute" name="userAttribute" value="true" #if( $attribute.userAttribute ) checked="checked" #end /><label for="userAttribute">$i18n.getString( 'user' )</label> <br />
             <input type="checkbox" id="userGroupAttribute" name="userGroupAttribute" value="true" #if( $attribute.userGroupAttribute ) checked="checked" #end /><label for="userGroupAttribute">$i18n.getString( 'user_group' )</label> <br />
+            <input type="checkbox" id="programAttribute" name="programAttribute" value="true" #if( $attribute.programAttribute ) checked="checked" #end /><label for="programAttribute">$i18n.getString( 'program' )</label> <br />
 		</td>
 	</tr>