import eu.etaxonomy.cdm.compare.taxon.HomotypicGroupTaxonComparator;
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
+import eu.etaxonomy.cdm.format.reference.OriginalSourceFormatter;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.io.common.CdmExportBase;
import eu.etaxonomy.cdm.io.common.ExportResult.ExportResultState;
import eu.etaxonomy.cdm.strategy.cache.HTMLTagRules;
import eu.etaxonomy.cdm.strategy.cache.TagEnum;
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
-import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceDefaultCacheStrategy;
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
/**
int index = 1;
for (IdentifiableSource source: typeDesignation.getSources()){
if (source.getCitation() != null){
- ReferenceDefaultCacheStrategy cacheStrategy = ((ReferenceDefaultCacheStrategy)source.getCitation().getCacheStrategy());
- stringbuilder.append(cacheStrategy.getCitation(source.getCitation(), source.getCitationMicroReference()));
+ stringbuilder.append(OriginalSourceFormatter.INSTANCE.format(source));
}
if (index < typeDesignation.getSources().size()) {
stringbuilder.append( ", ");
statusString += ": " + nameStatus.getRuleConsidered();
}
if (nameStatus.getCitation() != null) {
- String shortCitation = ((ReferenceDefaultCacheStrategy) nameStatus.getCitation().getCacheStrategy())
- .createShortCitation(nameStatus.getCitation(), null, false);
+ String shortCitation = OriginalSourceFormatter.INSTANCE.format(nameStatus.getCitation(), null);
statusString += " (" + shortCitation + ")";
}
// if (nameStatus.getCitationMicroReference() != null
if (taxonBases.size() == 1){
taxonBase = HibernateProxyHelper.deproxy(taxonBases.iterator().next());
- Reference secRef = taxonBase.getSec();
- if (secRef != null){
- sec = ((ReferenceDefaultCacheStrategy) secRef.getCacheStrategy())
- .createShortCitation(secRef, taxonBase.getSecMicroReference(), true);
+ if (taxonBase.getSec() != null){
+ sec = OriginalSourceFormatter.INSTANCE_WITH_BRACKETS.format(taxonBase.getSecSource());
}
if (taxonBase.isDoubtful()){
doubtful = "?";
}else{
//there are names used more than once?
for (TaxonBase<?> tb: taxonBases){
- Reference secRef = tb.getSec();
- if (secRef != null){
- sec = ((ReferenceDefaultCacheStrategy) secRef.getCacheStrategy())
- .createShortCitation(secRef, tb.getSecMicroReference(), true);
+ if (tb.getSec() != null){
+ sec = OriginalSourceFormatter.INSTANCE_WITH_BRACKETS.format(tb.getSecSource());
}
if (tb.isDoubtful()){
doubtful = "?";
String[] csvLine = new String[table.getSize()];
csvLine[table.getIndex(CdmLightExportTable.REFERENCE_ID)] = getId(state, reference);
// TODO short citations correctly
- String shortCitation = ((ReferenceDefaultCacheStrategy) reference.getCacheStrategy())
- .createShortCitation(reference, null, true); // Should be Author(year)
- // like in Taxon.sec
+ String shortCitation = OriginalSourceFormatter.INSTANCE_WITH_BRACKETS.format(reference, null); // Should be Author(year) like in Taxon.sec
csvLine[table.getIndex(CdmLightExportTable.BIBLIO_SHORT_CITATION)] = shortCitation;
// TODO get preferred title
csvLine[table.getIndex(CdmLightExportTable.REF_TITLE)] = reference.isProtectedTitleCache()
--- /dev/null
+/**
+* Copyright (C) 2021 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.reference;
+
+import java.util.List;
+
+import eu.etaxonomy.cdm.common.CdmUtils;
+import eu.etaxonomy.cdm.format.CdmFormatterBase;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.agent.Team;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
+
+/**
+ * @author a.mueller
+ * @since 13.05.2021
+ */
+public class OriginalSourceFormatter extends CdmFormatterBase<OriginalSourceBase>{
+
+ private final boolean withYearBrackets;
+
+ public static OriginalSourceFormatter INSTANCE = new OriginalSourceFormatter(false);
+ public static OriginalSourceFormatter INSTANCE_WITH_BRACKETS = new OriginalSourceFormatter(true);
+
+ /**
+ * @param withYearBrackets if <code>false</code> the result comes without brackets (default is <code>false</code>)
+ */
+ private OriginalSourceFormatter(boolean withYearBrackets) {
+ this.withYearBrackets = withYearBrackets;
+ }
+
+ @Override
+ public String format(OriginalSourceBase source) {
+ if (source == null){
+ return null;
+ }
+ Reference reference = source.getCitation();
+ String microReference = source.getCitationMicroReference();
+ if (reference == null && isBlank(microReference)){
+ return null;
+ }
+ return format(reference, microReference);
+ }
+
+ /**
+ * Creates a citation in form <i>author year: detail</i> or <i>author (year: detail)</i>.
+ * <BR>
+ * If reference has protected titlecache only the titlecache is returned (may change in future).
+ * <BR>
+ * The author team is abbreviated with <code>et al.</code> if more than 2 authors exist in the team.
+ *
+ * @param reference the reference to format
+ * @param citationDetail the microreference (page, figure, etc.), if <code>null</code> also the colon separator is not used
+ */
+ public String format(Reference reference, String citationDetail){
+ if (reference == null){
+ return null;
+ }
+
+ if(reference.isProtectedTitleCache()){
+ return handleCitationDetailInTitleCache(reference.getTitleCache(), citationDetail);
+ }
+ TeamOrPersonBase<?> authorship = reference.getAuthorship();
+ String authorStr = "";
+ if (authorship == null) {
+ return handleCitationDetailInTitleCache(reference.getTitleCache(), citationDetail);
+ }
+ authorship = CdmBase.deproxy(authorship);
+ if (authorship instanceof Person){
+ authorStr = getPersonString((Person)authorship);
+ }
+ else if (authorship instanceof Team){
+
+ Team team = CdmBase.deproxy(authorship, Team.class);
+ if (team.isProtectedTitleCache()){
+ authorStr = team.getTitleCache();
+ }else{
+ List<Person> teamMembers = team.getTeamMembers();
+ int etAlPosition = 2;
+ for (int i = 1; i <= teamMembers.size() &&
+ (i < etAlPosition || teamMembers.size() == etAlPosition && !team.isHasMoreMembers()) ; i++){
+ Person teamMember = teamMembers.get(i-1);
+ if(teamMember == null){
+ // this can happen in UIs in the process of adding new members
+ continue;
+ }
+ String concat = TeamDefaultCacheStrategy.concatString(team, teamMembers, i);
+ authorStr += concat + getPersonString(teamMember);
+ }
+ if (teamMembers.size() == 0){
+ authorStr = TeamDefaultCacheStrategy.EMPTY_TEAM;
+ } else if (team.isHasMoreMembers() || teamMembers.size() > etAlPosition){
+ authorStr += TeamDefaultCacheStrategy.ET_AL_TEAM_CONCATINATION_FULL + "al.";
+ }
+ }
+ }
+ String result = CdmUtils.concat(" ", authorStr, getShortCitationDate(reference, withYearBrackets, citationDetail));
+
+ return result;
+ }
+
+ private String getShortCitationDate(Reference reference, boolean withBrackets, String citationDetail) {
+ String result = null;
+ if (reference.getDatePublished() != null && !reference.getDatePublished().isEmpty()) {
+ if (isNotBlank(reference.getDatePublished().getFreeText())){
+ result = reference.getDatePublished().getFreeText();
+ }else if (isNotBlank(reference.getYear()) ){
+ result = reference.getYear();
+ }
+ if (isNotBlank(citationDetail)){
+ result = Nz(result) + ": " + citationDetail;
+ }
+ if (isNotBlank(result) && withBrackets){
+ result = "(" + result + ")";
+ }
+ }else if (reference.getInReference() != null){
+ result = getShortCitationDate(reference.getInReference(), withBrackets, citationDetail);
+ }
+ return result;
+ }
+
+ private String getPersonString(Person person) {
+ String shortCitation;
+ shortCitation = person.getFamilyName();
+ if (isBlank(shortCitation) ){
+ shortCitation = person.getTitleCache();
+ }
+ return shortCitation;
+ }
+
+ /**
+ * Adds the citationDetail to the protected titleCache assuming that this is not accurately parsed.
+ * If the detail is contained in the titleCache it is not added again to the result, otherwise
+ * it is concatenated with separator ":"
+ * @return the concatenated string
+ */
+ private String handleCitationDetailInTitleCache(String titleCache, String citationDetail) {
+ if (isBlank(citationDetail)){
+ return titleCache;
+ }else if (isBlank(titleCache)){
+ return ": " + citationDetail;
+ }else if (citationDetail.length() <= 3){
+ if (titleCache.contains(": " + citationDetail)){
+ return titleCache;
+ }
+ }else{
+ if (titleCache.contains(citationDetail)){
+ return titleCache;
+ }
+ }
+ return titleCache + ": " + citationDetail;
+ }
+}
\ No newline at end of file
package eu.etaxonomy.cdm.strategy.cache.reference;
+import eu.etaxonomy.cdm.format.reference.NomenclaturalSourceFormatter;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
*/
public interface IReferenceCacheStrategy extends IIdentifiableEntityCacheStrategy<Reference> {
- /**
- * Returns a short version of the reference, suitable for citation (e.g. ${authorname}, ${year})
- * @deprecated consider using {@link #createShortCitation(Reference, String, Boolean)}. These methods
- * will probably be merged in future
- */
- @Deprecated
- public String getCitation(Reference reference, String microReference);
-
/**
* Returns the full abbreviated title string which
* is a string representation of Reference which
* preferably uses the {@link Reference#getAbbrevTitle() abbrev title}
* of the reference instead of the title. This is not the same as
- * the {@link INomenclaturalReferenceCacheStrategy#nomenclaturalTitleCache
- * @return
+ * the {@link NomenclaturalSourceFormatter#format(Reference, String)
+ * @return the full abbreviated title cache
*/
public String getFullAbbrevTitleString(Reference reference);
-
- //TODO this method seems to be used only for type designations and/or cdmlight, it should be unified with getCitation()
- /**
- * Creates a citation in form <i>author year: detail</i> or <i>author (year: detail)</i>.
- * <BR>
- * If reference has protected titlecache only the titlecache is returned (may change in future).
- * <BR>
- * The author team is abbreviated with <code>et al.</code> if more than 2 authors exist in the team.
- *
- * @param reference the reference to format
- * @param citationDetail the microreference (page, figure, etc.), if <code>null</code> also the colon separator is not used
- * @param withYearBrackets if <code>false</code> the result comes without brackets (default is <code>false</code>)
- * @return
- */
- public String createShortCitation(Reference reference, String citationDetail, Boolean withYearBrackets);
-
-
-
}
*/\r
package eu.etaxonomy.cdm.strategy.cache.reference;\r
\r
-import java.util.List;\r
import java.util.UUID;\r
\r
import org.apache.commons.lang3.StringUtils;\r
\r
import eu.etaxonomy.cdm.common.CdmUtils;\r
import eu.etaxonomy.cdm.common.UTF8;\r
-import eu.etaxonomy.cdm.model.agent.Person;\r
-import eu.etaxonomy.cdm.model.agent.Team;\r
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;\r
-import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;\r
import eu.etaxonomy.cdm.model.reference.Reference;\r
import eu.etaxonomy.cdm.model.reference.ReferenceType;\r
import eu.etaxonomy.cdm.strategy.StrategyBase;\r
-import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;\r
\r
/**\r
* #5833\r
return result;\r
}\r
\r
- //TODO see comment on createShortCitation(...)\r
- @Override\r
- public String getCitation(Reference reference, String microReference) {\r
- // mostly copied from nomRefCacheStrat, refCache, journalCache\r
-\r
- if (reference == null){\r
- return null;\r
- }\r
- StringBuilder result = new StringBuilder();\r
- TeamOrPersonBase<?> team = reference.getAuthorship();\r
-\r
- String nextConcat = "";\r
-\r
- if (team != null && isNotBlank(team.getTitleCache())){\r
- result.append(team.getTitleCache() );\r
- //here is the difference between nomRef and others\r
- if (isNomRef(reference.getType())) {\r
- nextConcat = afterAuthor;\r
- }else{\r
- //FIXME check if this really makes sense\r
- result.append(afterAuthor);\r
- nextConcat = beforeYear;\r
- }\r
- }\r
-\r
- String year = reference.getYear();\r
- if (isNotBlank(year)){\r
- result.append(nextConcat + year);\r
- }\r
- if (isNotBlank(microReference)){\r
- result.append(": " + microReference);\r
- }\r
-\r
- return result.toString();\r
- }\r
-\r
- //TODO this method should probably be unified with getCitation(Reference reference, String microReference)\r
- @Override\r
- public String createShortCitation(Reference reference, String citationDetail, Boolean withYearBrackets) {\r
- if (withYearBrackets == null){\r
- withYearBrackets = false;\r
- }\r
- if(reference.isProtectedTitleCache()){\r
- return handleCitationDetailInTitleCache(reference.getTitleCache(), citationDetail);\r
- }\r
- TeamOrPersonBase<?> authorship = reference.getAuthorship();\r
- String shortCitation = "";\r
- if (authorship == null) {\r
- return handleCitationDetailInTitleCache(reference.getTitleCache(), citationDetail);\r
- }\r
- authorship = CdmBase.deproxy(authorship);\r
- if (authorship instanceof Person){\r
- shortCitation = getPersonString((Person)authorship);\r
- }\r
- else if (authorship instanceof Team){\r
-\r
- Team team = CdmBase.deproxy(authorship, Team.class);\r
- if (team.isProtectedTitleCache()){\r
- shortCitation = team.getTitleCache();\r
- }else{\r
- List<Person> teamMembers = team.getTeamMembers();\r
- int etAlPosition = 2;\r
- for (int i = 1; i <= teamMembers.size() &&\r
- (i < etAlPosition || teamMembers.size() == etAlPosition && !team.isHasMoreMembers()) ; i++){\r
- Person teamMember = teamMembers.get(i-1);\r
- if(teamMember == null){\r
- // this can happen in UIs in the process of adding new members\r
- continue;\r
- }\r
- String concat = TeamDefaultCacheStrategy.concatString(team, teamMembers, i);\r
- shortCitation += concat + getPersonString(teamMember);\r
- }\r
- if (teamMembers.size() == 0){\r
- shortCitation = TeamDefaultCacheStrategy.EMPTY_TEAM;\r
- } else if (team.isHasMoreMembers() || teamMembers.size() > etAlPosition){\r
- shortCitation += TeamDefaultCacheStrategy.ET_AL_TEAM_CONCATINATION_FULL + "al.";\r
- }\r
- }\r
- }\r
- shortCitation = CdmUtils.concat(" ", shortCitation, getShortCitationDate(reference, withYearBrackets, citationDetail));\r
-\r
- return shortCitation;\r
- }\r
-\r
- /**\r
- * Adds the citationDetail to the titleCache string that is returned from a method as data is not\r
- * accurately parsed.\r
- * @return\r
- */\r
- private String handleCitationDetailInTitleCache(String titleCache, String citationDetail) {\r
- if (StringUtils.isBlank(citationDetail)){\r
- return titleCache;\r
- }else if (StringUtils.isBlank(titleCache)){\r
- return ": " + citationDetail;\r
- }else if (citationDetail.length() <= 3){\r
- if (titleCache.contains(": " + citationDetail)){\r
- return titleCache;\r
- }\r
- }else{\r
- if (titleCache.contains(citationDetail)){\r
- return titleCache;\r
- }\r
- }\r
- return titleCache + ": " + citationDetail;\r
- }\r
-\r
- private String getShortCitationDate(Reference reference, boolean withBrackets, String citationDetail) {\r
- String result = null;\r
- if (reference.getDatePublished() != null && !reference.getDatePublished().isEmpty()) {\r
- if (isNotBlank(reference.getDatePublished().getFreeText())){\r
- result = reference.getDatePublished().getFreeText();\r
- }else if (isNotBlank(reference.getYear()) ){\r
- result = reference.getYear();\r
- }\r
- if (StringUtils.isNotEmpty(citationDetail)){\r
- result = CdmUtils.Nz(result) + ": " + citationDetail;\r
- }\r
- if (StringUtils.isNotBlank(result) && withBrackets){\r
- result = "(" + result + ")";\r
- }\r
- }else if (reference.getInReference() != null){\r
- result = getShortCitationDate(reference.getInReference(), withBrackets, citationDetail);\r
- }\r
- return result;\r
- }\r
-\r
- private String getPersonString(Person person) {\r
- String shortCitation;\r
- shortCitation = person.getFamilyName();\r
- if (isBlank(shortCitation) ){\r
- shortCitation = person.getTitleCache();\r
- }\r
- return shortCitation;\r
- }\r
-\r
// ************************ TITLE CACHE SUBS ********************************************/\r
\r
private String titleCacheRealInRef(Reference reference, boolean isAbbrev) {\r
import java.util.UUID;
import eu.etaxonomy.cdm.common.CdmUtils;
+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.name.TaxonName;
sec.getAuthorship() != null &&
isNotBlank(sec.getAuthorship().getTitleCache()) &&
isNotBlank(sec.getYear())){
- secRef = sec.getCacheStrategy().getCitation(sec, null); //microRef is handled later
+ secRef = OriginalSourceFormatter.INSTANCE.format(sec, null); //microRef is handled later
}else if ((sec.isWebPage() || sec.isDatabase() || sec.isMap())
&& 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();
--- /dev/null
+/**
+* Copyright (C) 2021 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.format.reference;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+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.reference.Reference;
+import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
+
+/**
+ * @author a.mueller
+ * @since 03.05.2021
+ */
+public class OriginalSourceFormatterTest {
+
+ //book // book section
+ private static Reference book1;
+ private static Team bookTeam1;
+
+ private static OriginalSourceFormatter formatter = OriginalSourceFormatter.INSTANCE;
+ private static OriginalSourceFormatter formatterWithBrackets = OriginalSourceFormatter.INSTANCE_WITH_BRACKETS;
+
+ @Before
+ public void setUp() throws Exception {
+
+ //book / section
+ book1 = ReferenceFactory.newBook();
+ bookTeam1 = Team.NewTitledInstance("Book Author", "TT.");
+ }
+
+ @Test
+ public void testCreateShortCitation(){
+ book1.setTitle("My book");
+ book1.setAuthorship(bookTeam1);
+ book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
+ Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
+
+ book1.setTitleCache(null, false);
+ book1.setEdition("ed. 3");
+
+ Assert.assertEquals("Unexpected title cache.", "Book Author 1975", formatter.format(book1, null));
+ Assert.assertEquals("Unexpected title cache.", "Book Author 1975", formatter.format(book1, ""));
+ Assert.assertEquals("Unexpected title cache.", "Book Author 1975: 55", formatter.format(book1, "55"));
+ Assert.assertEquals("Unexpected title cache.", "Book Author (1975: 55)",
+ formatterWithBrackets.format(book1, "55"));
+
+ //1 person
+ Person person1 = Person.NewInstance("Pers.", "Person", "P.", "Percy");
+ Team team = Team.NewInstance(person1);
+ book1.setAuthorship(team);
+ Assert.assertEquals("Unexpected title cache.", "Person 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(true);
+ Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(false);
+
+ //2 persons
+ Person person2 = Person.NewInstance("Lers.", "Lerson", "L.", "Lercy");
+ team.addTeamMember(person2);
+ Assert.assertEquals("Unexpected title cache.", "Person & Lerson 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(true);
+ Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(false);
+
+ //3 persons
+ Person person3 = Person.NewInstance("Gers.", "Gerson", "G.", "Gercy");
+ team.addTeamMember(person3);
+ Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(true);
+ Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", formatter.format(book1, "55"));
+ team.setHasMoreMembers(false); //in case we want to continue test
+ }
+}
\ No newline at end of file
// Assert.assertEquals("Unexpected title cache.", "auct.", webPage1.getTitleCache());
// }
- @Test
- public void testCreateShortCitation(){
- book1.setTitle("My book");
- book1.setAuthorship(bookTeam1);
- book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
- Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
-
- book1.setTitleCache(null, false);
- book1.setEdition("ed. 3");
-
- Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, null, false));
- Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, "", false));
- Assert.assertEquals("Unexpected title cache.", "Book Author 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- Assert.assertEquals("Unexpected title cache.", "Book Author (1975: 55)", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", true));
-
- //1 person
- Person person1 = Person.NewInstance("Pers.", "Person", "P.", "Percy");
- Team team = Team.NewInstance(person1);
- book1.setAuthorship(team);
- Assert.assertEquals("Unexpected title cache.", "Person 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(true);
- Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(false);
-
- //2 persons
- Person person2 = Person.NewInstance("Lers.", "Lerson", "L.", "Lercy");
- team.addTeamMember(person2);
- Assert.assertEquals("Unexpected title cache.", "Person & Lerson 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(true);
- Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(false);
-
- //3 persons
- Person person3 = Person.NewInstance("Gers.", "Gerson", "G.", "Gercy");
- team.addTeamMember(person3);
- Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(true);
- Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
- team.setHasMoreMembers(false); //in case we want to continue test
- }
}
\ No newline at end of file
sec.setAuthorship(Team.NewTitledInstance("Team", "T."));
sec.setDatePublished(TimePeriodParser.parseStringVerbatim("1798"));
taxonBase.setTitleCache(null);
- assertEquals("Taxon titlecache is wrong", expectedNameTitleCache + " sec. Team, 1798: p. 553",
+ assertEquals("Taxon titlecache is wrong", expectedNameTitleCache + " sec. Team 1798: p. 553",
taxonBase.getTitleCache());
}
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.common.UTF8;
+import eu.etaxonomy.cdm.format.reference.OriginalSourceFormatter;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
import eu.etaxonomy.cdm.strategy.cache.TaggedTextBuilder;
-import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceDefaultCacheStrategy;
/**
* @author a.mueller
OriginalSourceBase source) {
Reference ref = source.getCitation();
if (ref != null){
- ReferenceDefaultCacheStrategy strategy = ((ReferenceDefaultCacheStrategy)ref.getCacheStrategy());
- String shortCitation = strategy.createShortCitation(ref, source.getCitationMicroReference(), false);
- workingsetBuilder.add(TagEnum.reference, shortCitation, TypedEntityReference.fromEntity(ref, false));
+ String citation = OriginalSourceFormatter.INSTANCE.format(source);
+ workingsetBuilder.add(TagEnum.reference, citation, TypedEntityReference.fromEntity(ref, false));
}
}