Revision 11e38aae
Added by Andreas Müller almost 3 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/Registration.java | ||
---|---|---|
28 | 28 |
import javax.xml.bind.annotation.XmlType; |
29 | 29 |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
30 | 30 |
|
31 |
import org.apache.log4j.Logger; |
|
31 | 32 |
import org.hibernate.annotations.Cascade; |
32 | 33 |
import org.hibernate.annotations.CascadeType; |
33 | 34 |
import org.hibernate.annotations.Type; |
... | ... | |
69 | 70 |
public class Registration extends AnnotatableEntity { |
70 | 71 |
|
71 | 72 |
private static final long serialVersionUID = -5633923579539766801L; |
73 |
private static final Logger logger = Logger.getLogger(Registration.class); |
|
72 | 74 |
|
73 | 75 |
@XmlElement(name = "Identifier") |
74 | 76 |
@NullOrNotEmpty |
... | ... | |
260 | 262 |
} |
261 | 263 |
} |
262 | 264 |
|
265 |
@Override |
|
266 |
public Registration clone() { |
|
267 |
try { |
|
268 |
Registration result = (Registration)super.clone(); |
|
269 |
|
|
270 |
result.blockedBy = new HashSet<>(); |
|
271 |
for (Registration blockedByReg: this.blockedBy){ |
|
272 |
result.addBlockedBy(blockedByReg); |
|
273 |
} |
|
274 |
|
|
275 |
result.typeDesignations = new HashSet<>(); |
|
276 |
for (TypeDesignationBase<?> typeDesignation: this.typeDesignations){ |
|
277 |
result.addTypeDesignation(typeDesignation); |
|
278 |
} |
|
279 |
|
|
280 |
|
|
281 |
//no changes to: identifier, institution, registrationDate, specificIdentifier, |
|
282 |
//status, submitter |
|
283 |
return result; |
|
284 |
} catch (CloneNotSupportedException e) { |
|
285 |
logger.warn("Object does not implement cloneable"); |
|
286 |
e.printStackTrace(); |
|
287 |
return null; |
|
288 |
} |
|
289 |
|
|
290 |
} |
|
263 | 291 |
|
264 | 292 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonName.java | ||
---|---|---|
3702 | 3702 |
result.authorshipCache = null; |
3703 | 3703 |
} |
3704 | 3704 |
|
3705 |
//registrations |
|
3706 |
result.registrations = new HashSet<>(); |
|
3707 |
for (Registration registration : getRegistrations()){ |
|
3708 |
result.registrations.add(registration); |
|
3709 |
} |
|
3710 |
|
|
3705 | 3711 |
//no changes to: appendedPharse, nomenclaturalReference, |
3706 | 3712 |
//nomenclaturalMicroReference, parsingProblem, problemEnds, problemStarts |
3707 | 3713 |
//protectedFullTitleCache, rank |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java | ||
---|---|---|
1711 | 1711 |
result.setRelationsFromThisTaxon(new HashSet<>()); |
1712 | 1712 |
result.setRelationsToThisTaxon(new HashSet<>()); |
1713 | 1713 |
|
1714 |
if (withTaxonRelations){ |
|
1714 |
if (withTaxonRelations || withSynonyms){
|
|
1715 | 1715 |
for (TaxonRelationship fromRelationship : this.getRelationsFromThisTaxon()){ |
1716 |
TaxonRelationship newRelationship = fromRelationship.clone(); |
|
1717 |
newRelationship.setRelatedFrom(result); |
|
1718 |
result.relationsFromThisTaxon.add(newRelationship); |
|
1716 |
boolean isSynonymRelation = fromRelationship.getType() != null && |
|
1717 |
fromRelationship.getType().isAnySynonymOrMisappliedName(); |
|
1718 |
if (isSynonymRelation && withSynonyms || !isSynonymRelation && withTaxonRelations){ |
|
1719 |
TaxonRelationship newRelationship = fromRelationship.clone(); |
|
1720 |
newRelationship.setRelatedFrom(result); |
|
1721 |
result.relationsFromThisTaxon.add(newRelationship); |
|
1722 |
} |
|
1719 | 1723 |
} |
1720 | 1724 |
|
1721 | 1725 |
for (TaxonRelationship toRelationship : this.getRelationsToThisTaxon()){ |
1722 |
TaxonRelationship newRelationship = toRelationship.clone(); |
|
1723 |
newRelationship.setRelatedTo(result); |
|
1724 |
result.relationsToThisTaxon.add(newRelationship); |
|
1726 |
boolean isSynonymRelation = toRelationship.getType() != null && |
|
1727 |
toRelationship.getType().isAnySynonymOrMisappliedName(); |
|
1728 |
if (isSynonymRelation && withSynonyms || !isSynonymRelation && withTaxonRelations){ |
|
1729 |
TaxonRelationship newRelationship = toRelationship.clone(); |
|
1730 |
newRelationship.setRelatedTo(result); |
|
1731 |
result.relationsToThisTaxon.add(newRelationship); |
|
1732 |
} |
|
1725 | 1733 |
} |
1726 | 1734 |
} |
1727 | 1735 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonRelationshipType.java | ||
---|---|---|
188 | 188 |
return (allMisappliedNameTypes().contains(this)); |
189 | 189 |
} |
190 | 190 |
|
191 |
/** |
|
192 |
* <code>true</code> if this relationship type is any |
|
193 |
* of the {@link #isAnyMisappliedName() misapplied name relationships} or |
|
194 |
* any of the {@link #isAnySynonym() (pro parte) synonym relationships} |
|
195 |
*/ |
|
196 |
public boolean isAnySynonymOrMisappliedName(){ |
|
197 |
return (allMisappliedNameTypes().contains(this) || allSynonymTypes().contains(this)); |
|
198 |
} |
|
199 |
|
|
191 | 200 |
|
192 | 201 |
/** |
193 | 202 |
* <code>true</code> if this relationship type is any |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java | ||
---|---|---|
200 | 200 |
if (config.isReuseTaxa()){ |
201 | 201 |
childNodeClone = parentNodeClone.addChildTaxon(originalTaxon, config.getParentChildReference(), microReference); |
202 | 202 |
}else{ |
203 |
Taxon cloneTaxon = originalTaxon.clone(config.isCloneSynonyms(), config.isCloneTaxonRelationships(), |
|
204 |
config.isCloneDescriptiveData(), config.isCloneMedia()); |
|
203 |
Taxon cloneTaxon = originalTaxon.clone(config.isIncludeSynonymsIncludingManAndProParte(), |
|
204 |
config.isIncludeTaxonRelationshipsExcludingManAndProParte(), |
|
205 |
config.isIncludeDescriptiveData(), config.isIncludeMedia()); |
|
206 |
|
|
207 |
//name |
|
208 |
if (!config.isReuseNames()){ |
|
209 |
cloneTaxon.setName(cloneTaxon.getName().clone()); |
|
210 |
} |
|
211 |
|
|
205 | 212 |
// xxx KonzeptClone MAN, ppSyns; |
206 | 213 |
if (!config.isReuseTaxonSecundum()){ |
207 | 214 |
cloneTaxon.setSec(config.getTaxonSecundum()); |
... | ... | |
216 | 223 |
childNodeClone = parentNodeClone.addChildTaxon(cloneTaxon, config.getParentChildReference(), microReference); |
217 | 224 |
} |
218 | 225 |
|
219 |
//TODO necessary?
|
|
226 |
//probably necessary as taxon nodes do not cascade
|
|
220 | 227 |
taxonNodeDao.saveOrUpdate(childNodeClone); |
221 | 228 |
//add children |
222 | 229 |
List<TaxonNode> originalChildNodes = originalParentNode.getChildNodes(); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/SubtreeCloneConfigurator.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
private boolean reuseTaxa = false; |
39 | 39 |
//used only if reuseTaxa == false |
40 |
private boolean cloneSynonyms = true;
|
|
40 |
private boolean includeSynonymsIncludingManAndProParte = true;
|
|
41 | 41 |
//used only if reuseTaxa == false |
42 |
private boolean cloneDescriptiveData = true;
|
|
42 |
private boolean includeDescriptiveData = true;
|
|
43 | 43 |
//used only if reuseTaxa == false |
44 |
private boolean cloneMedia = true;
|
|
44 |
private boolean includeMedia = true;
|
|
45 | 45 |
//used only if reuseTaxa == false |
46 |
private boolean cloneTaxonRelationships = false;
|
|
46 |
private boolean includeTaxonRelationshipsExcludingManAndProParte = false;
|
|
47 | 47 |
//used only if reuseTaxa == false |
48 | 48 |
private boolean reuseNames = true; |
49 | 49 |
//used only if reuseTaxa == false |
... | ... | |
274 | 274 |
this.relationshipReference = relationshipReference; |
275 | 275 |
} |
276 | 276 |
|
277 |
public boolean isCloneSynonyms() {
|
|
278 |
return cloneSynonyms;
|
|
277 |
public boolean isIncludeSynonymsIncludingManAndProParte() {
|
|
278 |
return this.includeSynonymsIncludingManAndProParte;
|
|
279 | 279 |
} |
280 | 280 |
/** |
281 | 281 |
* If <code>true</code> the synonyms relationships of this taxon are cloned and attached to the new taxon. |
282 | 282 |
* <BR> |
283 | 283 |
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code> |
284 | 284 |
*/ |
285 |
public void setCloneSynonyms(boolean cloneSynonyms) {
|
|
286 |
this.cloneSynonyms = cloneSynonyms;
|
|
285 |
public void setIncludeSynonymsIncludingManAndProParte(boolean includeSynonyms) {
|
|
286 |
this.includeSynonymsIncludingManAndProParte = includeSynonyms;
|
|
287 | 287 |
} |
288 | 288 |
|
289 |
public boolean isCloneDescriptiveData() {
|
|
290 |
return cloneDescriptiveData;
|
|
289 |
public boolean isIncludeDescriptiveData() {
|
|
290 |
return includeDescriptiveData;
|
|
291 | 291 |
} |
292 |
|
|
293 | 292 |
/** |
294 |
* If <code>true</code> the descriptive data attached to this taxon are also cloned and attached to the new taxon. |
|
293 |
* If <code>true</code> the descriptive data attached to this taxon are included in the copy |
|
294 |
* and attached to the new taxon. |
|
295 | 295 |
* <BR> |
296 | 296 |
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code> |
297 | 297 |
*/ |
298 |
public void setCloneDescriptiveData(boolean cloneDescriptiveData) {
|
|
299 |
this.cloneDescriptiveData = cloneDescriptiveData;
|
|
298 |
public void setIncludeDescriptiveData(boolean includeDescriptiveData) {
|
|
299 |
this.includeDescriptiveData = includeDescriptiveData;
|
|
300 | 300 |
} |
301 | 301 |
|
302 |
public boolean isCloneMedia() {
|
|
303 |
return cloneMedia;
|
|
302 |
public boolean isIncludeMedia() {
|
|
303 |
return includeMedia;
|
|
304 | 304 |
} |
305 | 305 |
/** |
306 | 306 |
* If <code>true</code> the media attached to this taxon are also attached to the new taxon. |
307 |
* Media itself are always reused.<BR> |
|
307 |
* Media itself are always reused. |
|
308 |
* <BR> |
|
308 | 309 |
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code> |
309 | 310 |
*/ |
310 |
public void setCloneMedia(boolean cloneMedia) {
|
|
311 |
this.cloneMedia = cloneMedia;
|
|
311 |
public void setIncludeMedia(boolean includeMedia) {
|
|
312 |
this.includeMedia = includeMedia;
|
|
312 | 313 |
} |
313 | 314 |
|
314 |
public boolean isCloneTaxonRelationships() {
|
|
315 |
return cloneTaxonRelationships;
|
|
315 |
public boolean isIncludeTaxonRelationshipsExcludingManAndProParte() {
|
|
316 |
return includeTaxonRelationshipsExcludingManAndProParte;
|
|
316 | 317 |
} |
317 | 318 |
/** |
318 | 319 |
* If <code>true</code> the taxon (concept) relationships to and from this taxon are also cloned. |
320 |
* This includes all taxon relationships except those for {@link TaxonRelationshipType#isAnyMisappliedName() any misapplied names} |
|
321 |
* and {@link TaxonRelationshipType#isAnySynonym() any (pro parte synonyms)}. |
|
319 | 322 |
* <BR> |
320 | 323 |
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code> |
321 | 324 |
*/ |
322 |
public void setCloneTaxonRelationships(boolean cloneTaxonRelationships) {
|
|
323 |
this.cloneTaxonRelationships = cloneTaxonRelationships;
|
|
325 |
public void setIncludeTaxonRelationshipsExcludingManAndProParte(boolean includeTaxonRelationshipsExcludingManAndProParte) {
|
|
326 |
this.includeTaxonRelationshipsExcludingManAndProParte = includeTaxonRelationshipsExcludingManAndProParte;
|
|
324 | 327 |
} |
325 | 328 |
} |
Also available in: Unified diff
ref #9228 , ref #4866 some fixes for subtree cloning