cleanup
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / config / TaxonDeletionConfigurator.java
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.config;
10
11 import java.util.UUID;
12
13 import org.apache.logging.log4j.LogManager;
14 import org.apache.logging.log4j.Logger;
15
16 import eu.etaxonomy.cdm.api.service.ITaxonService;
17 import eu.etaxonomy.cdm.model.description.TaxonDescription;
18 import eu.etaxonomy.cdm.model.taxon.Classification;
19 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
21 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22
23 /**
24 * This class is used to configure taxon node deletion.
25 * It is initialized with the following default settings:
26 * <ul>
27 * <li> deleteSynonymRelations: <b>true</b></li>
28 * <li> deleteSynonymsIfPossible: <b>true</b></li>
29 * <li> deleteMisappliedNamesAndInvalidDesignations: <b>true</b></li>
30 * <li> deleteNameIfPossible: <b>true</b></li>
31 * <li> nameDeletionConfig: see {@link NameDeletionConfigurator}</li>
32 * <li> taxonNodeConfig: see {@link TaxonNodeDeletionConfigurator}</li>
33 * <li> deleteTaxonNodes: <b>true</b></li>
34 * <li> deleteTaxonRelationships: <b>true</b>; </li>
35 * <li> deleteDescriptions: <b>true</b></li>
36 * <li> deleteInAllClassifications: <b>true</b></li>
37 * </ul>
38 *
39 * @see ITaxonService#deleteTaxon(eu.etaxonomy.cdm.model.taxon.Taxon)
40 *
41 * @author a.mueller
42 * @since 09.11.2011
43 */
44 public class TaxonDeletionConfigurator extends TaxonBaseDeletionConfigurator {
45
46 private static final long serialVersionUID = -4932682946459109886L;
47 @SuppressWarnings("unused")
48 private static final Logger logger = LogManager.getLogger();
49
50 private boolean deleteSynonymsIfPossible = true;
51
52 private boolean deleteMisappliedNames = true;
53
54 private boolean deleteConceptRelationships = false;
55
56 //private NameDeletionConfigurator nameDeletionConfig = new NameDeletionConfigurator();
57
58 private TaxonNodeDeletionConfigurator taxonNodeConfig = new TaxonNodeDeletionConfigurator();
59
60 private boolean deleteTaxonNodes = true;
61
62 private boolean deleteTaxonRelationships = true;
63
64 private boolean deleteDescriptions = true;
65
66 private boolean deleteInAllClassifications = false;
67
68 private UUID classificationUuid = null;
69
70
71 public boolean isDeleteInAllClassifications() {
72 return deleteInAllClassifications;
73 }
74 public void setDeleteInAllClassifications(boolean deleteInAllClassifications) {
75 this.deleteInAllClassifications = deleteInAllClassifications;
76 }
77
78 /**
79 * If <code>true</code> related taxa with {@link TaxonRelationshipType} misappliedName
80 * will be removed if possible.<BR>
81 * It is possible to remove a related taxon if it is not used in any other context, e.g. any
82 * other @link {@link TaxonRelationship} or in another @link {@link Classification}
83 * @return
84 */
85 public boolean isDeleteMisappliedNames() {
86 return deleteMisappliedNames;
87 }
88 public void setDeleteMisappliedNames(
89 boolean deleteMisappliedNames) {
90 this.deleteMisappliedNames = deleteMisappliedNames;
91 }
92
93 /**
94 * The configurator for node deletion. Only evaluated if {@link #isDeleteNode()}
95 * is <code>true</code>.
96 * @see TaxonNodeDeletionConfigurator
97 * @see #isDeleteNode()
98 * @see #isDeleteSynonymsIfPossible()
99 * @return
100 */
101
102 public TaxonNodeDeletionConfigurator getTaxonNodeConfig() {
103 return taxonNodeConfig;
104 }
105 public void setTaxonNodeConfig(TaxonNodeDeletionConfigurator taxonNodeConfig) {
106 this.taxonNodeConfig = taxonNodeConfig;
107 }
108
109 /**
110 * If <code>true</code> synonyms will be removed if possible but only if {@link #isDeleteSynonymRelations()}
111 * is also <code>true</code>.
112 * It is possible to remove a synonym if it is not used in any other context
113 * @return
114 */
115 public boolean isDeleteSynonymsIfPossible() {
116 return deleteSynonymsIfPossible;
117 }
118 public void setDeleteSynonymsIfPossible(boolean deleteSynonymsIfPossible) {
119 this.deleteSynonymsIfPossible = deleteSynonymsIfPossible;
120 }
121
122 /**
123 * If <code>true</code> all {@link TaxonNode taxon nodes} this taxon belongs to
124 * are deleted. If <code>false</code> an exception is thrown if this taxon belongs
125 * to a taxon node.
126 * @return
127 */
128 public boolean isDeleteTaxonNodes() {
129 return deleteTaxonNodes;
130 }
131 public void setDeleteTaxonNodes(boolean deleteTaxonNodes) {
132 this.deleteTaxonNodes = deleteTaxonNodes;
133 }
134
135 /**
136 * If <code>true</code> all {@link TaxonRelationship taxon relationships} linked to
137 * the taxon are removed.
138 */
139 // TODO how to handle missapllied names
140 public boolean isDeleteTaxonRelationships() {
141 return deleteTaxonRelationships;
142 }
143 public void setDeleteTaxonRelationships(boolean deleteTaxonRelationships) {
144 this.deleteTaxonRelationships = deleteTaxonRelationships;
145 }
146
147 /**
148 * If <code>true</code> all {@link TaxonDescription taxon descriptions} linked to
149 * the taxon are deleted.
150 */
151 public boolean isDeleteDescriptions() {
152 return deleteDescriptions;
153 }
154 public void setDeleteDescriptions(boolean deleteDescriptions) {
155 this.deleteDescriptions = deleteDescriptions;
156 }
157
158 /**
159 * @return the deleteConceptRelationships
160 */
161 public boolean isDeleteConceptRelationships() {
162 return deleteConceptRelationships;
163 }
164 /**
165 * @param deleteConceptRelationships the deleteConceptRelationships to set
166 */
167 public void setDeleteConceptRelationships(boolean deleteConceptRelationships) {
168 this.deleteConceptRelationships = deleteConceptRelationships;
169 }
170
171 public UUID getClassificationUuid() {
172 return classificationUuid;
173 }
174 public void setClassificationUuid(UUID classificationUuid) {
175 this.classificationUuid = classificationUuid;
176 }
177 }