dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42296
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21622: Introduced AnalyticalObjectService and GenericAnalyticalObjectService. Centralizes methods for ha...
------------------------------------------------------------
revno: 21622
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-01-06 15:25:55 +0100
message:
Introduced AnalyticalObjectService and GenericAnalyticalObjectService. Centralizes methods for handling analytical objects.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/GenericAnalyticalObjectService.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.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/eventchart/EventChartDeletionHandler.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java 2016-01-06 14:25:55 +0000
@@ -32,10 +32,9 @@
import java.util.List;
import java.util.Map;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.common.AnalyticalObjectService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -48,6 +47,7 @@
* @author Lars Helge Overland
*/
public interface ChartService
+ extends AnalyticalObjectService<Chart>
{
String ID = ChartService.class.getName();
@@ -108,16 +108,4 @@
int getChartCount();
int getChartCountByName( String name );
-
- int countDataSetCharts( DataSet dataSet );
-
- int countIndicatorCharts( Indicator indicator );
-
- int countDataElementCharts( DataElement dataElement );
-
- int countPeriodCharts( Period period );
-
- int countOrganisationUnitCharts( OrganisationUnit organisationUnit );
-
- int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup );
}
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectService.java 2016-01-06 14:25:55 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2016, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.List;
+
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.program.ProgramIndicator;
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface AnalyticalObjectService<T extends BaseAnalyticalObject>
+{
+ List<T> getAnalyticalObjects( Indicator indicator );
+
+ List<T> getAnalyticalObjects( DataElement dataElement );
+
+ List<T> getAnalyticalObjects( DataSet dataSet );
+
+ List<T> getAnalyticalObjects( ProgramIndicator programIndicator );
+
+ List<T> getAnalyticalObjects( Period period );
+
+ List<T> getAnalyticalObjects( OrganisationUnit organisationUnit );
+
+ List<T> getAnalyticalObjects( CategoryOptionGroup categoryOptionGroup );
+
+ int countAnalyticalObjects( Indicator indicator );
+
+ int countAnalyticalObjects( DataElement dataElement );
+
+ int countAnalyticalObjects( DataSet dataSet );
+
+ int countAnalyticalObjects( ProgramIndicator programIndicator );
+
+ int countAnalyticalObjects( Period period );
+
+ int countAnalyticalObjects( OrganisationUnit organisationUnit );
+
+ int countAnalyticalObjects( CategoryOptionGroup categoryOptionGroup );
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2016-01-06 14:25:55 +0000
@@ -30,17 +30,13 @@
import java.util.List;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
+import org.hisp.dhis.common.AnalyticalObjectService;
/**
* @author Jan Henrik Overland
- * @version $Id$
*/
public interface MappingService
+ extends AnalyticalObjectService<MapView>
{
String ID = MappingService.class.getName();
@@ -126,16 +122,6 @@
MapLayer getMapLayerByMapSource( String mapSource );
List<MapLayer> getAllMapLayers();
-
+
int countMapViewMaps( MapView mapView );
-
- int countDataSetMapViews( DataSet dataSet );
-
- int countIndicatorMapViews( Indicator indicator );
-
- int countDataElementMapViews( DataElement dataElement );
-
- int countPeriodMapViews( Period period );
-
- int countOrganisationUnitMapViews( OrganisationUnit organisationUnit );
}
\ No newline at end of file
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2016-01-06 14:25:55 +0000
@@ -31,20 +31,15 @@
import java.util.Date;
import java.util.List;
+import org.hisp.dhis.common.AnalyticalObjectService;
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;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
/**
* @author Lars Helge Overland
- * @version $Id$
*/
public interface ReportTableService
+ extends AnalyticalObjectService<ReportTable>
{
String ID = ReportTableService.class.getName();
@@ -141,16 +136,4 @@
int getReportTableCount();
int getReportTableCountByName( String name );
-
- int countDataSetReportTables( DataSet dataSet );
-
- int countIndicatorReportTables( Indicator indicator );
-
- int countDataElementReportTables( DataElement dataElement );
-
- int countPeriodReportTables( Period period );
-
- int countOrganisationUnitReportTables( OrganisationUnit organisationUnit );
-
- int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup );
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/GenericAnalyticalObjectService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/GenericAnalyticalObjectService.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/GenericAnalyticalObjectService.java 2016-01-06 14:25:55 +0000
@@ -0,0 +1,118 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2016, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.List;
+
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.program.ProgramIndicator;
+
+/**
+ * @author Lars Helge Overland
+ */
+public abstract class GenericAnalyticalObjectService<T extends BaseAnalyticalObject>
+ implements AnalyticalObjectService<T>
+{
+ protected abstract AnalyticalObjectStore<T> getAnalyticalObjectStore();
+
+ public List<T> getAnalyticalObjects( Indicator indicator )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( indicator );
+ }
+
+ public List<T> getAnalyticalObjects( DataElement dataElement )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( dataElement );
+ }
+
+ public List<T> getAnalyticalObjects( DataSet dataSet )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( dataSet );
+ }
+
+ public List<T> getAnalyticalObjects( ProgramIndicator programIndicator )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( programIndicator );
+ }
+
+ public List<T> getAnalyticalObjects( Period period )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( period );
+ }
+
+ public List<T> getAnalyticalObjects( OrganisationUnit organisationUnit )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( organisationUnit );
+ }
+
+ public List<T> getAnalyticalObjects( CategoryOptionGroup categoryOptionGroup )
+ {
+ return getAnalyticalObjectStore().getAnalyticalObjects( categoryOptionGroup );
+ }
+
+ public int countAnalyticalObjects( Indicator indicator )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( indicator );
+ }
+
+ public int countAnalyticalObjects( DataElement dataElement )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( dataElement );
+ }
+
+ public int countAnalyticalObjects( DataSet dataSet )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( dataSet );
+ }
+
+ public int countAnalyticalObjects( ProgramIndicator programIndicator )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( programIndicator );
+ }
+
+ public int countAnalyticalObjects( Period period )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( period );
+ }
+
+ public int countAnalyticalObjects( OrganisationUnit organisationUnit )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( organisationUnit );
+ }
+
+ public int countAnalyticalObjects( CategoryOptionGroup categoryOptionGroup )
+ {
+ return getAnalyticalObjectStore().countAnalyticalObjects( categoryOptionGroup );
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/eventchart/EventChartDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/eventchart/EventChartDeletionHandler.java 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/eventchart/EventChartDeletionHandler.java 2016-01-06 14:25:55 +0000
@@ -62,6 +62,7 @@
public void deleteProgramStage( ProgramStage programStage )
{
Collection<EventChart> charts = eventChartService.getAllEventCharts();
+
for( EventChart chart : charts )
{
if( chart.getProgramStage().equals( programStage ))
@@ -75,6 +76,7 @@
public void deleteProgram( Program program )
{
Collection<EventChart> charts = eventChartService.getAllEventCharts();
+
for( EventChart chart : charts )
{
if( chart.getProgram().equals( program ))
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2016-01-06 14:03:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2016-01-06 14:25:55 +0000
@@ -30,8 +30,8 @@
import java.util.List;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.common.AnalyticalObjectStore;
+import org.hisp.dhis.common.GenericAnalyticalObjectService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -46,6 +46,7 @@
*/
@Transactional
public class DefaultMappingService
+ extends GenericAnalyticalObjectService<MapView>
implements MappingService
{
// -------------------------------------------------------------------------
@@ -98,6 +99,12 @@
// MappingService implementation
// -------------------------------------------------------------------------
+ @Override
+ protected AnalyticalObjectStore<MapView> getAnalyticalObjectStore()
+ {
+ return mapViewStore;
+ }
+
// -------------------------------------------------------------------------
// Map
// -------------------------------------------------------------------------
@@ -313,34 +320,4 @@
{
return mapStore.countMapViewMaps( mapView );
}
-
- @Override
- public int countDataSetMapViews( DataSet dataSet )
- {
- return mapViewStore.countAnalyticalObjects( dataSet );
- }
-
- @Override
- public int countIndicatorMapViews( Indicator indicator )
- {
- return mapViewStore.countAnalyticalObjects( indicator );
- }
-
- @Override
- public int countDataElementMapViews( DataElement dataElement )
- {
- return mapViewStore.countAnalyticalObjects( dataElement );
- }
-
- @Override
- public int countPeriodMapViews( Period period )
- {
- return mapViewStore.countAnalyticalObjects( period );
- }
-
- @Override
- public int countOrganisationUnitMapViews( OrganisationUnit organisationUnit )
- {
- return mapViewStore.countAnalyticalObjects( organisationUnit );
- }
}
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java 2016-01-06 14:25:55 +0000
@@ -71,30 +71,30 @@
@Override
public String allowDeleteDataSet( DataSet dataSet )
{
- return mappingService.countDataSetMapViews( dataSet ) == 0 ? null : ERROR;
+ return mappingService.countAnalyticalObjects( dataSet ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteIndicator( Indicator indicator )
{
- return mappingService.countIndicatorMapViews( indicator ) == 0 ? null : ERROR;
+ return mappingService.countAnalyticalObjects( indicator ) == 0 ? null : ERROR;
}
@Override
public String allowDeletePeriod( Period period )
{
- return mappingService.countPeriodMapViews( period ) == 0 ? null : ERROR;
+ return mappingService.countAnalyticalObjects( period ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteDataElement( DataElement dataElement )
{
- return mappingService.countDataElementMapViews( dataElement ) == 0 ? null : ERROR;
+ return mappingService.countAnalyticalObjects( dataElement ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
{
- return mappingService.countOrganisationUnitMapViews( organisationUnit ) == 0 ? null : ERROR;
+ return mappingService.countAnalyticalObjects( organisationUnit ) == 0 ? null : ERROR;
}
}
=== 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2016-01-06 14:25:55 +0000
@@ -67,36 +67,36 @@
@Override
public String allowDeleteDataSet( DataSet dataSet )
{
- return chartService.countDataSetCharts( dataSet ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( dataSet ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteIndicator( Indicator indicator )
{
- return chartService.countIndicatorCharts( indicator ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( indicator ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteDataElement( DataElement dataElement )
{
- return chartService.countDataElementCharts( dataElement ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( dataElement ) == 0 ? null : ERROR;
}
@Override
public String allowDeletePeriod( Period period )
{
- return chartService.countPeriodCharts( period ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( period ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
{
- return chartService.countOrganisationUnitCharts( organisationUnit ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( organisationUnit ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteCategoryOptionGroup( CategoryOptionGroup categoryOptionGroup )
{
- return chartService.countCategoryOptionGroups( categoryOptionGroup ) == 0 ? null : ERROR;
+ return chartService.countAnalyticalObjects( 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 2016-01-06 14:03:52 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java 2016-01-06 14:25:55 +0000
@@ -57,14 +57,13 @@
import org.hisp.dhis.common.AnalyticsType;
import org.hisp.dhis.common.BaseAnalyticalObject;
import org.hisp.dhis.common.DimensionalObject;
+import org.hisp.dhis.common.GenericAnalyticalObjectService;
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;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.i18n.I18nFormat;
@@ -120,6 +119,7 @@
*/
@Transactional
public class DefaultChartService
+ extends GenericAnalyticalObjectService<Chart>
implements ChartService
{
private static final Font TITLE_FONT = new Font( Font.SANS_SERIF, Font.BOLD, 12 );
@@ -202,6 +202,12 @@
// -------------------------------------------------------------------------
@Override
+ protected AnalyticalObjectStore<Chart> getAnalyticalObjectStore()
+ {
+ return chartStore;
+ }
+
+ @Override
public JFreeChart getJFreeChart( int id, I18nFormat format )
{
Chart chart = getChart( id );
@@ -980,40 +986,4 @@
{
return chartStore.getAllLikeName( name, first, max );
}
-
- @Override
- public int countDataSetCharts( DataSet dataSet )
- {
- return chartStore.countAnalyticalObjects( dataSet );
- }
-
- @Override
- public int countIndicatorCharts( Indicator indicator )
- {
- return chartStore.countAnalyticalObjects( indicator );
- }
-
- @Override
- public int countDataElementCharts( DataElement dataElement )
- {
- return chartStore.countAnalyticalObjects( dataElement );
- }
-
- @Override
- public int countPeriodCharts( Period period )
- {
- return chartStore.countAnalyticalObjects( period );
- }
-
- @Override
- public int countOrganisationUnitCharts( OrganisationUnit organisationUnit )
- {
- return chartStore.countAnalyticalObjects( organisationUnit );
- }
-
- @Override
- public int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup )
- {
- return chartStore.countAnalyticalObjects( 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 2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2016-01-06 14:25:55 +0000
@@ -66,36 +66,36 @@
@Override
public String allowDeleteDataSet( DataSet dataSet )
{
- return reportTableService.countDataSetReportTables( dataSet ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( dataSet ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteIndicator( Indicator indicator )
{
- return reportTableService.countIndicatorReportTables( indicator ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( indicator ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteDataElement( DataElement dataElement )
{
- return reportTableService.countDataElementReportTables( dataElement ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( dataElement ) == 0 ? null : ERROR;
}
@Override
public String allowDeletePeriod( Period period )
{
- return reportTableService.countPeriodReportTables( period ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( period ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
{
- return reportTableService.countOrganisationUnitReportTables( organisationUnit ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( organisationUnit ) == 0 ? null : ERROR;
}
@Override
public String allowDeleteCategoryOptionGroup( CategoryOptionGroup categoryOptionGroup )
{
- return reportTableService.countCategoryOptionGroups( categoryOptionGroup ) == 0 ? null : ERROR;
+ return reportTableService.countAnalyticalObjects( 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 2016-01-06 14:03:52 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2016-01-06 14:25:55 +0000
@@ -35,15 +35,11 @@
import org.hisp.dhis.analytics.AnalyticsService;
import org.hisp.dhis.common.AnalyticalObjectStore;
+import org.hisp.dhis.common.GenericAnalyticalObjectService;
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;
-import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
import org.hisp.dhis.report.ReportService;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
@@ -56,6 +52,7 @@
*/
@Transactional
public class DefaultReportTableService
+ extends GenericAnalyticalObjectService<ReportTable>
implements ReportTableService
{
// ---------------------------------------------------------------------
@@ -102,6 +99,12 @@
// -------------------------------------------------------------------------
@Override
+ protected AnalyticalObjectStore<ReportTable> getAnalyticalObjectStore()
+ {
+ return reportTableStore;
+ }
+
+ @Override
public Grid getReportTableGrid( String uid, I18nFormat format, Date reportingPeriod, String organisationUnitUid )
{
ReportTable reportTable = getReportTable( uid );
@@ -224,40 +227,4 @@
{
return reportTableStore.getAllOrderedName( first, max );
}
-
- @Override
- public int countDataSetReportTables( DataSet dataSet )
- {
- return reportTableStore.countAnalyticalObjects( dataSet );
- }
-
- @Override
- public int countIndicatorReportTables( Indicator indicator )
- {
- return reportTableStore.countAnalyticalObjects( indicator );
- }
-
- @Override
- public int countDataElementReportTables( DataElement dataElement )
- {
- return reportTableStore.countAnalyticalObjects( dataElement );
- }
-
- @Override
- public int countPeriodReportTables( Period period )
- {
- return reportTableStore.countAnalyticalObjects( period );
- }
-
- @Override
- public int countOrganisationUnitReportTables( OrganisationUnit organisationUnit )
- {
- return reportTableStore.countAnalyticalObjects( organisationUnit );
- }
-
- @Override
- public int countCategoryOptionGroups( CategoryOptionGroup categoryOptionGroup )
- {
- return reportTableStore.countAnalyticalObjects( categoryOptionGroup );
- }
}