import eu.etaxonomy.cdm.format.reference.OriginalSourceFormatter;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.TimePeriod;
import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.Synonym;
Reference sec = taxonBase.getSec();
sec = HibernateProxyHelper.deproxy(sec);
+ TimePeriod sourceAccessed = taxonBase.getSecSource() == null ? null : taxonBase.getSecSource().getAccessed();
+
String secRef;
if (sec == null){
//missing sec
sec.getAuthorship() != null &&
isNotBlank(sec.getAuthorship().getTitleCache()) &&
isNotBlank(sec.getYear())){
- secRef = OriginalSourceFormatter.INSTANCE.format(sec, null); //microRef is handled later
+ secRef = OriginalSourceFormatter.INSTANCE.format(sec, null, sourceAccessed); //microRef is handled later
}else if ((sec.isDynamic())
&& titleExists(sec)){ //maybe we should also test protected caches (but which one, the abbrev cache or the titleCache?
secRef = isNotBlank(sec.getAbbrevTitle())? sec.getAbbrevTitle() : sec.getTitle();
- String secDate = sec.getYear();
- if (isBlank(secDate) && sec.getAccessed() != null){
- secDate = String.valueOf(sec.getAccessed().getYear());
+ String year = sourceAccessed == null? null:sourceAccessed.getYear();
+ if (isBlank(year) && sec.getAccessed() != null){
+ year = String.valueOf(sec.getAccessed().getYear());
+ }
+ if (isBlank(year) && sec.getYear() != null){
+ year = sec.getYear();
}
- secRef = CdmUtils.concat(" ", secRef, secDate);
+
+ secRef = CdmUtils.concat(" ", secRef, year);
}else{
secRef = sec.getTitleCache();
//TODO maybe not always correct
import eu.etaxonomy.cdm.common.URI;
import eu.etaxonomy.cdm.model.agent.Person;
import eu.etaxonomy.cdm.model.agent.Team;
+import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
import eu.etaxonomy.cdm.model.name.IBotanicalName;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
import eu.etaxonomy.cdm.model.name.Rank;
taxonBase.setTitleCache(null, false);
Assert.assertEquals("Abies alba (L.) Mill. sec. MLW 1983", taxonBase.getTitleCache());
+ VerbatimTimePeriod accessed = TimePeriodParser.parseStringVerbatim("5 Mar 2014");
+ taxonBase.getSecSource().setAccessed(accessed);
+ Assert.assertEquals("Abies alba (L.) Mill. sec. MLW 2014", taxonBase.getTitleCache());
}
@Test