Revision 168723a2
Added by Anahit Babadshanjan over 15 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/CdmBase.java | ||
---|---|---|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.model.common; |
11 | 10 |
|
12 | 11 |
import java.beans.PropertyChangeEvent; |
... | ... | |
69 | 68 |
private static final long serialVersionUID = -3053225700018294809L; |
70 | 69 |
@SuppressWarnings("unused") |
71 | 70 |
private static final Logger logger = Logger.getLogger(CdmBase.class); |
72 |
|
|
71 |
|
|
73 | 72 |
@Transient |
74 | 73 |
@XmlTransient |
75 | 74 |
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); |
... | ... | |
347 | 346 |
//no changes to: - |
348 | 347 |
return result; |
349 | 348 |
} |
349 |
|
|
350 | 350 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.cdm.jaxb.LSIDAdapter; |
40 | 40 |
import eu.etaxonomy.cdm.model.media.Rights; |
41 | 41 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
42 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
43 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
42 | 44 |
|
43 | 45 |
/** |
44 | 46 |
* Superclass for the primary CDM classes that can be referenced from outside via LSIDs and contain a simple generated title string as a label for human reading. |
... | ... | |
277 | 279 |
// TODO: Avoid using instanceof operator |
278 | 280 |
// Use Class.getDeclaredMethod() instead to find out whether class has getNameCache() method? |
279 | 281 |
|
280 |
if ((identifiableEntity instanceof NonViralName) && (this instanceof NonViralName)) { |
|
281 |
|
|
282 |
String thisNameCache = ((NonViralName<?>)this).getNameCache(); |
|
283 |
String specifiedNameCache = ((NonViralName<?>)identifiableEntity).getNameCache(); |
|
282 |
// Compare name cache |
|
283 |
String specifiedNameCache = ""; |
|
284 |
String thisNameCache = ""; |
|
285 |
|
|
286 |
if(identifiableEntity instanceof NonViralName) { |
|
287 |
specifiedNameCache = ((NonViralName<?>)identifiableEntity).getNameCache(); |
|
288 |
} else if(identifiableEntity instanceof TaxonBase) { |
|
289 |
TaxonNameBase<?,?> taxonNameBase= ((TaxonBase)identifiableEntity).getName(); |
|
290 |
specifiedNameCache = ((NonViralName<?>)taxonNameBase).getNameCache(); |
|
291 |
} |
|
292 |
|
|
293 |
if(this instanceof NonViralName) { |
|
294 |
thisNameCache = ((NonViralName<?>)this).getNameCache(); |
|
295 |
} else if(this instanceof TaxonBase) { |
|
296 |
TaxonNameBase<?,?> taxonNameBase= ((TaxonBase)this).getName(); |
|
297 |
thisNameCache = ((NonViralName<?>)taxonNameBase).getNameCache(); |
|
298 |
} |
|
299 |
|
|
300 |
if (!specifiedNameCache.equals("") && !thisNameCache.equals("")) { |
|
284 | 301 |
result = thisNameCache.compareTo(specifiedNameCache); |
285 | 302 |
} |
286 | 303 |
|
287 |
// Compare the title cache if name cache is equal
|
|
304 |
// Compare title cache
|
|
288 | 305 |
if (result == 0) { |
289 | 306 |
String thisTitleCache = getTitleCache(); |
290 | 307 |
String specifiedTitleCache = identifiableEntity.getTitleCache(); |
291 | 308 |
result = thisTitleCache.compareTo(specifiedTitleCache); |
292 |
|
|
293 | 309 |
} |
294 | 310 |
return result; |
295 | 311 |
} |
296 | 312 |
|
313 |
|
|
297 | 314 |
//****************** CLONE ************************************************/ |
298 | 315 |
|
299 | 316 |
/* (non-Javadoc) |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java | ||
---|---|---|
75 | 75 |
* The corresponding {@link Feature feature} is set to {@link Feature#DISTRIBUTION() DISTRIBUTION}. |
76 | 76 |
*/ |
77 | 77 |
protected Distribution(){ |
78 |
super(Feature.DISTRIBUTION());
|
|
78 |
super(); |
|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
|
... | ... | |
87 | 87 |
*/ |
88 | 88 |
public static Distribution NewInstance(){ |
89 | 89 |
Distribution result = new Distribution(); |
90 |
result.setType(Feature.DISTRIBUTION()); |
|
90 | 91 |
return result; |
91 | 92 |
} |
92 | 93 |
|
... | ... | |
99 | 100 |
* @see #NewInstance() |
100 | 101 |
*/ |
101 | 102 |
public static Distribution NewInstance(NamedArea area, PresenceAbsenceTermBase<?> status){ |
102 |
Distribution result = new Distribution();
|
|
103 |
Distribution result = NewInstance();
|
|
103 | 104 |
result.setArea(area); |
104 | 105 |
result.setStatus(status); |
105 | 106 |
return result; |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/FeatureNode.java | ||
---|---|---|
190 | 190 |
*/ |
191 | 191 |
public void addChild(FeatureNode child, int index){ |
192 | 192 |
if (index < 0 || index > children.size() + 1){ |
193 |
throw new IndexOutOfBoundsException("Wrong index");
|
|
193 |
throw new IndexOutOfBoundsException("Wrong index: " + index);
|
|
194 | 194 |
} |
195 | 195 |
if (child.getParent() != null){ |
196 | 196 |
child.getParent().removeChild(child); |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java | ||
---|---|---|
18 | 18 |
import javax.persistence.FetchType; |
19 | 19 |
import javax.persistence.Inheritance; |
20 | 20 |
import javax.persistence.InheritanceType; |
21 |
import javax.persistence.JoinColumn; |
|
21 | 22 |
import javax.persistence.ManyToMany; |
22 | 23 |
import javax.persistence.ManyToOne; |
23 | 24 |
import javax.persistence.OneToMany; |
... | ... | |
41 | 42 |
import org.hibernate.search.annotations.Indexed; |
42 | 43 |
import org.springframework.util.ReflectionUtils; |
43 | 44 |
|
45 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
44 | 46 |
import eu.etaxonomy.cdm.model.common.IParsable; |
45 | 47 |
import eu.etaxonomy.cdm.model.common.IReferencedEntity; |
46 | 48 |
import eu.etaxonomy.cdm.model.common.IRelated; |
... | ... | |
96 | 98 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
97 | 99 |
@Table(appliesTo="TaxonNameBase", indexes = { @Index(name = "taxonNameBaseTitleCacheIndex", columnNames = { "titleCache" }) }) |
98 | 100 |
public abstract class TaxonNameBase<T extends TaxonNameBase<?,?>, S extends INameCacheStrategy> extends IdentifiableEntity implements IReferencedEntity, IParsable, IRelated { |
101 |
|
|
99 | 102 |
private static final long serialVersionUID = -4530368639601532116L; |
100 | 103 |
private static final Logger logger = Logger.getLogger(TaxonNameBase.class); |
101 | 104 |
|
... | ... | |
639 | 642 |
public INomenclaturalReference getNomenclaturalReference(){ |
640 | 643 |
return (INomenclaturalReference)this.nomenclaturalReference; |
641 | 644 |
} |
645 |
|
|
642 | 646 |
/** |
643 | 647 |
* Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name. |
644 | 648 |
* The corresponding {@link eu.etaxonomy.cdm.model.reference.ReferenceBase.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true |
... | ... | |
824 | 828 |
boolean isNotDesignated, |
825 | 829 |
boolean addToAllHomotypicNames) { |
826 | 830 |
NameTypeDesignation nameTypeDesignation = new NameTypeDesignation(typeSpecies, citation, citationMicroReference, originalNameString, isRejectedType, isConservedType, isLectoType, isNotDesignated); |
831 |
nameTypeDesignation.setLectoType(isLectoType); |
|
827 | 832 |
addTypeDesignation(nameTypeDesignation, addToAllHomotypicNames); |
828 | 833 |
} |
829 | 834 |
|
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/name/TaxonNameBaseTest.java | ||
---|---|---|
23 | 23 |
import org.junit.Test; |
24 | 24 |
|
25 | 25 |
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer; |
26 |
import eu.etaxonomy.cdm.model.reference.Generic; |
|
27 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
|
26 | 28 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
27 | 29 |
import eu.etaxonomy.cdm.model.description.TaxonNameDescription; |
28 | 30 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
336 | 338 |
*/ |
337 | 339 |
@Test |
338 | 340 |
public void testGetNomenclaturalReference() { |
339 |
logger.warn("not yet implemented"); |
|
341 |
INomenclaturalReference nr = nameBase1.getNomenclaturalReference(); |
|
342 |
assertNull("Nomenclatural Reference shall be null", nr); |
|
343 |
nameBase1.setNomenclaturalReference(Generic.NewInstance()); |
|
344 |
nr = nameBase1.getNomenclaturalReference(); |
|
345 |
assertNotNull("Nomenclatural Reference shall not be null", nr); |
|
340 | 346 |
} |
341 | 347 |
|
342 | 348 |
/** |
Also available in: Unified diff
Merged branches/cdmlib/2.0 changes r5130:5370 into the trunk