1 |
e8bc0f43
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2009 EDIT
|
3 |
ee369c1a
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
e8bc0f43
|
Andreas Müller
|
* http://www.e-taxonomy.eu
|
5 |
ee369c1a
|
Patric Plitzner
|
*
|
6 |
e8bc0f43
|
Andreas Müller
|
* 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 |
eb4afba6
|
Andreas Müller
|
import java.util.ArrayList;
|
12 |
e8bc0f43
|
Andreas Müller
|
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 |
ee369c1a
|
Patric Plitzner
|
*
|
23 |
e8bc0f43
|
Andreas Müller
|
* @author a.mueller
|
24 |
53db84af
|
Andreas Müller
|
* @since 04.01.2012
|
25 |
e8bc0f43
|
Andreas Müller
|
*
|
26 |
|
|
*/
|
27 |
ef52cdd5
|
Katja Luther
|
public class DeleteResult extends UpdateResult{
|
28 |
d9848104
|
Cherian Mathew
|
|
29 |
2df2798e
|
Andreas Müller
|
private static final long serialVersionUID = 8856465763413085548L;
|
30 |
ee369c1a
|
Patric Plitzner
|
|
31 |
2df2798e
|
Andreas Müller
|
@SuppressWarnings("unused")
|
32 |
|
|
private static final Logger logger = Logger.getLogger(DeleteResult.class);
|
33 |
41c712fd
|
Katja Luther
|
|
34 |
ee369c1a
|
Patric Plitzner
|
|
35 |
|
|
|
36 |
815a9015
|
Katja Luther
|
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 |
ee369c1a
|
Patric Plitzner
|
|
42 |
a7f43cf4
|
Patric Plitzner
|
//
|
43 |
2df2798e
|
Andreas Müller
|
// private Set<PersistPair> objectsToSave = new HashSet<>();
|
44 |
ee369c1a
|
Patric Plitzner
|
|
45 |
a7f43cf4
|
Patric Plitzner
|
// protected class PersistPair{
|
46 |
|
|
// protected CdmBase objectToPersist;
|
47 |
|
|
// protected ICdmEntityDao<CdmBase> dao;
|
48 |
|
|
// }
|
49 |
ee369c1a
|
Patric Plitzner
|
|
50 |
41c712fd
|
Katja Luther
|
|
51 |
e8bc0f43
|
Andreas Müller
|
|
52 |
ee369c1a
|
Patric Plitzner
|
//***************************** GETTER /SETTER /ADDER *************************/
|
53 |
41c712fd
|
Katja Luther
|
|
54 |
e8bc0f43
|
Andreas Müller
|
|
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 |
ee369c1a
|
Patric Plitzner
|
|
69 |
|
|
|
70 |
41c712fd
|
Katja Luther
|
@Override
|
71 |
|
|
public void includeResult(UpdateResult includedResult){
|
72 |
|
|
|
73 |
|
|
this.setMaxStatus(includedResult.getStatus());
|
74 |
|
|
this.addExceptions(includedResult.getExceptions());
|
75 |
|
|
this.addUpdatedObjects(includedResult.getUpdatedObjects());
|
76 |
815a9015
|
Katja Luther
|
if (includedResult instanceof DeleteResult){
|
77 |
|
|
this.addDeletedObjects(((DeleteResult)includedResult).getDeletedObjects());
|
78 |
|
|
}
|
79 |
41c712fd
|
Katja Luther
|
|
80 |
|
|
}
|
81 |
815a9015
|
Katja Luther
|
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 |
ee369c1a
|
Patric Plitzner
|
|
91 |
e8bc0f43
|
Andreas Müller
|
}
|