1
package org.hisp.dhis.datamart;
3
import org.hisp.dhis.dataelement.DataElement;
4
import org.hisp.dhis.indicator.Indicator;
5
import org.hisp.dhis.source.Source;
6
import org.hisp.dhis.system.deletion.DeletionHandler;
9
* Copyright (c) 2004-2007, University of Oslo
10
* All rights reserved.
12
* Redistribution and use in source and binary forms, with or without
13
* modification, are permitted provided that the following conditions are met:
14
* * Redistributions of source code must retain the above copyright notice, this
15
* list of conditions and the following disclaimer.
16
* * Redistributions in binary form must reproduce the above copyright notice,
17
* this list of conditions and the following disclaimer in the documentation
18
* and/or other materials provided with the distribution.
19
* * Neither the name of the HISP project nor the names of its contributors may
20
* be used to endorse or promote products derived from this software without
21
* specific prior written permission.
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
* @author Lars Helge Overland
39
public class DataMartExportDeletionHandler
40
extends DeletionHandler
42
// -------------------------------------------------------------------------
44
// -------------------------------------------------------------------------
46
private DataMartExportService dataMartExportService;
48
public void setDataMartExportService( DataMartExportService dataMartExportService )
50
this.dataMartExportService = dataMartExportService;
53
// -------------------------------------------------------------------------
54
// DeletionHandler implementation
55
// -------------------------------------------------------------------------
58
public String getClassName()
60
return DataMartExport.class.getSimpleName();
64
public boolean allowDeleteDataElement( DataElement dataElement )
66
for ( DataMartExport export : dataMartExportService.getAllDataMartExports() )
68
if ( export.getDataElements().remove( dataElement ) )
70
dataMartExportService.saveDataMartExport( export );
78
public boolean allowDeleteIndicator( Indicator indicator )
80
for ( DataMartExport export : dataMartExportService.getAllDataMartExports() )
82
if ( export.getIndicators().remove( indicator ) )
84
dataMartExportService.saveDataMartExport( export );
92
public boolean allowDeleteSource( Source source )
94
for ( DataMartExport export : dataMartExportService.getAllDataMartExports() )
96
if ( export.getOrganisationUnits().remove( source ) )
98
dataMartExportService.saveDataMartExport( export );