import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
public class Registration extends AnnotatableEntity {
private static final long serialVersionUID = -5633923579539766801L;
+ private static final Logger logger = Logger.getLogger(Registration.class);
@XmlElement(name = "Identifier")
@NullOrNotEmpty
}
}
+ @Override
+ public Registration clone() {
+ try {
+ Registration result = (Registration)super.clone();
+
+ result.blockedBy = new HashSet<>();
+ for (Registration blockedByReg: this.blockedBy){
+ result.addBlockedBy(blockedByReg);
+ }
+
+ result.typeDesignations = new HashSet<>();
+ for (TypeDesignationBase<?> typeDesignation: this.typeDesignations){
+ result.addTypeDesignation(typeDesignation);
+ }
+
+
+ //no changes to: identifier, institution, registrationDate, specificIdentifier,
+ //status, submitter
+ return result;
+ } catch (CloneNotSupportedException e) {
+ logger.warn("Object does not implement cloneable");
+ e.printStackTrace();
+ return null;
+ }
+
+ }
}
result.authorshipCache = null;
}
+ //registrations
+ result.registrations = new HashSet<>();
+ for (Registration registration : getRegistrations()){
+ result.registrations.add(registration);
+ }
+
//no changes to: appendedPharse, nomenclaturalReference,
//nomenclaturalMicroReference, parsingProblem, problemEnds, problemStarts
//protectedFullTitleCache, rank
result.setRelationsFromThisTaxon(new HashSet<>());
result.setRelationsToThisTaxon(new HashSet<>());
- if (withTaxonRelations){
+ if (withTaxonRelations || withSynonyms){
for (TaxonRelationship fromRelationship : this.getRelationsFromThisTaxon()){
- TaxonRelationship newRelationship = fromRelationship.clone();
- newRelationship.setRelatedFrom(result);
- result.relationsFromThisTaxon.add(newRelationship);
+ boolean isSynonymRelation = fromRelationship.getType() != null &&
+ fromRelationship.getType().isAnySynonymOrMisappliedName();
+ if (isSynonymRelation && withSynonyms || !isSynonymRelation && withTaxonRelations){
+ TaxonRelationship newRelationship = fromRelationship.clone();
+ newRelationship.setRelatedFrom(result);
+ result.relationsFromThisTaxon.add(newRelationship);
+ }
}
for (TaxonRelationship toRelationship : this.getRelationsToThisTaxon()){
- TaxonRelationship newRelationship = toRelationship.clone();
- newRelationship.setRelatedTo(result);
- result.relationsToThisTaxon.add(newRelationship);
+ boolean isSynonymRelation = toRelationship.getType() != null &&
+ toRelationship.getType().isAnySynonymOrMisappliedName();
+ if (isSynonymRelation && withSynonyms || !isSynonymRelation && withTaxonRelations){
+ TaxonRelationship newRelationship = toRelationship.clone();
+ newRelationship.setRelatedTo(result);
+ result.relationsToThisTaxon.add(newRelationship);
+ }
}
}
return (allMisappliedNameTypes().contains(this));
}
+ /**
+ * <code>true</code> if this relationship type is any
+ * of the {@link #isAnyMisappliedName() misapplied name relationships} or
+ * any of the {@link #isAnySynonym() (pro parte) synonym relationships}
+ */
+ public boolean isAnySynonymOrMisappliedName(){
+ return (allMisappliedNameTypes().contains(this) || allSynonymTypes().contains(this));
+ }
+
/**
* <code>true</code> if this relationship type is any
if (config.isReuseTaxa()){
childNodeClone = parentNodeClone.addChildTaxon(originalTaxon, config.getParentChildReference(), microReference);
}else{
- Taxon cloneTaxon = originalTaxon.clone(config.isCloneSynonyms(), config.isCloneTaxonRelationships(),
- config.isCloneDescriptiveData(), config.isCloneMedia());
+ Taxon cloneTaxon = originalTaxon.clone(config.isIncludeSynonymsIncludingManAndProParte(),
+ config.isIncludeTaxonRelationshipsExcludingManAndProParte(),
+ config.isIncludeDescriptiveData(), config.isIncludeMedia());
+
+ //name
+ if (!config.isReuseNames()){
+ cloneTaxon.setName(cloneTaxon.getName().clone());
+ }
+
// xxx KonzeptClone MAN, ppSyns;
if (!config.isReuseTaxonSecundum()){
cloneTaxon.setSec(config.getTaxonSecundum());
childNodeClone = parentNodeClone.addChildTaxon(cloneTaxon, config.getParentChildReference(), microReference);
}
- //TODO necessary?
+ //probably necessary as taxon nodes do not cascade
taxonNodeDao.saveOrUpdate(childNodeClone);
//add children
List<TaxonNode> originalChildNodes = originalParentNode.getChildNodes();
private boolean reuseTaxa = false;
//used only if reuseTaxa == false
- private boolean cloneSynonyms = true;
+ private boolean includeSynonymsIncludingManAndProParte = true;
//used only if reuseTaxa == false
- private boolean cloneDescriptiveData = true;
+ private boolean includeDescriptiveData = true;
//used only if reuseTaxa == false
- private boolean cloneMedia = true;
+ private boolean includeMedia = true;
//used only if reuseTaxa == false
- private boolean cloneTaxonRelationships = false;
+ private boolean includeTaxonRelationshipsExcludingManAndProParte = false;
//used only if reuseTaxa == false
private boolean reuseNames = true;
//used only if reuseTaxa == false
this.relationshipReference = relationshipReference;
}
- public boolean isCloneSynonyms() {
- return cloneSynonyms;
+ public boolean isIncludeSynonymsIncludingManAndProParte() {
+ return this.includeSynonymsIncludingManAndProParte;
}
/**
* If <code>true</code> the synonyms relationships of this taxon are cloned and attached to the new taxon.
* <BR>
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
*/
- public void setCloneSynonyms(boolean cloneSynonyms) {
- this.cloneSynonyms = cloneSynonyms;
+ public void setIncludeSynonymsIncludingManAndProParte(boolean includeSynonyms) {
+ this.includeSynonymsIncludingManAndProParte = includeSynonyms;
}
- public boolean isCloneDescriptiveData() {
- return cloneDescriptiveData;
+ public boolean isIncludeDescriptiveData() {
+ return includeDescriptiveData;
}
-
/**
- * If <code>true</code> the descriptive data attached to this taxon are also cloned and attached to the new taxon.
+ * If <code>true</code> the descriptive data attached to this taxon are included in the copy
+ * and attached to the new taxon.
* <BR>
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
*/
- public void setCloneDescriptiveData(boolean cloneDescriptiveData) {
- this.cloneDescriptiveData = cloneDescriptiveData;
+ public void setIncludeDescriptiveData(boolean includeDescriptiveData) {
+ this.includeDescriptiveData = includeDescriptiveData;
}
- public boolean isCloneMedia() {
- return cloneMedia;
+ public boolean isIncludeMedia() {
+ return includeMedia;
}
/**
* If <code>true</code> the media attached to this taxon are also attached to the new taxon.
- * Media itself are always reused.<BR>
+ * Media itself are always reused.
+ * <BR>
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
*/
- public void setCloneMedia(boolean cloneMedia) {
- this.cloneMedia = cloneMedia;
+ public void setIncludeMedia(boolean includeMedia) {
+ this.includeMedia = includeMedia;
}
- public boolean isCloneTaxonRelationships() {
- return cloneTaxonRelationships;
+ public boolean isIncludeTaxonRelationshipsExcludingManAndProParte() {
+ return includeTaxonRelationshipsExcludingManAndProParte;
}
/**
* If <code>true</code> the taxon (concept) relationships to and from this taxon are also cloned.
+ * This includes all taxon relationships except those for {@link TaxonRelationshipType#isAnyMisappliedName() any misapplied names}
+ * and {@link TaxonRelationshipType#isAnySynonym() any (pro parte synonyms)}.
* <BR>
* This parameter is used only if <code>{@link #isReuseTaxa() reuseTaxa} == false</code>
*/
- public void setCloneTaxonRelationships(boolean cloneTaxonRelationships) {
- this.cloneTaxonRelationships = cloneTaxonRelationships;
+ public void setIncludeTaxonRelationshipsExcludingManAndProParte(boolean includeTaxonRelationshipsExcludingManAndProParte) {
+ this.includeTaxonRelationshipsExcludingManAndProParte = includeTaxonRelationshipsExcludingManAndProParte;
}
}