1
|
1 package de.mpiwg.itgroup.ismi.publicView.pages;
|
|
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.mpi.openmind.repository.bo.Entity;
|
|
9 import org.mpi.openmind.repository.bo.ViewerAttribute;
|
|
10 import org.mpi.openmind.repository.bo.ViewerPage;
|
|
11 import org.mpi.openmind.repository.utils.OMUtils;
|
8
|
12 import org.mpi.openmind.repository.utils.RomanizationLoC;
|
1
|
13
|
|
14 import de.mpiwg.itgroup.diva.jsp.AbsJSPWrapper;
|
|
15
|
|
16 public class JSPDynamicPage extends AbsJSPWrapper{
|
|
17
|
|
18 private Long currentEntId;
|
|
19 private ViewerPage page;
|
|
20 private Map<String, List<String>> attMap;
|
|
21 private Map<String, String> attMapTextAlign;
|
|
22 private List<String> labelList;
|
|
23
|
|
24 private boolean errorLoading;
|
|
25
|
|
26 protected Entity digi;
|
|
27
|
|
28
|
|
29 public void load(String currentEntId){
|
|
30 try {
|
|
31 this.load(Long.parseLong(currentEntId));
|
|
32 } catch (Exception e) {
|
|
33 e.printStackTrace();
|
|
34 }
|
|
35 }
|
|
36
|
|
37 public void load(Long newEntId){
|
|
38 this.currentEntId = newEntId;
|
|
39 Entity ent = getWrapper().getEntityById(currentEntId);
|
|
40
|
|
41 this.errorLoading = (ent != null) ? true : false;
|
|
42 if(ent == null){
|
|
43 this.getSessionBean().addGeneralMsg("The entity " + currentEntId + " was not found.");
|
|
44 }
|
|
45
|
|
46 this.page = null;
|
|
47
|
|
48 this.attMap = new HashMap<String, List<String>>();
|
|
49 this.attMapTextAlign = new HashMap<String, String>();
|
|
50 this.labelList = new ArrayList<String>();
|
|
51 if(ent != null){
|
|
52
|
|
53 this.page = getWrapper().getViewerPage(ent.getObjectClass());
|
|
54 if(page != null){
|
|
55 List<ViewerAttribute> attList = getWrapper().getViewerAttributes(page.getId());
|
|
56 for(ViewerAttribute att : attList){
|
|
57 try {
|
|
58
|
|
59 if(att.getDisplayMode() != ViewerAttribute.HIDE){
|
|
60 this.attMapTextAlign.put(att.getLabel(), att.getTextAlign());
|
|
61 List<String> values = OMUtils.resolveQuery(currentEntId, att.getQuery(), getWrapper(), att.getContentType());
|
8
|
62 values = romanizeList(values);
|
1
|
63 if(values.size() > 0 || att.getDisplayMode() == ViewerAttribute.SHOW_ALWAYS){
|
|
64 this.attMap.put(att.getLabel(), values);
|
|
65 this.labelList.add(att.getLabel());
|
|
66 }
|
|
67 }
|
|
68
|
|
69 } catch (Exception e) {
|
|
70 e.printStackTrace();
|
|
71 }
|
|
72 }
|
|
73 }
|
|
74 }
|
119
|
75 //System.out.println("");
|
1
|
76 }
|
8
|
77
|
|
78 public List<String> romanizeList(List<String> list){
|
|
79 List<String> rs = new ArrayList<String>();
|
|
80 for(String s : list){
|
|
81 rs.add(RomanizationLoC.convert(s));
|
|
82 }
|
|
83 return rs;
|
|
84 }
|
1
|
85
|
|
86 public Long getCurrentEntId() {
|
|
87 return currentEntId;
|
|
88 }
|
|
89
|
|
90 public void setCurrentEntId(Long currentEntId) {
|
|
91 this.currentEntId = currentEntId;
|
|
92 }
|
|
93
|
|
94 public ViewerPage getPage() {
|
|
95 return page;
|
|
96 }
|
|
97
|
|
98
|
|
99 public void setPage(ViewerPage page) {
|
|
100 this.page = page;
|
|
101 }
|
|
102
|
|
103
|
|
104 public Map<String, List<String>> getAttMap() {
|
|
105 return attMap;
|
|
106 }
|
|
107
|
|
108
|
|
109 public void setAttMap(Map<String, List<String>> attMap) {
|
|
110 this.attMap = attMap;
|
|
111 }
|
|
112
|
|
113 public List<String> getLabels(){
|
|
114 return this.labelList;
|
|
115 }
|
|
116
|
|
117 public String getDigiLabel(){
|
|
118 return (digi == null) ? null : digi.getOwnValue();
|
|
119 }
|
|
120
|
|
121 public Long getDigiId(){
|
|
122 return (digi == null) ? null : digi.getId();
|
|
123 }
|
|
124
|
|
125 public Entity getDigi() {
|
|
126 return digi;
|
|
127 }
|
|
128
|
|
129 public void setDigi(Entity digi) {
|
|
130 this.digi = digi;
|
|
131 }
|
|
132
|
|
133 public Map<String, String> getAttMapTextAlign() {
|
|
134 return attMapTextAlign;
|
|
135 }
|
|
136
|
|
137 public boolean isErrorLoading(){
|
|
138 return this.errorLoading;
|
|
139 }
|
|
140 }
|