dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36369
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18618: wip, metadata attributes for PS, TE, TEA
------------------------------------------------------------
revno: 18618
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-03-18 20:03:25 +0700
message:
wip, metadata attributes for PS, TE, TEA
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/ProgramStage.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml
dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml
--
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 2015-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attribute.java 2015-03-18 13:03:25 +0000
@@ -78,6 +78,12 @@
private boolean programAttribute;
+ private boolean programStageAttribute;
+
+ private boolean trackedEntityAttribute;
+
+ private boolean trackedEntityAttributeAttribute;
+
private boolean mandatory;
private Integer sortOrder;
@@ -264,6 +270,45 @@
this.programAttribute = programAttribute;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public boolean isProgramStageAttribute()
+ {
+ return programStageAttribute;
+ }
+
+ public void setProgramStageAttribute( boolean programStageAttribute )
+ {
+ this.programStageAttribute = programStageAttribute;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public boolean isTrackedEntityAttribute()
+ {
+ return trackedEntityAttribute;
+ }
+
+ public void setTrackedEntityAttribute( boolean trackedEntityAttribute )
+ {
+ this.trackedEntityAttribute = trackedEntityAttribute;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public boolean isTrackedEntityAttributeAttribute()
+ {
+ return trackedEntityAttributeAttribute;
+ }
+
+ public void setTrackedEntityAttributeAttribute( boolean trackedEntityAttributeAttribute )
+ {
+ this.trackedEntityAttributeAttribute = trackedEntityAttributeAttribute;
+ }
+
public Set<AttributeValue> getAttributeValues()
{
return attributeValues;
@@ -307,6 +352,9 @@
userAttribute = attribute.isUserAttribute();
userGroupAttribute = attribute.isUserGroupAttribute();
programAttribute = attribute.isProgramAttribute();
+ programStageAttribute = attribute.isProgramStageAttribute();
+ trackedEntityAttribute = attribute.isTrackedEntityAttribute();
+ trackedEntityAttributeAttribute = attribute.isTrackedEntityAttributeAttribute();
mandatory = attribute.isMandatory();
if ( strategy.isReplace() )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStage.java 2015-03-18 13:03:25 +0000
@@ -36,6 +36,7 @@
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;
@@ -127,6 +128,11 @@
private PeriodType periodType;
+ /**
+ * Set of the dynamic attributes values that belong to this data element.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -494,7 +500,20 @@
this.periodType = periodType;
}
-
+ @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, MergeStrategy strategy )
{
@@ -554,6 +573,9 @@
reminders.clear();
reminders.addAll( programStage.getReminders() );
+
+ attributeValues.clear();
+ attributeValues.addAll( programStage.getAttributeValues() );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntity.java 2015-03-18 13:03:25 +0000
@@ -28,9 +28,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+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.BaseNameableObject;
import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.MergeStrategy;
+import org.hisp.dhis.common.view.DetailedView;
+import org.hisp.dhis.common.view.ExportView;
+
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Chau Thu Tran
@@ -41,6 +53,11 @@
{
private static final long serialVersionUID = 3520485123419518620L;
+ /**
+ * Set of the dynamic attributes values that belong to this data element.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<>();
+
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
@@ -56,4 +73,32 @@
this.name = name;
this.description = description;
}
+
+ @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, MergeStrategy strategy )
+ {
+ super.mergeWith( other, strategy );
+
+ if ( other.getClass().isInstance( this ) )
+ {
+ TrackedEntity trackedEntity = (TrackedEntity) other;
+
+ attributeValues.clear();
+ attributeValues.addAll( trackedEntity.getAttributeValues() );
+ }
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java 2015-03-18 13:03:25 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.common.BaseDimensionalObject;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -46,6 +48,9 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* @author Abyot Asalefew
*/
@@ -95,6 +100,11 @@
private Boolean programScope = false;
+ /**
+ * Set of the dynamic attributes values that belong to this data element.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -349,6 +359,20 @@
this.confidential = confidential;
}
+ @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, MergeStrategy strategy )
{
@@ -390,6 +414,9 @@
programScope = trackedEntityAttribute.getProgramScope() == null ? programScope : trackedEntityAttribute.getProgramScope();
confidential = trackedEntityAttribute.getConfidential() == null ? confidential : trackedEntityAttribute.getConfidential();
}
+
+ attributeValues.clear();
+ attributeValues.addAll( trackedEntityAttribute.getAttributeValues() );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2015-02-24 13:16:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2015-03-18 13:03:25 +0000
@@ -29,7 +29,7 @@
<property name="textType" column="textType" length="16" />
<property name="domainType" column="domainType" type="org.hisp.dhis.dataelement.DataElementDomainUserType" not-null="true" />
-
+
<property name="aggregationOperator" not-null="true" column="aggregationtype" length="16" />
<many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo"
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2015-03-14 07:57:45 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2015-03-18 13:03:25 +0000
@@ -70,19 +70,27 @@
<property name="openAfterEnrollment" />
<property name="reportDateToUse" />
-
+
<property name="preGenerateUID" />
-
+
<list name="programIndicators" table="programstage_programindicators">
<key column="programStageid" />
<list-index column="sort_order" base="1" />
<many-to-many class="org.hisp.dhis.program.ProgramIndicator" column="programindicatorid" />
</list>
-
+
<property name="sortOrder" column="sort_order" />
-
+
<many-to-one name="periodType" lazy="false" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
foreign-key="fk_programstage_periodtypeid" />
-
+
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="programstageattributevalues">
+ <cache usage="read-write" />
+ <key column="programstageid" />
+ <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
+ </set>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml 2014-05-26 12:44:15 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntity.hbm.xml 2015-03-18 13:03:25 +0000
@@ -18,5 +18,13 @@
<property name="description" type="text" />
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="trackedentityattributevalues">
+ <cache usage="read-write" />
+ <key column="trackedentityid" />
+ <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
+ </set>
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-02-24 21:48:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/org/hisp/dhis/trackedentity/hibernate/TrackedEntityAttribute.hbm.xml 2015-03-18 13:03:25 +0000
@@ -21,11 +21,11 @@
<property name="valueType" column="valuetype" not-null="true" />
- <many-to-one name="attributeGroup" class="org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup"
- column="trackedentityattributegroupid" foreign-key="fk_trackedentityattribute_attributegroupid" />
+ <many-to-one name="attributeGroup" class="org.hisp.dhis.trackedentity.TrackedEntityAttributeGroup"
+ column="trackedentityattributegroupid" foreign-key="fk_trackedentityattribute_attributegroupid" />
- <many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet"
- column="optionsetid" foreign-key="fk_trackedentityattribute_optionsetid" />
+ <many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet"
+ column="optionsetid" foreign-key="fk_trackedentityattribute_optionsetid" />
<many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet" column="legendsetid"
foreign-key="fk_dataelement_legendset" />
@@ -39,9 +39,9 @@
<property name="sortOrderInVisitSchedule" />
<property name="displayInListNoProgram" />
-
+
<property name="sortOrderInListNoProgram" />
-
+
<property name="confidential" />
<property name="unique" column="uniquefield" />
@@ -49,10 +49,10 @@
<property name="orgunitScope" />
<property name="programScope" />
-
+
<!-- Access properties -->
- <many-to-one name="user" class="org.hisp.dhis.user.User"
- column="userid" foreign-key="fk_trackedentityattribute_userid" />
+ <many-to-one name="user" class="org.hisp.dhis.user.User"
+ column="userid" foreign-key="fk_trackedentityattribute_userid" />
<property name="publicAccess" length="8" />
@@ -62,5 +62,13 @@
<many-to-many class="org.hisp.dhis.user.UserGroupAccess" column="usergroupaccessid" unique="true" />
</set>
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="trackedentityattributeattributevalues">
+ <cache usage="read-write" />
+ <key column="trackedentityattributeid" />
+ <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
+ </set>
+
</class>
</hibernate-mapping>