1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.api.application;
|
11
|
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
16
|
|
17
|
/**
|
18
|
* @author cmathew
|
19
|
* @date 7 Apr 2015
|
20
|
*
|
21
|
*/
|
22
|
public class CdmChangeEvent {
|
23
|
|
24
|
public enum Action {
|
25
|
Create,
|
26
|
Update,
|
27
|
Delete
|
28
|
}
|
29
|
|
30
|
private final Action action;
|
31
|
private final Set<CdmBase> changedObjects;
|
32
|
private final Class sourceType;
|
33
|
private Object source;
|
34
|
|
35
|
public CdmChangeEvent(Action action, Set<CdmBase> changedObjects, Class sourceType) {
|
36
|
this.action = action;
|
37
|
this.changedObjects = changedObjects;
|
38
|
this.sourceType = sourceType;
|
39
|
}
|
40
|
|
41
|
public CdmChangeEvent(Action action, CdmBase changedObject, Class sourceType) {
|
42
|
this.action = action;
|
43
|
changedObjects = new HashSet<CdmBase>();
|
44
|
changedObjects.add(changedObject);
|
45
|
this.sourceType = sourceType;
|
46
|
}
|
47
|
|
48
|
public CdmChangeEvent(Action action, Set<CdmBase> changedObjects, Object source) {
|
49
|
this(action, changedObjects, source.getClass());
|
50
|
this.source = source;
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* @return the action
|
55
|
*/
|
56
|
public Action getAction() {
|
57
|
return action;
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* @return the changedObjects
|
62
|
*/
|
63
|
public Set<? extends CdmBase> getChangedObjects() {
|
64
|
return changedObjects;
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* @return the sourceType
|
69
|
*/
|
70
|
public Class getSourceType() {
|
71
|
return sourceType;
|
72
|
}
|
73
|
|
74
|
|
75
|
/**
|
76
|
* @return the source
|
77
|
*/
|
78
|
public Object getSource() {
|
79
|
return source;
|
80
|
}
|
81
|
|
82
|
public boolean hasChanges() {
|
83
|
return changedObjects != null && !changedObjects.isEmpty();
|
84
|
}
|
85
|
|
86
|
}
|