package eu.etaxonomy.cdm.model.name;
-import eu.etaxonomy.cdm.model.agent.Agent;
-import eu.etaxonomy.cdm.model.agent.INomenclaturalAgent;
+import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
-import eu.etaxonomy.cdm.strategy.BotanicNameDefaultCacheStrategy;
-import eu.etaxonomy.cdm.strategy.NonViralNameDefaultCacheStrategy;
+import eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy;
+import eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
+import org.hibernate.annotations.Target;
import javax.persistence.*;
*/
@Entity
public class NonViralName<T extends NonViralName> extends TaxonNameBase<NonViralName> {
- static Logger logger = Logger.getLogger(NonViralName.class);
+ private static final Logger logger = Logger.getLogger(NonViralName.class);
+
//The suprageneric or the genus name
private String genusOrUninomial;
//Genus subdivision epithet
//Species subdivision epithet
private String infraSpecificEpithet;
//Author team that published the present combination
- private INomenclaturalAgent combinationAuthorTeam;
+ private INomenclaturalAuthor combinationAuthorTeam;
//Author team that contributed to the publication of the present combination
- private INomenclaturalAgent exCombinationAuthorTeam;
+ private INomenclaturalAuthor exCombinationAuthorTeam;
//Author team that published the original publication
- private INomenclaturalAgent basionymAuthorTeam;
+ private INomenclaturalAuthor basionymAuthorTeam;
//Author team that contributed to the original publication of the name
- private INomenclaturalAgent exBasionymAuthorTeam;
+ private INomenclaturalAuthor exBasionymAuthorTeam;
//concatenated und formated authorteams including basionym and combination authors
private String authorshipCache;
+ //this flag shows if the getAuthorshipCache should return generated value(false) or the given String(true)
+ protected boolean protectedAuthorshipCache;
+
+
+ public static NonViralName NewInstance(Rank rank){
+ return new NonViralName(rank, null);
+ }
+
+ public static NonViralName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
+ return new NonViralName(rank, homotypicalGroup);
+ }
+
//needed by hibernate
protected NonViralName(){
setNameCacheStrategy();
}
- private void setNameCacheStrategy(){
- if (getClass() == NonViralName.class){
- this.cacheStrategy = NonViralNameDefaultCacheStrategy.NewInstance();
- }
-
- }
-
- public NonViralName(Rank rank) {
- super(rank);
+ protected NonViralName(Rank rank, HomotypicalGroup homotypicalGroup) {
+ super(rank, homotypicalGroup);
setNameCacheStrategy();
}
- public NonViralName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, INomenclaturalAgent combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef) {
- super(rank);
+ protected NonViralName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
+ super(rank, homotypicalGroup);
setNameCacheStrategy();
setGenusOrUninomial(genusOrUninomial);
setSpecificEpithet(specificEpithet);
setNomenclaturalReference(nomenclaturalReference);
this.setNomenclaturalMicroReference(nomenclMicroRef);
}
+
+ private void setNameCacheStrategy(){
+ if (getClass() == NonViralName.class){
+ this.cacheStrategy = NonViralNameDefaultCacheStrategy.NewInstance();
+ }
+
+ }
@ManyToOne
@Cascade({CascadeType.SAVE_UPDATE})
- public INomenclaturalAgent getCombinationAuthorTeam(){
+ @Target(TeamOrPersonBase.class)
+ public INomenclaturalAuthor getCombinationAuthorTeam(){
return this.combinationAuthorTeam;
}
- public void setCombinationAuthorTeam(INomenclaturalAgent combinationAuthorTeam){
+ public void setCombinationAuthorTeam(INomenclaturalAuthor combinationAuthorTeam){
this.combinationAuthorTeam = combinationAuthorTeam;
}
@ManyToOne
@Cascade({CascadeType.SAVE_UPDATE})
- public INomenclaturalAgent getExCombinationAuthorTeam(){
+ @Target(TeamOrPersonBase.class)
+ public INomenclaturalAuthor getExCombinationAuthorTeam(){
return this.exCombinationAuthorTeam;
}
- public void setExCombinationAuthorTeam(INomenclaturalAgent exCombinationAuthorTeam){
+ public void setExCombinationAuthorTeam(INomenclaturalAuthor exCombinationAuthorTeam){
this.exCombinationAuthorTeam = exCombinationAuthorTeam;
}
@ManyToOne
@Cascade({CascadeType.SAVE_UPDATE})
- public INomenclaturalAgent getBasionymAuthorTeam(){
+ @Target(TeamOrPersonBase.class)
+ public INomenclaturalAuthor getBasionymAuthorTeam(){
return basionymAuthorTeam;
}
- public void setBasionymAuthorTeam(INomenclaturalAgent basionymAuthorTeam) {
+ public void setBasionymAuthorTeam(INomenclaturalAuthor basionymAuthorTeam) {
this.basionymAuthorTeam = basionymAuthorTeam;
}
@ManyToOne
@Cascade({CascadeType.SAVE_UPDATE})
- public INomenclaturalAgent getExBasionymAuthorTeam(){
+ @Target(TeamOrPersonBase.class)
+ public INomenclaturalAuthor getExBasionymAuthorTeam(){
return exBasionymAuthorTeam;
}
- public void setExBasionymAuthorTeam(INomenclaturalAgent exBasionymAuthorTeam) {
+ public void setExBasionymAuthorTeam(INomenclaturalAuthor exBasionymAuthorTeam) {
this.exBasionymAuthorTeam = exBasionymAuthorTeam;
}
return cacheStrategy.getTitleCache(this);
}
}
+
+ public String generateAuthorship(){
+ if (cacheStrategy == null){
+ logger.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
+ return null;
+ }else{
+ return ((INonViralNameCacheStrategy<T>)cacheStrategy).getAuthorshipCache((T)this);
+ }
+ }
/**
* returns concatenated und formated authorteams including basionym and
* combination authors
*/
public String getAuthorshipCache() {
+ if (protectedAuthorshipCache){
+ return this.authorshipCache;
+ }
+ // is title dirty, i.e. equal NULL?
+ if (authorshipCache == null){
+ this.authorshipCache = generateAuthorship();
+ }else{
+ //TODO get is Dirty of authors
+ this.authorshipCache = generateAuthorship();
+ }
return authorshipCache;
}
@Override
@Transient
public boolean isCodeCompliant() {
- // TODO Auto-generated method stub
+ //FIXME
+ logger.warn("is CodeCompliant not yet implemented");
return false;
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#getNomeclaturalCode()
+ */
+ @Transient
+ @Override
+ public NomenclaturalCode getNomeclaturalCode() {
+ logger.warn("Non Viral Name has no specific Code defined. Use subclasses");
+ return null;
+ }
+
+
+
}
\ No newline at end of file