1
|
1 package de.mpiwg.itgroup.ismi.publicView.pages;
|
|
2
|
|
3 import java.util.List;
|
|
4
|
|
5 import org.mpi.openmind.repository.bo.Attribute;
|
|
6 import org.mpi.openmind.repository.bo.Entity;
|
|
7 import org.mpi.openmind.repository.utils.RomanizationLoC;
|
|
8
|
|
9 public class WitnessDynamicPage extends JSPDynamicPage{
|
|
10
|
|
11 private Long titleId;
|
|
12 private Long authorId;
|
|
13 private String author;
|
|
14 private String title;
|
|
15 private String firstPage;
|
|
16
|
|
17 @Override
|
|
18 public void load(Long witnessId){
|
|
19 super.load(witnessId);
|
|
20
|
|
21 this.titleId = null;
|
|
22 this.title = null;
|
|
23 this.author = null;
|
|
24 this.authorId = null;
|
|
25
|
|
26
|
|
27 if(witnessId != null){
|
|
28
|
|
29 this.loadFirstPage();
|
|
30
|
|
31 //loading the digitalization object
|
|
32 List<Entity> list = getWrapper().getTargetsForSourceRelation(witnessId, "is_part_of", "CODEX", 1);
|
|
33 if (list.size() > 0) {
|
|
34 Entity codex = list.get(0);
|
|
35 List<Entity> list0 = getWrapper().getSourcesForTargetRelation(codex.getId(), "is_digitalization_of", "DIGITALIZATION", 1);
|
|
36 this.digi = (list0.size() == 0) ? null : list0.get(0);
|
|
37 }
|
|
38
|
|
39
|
|
40 //loading witness
|
|
41 List<Entity> list0 = getWrapper().getTargetsForSourceRelation(witnessId, "is_exemplar_of", "TEXT", 1);
|
|
42 if (list0.size() > 0) {
|
|
43
|
|
44 this.titleId = list0.get(0).getId();
|
|
45 this.title = RomanizationLoC.convert(list0.get(0).getOwnValue());
|
|
46 System.out.println("&&&&&& " + this.title);
|
|
47
|
|
48 list0 = getWrapper().getTargetsForSourceRelation(this.titleId, "was_created_by", "PERSON", 1);
|
|
49 if(list0.size() > 0){
|
|
50 this.authorId = list0.get(0).getId();
|
|
51 this.author = RomanizationLoC.convert(list0.get(0).getOwnValue());
|
|
52 }
|
|
53 }
|
|
54 }
|
|
55 }
|
|
56
|
|
57 /**
|
|
58 * The start_page saves the first page of the witness in the codex.
|
|
59 * start_page can contains number from the 1, however the diva viewer considers that the first page is 0.
|
|
60 * For this reason, if a witness contains this attribute, then we must subtract 1 page.
|
|
61 */
|
|
62 public void loadFirstPage(){
|
|
63 Attribute firstPageAtt = getWrapper().getAttributeByName(getCurrentEntId(), "start_page");
|
|
64 Integer tmp = 0;
|
|
65
|
|
66 if(firstPageAtt != null){
|
|
67 try {
|
|
68 tmp = Integer.parseInt(firstPageAtt.getOwnValue());
|
|
69 tmp = (tmp > 0) ? tmp-1 : tmp;
|
|
70 } catch (Exception e) {}
|
|
71 }
|
|
72
|
|
73 this.firstPage = tmp.toString();
|
|
74 }
|
|
75
|
|
76 public void init(){
|
|
77 try {
|
|
78
|
|
79 this.load(Long.parseLong(getRequest().getParameter("eid")));
|
|
80
|
|
81 } catch (Exception e) {
|
|
82 e.printStackTrace();
|
|
83 }
|
|
84 }
|
|
85
|
|
86 public Long getTitleId() {
|
|
87 return titleId;
|
|
88 }
|
|
89
|
|
90 public void setTitleId(Long titleId) {
|
|
91 this.titleId = titleId;
|
|
92 }
|
|
93
|
|
94 public Long getAuthorId() {
|
|
95 return authorId;
|
|
96 }
|
|
97
|
|
98 public void setAuthorId(Long authorId) {
|
|
99 this.authorId = authorId;
|
|
100 }
|
|
101
|
|
102 public String getAuthor() {
|
|
103 return author;
|
|
104 }
|
|
105
|
|
106 public void setAuthor(String author) {
|
|
107 this.author = author;
|
|
108 }
|
|
109
|
|
110 public String getTitle() {
|
|
111 return title;
|
|
112 }
|
|
113
|
|
114 public void setTitle(String title) {
|
|
115 this.title = title;
|
|
116 }
|
|
117
|
|
118 public String getFirstPage(){
|
|
119 return this.firstPage;
|
|
120 }
|
|
121 }
|