dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14090
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4650: updated deletionhandlers to handle attributevalues
------------------------------------------------------------
revno: 4650
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-22 15:25:54 +0200
message:
updated deletionhandlers to handle attributevalues
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java 2011-06-22 06:57:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java 2011-09-22 13:25:54 +0000
@@ -29,6 +29,10 @@
import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
+import java.util.Iterator;
+
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -57,6 +61,13 @@
this.categoryService = categoryService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -68,6 +79,22 @@
}
@Override
+ public void deleteDataElement( DataElement dataElement )
+ {
+ // Delete attributeValues
+ Iterator<AttributeValue> iterator = dataElement.getAttributeValues().iterator();
+
+ while ( iterator.hasNext() )
+ {
+ AttributeValue attributeValue = iterator.next();
+ iterator.remove();
+ attributeService.deleteAttributeValue( attributeValue );
+ }
+
+ dataElementService.updateDataElement( dataElement );
+ }
+
+ @Override
public void deleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
{
DataElementCategoryCombo default_ = categoryService
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java 2011-07-14 10:31:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java 2011-09-22 13:25:54 +0000
@@ -27,8 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Iterator;
import java.util.Set;
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -61,6 +64,13 @@
this.expressionService = expressionService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -72,6 +82,22 @@
}
@Override
+ public void deleteIndicator( Indicator indicator )
+ {
+ // Delete attributeValues
+ Iterator<AttributeValue> iterator = indicator.getAttributeValues().iterator();
+
+ while ( iterator.hasNext() )
+ {
+ AttributeValue attributeValue = iterator.next();
+ iterator.remove();
+ attributeService.deleteAttributeValue( attributeValue );
+ }
+
+ indicatorService.updateIndicator( indicator );
+ }
+
+ @Override
public boolean allowDeleteIndicatorType( IndicatorType indicatorType )
{
for ( Indicator indicator : indicatorService.getAllIndicators() )
@@ -108,7 +134,7 @@
}
}
}
-
+
@Override
public void deleteDataSet( DataSet dataSet )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitDeletionHandler.java 2011-06-22 06:57:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitDeletionHandler.java 2011-09-22 13:25:54 +0000
@@ -27,6 +27,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Iterator;
+
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.system.deletion.DeletionHandler;
import org.hisp.dhis.user.User;
@@ -48,6 +52,13 @@
this.organisationUnitService = organisationUnitService;
}
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -57,7 +68,23 @@
{
return OrganisationUnit.class.getSimpleName();
}
-
+
+ @Override
+ public void deleteOrganisationUnit( OrganisationUnit unit )
+ {
+ // Delete attributeValues
+ Iterator<AttributeValue> iterator = unit.getAttributeValues().iterator();
+
+ while ( iterator.hasNext() )
+ {
+ AttributeValue attributeValue = iterator.next();
+ iterator.remove();
+ attributeService.deleteAttributeValue( attributeValue );
+ }
+
+ organisationUnitService.updateOrganisationUnit( unit );
+ }
+
@Override
public void deleteDataSet( DataSet dataSet )
{
@@ -69,7 +96,7 @@
}
}
}
-
+
@Override
public void deleteUser( User user )
{
@@ -81,7 +108,7 @@
}
}
}
-
+
@Override
public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java 2011-06-22 06:57:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java 2011-09-22 13:25:54 +0000
@@ -27,6 +27,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Iterator;
+
+import org.hisp.dhis.attribute.AttributeService;
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -47,7 +51,14 @@
{
this.userService = userService;
}
-
+
+ private AttributeService attributeService;
+
+ public void setAttributeService( AttributeService attributeService )
+ {
+ this.attributeService = attributeService;
+ }
+
// -------------------------------------------------------------------------
// DeletionHandler implementation
// -------------------------------------------------------------------------
@@ -57,7 +68,23 @@
{
return User.class.getSimpleName();
}
-
+
+ @Override
+ public void deleteUser( User user )
+ {
+ // Delete attributeValues
+ Iterator<AttributeValue> iterator = user.getAttributeValues().iterator();
+
+ while ( iterator.hasNext() )
+ {
+ AttributeValue attributeValue = iterator.next();
+ iterator.remove();
+ attributeService.deleteAttributeValue( attributeValue );
+ }
+
+ userService.updateUser( user );
+ }
+
@Override
public void deleteOrganisationUnit( OrganisationUnit unit )
{
@@ -69,7 +96,7 @@
}
}
}
-
+
@Override
public boolean allowDeleteUserAuthorityGroup( UserAuthorityGroup authorityGroup )
{
@@ -77,7 +104,7 @@
{
if ( credentials != null && credentials.getUserAuthorityGroups() != null )
{
- for ( UserAuthorityGroup role : credentials.getUserAuthorityGroups())
+ for ( UserAuthorityGroup role : credentials.getUserAuthorityGroups() )
{
if ( role.equals( authorityGroup ) )
{
@@ -86,7 +113,7 @@
}
}
}
-
+
return true;
}
}
=== 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 2011-09-12 10:48:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-09-22 13:25:54 +0000
@@ -1054,6 +1054,7 @@
<bean id="org.hisp.dhis.dataelement.DataElementDeletionHandler" class="org.hisp.dhis.dataelement.DataElementDeletionHandler">
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.dataelement.DataElementGroupDeletionHandler" class="org.hisp.dhis.dataelement.DataElementGroupDeletionHandler">
@@ -1093,6 +1094,7 @@
<bean id="org.hisp.dhis.indicator.IndicatorDeletionHandler" class="org.hisp.dhis.indicator.IndicatorDeletionHandler">
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.indicator.IndicatorGroupDeletionHandler" class="org.hisp.dhis.indicator.IndicatorGroupDeletionHandler">
@@ -1121,6 +1123,7 @@
<bean id="org.hisp.dhis.organisationunit.OrganisationUnitDeletionHandler" class="org.hisp.dhis.organisationunit.OrganisationUnitDeletionHandler">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.organisationunit.OrganisationUnitGroupDeletionHandler" class="org.hisp.dhis.organisationunit.OrganisationUnitGroupDeletionHandler">
@@ -1137,6 +1140,7 @@
<bean id="org.hisp.dhis.user.UserDeletionHandler" class="org.hisp.dhis.user.UserDeletionHandler">
<property name="userService" ref="org.hisp.dhis.user.UserService" />
+ <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
</bean>
<bean id="org.hisp.dhis.user.UserAuthorityGroupDeletionHandler" class="org.hisp.dhis.user.UserAuthorityGroupDeletionHandler">
@@ -1239,29 +1243,14 @@
method="intercept" />
</aop:aspect>
- <!--
- <aop:aspect ref="i18nTranslationInterceptor"> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.dataelement.DataElementService.get*(..) )"
- method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.dataelement.DataElementCategoryService.get*(..) )"
- method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.indicator.IndicatorService.get*(..) )"
- method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.datadictionary.DataDictionaryService.get*(..) )"
- method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( * org.hisp.dhis.dataset.DataSetService.get*(..)
- )" method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.organisationunit.OrganisationUnitService.get*(..) )"
- method="intercept" returning="object"/> <aop:after-returning
- pointcut="execution( *
- org.hisp.dhis.organisationunit.OrganisationUnitGroupService.get*(..)
- )" method="intercept" returning="object"/> </aop:aspect>
- -->
+ <!-- <aop:aspect ref="i18nTranslationInterceptor"> <aop:after-returning pointcut="execution( * org.hisp.dhis.dataelement.DataElementService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.dataelement.DataElementCategoryService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.indicator.IndicatorService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.datadictionary.DataDictionaryService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.dataset.DataSetService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.organisationunit.OrganisationUnitService.get*(..)
+ )" method="intercept" returning="object"/> <aop:after-returning pointcut="execution( * org.hisp.dhis.organisationunit.OrganisationUnitGroupService.get*(..)
+ )" method="intercept" returning="object"/> </aop:aspect> -->
</aop:config>
<!-- Security import -->
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2011-07-28 03:25:28 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2011-09-22 13:25:54 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartGroup;