use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TaxonRelationshipFormatter method getReferenceTags.
private List<TaggedText> getReferenceTags(Reference ref, String detail, /*boolean isSensu,*/
boolean isRelation) {
List<TaggedText> result = new ArrayList<>();
String secRef;
if (ref != null) {
TeamOrPersonBase<?> author = CdmBase.deproxy(ref.getAuthorship());
//
if (ref.isProtectedTitleCache() == false && author != null && isNotBlank(author.getTitleCache())) {
if (author.isInstanceOf(Person.class)) {
secRef = PersonDefaultCacheStrategy.INSTANCE().getFamilyTitle((Person) author);
} else {
// #9624
secRef = TeamDefaultCacheStrategy.INSTANCE_ET_AL_2().getFamilyTitle((Team) author);
}
if (isNotBlank(ref.getYear())) {
secRef += " " + ref.getYear();
}
} else {
secRef = ref.getTitleCache();
}
TagEnum secType = /*isSensu? TagEnum.sensuReference : */
isRelation ? TagEnum.relSecReference : TagEnum.secReference;
TaggedText refTag = TaggedText.NewInstance(secType, secRef);
refTag.setEntityReference(new TypedEntityReference<>(CdmBase.deproxy(ref).getClass(), ref.getUuid()));
result.add(refTag);
}
if (isNotBlank(detail)) {
result.add(TaggedText.NewSeparatorInstance(DETAIL_SEPARATOR));
TagEnum detailType = /*isSensu? TagEnum.sensuMicroReference : */
isRelation ? TagEnum.relSecMicroReference : TagEnum.secMicroReference;
TaggedText microTag = TaggedText.NewInstance(detailType, detail);
result.add(microTag);
}
return result;
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class NameCacheStrategyBase method addOriginalSpelling.
protected void addOriginalSpelling(List<TaggedText> tags, TaxonName currentName) {
currentName = CdmBase.deproxy(currentName);
// Hibernate.initialize(currentName.getRelationsToThisName());
TaxonName originalName = currentName.getOriginalSpelling();
if (originalName != null) {
String originalNameString;
tags.add(TaggedText.NewSeparatorInstance(" [as \""));
if (!originalName.isNonViral()) {
originalNameString = originalName.getTitleCache();
tags.add(new TaggedText(TagEnum.name, originalNameString));
} else {
INonViralName originalNvName = CdmBase.deproxy(originalName);
originalNameString = makeOriginalNameString(originalNvName, tags);
for (String split : originalNameString.split(" ")) {
if (split.matches(NonViralNameParserImplRegExBase.infraSpeciesMarker) || split.matches(NonViralNameParserImplRegExBase.oldInfraSpeciesMarker)) {
tags.add(new TaggedText(TagEnum.rank, split));
} else {
tags.add(new TaggedText(TagEnum.name, split));
}
}
}
tags.add(TaggedText.NewSeparatorInstance("\"]"));
} else {
return;
}
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class NameCacheStrategyBase method getNomStatusTags.
@Override
public List<TaggedText> getNomStatusTags(TaxonName taxonName, boolean includeSeparatorBefore, boolean includeSeparatorAfter) {
Set<NomenclaturalStatus> ncStati = taxonName.getStatus();
Iterator<NomenclaturalStatus> iterator = ncStati.iterator();
List<TaggedText> nomStatusTags = new ArrayList<>();
while (iterator.hasNext()) {
NomenclaturalStatus ncStatus = iterator.next();
// since the NewInstance method of nomencatural status allows null as parameter
// we have to check for null values here
String nomStatusStr = "not defined";
if (ncStatus.getType() != null) {
NomenclaturalStatusType statusType = ncStatus.getType();
List<Language> prefLangs = Arrays.asList(new Language[] { Language.LATIN(), Language.DEFAULT() });
Representation repr = statusType.getPreferredRepresentation(prefLangs);
if (repr != null) {
if (!Language.LATIN().equals(repr.getLanguage())) {
String message = "No latin representation available for nom. status. " + statusType.getTitleCache();
logger.info(message);
}
nomStatusStr = repr.getAbbreviatedLabel();
} else {
String message = "No representation available for nom. status. " + statusType.getTitleCache();
logger.warn(message);
nomStatusStr = statusType.getTitleCache();
}
} else if (isNotBlank(ncStatus.getRuleConsidered())) {
nomStatusStr = ncStatus.getRuleConsidered();
}
String statusSeparator = ", ";
if (includeSeparatorBefore) {
nomStatusTags.add(new TaggedText(TagEnum.separator, statusSeparator));
}
nomStatusTags.add(new TaggedText(TagEnum.nomStatus, nomStatusStr, new TypedEntityReference<>(ncStatus.getClass(), ncStatus.getUuid())));
if (includeSeparatorAfter) {
nomStatusTags.add(new TaggedText(TagEnum.postSeparator, ","));
}
}
return nomStatusTags;
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class NameCacheStrategyBase method getTaggedTitle.
@Override
public List<TaggedText> getTaggedTitle(TaxonName taxonName) {
if (taxonName == null) {
return null;
}
if (taxonName.isProtectedTitleCache()) {
// protected title cache
List<TaggedText> tags = new ArrayList<>();
tags.add(new TaggedText(TagEnum.name, taxonName.getTitleCache()));
return tags;
} else {
return doGetTaggedTitle(taxonName);
}
}
use of eu.etaxonomy.cdm.strategy.cache.TaggedText in project cdmlib by cybertaxonomy.
the class TaxonNameDefaultCacheStrategy method getInfraGenusTaggedNameCache.
/**
* Returns the tag list for an infrageneric taxon (including species aggregates).
*
* @see #getSpeciesAggregateTaggedCache(NonViralName)
* @param nonViralName
* @return
*/
protected List<TaggedText> getInfraGenusTaggedNameCache(INonViralName nonViralName, boolean addAppended) {
Rank rank = nonViralName.getRank();
if (rank != null && rank.isSpeciesAggregate() && isBlank(nonViralName.getAuthorshipCache())) {
return getSpeciesAggregateTaggedCache(nonViralName, addAppended);
}
// genus
List<TaggedText> tags = getUninomialTaggedPart(nonViralName);
// marker
String infraGenericMarker;
if (rank != null) {
try {
infraGenericMarker = rank.getInfraGenericMarker();
if (rank.equals(Rank.SECTION_BOTANY()) || rank.equals(Rank.SUBSECTION_BOTANY())) {
infraGenericMarker = infraGenericMarker.replace("(bot.)", "");
}
} catch (UnknownCdmTypeException e) {
infraGenericMarker = "'unhandled infrageneric rank'";
}
} else {
infraGenericMarker = "'undefined infrageneric rank'";
}
String infraGenEpi = CdmUtils.Nz(nonViralName.getInfraGenericEpithet()).trim();
if (nonViralName.isBinomHybrid()) {
infraGenericMarker = CdmUtils.concat("", NOTHO, infraGenericMarker);
}
addInfraGenericPart(nonViralName, tags, infraGenericMarker, infraGenEpi);
addAppendedTaggedPhrase(tags, nonViralName, addAppended);
return tags;
}
Aggregations