Revision 94d72025
Added by Andreas Müller almost 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonName.java | ||
---|---|---|
72 | 72 |
import eu.etaxonomy.cdm.model.common.IParsable; |
73 | 73 |
import eu.etaxonomy.cdm.model.common.IRelated; |
74 | 74 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
75 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
75 | 76 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
76 | 77 |
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction; |
77 | 78 |
import eu.etaxonomy.cdm.model.common.TermType; |
... | ... | |
127 | 128 |
"appendedPhrase", |
128 | 129 |
"nomenclaturalMicroReference", |
129 | 130 |
"nomenclaturalReference", |
131 |
"nomenclaturalSource", |
|
130 | 132 |
"rank", |
131 | 133 |
"fullTitleCache", |
132 | 134 |
"protectedFullTitleCache", |
... | ... | |
233 | 235 |
// @NullOrNotEmpty |
234 | 236 |
@Column(length=255) |
235 | 237 |
private String appendedPhrase; |
236 |
|
|
237 |
@XmlElement(name = "NomenclaturalMicroReference") |
|
238 |
@Field |
|
239 |
@CacheUpdate(noUpdate ="titleCache") |
|
240 |
//TODO Val #3379 |
|
241 |
// @NullOrNotEmpty |
|
242 |
@Column(length=255) |
|
243 |
private String nomenclaturalMicroReference; |
|
238 |
// |
|
239 |
// @XmlElement(name = "NomenclaturalMicroReference")
|
|
240 |
// @Field
|
|
241 |
// @CacheUpdate(noUpdate ="titleCache")
|
|
242 |
// //TODO Val #3379
|
|
243 |
//// @NullOrNotEmpty
|
|
244 |
// @Column(length=255)
|
|
245 |
// private String nomenclaturalMicroReference;
|
|
244 | 246 |
|
245 | 247 |
@XmlAttribute |
246 | 248 |
@CacheUpdate(noUpdate ={"titleCache","fullTitleCache"}) |
... | ... | |
325 | 327 |
// @NotNull |
326 | 328 |
@IndexedEmbedded(depth=1) |
327 | 329 |
private Rank rank; |
328 |
|
|
329 |
@XmlElement(name = "NomenclaturalReference") |
|
330 |
// |
|
331 |
// @XmlElement(name = "NomenclaturalReference") |
|
332 |
// @XmlIDREF |
|
333 |
// @XmlSchemaType(name = "IDREF") |
|
334 |
// @ManyToOne(fetch = FetchType.LAZY) |
|
335 |
// @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE}) |
|
336 |
// @CacheUpdate(noUpdate ="titleCache") |
|
337 |
// @IndexedEmbedded |
|
338 |
// private Reference nomenclaturalReference; |
|
339 |
|
|
340 |
@XmlElement(name = "NomenclaturalSource") |
|
330 | 341 |
@XmlIDREF |
331 | 342 |
@XmlSchemaType(name = "IDREF") |
332 | 343 |
@ManyToOne(fetch = FetchType.LAZY) |
333 | 344 |
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE}) |
334 | 345 |
@CacheUpdate(noUpdate ="titleCache") |
335 | 346 |
@IndexedEmbedded |
336 |
private Reference nomenclaturalReference; |
|
347 |
private DescriptionElementSource nomenclaturalSource; |
|
348 |
|
|
349 |
|
|
337 | 350 |
|
338 | 351 |
@XmlElementWrapper(name = "Registrations") |
339 | 352 |
@XmlElement(name = "Registration") |
... | ... | |
663 | 676 |
* @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy |
664 | 677 |
* @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy |
665 | 678 |
*/ |
666 |
protected TaxonName(NomenclaturalCode type, Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorship, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) { |
|
679 |
protected TaxonName(NomenclaturalCode type, Rank rank, String genusOrUninomial, |
|
680 |
String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, |
|
681 |
TeamOrPersonBase combinationAuthorship, Reference nomenclaturalReference, |
|
682 |
String nomenclMicroRef, HomotypicalGroup homotypicalGroup) { |
|
667 | 683 |
this(type, rank, homotypicalGroup); |
668 | 684 |
setGenusOrUninomial(genusOrUninomial); |
669 | 685 |
setInfraGenericEpithet (infraGenericEpithet); |
... | ... | |
2223 | 2239 |
this.rank = rank; |
2224 | 2240 |
} |
2225 | 2241 |
|
2226 |
/** |
|
2227 |
* Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name. |
|
2228 |
* The nomenclatural reference is here meant to be the one publication |
|
2229 |
* <i>this</i> taxon name was originally published in while fulfilling the formal |
|
2230 |
* requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}. |
|
2231 |
* |
|
2232 |
* @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference |
|
2233 |
* @see eu.etaxonomy.cdm.model.reference.Reference |
|
2234 |
*/ |
|
2242 |
|
|
2235 | 2243 |
@Override |
2236 |
public INomenclaturalReference getNomenclaturalReference(){ |
|
2237 |
return this.nomenclaturalReference; |
|
2244 |
public Reference getNomenclaturalReference(){ |
|
2245 |
if (this.nomenclaturalSource == null){ |
|
2246 |
return null; |
|
2247 |
} |
|
2248 |
return this.nomenclaturalSource.getCitation(); |
|
2249 |
} |
|
2250 |
|
|
2251 |
@Override |
|
2252 |
public DescriptionElementSource getNomenclaturalSource(){ |
|
2253 |
return this.nomenclaturalSource; |
|
2254 |
} |
|
2255 |
|
|
2256 |
protected DescriptionElementSource getNomenclaturalSource(boolean createIfNotExist){ |
|
2257 |
if (this.nomenclaturalSource == null){ |
|
2258 |
if (!createIfNotExist){ |
|
2259 |
return null; |
|
2260 |
} |
|
2261 |
this.nomenclaturalSource = DescriptionElementSource.NewInstance(OriginalSourceType.NomenclaturalReference); |
|
2262 |
} |
|
2263 |
return this.nomenclaturalSource; |
|
2238 | 2264 |
} |
2265 |
|
|
2239 | 2266 |
/** |
2240 | 2267 |
* Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name. |
2241 | 2268 |
* The corresponding {@link eu.etaxonomy.cdm.model.reference.Reference.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true |
2242 | 2269 |
* as it is obviously used for nomenclatural purposes. |
2243 | 2270 |
* |
2271 |
* Shortcut to set the nomenclatural reference. |
|
2272 |
* |
|
2244 | 2273 |
* @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference} |
2245 | 2274 |
* @see #getNomenclaturalReference() |
2246 | 2275 |
*/ |
2276 |
|
|
2247 | 2277 |
@Override |
2248 |
public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference){ |
|
2249 |
if(nomenclaturalReference != null){ |
|
2250 |
if(!INomenclaturalReference.class.isAssignableFrom(nomenclaturalReference.getClass())){ |
|
2251 |
throw new IllegalArgumentException("Parameter nomenclaturalReference is not assignable from INomenclaturalReference"); |
|
2252 |
} |
|
2253 |
this.nomenclaturalReference = (Reference)nomenclaturalReference; |
|
2254 |
} else { |
|
2255 |
this.nomenclaturalReference = null; |
|
2278 |
public void setNomenclaturalReference(Reference nomenclaturalReference){ |
|
2279 |
getNomenclaturalSource(true).setCitation(nomenclaturalReference); |
|
2280 |
checkNullSource(); |
|
2281 |
} |
|
2282 |
|
|
2283 |
|
|
2284 |
/** |
|
2285 |
* |
|
2286 |
*/ |
|
2287 |
private void checkNullSource() { |
|
2288 |
if (this.nomenclaturalSource == null){ |
|
2289 |
return; |
|
2290 |
}else if (this.nomenclaturalSource.getCitation() != null |
|
2291 |
|| this.nomenclaturalSource.getCitationMicroReference() != null |
|
2292 |
|| this.nomenclaturalSource.getNameUsedInSource() != null |
|
2293 |
|| isBlank(this.nomenclaturalSource.getOriginalNameString())){ |
|
2294 |
//TODO what about supplemental data? |
|
2295 |
return; |
|
2296 |
}else{ |
|
2297 |
this.nomenclaturalSource = null; |
|
2256 | 2298 |
} |
2257 | 2299 |
} |
2258 | 2300 |
|
2301 |
|
|
2302 |
@Override |
|
2303 |
public void setNomenclaturalSource(DescriptionElementSource nomenclaturalSource) throws IllegalArgumentException { |
|
2304 |
if (!OriginalSourceType.NomenclaturalReference.equals(nomenclaturalSource.getType()) ){ |
|
2305 |
throw new IllegalArgumentException("Nomenclatural source must be of type " + OriginalSourceType.NomenclaturalReference.getMessage()); |
|
2306 |
} |
|
2307 |
this.nomenclaturalSource = nomenclaturalSource; |
|
2308 |
} |
|
2309 |
|
|
2259 | 2310 |
/** |
2260 | 2311 |
* Returns the appended phrase string assigned to <i>this</i> taxon name. |
2261 | 2312 |
* The appended phrase is a non-atomised addition to a name. It is |
... | ... | |
2285 | 2336 |
//Details of the nomenclatural reference (protologue). |
2286 | 2337 |
@Override |
2287 | 2338 |
public String getNomenclaturalMicroReference(){ |
2288 |
return this.nomenclaturalMicroReference; |
|
2339 |
if (this.nomenclaturalSource == null){ |
|
2340 |
return null; |
|
2341 |
} |
|
2342 |
return this.nomenclaturalSource.getCitationMicroReference(); |
|
2289 | 2343 |
} |
2290 | 2344 |
/** |
2291 | 2345 |
* @see #getNomenclaturalMicroReference() |
2292 | 2346 |
*/ |
2293 | 2347 |
@Override |
2294 | 2348 |
public void setNomenclaturalMicroReference(String nomenclaturalMicroReference){ |
2295 |
this.nomenclaturalMicroReference = StringUtils.isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference; |
|
2349 |
this.getNomenclaturalSource(true).setCitationMicroReference(StringUtils.isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference); |
|
2350 |
checkNullSource(); |
|
2296 | 2351 |
} |
2297 | 2352 |
|
2298 | 2353 |
@Override |
Also available in: Unified diff
ref #6581 first incomplete version for making nomenclatural reference an orginal source