Mercurial > hg > ismi-richfaces
diff src/main/java/de/mpiwg/itgroup/ismi/utils/templates/TitleTemplate.java @ 1:2e911857a759
(none)
author | jurzua |
---|---|
date | Wed, 29 Oct 2014 14:00:28 +0000 |
parents | |
children | 54c1bb63a713 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/itgroup/ismi/utils/templates/TitleTemplate.java Wed Oct 29 14:00:28 2014 +0000 @@ -0,0 +1,204 @@ +package de.mpiwg.itgroup.ismi.utils.templates; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.mpi.openmind.cache.WrapperService; +import org.mpi.openmind.repository.bo.Attribute; +import org.mpi.openmind.repository.bo.Entity; +import org.mpi.openmind.repository.bo.Relation; +import org.mpi.openmind.repository.utils.RomanizationLoC; + +import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; + +public class TitleTemplate extends AbstractTemplate{ + + private static Logger logger = Logger.getLogger(TitleTemplate.class); + + public String ov; + public String privacity; + public String fullTitle; + public String fullTitleTranslit; + public String language; + public String notes; + public String category; + public String createIn; + public String incipit; + public String explicit; + public String dedication; + public String tableOfContents; + public String author; + public Long authorId; + //extra + public List<String> aliasList; + public List<String> authorMisattributionList; + public String personDedicatedTo; + public String commentaryOnText; + public String translationOfText; + public String versionOfText; + + + public String creationDate; + + public TitleTemplate(Entity entity, WrapperService om, boolean useRomanization){ + + //logger.info("Diplaying " + entity); + + this.aliasList = new ArrayList<String>(); + this.authorMisattributionList = new ArrayList<String>(); + + if(entity != null){ + + this.privacity = entity.getPrivacity(); + + //attributes + Attribute att = om.getAttributeByName(entity.getId(), "full_title"); + this.fullTitle = (att != null) ? att.getOwnValue() : null; + this.fullTitle = (useRomanization) ? RomanizationLoC.convert(fullTitle) : fullTitle; + + att = om.getAttributeByName(entity.getId(), "full_title_translit"); + this.fullTitleTranslit = (att != null) ? att.getOwnValue() : null; + this.fullTitleTranslit = (useRomanization) ? RomanizationLoC.convert(fullTitleTranslit) : fullTitleTranslit; + + att = om.getAttributeByName(entity.getId(), "creation_date"); + if(att != null){ + Calendar creationDate = new Calendar(att.getOwnValue()); + this.creationDate = creationDate.getCalendarAsHtml(); + } + + att = om.getAttributeByName(entity.getId(), "language"); + this.language = (att != null) ? att.getOwnValue() : null; + + att = om.getAttributeByName(entity.getId(), "notes"); + this.notes = (att != null) ? att.getOwnValue() : null; + + att = om.getAttributeByName(entity.getId(), "incipit"); + this.incipit = (att != null) ? att.getOwnValue() : null; + + att = om.getAttributeByName(entity.getId(), "explicit"); + this.explicit = (att != null) ? att.getOwnValue() : null; + + att = om.getAttributeByName(entity.getId(), "dedication"); + this.dedication = (att != null) ? att.getOwnValue() : null; + + att = om.getAttributeByName(entity.getId(), "table_of_contents"); + this.tableOfContents = (att != null) ? att.getOwnValue() : null; + + List<Entity> tarList = om.getTargetsForSourceRelation(entity.getId(), "has_subject", "SUBJECT", 1); + this.category = (tarList.size() > 0) ? tarList.get(0).getOwnValue() : null ; + + tarList = om.getTargetsForSourceRelation(entity.getId(), "was_created_in", "PLACE", 1); + this.createIn = (tarList.size() > 0) ? tarList.get(0).getOwnValue() : null ; + + List<Entity> list0 = om.getSourcesForTargetRelation(entity.getId(), "is_reference_of", "REFERENCE", -1); + for(Entity ref : list0){ + this.refEntityList.add(om.getEntityContent(ref)); + } + + + + list0 = om.getTargetsForSourceRelation(entity.getId(), "was_created_by", "PERSON", -1); + if(list0.size() > 0){ + this.author = list0.get(0).getOwnValue(); + this.author = (useRomanization) ? RomanizationLoC.convert(author) : author; + this.authorId = list0.get(0).getId(); + } + + //extra fields ... + + list0 = om.getSourcesForTargetRelation(entity, "is_alias_title_of", "ALIAS", -1); + for(Entity alias : list0){ + this.aliasList.add(alias.getOwnValue()); + } + + list0 = om.getTargetsForSourceRelation(entity, "has_author_misattribution", "MISATTRIBUTION", -1); + for(Entity misatt : list0){ + List<Entity> authorMissattList = om.getTargetsForSourceRelation(misatt, "misattributed_to", "PERSON", 1); + if(authorMissattList.size() == 1){ + String authorMiss = authorMissattList.get(0).getOwnValue(); + authorMiss = (useRomanization) ? RomanizationLoC.convert(authorMiss) : authorMiss; + this.authorMisattributionList.add(authorMiss); + } + } + + list0 = om.getTargetsForSourceRelation(entity, "was_dedicated_to", "PERSON", 1); + this.personDedicatedTo = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; + this.personDedicatedTo = (useRomanization) ? RomanizationLoC.convert(personDedicatedTo) : personDedicatedTo; + + list0 = om.getTargetsForSourceRelation(entity, "is_commentary_on", "TEXT", 1); + this.commentaryOnText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; + this.commentaryOnText = (useRomanization) ? RomanizationLoC.convert(commentaryOnText) : commentaryOnText; + + list0 = om.getTargetsForSourceRelation(entity, "is_translation_of", "TEXT", 1); + this.translationOfText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; + this.translationOfText = (useRomanization) ? RomanizationLoC.convert(translationOfText) : translationOfText; + + list0 = om.getTargetsForSourceRelation(entity, "is_version_of", "TEXT", 1); + this.versionOfText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; + this.versionOfText = (useRomanization) ? RomanizationLoC.convert(versionOfText) : versionOfText; + } + + this.loadRefernces(); + + } + + public String getOv() { + return ov; + } + public String getPrivacity() { + return privacity; + } + public String getFullTitle() { + return fullTitle; + } + public String getFullTitleTranslit() { + return fullTitleTranslit; + } + public String getLanguage() { + return language; + } + public String getNotes() { + return notes; + } + public String getCategory() { + return category; + } + public String getCreateIn() { + return createIn; + } + public String getIncipit() { + return incipit; + } + public String getExplicit() { + return explicit; + } + public String getDedication() { + return dedication; + } + public String getTableOfContents() { + return tableOfContents; + } + public List<String> getAliasList() { + return aliasList; + } + public String getCreationDate() { + return creationDate; + } + public String getAuthor() { + return author; + } + public Long getAuthorId() { + return authorId; + } + + public boolean getHasAuthor(){ + return this.authorId != null; + } + + public List<String> getAuthorMisattributionList() { + return authorMisattributionList; + } +}