dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34911
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17909: Deletion handling for category option groups
------------------------------------------------------------
revno: 17909
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-07 19:22:38 +0100
message:
Deletion handling for category option groups
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.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/chart/ChartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2014-09-15 20:06:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2015-01-07 18:22:38 +0000
@@ -33,6 +33,7 @@
import java.util.List;
import java.util.Map;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.DataSet;
@@ -118,4 +119,6 @@
int countDataElementCharts( DataElement dataElement );
int countOrganisationUnitCharts( OrganisationUnit organisationUnit );
+
+ int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java 2014-04-28 11:24:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java 2015-01-07 18:22:38 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
@@ -46,4 +47,6 @@
int countDataElementAnalyticalObject( DataElement dataElement );
int countOrganisationUnitAnalyticalObject( OrganisationUnit organisationUnit );
+
+ int countCategoryOptionGroupAnalyticalObject( CategoryOptionGroup categoryOptionGroup );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2014-04-28 11:24:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2015-01-07 18:22:38 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
@@ -156,4 +157,6 @@
int countDataElementReportTables( DataElement dataElement );
int countOrganisationUnitReportTables( OrganisationUnit organisationUnit );
+
+ int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java 2014-04-28 11:24:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java 2015-01-07 18:22:38 +0000
@@ -31,6 +31,7 @@
import org.hibernate.Query;
import org.hisp.dhis.common.AnalyticalObjectStore;
import org.hisp.dhis.common.BaseAnalyticalObject;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
@@ -77,4 +78,13 @@
return ((Long) query.uniqueResult()).intValue();
}
+
+ @Override
+ public int countCategoryOptionGroupAnalyticalObject( CategoryOptionGroup categoryOptionGroup )
+ {
+ Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where :categoryOptionGroup in elements(c.categoryOptionGroups)" );
+ query.setEntity( "categoryOptionGroup", categoryOptionGroup );
+
+ return ((Long) query.uniqueResult()).intValue();
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2014-04-28 11:24:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2015-01-07 18:22:38 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
@@ -85,4 +86,10 @@
{
return chartService.countOrganisationUnitCharts( organisationUnit ) == 0 ? null : ERROR;
}
+
+ @Override
+ public String allowDeleteCategoryOptionGroup( CategoryOptionGroup categoryOptionGroup )
+ {
+ return chartService.countCategoryOptionGroups( categoryOptionGroup ) == 0 ? null : ERROR;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2014-11-21 10:22:56 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2015-01-07 18:22:38 +0000
@@ -69,6 +69,7 @@
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.common.NumericSortWrapper;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementOperand;
@@ -1029,4 +1030,10 @@
{
return chartStore.countOrganisationUnitAnalyticalObject( organisationUnit );
}
+
+ @Override
+ public int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup )
+ {
+ return chartStore.countCategoryOptionGroupAnalyticalObject( categoryOptionGroup );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2014-04-28 11:24:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2015-01-07 18:22:38 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.indicator.Indicator;
@@ -84,4 +85,10 @@
{
return reportTableService.countOrganisationUnitReportTables( organisationUnit ) == 0 ? null : ERROR;
}
+
+ @Override
+ public String allowDeleteCategoryOptionGroup( CategoryOptionGroup categoryOptionGroup )
+ {
+ return reportTableService.countCategoryOptionGroups( categoryOptionGroup ) == 0 ? null : ERROR;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2014-11-03 02:33:50 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2015-01-07 18:22:38 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.analytics.AnalyticsService;
import org.hisp.dhis.common.AnalyticalObjectStore;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
@@ -264,4 +265,10 @@
{
return reportTableStore.countOrganisationUnitAnalyticalObject( organisationUnit );
}
+
+ @Override
+ public int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup )
+ {
+ return reportTableStore.countCategoryOptionGroupAnalyticalObject( categoryOptionGroup );
+ }
}