1
|
1 package de.mpiwg.itgroup.ismi.publicView;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.List;
|
|
5
|
|
6 import org.apache.commons.lang.StringUtils;
|
|
7 import org.mpi.openmind.repository.bo.Attribute;
|
|
8 import org.mpi.openmind.repository.bo.Entity;
|
|
9 import org.mpi.openmind.repository.bo.ViewerPage;
|
|
10 import org.mpi.openmind.repository.utils.RomanizationLoC;
|
|
11
|
|
12 import de.mpiwg.itgroup.ismi.entry.beans.AbstractBean;
|
|
13
|
|
14 public class PublicCodexView extends AbstractBean{
|
|
15 private static final long serialVersionUID = -3013781647163292966L;
|
|
16
|
|
17 private Entity codex;
|
|
18 private Entity digi;
|
|
19 private List<WitnessItem> witnessList;
|
|
20 private boolean codexPublic = true;
|
|
21
|
|
22 private Long dynamicCodexPageId;
|
|
23 private Long dynamicWitnessPageId;
|
|
24
|
|
25 public void load(String id){
|
|
26 try {
|
|
27 this.load(Long.parseLong(id));
|
|
28 } catch (Exception e) {
|
|
29 e.printStackTrace();
|
|
30 }
|
|
31 }
|
|
32 public void load(Long id){
|
|
33 this.witnessList = new ArrayList<WitnessItem>();
|
|
34 this.codex = getWrapper().getEntityById(id);
|
|
35 this.digi = null;
|
|
36 if(codex != null){
|
|
37
|
|
38 List<Entity> tmp = getWrapper().getSourcesForTargetRelation(codex, "is_digitalization_of", "DIGITALIZATION", 1);
|
|
39 digi = (tmp.isEmpty()) ? null : tmp.get(0);
|
|
40
|
|
41 tmp = getWrapper().getSourcesForTargetRelation(codex, "is_part_of", "WITNESS", -1);
|
|
42
|
|
43 for(Entity witness : tmp){
|
|
44
|
|
45 List<Entity> list0 = getWrapper().getTargetsForSourceRelation(witness.getId(), "is_exemplar_of", "TEXT", 1);
|
|
46 //TODO the label should be normalized with the new algorithm of Chantal
|
|
47 String label = (list0.isEmpty()) ? witness.getOwnValue() : list0.get(0).getOwnValue();
|
|
48
|
|
49 //calculating the image index for the diva viewer
|
|
50 //String divaImageIndex = this.getDivaImage(digi.getOwnValue(), getWrapper().getAttributeByName(witness.getId(), "start_page"));
|
|
51 this.witnessList.add(new WitnessItem(witness.getId(), label/*, divaImageIndex*/));
|
|
52 }
|
|
53
|
|
54
|
|
55 }
|
|
56 ViewerPage tmp = getWrapper().getViewerPage("Codex");
|
|
57 this.dynamicCodexPageId = (tmp == null) ? dynamicCodexPageId : tmp.getId();
|
|
58
|
|
59 tmp = getWrapper().getViewerPage("Witness");
|
|
60 this.dynamicWitnessPageId = (tmp == null) ? dynamicWitnessPageId : tmp.getId();
|
|
61 }
|
|
62
|
|
63 public boolean isCodexPublic(){
|
|
64 return this.codexPublic;
|
|
65 }
|
|
66 public Entity getCodex() {
|
|
67 return codex;
|
|
68 }
|
|
69 public void setCodex(Entity codex) {
|
|
70 this.codex = codex;
|
|
71 }
|
|
72 public Entity getDigi() {
|
|
73 return digi;
|
|
74 }
|
|
75 public void setDigi(Entity digi) {
|
|
76 this.digi = digi;
|
|
77 }
|
|
78 public List<WitnessItem> getWitnessList() {
|
|
79 return witnessList;
|
|
80 }
|
|
81 public void setWitnessList(List<WitnessItem> witnessList) {
|
|
82 this.witnessList = witnessList;
|
|
83 }
|
|
84 public void setCodexPublic(boolean codexPublic) {
|
|
85 this.codexPublic = codexPublic;
|
|
86 }
|
|
87 public Long getDynamicCodexPageId() {
|
|
88 return dynamicCodexPageId;
|
|
89 }
|
|
90 public Long getDynamicWitnessPageId() {
|
|
91 return dynamicWitnessPageId;
|
|
92 }
|
|
93
|
|
94 public class WitnessItem{
|
|
95 private String label;
|
|
96 private Long id;
|
|
97
|
|
98 public WitnessItem(Long id, String label){
|
|
99 this.id = id;
|
|
100 this.label = RomanizationLoC.convert(label);
|
|
101 }
|
|
102
|
|
103 public String getLabel() {
|
|
104 return label;
|
|
105 }
|
|
106
|
|
107 public Long getId() {
|
|
108 return id;
|
|
109 }
|
|
110 }
|
|
111 }
|