1
|
1 package de.mpiwg.itgroup.diva.jsp;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.Collections;
|
|
5 import java.util.List;
|
|
6
|
|
7 import org.apache.commons.lang.StringUtils;
|
|
8 import org.mpi.openmind.repository.bo.Entity;
|
|
9
|
|
10 import de.mpiwg.itgroup.ismi.utils.templates.CodexTemplate;
|
|
11 import de.mpiwg.itgroup.ismi.utils.templates.WitnessTemplate;
|
|
12
|
|
13
|
|
14 public class JSPDigitalization extends AbsJSPWrapper{
|
|
15
|
|
16 private Long digiId;
|
|
17 private Entity digi;
|
|
18
|
|
19 private String name;
|
|
20 private String numFiles;
|
|
21
|
|
22
|
|
23 private CodexTemplate codex;
|
|
24 private List<WitnessTemplate> witnessList = new ArrayList<WitnessTemplate>();
|
|
25 private List<WitnessTemplate> unknownList = new ArrayList<WitnessTemplate>();
|
|
26
|
|
27 public String getDigiLabel(){
|
|
28 return (digi == null) ? null : digi.getOwnValue();
|
|
29 }
|
|
30
|
|
31 public String getUserName(){
|
|
32 if(getSessionBean() != null)
|
|
33 return getSessionBean().getUsername();
|
|
34 return null;
|
|
35 }
|
|
36
|
|
37 public boolean hasLogin(){
|
|
38 return !StringUtils.isEmpty(getUserName());
|
|
39 }
|
|
40
|
|
41 public boolean canEdit(){
|
|
42 if(getSessionBean() != null)
|
|
43 return getSessionBean().isCanEdit();
|
|
44 return false;
|
|
45 }
|
|
46
|
|
47 @Override
|
|
48 public void init(){
|
|
49 try {
|
|
50 this.loadDigitalization(Long.parseLong(getRequest().getParameter("digiId")));
|
|
51
|
|
52 } catch (Exception e) {
|
|
53 e.printStackTrace();
|
|
54 }
|
|
55 }
|
|
56
|
|
57 private void reset(){
|
|
58 this.witnessList = new ArrayList<WitnessTemplate>();
|
|
59 this.unknownList = new ArrayList<WitnessTemplate>();
|
|
60 this.codex = null;
|
|
61 this.digi = null;
|
|
62 this.digiId = null;
|
|
63 this.name = null;
|
|
64 this.numFiles = null;
|
|
65 }
|
|
66
|
|
67 private void loadDigitalization(Long digiId){
|
|
68 this.reset();
|
|
69 if(digiId != null){
|
|
70 this.digiId = digiId;
|
|
71 this.digi = getWrapper().getEntityByIdWithContent(digiId);
|
|
72 this.name = digi.getOwnValue();
|
|
73 this.numFiles = (digi.getAttributeByName("num_files") != null)? digi.getAttributeByName("num_files").getValue() : "";
|
|
74
|
|
75 List<Entity> list = getWrapper().getTargetsForSourceRelation(digi, "is_digitalization_of", "CODEX", 1);
|
|
76 if(list.size() > 0){
|
|
77 this.codex = new CodexTemplate(list.get(0), getWrapper());
|
|
78 List<Entity> list0 = getWrapper().getSourcesForTargetRelation(list.get(0), "is_part_of", "WITNESS", -1);
|
|
79 for(Entity witness : list0){
|
|
80 WitnessTemplate tmp = new WitnessTemplate(witness, getWrapper(), true);
|
|
81 this.witnessList.add(tmp);
|
|
82 if(tmp.isUnknown()){
|
|
83 this.unknownList.add(tmp);
|
|
84 }
|
|
85 }
|
|
86 }
|
|
87 }
|
|
88 Collections.sort(this.witnessList);
|
|
89 Collections.sort(this.unknownList);
|
|
90 }
|
|
91
|
|
92 public Entity getDigi() {
|
|
93 return digi;
|
|
94 }
|
|
95
|
|
96 public CodexTemplate getCodex() {
|
|
97 return codex;
|
|
98 }
|
|
99
|
|
100 public List<WitnessTemplate> getWitnessList() {
|
|
101 return this.witnessList;
|
|
102 }
|
|
103
|
|
104 public List<WitnessTemplate> getUnknownList() {
|
|
105 return unknownList;
|
|
106 }
|
|
107
|
|
108 public String getName() {
|
|
109 return name;
|
|
110 }
|
|
111
|
|
112 public String getNumFiles() {
|
|
113 return numFiles;
|
|
114 }
|
|
115
|
|
116 public Long getDigiId(){
|
|
117 return this.digiId;
|
|
118 }
|
|
119 }
|
|
120
|
|
121
|
|
122
|