Mercurial > hg > ismi-richfaces
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:74df02964906 | 1:2e911857a759 |
---|---|
1 package de.mpiwg.itgroup.ismi.utils.templates; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.HashMap; | |
5 import java.util.List; | |
6 import java.util.Map; | |
7 | |
8 import org.apache.log4j.Logger; | |
9 import org.mpi.openmind.cache.WrapperService; | |
10 import org.mpi.openmind.repository.bo.Attribute; | |
11 import org.mpi.openmind.repository.bo.Entity; | |
12 import org.mpi.openmind.repository.bo.Relation; | |
13 import org.mpi.openmind.repository.utils.RomanizationLoC; | |
14 | |
15 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
16 | |
17 public class TitleTemplate extends AbstractTemplate{ | |
18 | |
19 private static Logger logger = Logger.getLogger(TitleTemplate.class); | |
20 | |
21 public String ov; | |
22 public String privacity; | |
23 public String fullTitle; | |
24 public String fullTitleTranslit; | |
25 public String language; | |
26 public String notes; | |
27 public String category; | |
28 public String createIn; | |
29 public String incipit; | |
30 public String explicit; | |
31 public String dedication; | |
32 public String tableOfContents; | |
33 public String author; | |
34 public Long authorId; | |
35 //extra | |
36 public List<String> aliasList; | |
37 public List<String> authorMisattributionList; | |
38 public String personDedicatedTo; | |
39 public String commentaryOnText; | |
40 public String translationOfText; | |
41 public String versionOfText; | |
42 | |
43 | |
44 public String creationDate; | |
45 | |
46 public TitleTemplate(Entity entity, WrapperService om, boolean useRomanization){ | |
47 | |
48 //logger.info("Diplaying " + entity); | |
49 | |
50 this.aliasList = new ArrayList<String>(); | |
51 this.authorMisattributionList = new ArrayList<String>(); | |
52 | |
53 if(entity != null){ | |
54 | |
55 this.privacity = entity.getPrivacity(); | |
56 | |
57 //attributes | |
58 Attribute att = om.getAttributeByName(entity.getId(), "full_title"); | |
59 this.fullTitle = (att != null) ? att.getOwnValue() : null; | |
60 this.fullTitle = (useRomanization) ? RomanizationLoC.convert(fullTitle) : fullTitle; | |
61 | |
62 att = om.getAttributeByName(entity.getId(), "full_title_translit"); | |
63 this.fullTitleTranslit = (att != null) ? att.getOwnValue() : null; | |
64 this.fullTitleTranslit = (useRomanization) ? RomanizationLoC.convert(fullTitleTranslit) : fullTitleTranslit; | |
65 | |
66 att = om.getAttributeByName(entity.getId(), "creation_date"); | |
67 if(att != null){ | |
68 Calendar creationDate = new Calendar(att.getOwnValue()); | |
69 this.creationDate = creationDate.getCalendarAsHtml(); | |
70 } | |
71 | |
72 att = om.getAttributeByName(entity.getId(), "language"); | |
73 this.language = (att != null) ? att.getOwnValue() : null; | |
74 | |
75 att = om.getAttributeByName(entity.getId(), "notes"); | |
76 this.notes = (att != null) ? att.getOwnValue() : null; | |
77 | |
78 att = om.getAttributeByName(entity.getId(), "incipit"); | |
79 this.incipit = (att != null) ? att.getOwnValue() : null; | |
80 | |
81 att = om.getAttributeByName(entity.getId(), "explicit"); | |
82 this.explicit = (att != null) ? att.getOwnValue() : null; | |
83 | |
84 att = om.getAttributeByName(entity.getId(), "dedication"); | |
85 this.dedication = (att != null) ? att.getOwnValue() : null; | |
86 | |
87 att = om.getAttributeByName(entity.getId(), "table_of_contents"); | |
88 this.tableOfContents = (att != null) ? att.getOwnValue() : null; | |
89 | |
90 List<Entity> tarList = om.getTargetsForSourceRelation(entity.getId(), "has_subject", "SUBJECT", 1); | |
91 this.category = (tarList.size() > 0) ? tarList.get(0).getOwnValue() : null ; | |
92 | |
93 tarList = om.getTargetsForSourceRelation(entity.getId(), "was_created_in", "PLACE", 1); | |
94 this.createIn = (tarList.size() > 0) ? tarList.get(0).getOwnValue() : null ; | |
95 | |
96 List<Entity> list0 = om.getSourcesForTargetRelation(entity.getId(), "is_reference_of", "REFERENCE", -1); | |
97 for(Entity ref : list0){ | |
98 this.refEntityList.add(om.getEntityContent(ref)); | |
99 } | |
100 | |
101 | |
102 | |
103 list0 = om.getTargetsForSourceRelation(entity.getId(), "was_created_by", "PERSON", -1); | |
104 if(list0.size() > 0){ | |
105 this.author = list0.get(0).getOwnValue(); | |
106 this.author = (useRomanization) ? RomanizationLoC.convert(author) : author; | |
107 this.authorId = list0.get(0).getId(); | |
108 } | |
109 | |
110 //extra fields ... | |
111 | |
112 list0 = om.getSourcesForTargetRelation(entity, "is_alias_title_of", "ALIAS", -1); | |
113 for(Entity alias : list0){ | |
114 this.aliasList.add(alias.getOwnValue()); | |
115 } | |
116 | |
117 list0 = om.getTargetsForSourceRelation(entity, "has_author_misattribution", "MISATTRIBUTION", -1); | |
118 for(Entity misatt : list0){ | |
119 List<Entity> authorMissattList = om.getTargetsForSourceRelation(misatt, "misattributed_to", "PERSON", 1); | |
120 if(authorMissattList.size() == 1){ | |
121 String authorMiss = authorMissattList.get(0).getOwnValue(); | |
122 authorMiss = (useRomanization) ? RomanizationLoC.convert(authorMiss) : authorMiss; | |
123 this.authorMisattributionList.add(authorMiss); | |
124 } | |
125 } | |
126 | |
127 list0 = om.getTargetsForSourceRelation(entity, "was_dedicated_to", "PERSON", 1); | |
128 this.personDedicatedTo = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; | |
129 this.personDedicatedTo = (useRomanization) ? RomanizationLoC.convert(personDedicatedTo) : personDedicatedTo; | |
130 | |
131 list0 = om.getTargetsForSourceRelation(entity, "is_commentary_on", "TEXT", 1); | |
132 this.commentaryOnText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; | |
133 this.commentaryOnText = (useRomanization) ? RomanizationLoC.convert(commentaryOnText) : commentaryOnText; | |
134 | |
135 list0 = om.getTargetsForSourceRelation(entity, "is_translation_of", "TEXT", 1); | |
136 this.translationOfText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; | |
137 this.translationOfText = (useRomanization) ? RomanizationLoC.convert(translationOfText) : translationOfText; | |
138 | |
139 list0 = om.getTargetsForSourceRelation(entity, "is_version_of", "TEXT", 1); | |
140 this.versionOfText = (list0.size() == 1) ? list0.get(0).getOwnValue() : null; | |
141 this.versionOfText = (useRomanization) ? RomanizationLoC.convert(versionOfText) : versionOfText; | |
142 } | |
143 | |
144 this.loadRefernces(); | |
145 | |
146 } | |
147 | |
148 public String getOv() { | |
149 return ov; | |
150 } | |
151 public String getPrivacity() { | |
152 return privacity; | |
153 } | |
154 public String getFullTitle() { | |
155 return fullTitle; | |
156 } | |
157 public String getFullTitleTranslit() { | |
158 return fullTitleTranslit; | |
159 } | |
160 public String getLanguage() { | |
161 return language; | |
162 } | |
163 public String getNotes() { | |
164 return notes; | |
165 } | |
166 public String getCategory() { | |
167 return category; | |
168 } | |
169 public String getCreateIn() { | |
170 return createIn; | |
171 } | |
172 public String getIncipit() { | |
173 return incipit; | |
174 } | |
175 public String getExplicit() { | |
176 return explicit; | |
177 } | |
178 public String getDedication() { | |
179 return dedication; | |
180 } | |
181 public String getTableOfContents() { | |
182 return tableOfContents; | |
183 } | |
184 public List<String> getAliasList() { | |
185 return aliasList; | |
186 } | |
187 public String getCreationDate() { | |
188 return creationDate; | |
189 } | |
190 public String getAuthor() { | |
191 return author; | |
192 } | |
193 public Long getAuthorId() { | |
194 return authorId; | |
195 } | |
196 | |
197 public boolean getHasAuthor(){ | |
198 return this.authorId != null; | |
199 } | |
200 | |
201 public List<String> getAuthorMisattributionList() { | |
202 return authorMisattributionList; | |
203 } | |
204 } |