Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/search/beans/DisplayBean.java @ 215:26138384984c
update more instances of IIIF server URL.
author | casties |
---|---|
date | Sat, 15 Jan 2022 16:09:55 +0100 |
parents | e07e9f5afaa3 |
children |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.search.beans; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import javax.faces.event.ActionEvent; | |
7 import javax.faces.model.SelectItem; | |
8 | |
9 import org.apache.log4j.Logger; | |
10 import org.mpi.openmind.repository.bo.Entity; | |
11 | |
12 import de.mpiwg.itgroup.ismi.auxObjects.SelectItem0; | |
13 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | |
14 import de.mpiwg.itgroup.ismi.entry.utils.PrivacityUtils; | |
15 import de.mpiwg.itgroup.ismi.utils.templates.TitleTemplate; | |
16 import de.mpiwg.itgroup.ismi.utils.templates.WitnessTemplate; | |
17 | |
18 public class DisplayBean extends AbstractISMIBean { | |
19 | |
20 /** | |
21 * | |
22 */ | |
23 private static final long serialVersionUID = 1296816397468908012L; | |
24 | |
25 private static Logger logger = Logger.getLogger(DisplayBean.class); | |
26 | |
27 protected TitleTemplate title; | |
28 protected WitnessTemplate witness; | |
29 | |
30 //Witness elements | |
31 protected List<SelectItem0> witnessItems = new ArrayList<SelectItem0>(); | |
32 protected Long selectedWitnessId; | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
33 protected boolean showWitnessesWithScans = false; |
1 | 34 |
35 //Title elements | |
36 protected Long selectedTitleId; | |
37 protected List<SelectItem0> titleItems = new ArrayList<SelectItem0>(); | |
38 | |
39 protected void resetDisplay(){ | |
40 this.witness = null; | |
41 this.selectedWitnessId = null; | |
42 this.title = null; | |
43 this.selectedTitleId = null; | |
44 this.witnessItems = new ArrayList<SelectItem0>(); | |
45 } | |
46 | |
47 public void showTitle(Long textId){ | |
48 this.selectedTitleId = textId; | |
49 | |
50 this.witness = null; | |
51 this.witnessItems = new ArrayList<SelectItem0>(); | |
52 this.selectedWitnessId = null; | |
53 | |
54 long start = System.currentTimeMillis(); | |
55 | |
56 Entity entTitle = getWrapper().getEntityById(this.selectedTitleId); | |
57 | |
58 if(this.selectedTitleId != null){ | |
59 | |
60 this.titleItems = SelectItem0.valueChange(titleItems, textId); | |
61 this.title = new TitleTemplate(entTitle, getWrapper(), false); | |
62 | |
63 //****** getting witnesses ********************** | |
64 long startWitness = System.currentTimeMillis(); | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
65 List<Entity> list = new ArrayList<Entity>(); |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
66 List<Entity> allwits = getWrapper().getSourcesForTargetRelation(selectedTitleId, is_exemplar_of, WITNESS, -1); |
77
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
67 boolean hasScans = false; |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
68 for (Entity witness : allwits) { |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
69 // get CODEX for WITNESS |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
70 List<Entity> codices = getWrapper().getTargetsForSourceRelation(witness.getId(), is_part_of, CODEX, 1); |
83 | 71 if (codices.isEmpty()) { |
72 logger.error("WITNESS ["+witness.getId()+"] has no CODEX!"); | |
73 } else { | |
74 Entity codex = codices.get(0); | |
75 // look at DIGITALIZATION of CODEX | |
76 List<Entity> digis = getWrapper().getSourcesForTargetRelation(codex.getId(), is_digitalization_of, DIGITALIZATION, 1); | |
77 hasScans = !digis.isEmpty(); | |
78 if (this.showWitnessesWithScans && !hasScans) { | |
79 continue; | |
80 } | |
77
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
81 } |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
82 String witlabel = witness.getOwnValue() + " [" + witness.getId() + "]" + (hasScans ? "+S" : ""); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
83 SelectItem0 item = new SelectItem0(witness.getId(), witlabel, true); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
84 this.witnessItems.add(item); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
85 list.add(witness); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
86 } |
1 | 87 |
88 if(list.size() > 0){ | |
89 this.showWitness(list.get(0).getId()); | |
90 } | |
91 | |
92 long diff = System.currentTimeMillis() - startWitness; | |
93 if(diff > 1000){ | |
94 logger.info("Time - listenerShowTitle().getSourcesForTargetRelation(title, 'X', WITNESS, -1) = " + diff + " [ms], Text id= " + this.selectedTitleId); | |
95 | |
96 } | |
97 //************************************************ | |
98 } | |
99 long diff = System.currentTimeMillis() - start; | |
100 | |
101 if(diff > 1000){ | |
102 logger.info("Time - listenerShowTitle() " + diff + " [ms], Text id= " + this.selectedTitleId); | |
103 } | |
104 } | |
105 | |
106 | |
107 public void listenerShowWitness0(ActionEvent event){ | |
108 SelectItem0 item = (SelectItem0)getRequestBean("witnessItem"); | |
109 if (item != null) { | |
110 this.redirect(null, "?textId=" + selectedTitleId + "&witnessId=" + item.getValue() + "#witnesses"); | |
111 } | |
112 } | |
113 | |
114 | |
115 public void showWitness(Long selectedWitnessId) { | |
116 | |
117 this.selectedWitnessId = selectedWitnessId; | |
118 | |
119 if (this.selectedWitnessId != null) { | |
120 this.witnessItems = SelectItem0.valueChange(witnessItems, selectedWitnessId); | |
121 Entity entWitness = getWrapper().getEntityById(selectedWitnessId); | |
122 | |
123 if (entWitness != null) { | |
124 this.witness = new WitnessTemplate(entWitness, getWrapper(), true); | |
125 } | |
126 } | |
127 } | |
128 | |
129 /** | |
130 * This method is called from the result of the simple search. It will set the title(text) into the currentText to be edited. | |
131 * @return | |
132 */ | |
133 public String actionEditTitle() { | |
134 if(this.selectedTitleId != null){ | |
135 getSessionBean().editEntity(getWrapper().getEntityById(selectedTitleId)); | |
136 return "entry_edit_entity"; | |
137 } | |
138 return ""; | |
139 } | |
140 | |
141 /** | |
142 * This method is called from the result of the simple search. It will set | |
143 * the witness into the currentWitness to be edited. | |
144 * | |
145 * @return | |
146 */ | |
147 public String actionEditWitness() { | |
148 if (this.selectedWitnessId != null) { | |
149 getSessionBean().editEntity(getWrapper().getEntityById(selectedWitnessId)); | |
150 return "entry_edit_entity"; | |
151 } | |
152 return ""; | |
153 } | |
154 | |
155 //Privacity titles | |
156 public void changePrivacity4Title(ActionEvent event){ | |
157 try { | |
158 if(selectedTitleId != null){ | |
159 List<Entity> saveList = PrivacityUtils.changePrivacity4Title(getWrapper().getEntityById(selectedTitleId), null, getWrapper()); | |
160 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
161 this.showTitle(selectedTitleId); | |
162 } | |
163 } catch (Exception e) { | |
164 logger.error(e.getMessage(), e); | |
165 printInternalError(e); | |
166 } | |
167 } | |
168 | |
169 //Privacity witnesses | |
170 public void changePrivacity4Witness(ActionEvent event){ | |
171 try { | |
172 if(selectedWitnessId != null){ | |
173 List<Entity> saveList = PrivacityUtils.changePrivacity4Witness(getWrapper().getEntityById(selectedWitnessId), null, getWrapper()); | |
174 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
175 this.showWitness(selectedWitnessId); | |
176 } | |
177 } catch (Exception e) { | |
178 logger.error(e.getMessage(), e); | |
179 printInternalError(e); | |
180 } | |
181 | |
182 } | |
183 | |
184 private void changeAllWitnesses(boolean privacity) throws Exception{ | |
185 List<Entity> saveList = new ArrayList<Entity>(); | |
186 for(SelectItem item : witnessItems){ | |
187 Long id = (Long)item.getValue(); | |
188 Entity witness = getWrapper().getEntityById(id); | |
189 saveList.addAll(PrivacityUtils.changePrivacity4Witness(witness, privacity, getWrapper())); | |
190 } | |
191 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
192 this.showWitness(selectedWitnessId); | |
193 } | |
194 | |
195 public void listenerMakeAllWitnessesPublic(ActionEvent event){ | |
196 try { | |
197 this.changeAllWitnesses(true); | |
198 } catch (Exception e) { | |
199 logger.error(e.getMessage(), e); | |
200 printInternalError(e); | |
201 } | |
202 } | |
203 | |
204 public void listenerMakeAllWitnessesPrivate(ActionEvent event){ | |
205 try { | |
206 this.changeAllWitnesses(false); | |
207 } catch (Exception e) { | |
208 logger.error(e.getMessage(), e); | |
209 printInternalError(e); | |
210 } | |
211 | |
212 } | |
213 | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
214 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
215 public void changeShowWitnessesWithScans() { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
216 if (this.selectedTitleId != null) { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
217 showTitle(this.selectedTitleId); |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
218 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
219 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
220 |
1 | 221 public int getWitnessItemsSize() { |
222 if(witnessItems != null) | |
223 return witnessItems.size(); | |
224 return 0; | |
225 } | |
226 | |
227 public TitleTemplate getTitle() { | |
228 return title; | |
229 } | |
230 | |
231 public WitnessTemplate getWitness() { | |
232 return witness; | |
233 } | |
234 | |
235 public List<SelectItem0> getWitnessItems() { | |
236 return witnessItems; | |
237 } | |
238 | |
239 public Long getSelectedWitnessId() { | |
240 return selectedWitnessId; | |
241 } | |
242 | |
243 public Long getSelectedTitleId() { | |
244 return selectedTitleId; | |
245 } | |
246 | |
247 public void setSelectedWitnessId(Long selectedWitnessId) { | |
248 this.selectedWitnessId = selectedWitnessId; | |
249 } | |
250 | |
251 public void setSelectedTitleId(Long selectedTitleId) { | |
252 this.selectedTitleId = selectedTitleId; | |
253 } | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
254 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
255 public boolean isShowWitnessesWithScans() { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
256 return showWitnessesWithScans; |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
257 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
258 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
259 public void setShowWitnessesWithScans(boolean showWitnessesWithScans) { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
260 this.showWitnessesWithScans = showWitnessesWithScans; |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
261 } |
1 | 262 } |