Project

General

Profile

Download (13.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2020 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.config;
10

    
11
import java.io.Serializable;
12
import java.util.HashSet;
13
import java.util.Set;
14
import java.util.UUID;
15

    
16
import eu.etaxonomy.cdm.model.reference.Reference;
17
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
18
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
19

    
20
/**
21
 * @author a.mueller
22
 * @since 30.11.2020
23
 */
24
public class SubtreeCloneConfigurator implements Serializable {
25

    
26
    private static final long serialVersionUID = 5599009171476893297L;
27

    
28
    //might be replaced by a TaxonNodeFilter in future (but requires treebuilding and handling for missing inbetween taxa a tree)
29
    private Set<UUID> subTreeUuids;
30

    
31
    private String newClassificationName = "Taxon subtree clone";
32

    
33
    private boolean reuseClassificationReference = false;
34
     //used only if reuseClassificationReferenceUuid == false
35
     private UUID classificationReferenceUuid;
36
     private Reference classificationReference;
37

    
38
    private boolean reuseTaxa = false;
39
     //used only if reuseTaxa == false
40
     private boolean includeSynonymsIncludingManAndProParte = true;
41
     //used only if reuseTaxa == false
42
     private boolean includeDescriptiveData = true;
43
     //used only if reuseTaxa == false
44
     private boolean includeMedia = true;
45
     //used only if reuseTaxa == false
46
     private boolean includeTaxonRelationshipsExcludingManAndProParte = false;
47
     //used only if reuseTaxa == false
48
     private boolean reuseNames = true;
49
     //used only if reuseTaxa == false
50
     private boolean reuseTaxonSecundum = true;
51
      //used only if reuseTaxa == false AND reuseTaxonSecundum = false
52
      private UUID taxonSecundumUuid = null;
53
      private Reference taxonSecundum;
54

    
55
    private boolean reuseParentChildReference = true;
56
     //used only if reuseParentChildReference == false
57
     private UUID parentChildReferenceUuid = null;
58
     private Reference parentChildReference;
59

    
60
    private TaxonRelationshipType relationTypeToOldTaxon;
61
     //used only if relationTypeToOldTaxon != null
62
     private boolean relationDoubtful = true;
63
     //used only if relationTypeToOldTaxon != null
64
     private UUID relationshipReferenceUuid = null;
65
     private Reference relationshipReference;
66

    
67

    
68
    /**
69
     * Creates a default instance with default values. E.g. reuseNames is <code>true</code>.
70
     * @param subTreeUuid
71
     * @param classificationName
72
     * @return
73
     */
74
    public static SubtreeCloneConfigurator NewBaseInstance(UUID subTreeUuid, String classificationName
75
            ){
76
        Set<UUID> subTreeUuids = new HashSet<>();
77
        subTreeUuids.add(subTreeUuid);
78
        return new SubtreeCloneConfigurator(subTreeUuids, classificationName,
79
                false, null,
80
                false, true, null,
81
                true, null,
82
                null,
83
                true
84
                );
85
    }
86

    
87
    public static SubtreeCloneConfigurator NewInstance(Set<UUID> subTreeUuids, String classificationName,
88
            boolean reuseClassificationReference, UUID classificationReferenceUuid, boolean reuseTaxa,
89
            boolean reuseTaxonSecundum, UUID taxonSecundumUuid, boolean reuseParentChildReference,
90
            UUID parentChildReferenceUuid, TaxonRelationshipType relationTypeToOldTaxon, boolean reuseNames){
91
        return new SubtreeCloneConfigurator(subTreeUuids, classificationName,
92
            reuseClassificationReference, classificationReferenceUuid,
93
            reuseTaxa, reuseTaxonSecundum, taxonSecundumUuid,
94
            reuseParentChildReference, parentChildReferenceUuid,
95
            relationTypeToOldTaxon,
96
            reuseNames);
97
    }
98

    
99

    
100
// ******************************** CONSTRUCTOR ********************************/
101

    
102
    private SubtreeCloneConfigurator(Set<UUID> subTreeUuids, String newClassificationName,
103
            boolean reuseClassificationReference, UUID classificationReferenceUuid,
104
            boolean reuseTaxa, boolean reuseTaxonSecundum, UUID taxonSecundumUuid,
105
            boolean reuseParentChildReference, UUID parentChildReferenceUuid,
106
            TaxonRelationshipType relationTypeToOldTaxon,
107
            boolean reuseNames) {
108
        this.subTreeUuids = subTreeUuids;
109
        this.newClassificationName = newClassificationName;
110
        this.reuseClassificationReference = reuseClassificationReference;
111
        this.classificationReferenceUuid = classificationReferenceUuid;
112
        this.reuseTaxa = reuseTaxa;
113
        this.reuseTaxonSecundum = reuseTaxonSecundum;
114
        this.taxonSecundumUuid = taxonSecundumUuid;
115
        this.reuseParentChildReference = reuseParentChildReference;
116
        this.parentChildReferenceUuid = parentChildReferenceUuid;
117
        this.relationTypeToOldTaxon = relationTypeToOldTaxon;
118
        this.reuseNames = reuseNames;
119
    }
120

    
121
// ******************** GETTER / SETTER ********************************/
122

    
123
    public Set<UUID> getSubTreeUuids() {
124
        return subTreeUuids;
125
    }
126
    public void setSubTreeUuids(Set<UUID> subTreeUuid) {
127
        this.subTreeUuids = subTreeUuid;
128
    }
129

    
130
    public String getNewClassificationName() {
131
        return newClassificationName;
132
    }
133
    public void setNewClassificationName(String newClassificationName) {
134
        this.newClassificationName = newClassificationName;
135
    }
136

    
137
    public UUID getClassificationReferenceUuid() {
138
        return classificationReferenceUuid;
139
    }
140
    public void setClassificationReferenceUuid(UUID classificationReferenceUuid) {
141
        this.classificationReferenceUuid = classificationReferenceUuid;
142
    }
143

    
144
    public UUID getTaxonSecundumUuid() {
145
        return taxonSecundumUuid;
146
    }
147
    public void setTaxonSecundumUuid(UUID taxonSecundumUuid) {
148
        this.taxonSecundumUuid = taxonSecundumUuid;
149
    }
150

    
151
    public UUID getParentChildReferenceUuid() {
152
        return parentChildReferenceUuid;
153
    }
154
    public void setParentChildReferenceUuid(UUID parentChildReferenceUuid) {
155
        this.parentChildReferenceUuid = parentChildReferenceUuid;
156
    }
157

    
158
    public TaxonRelationshipType getRelationTypeToOldTaxon() {
159
        return relationTypeToOldTaxon;
160
    }
161
    public void setRelationTypeToOldTaxon(TaxonRelationshipType relationTypeToOldTaxon) {
162
        this.relationTypeToOldTaxon = relationTypeToOldTaxon;
163
    }
164

    
165
    public boolean isReuseTaxa() {
166
        return reuseTaxa;
167
    }
168
    public void setReuseTaxa(boolean reuseTaxa) {
169
        this.reuseTaxa = reuseTaxa;
170
    }
171

    
172
    public boolean isReuseNames() {
173
        return reuseNames;
174
    }
175
    /**
176
     * @param reuseNames
177
     * @deprecated  as it is not fully implemented yet and generally not recommended
178
     *          to clone names in a database; see comments in #9349 why name cloning
179
     *          needs to be done with care
180
     */
181
    @Deprecated
182
    public void setReuseNames(boolean reuseNames) {
183
        this.reuseNames = reuseNames;
184
    }
185
    public boolean isReuseClassificationReference() {
186
        return reuseClassificationReference;
187
    }
188
    public void setReuseClassificationReference(boolean reuseClassificationReference) {
189
        this.reuseClassificationReference = reuseClassificationReference;
190
    }
191
    public boolean isReuseTaxonSecundum() {
192
        return reuseTaxonSecundum;
193
    }
194
    public void setReuseTaxonSecundum(boolean reuseTaxonSecundum) {
195
        this.reuseTaxonSecundum = reuseTaxonSecundum;
196
    }
197
    public boolean isReuseParentChildReference() {
198
        return reuseParentChildReference;
199
    }
200
    public void setReuseParentChildReference(boolean reuseParentChildReference) {
201
        this.reuseParentChildReference = reuseParentChildReference;
202
    }
203

    
204
    public boolean isRelationDoubtful() {
205
        return relationDoubtful;
206
    }
207

    
208
    public void setRelationDoubtful(boolean relationDoubtful) {
209
        this.relationDoubtful = relationDoubtful;
210
    }
211

    
212
    public UUID getRelationshipReferenceUuid() {
213
        return relationshipReferenceUuid;
214
    }
215

    
216
    public void setRelationshipReferenceUuid(UUID relationshipReferenceUuid) {
217
        this.relationshipReferenceUuid = relationshipReferenceUuid;
218
    }
219

    
220
    public Reference getClassificationReference() {
221
        return classificationReference;
222
    }
223

    
224
    /**
225
     * Sets the reference for the classification reference. Also the {@link #getClassificationReferenceUuid()
226
     * classification reference uuid} is set by this method.<BR>
227
     * This parameter is used only if <code>{@link #isReuseClassificationReference() reuse classification reference} == false</code>
228
     * <BR>
229
     * NOTE: Only use persistent references if configurator is not used within a single transaction.
230
     * @param parentChildReference
231
     */
232
    public void setClassificationReference(Reference classificationReference) {
233
        this.classificationReference = classificationReference;
234
    }
235

    
236
    public Reference getTaxonSecundum() {
237
        return taxonSecundum;
238
    }
239
    /**
240
     * Sets the taxon secundum reference. Also the {@link #getTaxonSecundumUuid() taxon secundum reference uuid} is set by this method.<BR>
241
     * This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false && {@link #isReuseTaxonSecundum()
242
     * reuseTaxonSecundum} == false</code>
243
     * <BR>
244
     * NOTE: Only use persistent references if configurator is not used within a single transaction.
245
     * @param taxonSecundum
246
     */
247
    public void setTaxonSecundum(Reference taxonSecundum) {
248
        this.taxonSecundum = taxonSecundum;
249
        this.taxonSecundumUuid = taxonSecundum == null ? null : taxonSecundum.getUuid();
250
    }
251

    
252
    public Reference getParentChildReference() {
253
        return parentChildReference;
254
    }
255

    
256
    /**
257
     * Sets the reference for the parent child relationship. Also the {@link #getParentChildReferenceUuid()
258
     * parent child reference uuid} is set by this method.<BR>
259
     * This parameter is used only if <code>{@link #isReuseParentChildReference() reuse parent child reference} == false</code>
260
     * <BR>
261
     * NOTE: Only use persistent references if configurator is not used within a single transaction.
262
     * @param parentChildReference
263
     */
264
    public void setParentChildReference(Reference parentChildReference) {
265
        this.parentChildReference = parentChildReference;
266
    }
267

    
268
    public Reference getRelationshipReference() {
269
        return relationshipReference;
270
    }
271

    
272
    /**
273
     * Sets the reference for the new taxon to old taxon {@link TaxonRelationship taxon relationship}.
274
     * Also the {@link #getRelationshipReferenceUuid() relationship reference uuid} is set by this method.<BR>
275
     * This parameter is used only if <code>{@link #relationTypeToOldTaxon() relationTypeToOldTaxon} != null</code>
276
     * <BR>
277
     * NOTE: Only use persistent references if configurator is not used within a single transaction.
278
     * @param parentChildReference
279
     */
280
    public void setRelationshipReference(Reference relationshipReference) {
281
        this.relationshipReference = relationshipReference;
282
    }
283

    
284
    public boolean isIncludeSynonymsIncludingManAndProParte() {
285
        return this.includeSynonymsIncludingManAndProParte;
286
    }
287
    /**
288
     * If <code>true</code> the synonyms relationships of this taxon are cloned and attached to the new taxon.
289
     * <BR>
290
     * This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
291
     */
292
    public void setIncludeSynonymsIncludingManAndProParte(boolean includeSynonyms) {
293
        this.includeSynonymsIncludingManAndProParte = includeSynonyms;
294
    }
295

    
296
    public boolean isIncludeDescriptiveData() {
297
        return includeDescriptiveData;
298
    }
299
    /**
300
     * If <code>true</code> the descriptive data attached to this taxon are included in the copy
301
     * and attached to the new taxon.
302
     * <BR>
303
     * This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
304
     */
305
    public void setIncludeDescriptiveData(boolean includeDescriptiveData) {
306
        this.includeDescriptiveData = includeDescriptiveData;
307
    }
308

    
309
    public boolean isIncludeMedia() {
310
        return includeMedia;
311
    }
312
    /**
313
     * If <code>true</code> the media attached to this taxon are also attached to the new taxon.
314
     * Media itself are always reused.
315
     * <BR>
316
     * This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
317
     */
318
    public void setIncludeMedia(boolean includeMedia) {
319
        this.includeMedia = includeMedia;
320
    }
321

    
322
    public boolean isIncludeTaxonRelationshipsExcludingManAndProParte() {
323
        return includeTaxonRelationshipsExcludingManAndProParte;
324
    }
325
    /**
326
     * If <code>true</code> the taxon (concept) relationships to and from this taxon are also cloned.
327
     * This includes all taxon relationships except those for {@link TaxonRelationshipType#isAnyMisappliedName() any misapplied names}
328
     * and {@link TaxonRelationshipType#isAnySynonym() any (pro parte synonyms)}.
329
     * <BR>
330
     * This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
331
     */
332
    public void setIncludeTaxonRelationshipsExcludingManAndProParte(boolean includeTaxonRelationshipsExcludingManAndProParte) {
333
        this.includeTaxonRelationshipsExcludingManAndProParte = includeTaxonRelationshipsExcludingManAndProParte;
334
    }
335
}
(23-23/30)