Project

General

Profile

Download (13.6 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
     private boolean doRecursive = true;  //once TaxonNodeFilter is used this is not neeeded anymore
68

    
69

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

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

    
102

    
103
// ******************************** CONSTRUCTOR ********************************/
104

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

    
125
// ******************** GETTER / SETTER ********************************/
126

    
127
    public Set<UUID> getSubTreeUuids() {
128
        return subTreeUuids;
129
    }
130
    public void setSubTreeUuids(Set<UUID> subTreeUuid) {
131
        this.subTreeUuids = subTreeUuid;
132
    }
133

    
134
    public String getNewClassificationName() {
135
        return newClassificationName;
136
    }
137
    public void setNewClassificationName(String newClassificationName) {
138
        this.newClassificationName = newClassificationName;
139
    }
140

    
141
    public UUID getClassificationReferenceUuid() {
142
        return classificationReferenceUuid;
143
    }
144
    public void setClassificationReferenceUuid(UUID classificationReferenceUuid) {
145
        this.classificationReferenceUuid = classificationReferenceUuid;
146
    }
147

    
148
    public UUID getTaxonSecundumUuid() {
149
        return taxonSecundumUuid;
150
    }
151
    public void setTaxonSecundumUuid(UUID taxonSecundumUuid) {
152
        this.taxonSecundumUuid = taxonSecundumUuid;
153
    }
154

    
155
    public UUID getParentChildReferenceUuid() {
156
        return parentChildReferenceUuid;
157
    }
158
    public void setParentChildReferenceUuid(UUID parentChildReferenceUuid) {
159
        this.parentChildReferenceUuid = parentChildReferenceUuid;
160
    }
161

    
162
    public TaxonRelationshipType getRelationTypeToOldTaxon() {
163
        return relationTypeToOldTaxon;
164
    }
165
    public void setRelationTypeToOldTaxon(TaxonRelationshipType relationTypeToOldTaxon) {
166
        this.relationTypeToOldTaxon = relationTypeToOldTaxon;
167
    }
168

    
169
    public boolean isReuseTaxa() {
170
        return reuseTaxa;
171
    }
172
    public void setReuseTaxa(boolean reuseTaxa) {
173
        this.reuseTaxa = reuseTaxa;
174
    }
175

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

    
208
    public boolean isRelationDoubtful() {
209
        return relationDoubtful;
210
    }
211

    
212
    public void setRelationDoubtful(boolean relationDoubtful) {
213
        this.relationDoubtful = relationDoubtful;
214
    }
215

    
216
    public UUID getRelationshipReferenceUuid() {
217
        return relationshipReferenceUuid;
218
    }
219

    
220
    public void setRelationshipReferenceUuid(UUID relationshipReferenceUuid) {
221
        this.relationshipReferenceUuid = relationshipReferenceUuid;
222
    }
223

    
224
    public Reference getClassificationReference() {
225
        return classificationReference;
226
    }
227

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

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

    
256
    public Reference getParentChildReference() {
257
        return parentChildReference;
258
    }
259

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

    
272
    public Reference getRelationshipReference() {
273
        return relationshipReference;
274
    }
275

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

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

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

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

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

    
340
    public boolean isDoRecursive() {
341
        return doRecursive;
342
    }
343
    /**
344
     * If set to <code>true</code> also clone children. Default is <code>true</code>.
345
     *
346
     * @param doRecursive
347
     */
348
    public void setDoRecursive(boolean doRecursive) {
349
        this.doRecursive = doRecursive;
350
    }
351
}
(23-23/30)