dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22724
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11015: Map data element operand, proper save
------------------------------------------------------------
revno: 11015
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-05-27 14:47:46 +0200
message:
Map data element operand, proper save
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.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/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2013-05-19 18:49:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2013-05-27 12:47:46 +0000
@@ -151,6 +151,11 @@
@Override
public String getUid()
{
+ if ( uid != null )
+ {
+ return uid;
+ }
+
String uid = null;
if ( dataElement != null )
@@ -522,6 +527,7 @@
{
return "DataElementOperand{" +
"id=" + id +
+ ", uid=" + uid +
", dataElement=" + dataElement +
", categoryOptionCombo=" + categoryOptionCombo +
", dataElementId=" + dataElementId +
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java 2012-11-07 07:06:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java 2013-05-27 12:47:46 +0000
@@ -31,6 +31,8 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.DataElementOperandService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -54,6 +56,13 @@
{
this.mappingService = mappingService;
}
+
+ private DataElementOperandService operandService;
+
+ public void setOperandService( DataElementOperandService operandService )
+ {
+ this.operandService = operandService;
+ }
// -------------------------------------------------------------------------
// DeletionHandler implementation
@@ -66,6 +75,18 @@
}
@Override
+ public void deleteMapView( MapView mapView )
+ {
+ DataElementOperand operand = mapView.getDataElementOperand();
+
+ if ( operand != null )
+ {
+ mapView.setDataElementOperand( null );
+ operandService.deleteDataElementOperand( operand );
+ }
+ }
+
+ @Override
public String allowDeletePeriod( Period period )
{
for ( MapView mapView : mappingService.getAllMapViews() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-05-27 11:34:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-05-27 12:47:46 +0000
@@ -962,6 +962,7 @@
<bean id="org.hisp.dhis.mapping.MapViewDeletionHandler" class="org.hisp.dhis.mapping.MapViewDeletionHandler">
<property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+ <property name="operandService" ref="org.hisp.dhis.dataelement.DataElementOperandService" />
</bean>
<!-- DeletionManager -->
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2013-05-24 16:59:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2013-05-27 12:47:46 +0000
@@ -34,10 +34,11 @@
<many-to-one name="dataElement" class="org.hisp.dhis.dataelement.DataElement" column="dataelementid"
foreign-key="fk_mapview_dataelementid" />
- <one-to-one name="dataElementOperand" class="org.hisp.dhis.dataelement.DataElementOperand"
- foreign-key="fk_mapview_dataelementoperandid" cascade="all-delete-orphan" />
+ <many-to-one name="dataElementOperand" class="org.hisp.dhis.dataelement.DataElementOperand" column="dataelementoperandid"
+ foreign-key="fk_mapview_dataelementoperandid" cascade="all" />
- <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid" foreign-key="fk_mapview_periodid" />
+ <many-to-one name="period" class="org.hisp.dhis.period.Period" column="periodid"
+ foreign-key="fk_mapview_periodid" />
<many-to-one name="parentOrganisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
column="parentorganisationunitid" foreign-key="fk_mapview_parentorganisationunitid" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-05-24 15:23:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-05-27 12:47:46 +0000
@@ -200,8 +200,6 @@
// Supportive methods
//--------------------------------------------------------------------------
- // TODO use the import service instead
-
private void mergeMap( Map map )
{
if ( map.getUser() != null )