1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.api.service;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.List;
|
14
|
import java.util.Set;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
19
|
|
20
|
/**
|
21
|
* This class represents the result of a delete action.
|
22
|
*
|
23
|
* @author a.mueller
|
24
|
* @since 04.01.2012
|
25
|
*
|
26
|
*/
|
27
|
public class DeleteResult extends UpdateResult{
|
28
|
|
29
|
private static final long serialVersionUID = 8856465763413085548L;
|
30
|
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(DeleteResult.class);
|
33
|
|
34
|
|
35
|
|
36
|
private final List<Exception> exceptions = new ArrayList();
|
37
|
|
38
|
private final Set<CdmBase> relatedObjects = new HashSet();
|
39
|
|
40
|
private Set<CdmBase> deletedObjects = new HashSet();
|
41
|
|
42
|
//
|
43
|
// private Set<PersistPair> objectsToSave = new HashSet<>();
|
44
|
|
45
|
// protected class PersistPair{
|
46
|
// protected CdmBase objectToPersist;
|
47
|
// protected ICdmEntityDao<CdmBase> dao;
|
48
|
// }
|
49
|
|
50
|
|
51
|
|
52
|
//***************************** GETTER /SETTER /ADDER *************************/
|
53
|
|
54
|
|
55
|
/**
|
56
|
* Related objects that prevent the delete action to take place.
|
57
|
* @return
|
58
|
*/
|
59
|
public Set<CdmBase> getRelatedObjects() {
|
60
|
return relatedObjects;
|
61
|
}
|
62
|
public void addRelatedObject(CdmBase relatedObject) {
|
63
|
this.relatedObjects.add(relatedObject);
|
64
|
}
|
65
|
public void addRelatedObjects(Set<? extends CdmBase> relatedObjects) {
|
66
|
this.relatedObjects.addAll(relatedObjects);
|
67
|
}
|
68
|
|
69
|
|
70
|
@Override
|
71
|
public void includeResult(UpdateResult includedResult){
|
72
|
|
73
|
this.setMaxStatus(includedResult.getStatus());
|
74
|
this.addExceptions(includedResult.getExceptions());
|
75
|
this.addUpdatedObjects(includedResult.getUpdatedObjects());
|
76
|
if (includedResult instanceof DeleteResult){
|
77
|
this.addDeletedObjects(((DeleteResult)includedResult).getDeletedObjects());
|
78
|
}
|
79
|
|
80
|
}
|
81
|
public Set<CdmBase> getDeletedObjects() {
|
82
|
return deletedObjects;
|
83
|
}
|
84
|
public void addDeletedObjects(Set<CdmBase> deletedObjects) {
|
85
|
this.deletedObjects.addAll(deletedObjects);
|
86
|
}
|
87
|
public void addDeletedObject(CdmBase deletedObject) {
|
88
|
this.deletedObjects.add(deletedObject);
|
89
|
}
|
90
|
|
91
|
}
|