dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38969
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19784: add attributes to categoryOption/categoryOptionGroup, wip
------------------------------------------------------------
revno: 19784
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-08-19 10:02:24 +0700
message:
add attributes to categoryOption/categoryOptionGroup, wip
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryOptionGroup.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/CategoryOptionGroup.hbm.xml
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/DataElementCategoryOption.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.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/dataelement/CategoryOptionGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryOptionGroup.java 2015-07-13 12:34:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/CategoryOptionGroup.java 2015-08-19 03:02:24 +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.BaseNameableObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -58,6 +59,11 @@
private CategoryOptionGroupSet groupSet;
+ /**
+ * Set of the dynamic attributes values that belong to this data element.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -122,6 +128,20 @@
this.groupSet = groupSet;
}
+ @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 )
{
@@ -146,6 +166,9 @@
{
addCategoryOption( categoryOption );
}
+
+ attributeValues.clear();
+ attributeValues.addAll( categoryOptionGroup.getAttributeValues() );
}
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2015-07-13 12:34:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOption.java 2015-08-19 03:02:24 +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.BaseNameableObject;
import org.hisp.dhis.common.DxfNamespaces;
@@ -76,6 +77,11 @@
private Set<CategoryOptionGroup> groups = new HashSet<>();
+ /**
+ * Set of the dynamic attributes values that belong to this data element.
+ */
+ private Set<AttributeValue> attributeValues = new HashSet<>();
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -259,6 +265,20 @@
this.groups = groups;
}
+ @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 )
{
@@ -288,6 +308,8 @@
categories.addAll( categoryOption.getCategories() );
groups.addAll( categoryOption.getGroups() );
categoryOptionCombos.addAll( categoryOption.getCategoryOptionCombos() );
+ attributeValues.clear();
+ attributeValues.addAll( categoryOption.getAttributeValues() );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/CategoryOptionGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/CategoryOptionGroup.hbm.xml 2014-05-12 20:45:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/CategoryOptionGroup.hbm.xml 2015-08-19 03:02:24 +0000
@@ -26,6 +26,14 @@
foreign-key="fk_categoryoptiongroupmembers_categoryoptiongroupid" />
</set>
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="categoryoptiongroupattributevalues">
+ <cache usage="read-write" />
+ <key column="categoryoptiongroupid" />
+ <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" column="userid" foreign-key="fk_categoryoptiongroup_userid" />
=== 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-03-18 13:03:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2015-08-19 03:02:24 +0000
@@ -58,14 +58,6 @@
<property name="zeroIsSignificant" not-null="true" />
- <!-- Dynamic attribute values -->
-
- <set name="attributeValues" table="dataelementattributevalues">
- <cache usage="read-write" />
- <key column="dataelementid" />
- <many-to-many class="org.hisp.dhis.attribute.AttributeValue" column="attributevalueid" unique="true" />
- </set>
-
<many-to-one name="optionSet" class="org.hisp.dhis.option.OptionSet" column="optionsetid"
foreign-key="fk_dataelement_optionsetid" />
@@ -75,6 +67,14 @@
<many-to-one name="legendSet" class="org.hisp.dhis.legend.LegendSet" column="legendsetid"
foreign-key="fk_dataelement_legendset" />
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="dataelementattributevalues">
+ <cache usage="read-write" />
+ <key column="dataelementid" />
+ <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" column="userid" foreign-key="fk_dataelement_userid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml 2014-11-15 13:26:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementCategoryOption.hbm.xml 2015-08-19 03:02:24 +0000
@@ -3,7 +3,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"
[<!ENTITY identifiableProperties SYSTEM "classpath://org/hisp/dhis/common/identifiableProperties.hbm">]
->
+ >
<hibernate-mapping>
<class name="org.hisp.dhis.dataelement.DataElementCategoryOption" table="dataelementcategoryoption">
@@ -49,6 +49,14 @@
<many-to-many class="org.hisp.dhis.dataelement.CategoryOptionGroup" column="categoryoptiongroupid" />
</set>
+ <!-- Dynamic attribute values -->
+
+ <set name="attributeValues" table="dataelementcategoryoptionattributevalues">
+ <cache usage="read-write" />
+ <key column="categoryoptionid" />
+ <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" column="userid" foreign-key="fk_dataelementcategoryoption_userid" />
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2015-07-03 01:33:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java 2015-08-19 03:02:24 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
+import org.springframework.beans.factory.annotation.Autowired;
/**
* @author Torgeir Lorange Ostby
@@ -60,41 +61,21 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private DataElementService dataElementService;
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
+ @Autowired
private DataElementCategoryService dataElementCategoryService;
- public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
- {
- this.dataElementCategoryService = dataElementCategoryService;
- }
-
+ @Autowired
private AttributeService attributeService;
- public void setAttributeService( AttributeService attributeService )
- {
- this.attributeService = attributeService;
- }
-
+ @Autowired
private OptionService optionService;
- public void setOptionService( OptionService optionService )
- {
- this.optionService = optionService;
- }
-
+ @Autowired
private LegendService legendService;
- public void setLegendService( LegendService legendService )
- {
- this.legendService = legendService;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java 2015-07-03 01:33:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java 2015-08-19 03:02:24 +0000
@@ -52,6 +52,7 @@
import org.hisp.dhis.system.util.AttributeUtils;
import com.opensymphony.xwork2.Action;
+import org.springframework.beans.factory.annotation.Autowired;
/**
* @author Torgeir Lorange Ostby
@@ -63,48 +64,24 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
private DataElementService dataElementService;
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
+ @Autowired
private DataElementCategoryService dataElementCategoryService;
- public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
- {
- this.dataElementCategoryService = dataElementCategoryService;
- }
-
+ @Autowired
private DataSetService dataSetService;
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
+ @Autowired
private AttributeService attributeService;
- public void setAttributeService( AttributeService attributeService )
- {
- this.attributeService = attributeService;
- }
-
+ @Autowired
private OptionService optionService;
- public void setOptionService( OptionService optionService )
- {
- this.optionService = optionService;
- }
-
+ @Autowired
private LegendService legendService;
- public void setLegendService( LegendService legendService )
- {
- this.legendService = legendService;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml 2015-02-24 13:16:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/META-INF/dhis/beans.xml 2015-08-19 03:02:24 +0000
@@ -37,21 +37,10 @@
<bean id="org.hisp.dhis.dd.action.dataelement.AddDataElementAction" class="org.hisp.dhis.dd.action.dataelement.AddDataElementAction"
scope="prototype">
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
- <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
- <property name="legendService" ref="org.hisp.dhis.legend.LegendService" />
</bean>
<bean id="org.hisp.dhis.dd.action.dataelement.UpdateDataElementAction" class="org.hisp.dhis.dd.action.dataelement.UpdateDataElementAction"
scope="prototype">
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- <property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
- <property name="optionService" ref="org.hisp.dhis.option.OptionService" />
- <property name="legendService" ref="org.hisp.dhis.legend.LegendService" />
</bean>
<bean id="org.hisp.dhis.dd.action.dataelement.ShowDataElementFormAction" class="org.hisp.dhis.dd.action.dataelement.ShowDataElementFormAction"