Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/search/beans/DisplayBean.java @ 77:985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
author | casties |
---|---|
date | Tue, 28 Jun 2016 16:18:49 -0400 |
parents | 70207f24937e |
children | e07e9f5afaa3 |
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); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
71 Entity codex = codices.get(0); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
72 // Attribute pub = getWrapper().getAttributeByName(codex.getId(), "public"); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
73 // if (pub == null || ! pub.getValue().equals("true")) { |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
74 // look at DIGITALIZATION |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
75 List<Entity> digis = getWrapper().getSourcesForTargetRelation(codex.getId(), is_digitalization_of, DIGITALIZATION, 1); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
76 hasScans = !digis.isEmpty(); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
77 if (this.showWitnessesWithScans && !hasScans) { |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
78 continue; |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
79 } |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
80 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
|
81 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
|
82 this.witnessItems.add(item); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
83 list.add(witness); |
985dcecba904
"show scans" link and indicator for all witnesses with digitalization (no check for public).
casties
parents:
72
diff
changeset
|
84 } |
1 | 85 |
86 if(list.size() > 0){ | |
87 this.showWitness(list.get(0).getId()); | |
88 } | |
89 | |
90 long diff = System.currentTimeMillis() - startWitness; | |
91 if(diff > 1000){ | |
92 logger.info("Time - listenerShowTitle().getSourcesForTargetRelation(title, 'X', WITNESS, -1) = " + diff + " [ms], Text id= " + this.selectedTitleId); | |
93 | |
94 } | |
95 //************************************************ | |
96 } | |
97 long diff = System.currentTimeMillis() - start; | |
98 | |
99 if(diff > 1000){ | |
100 logger.info("Time - listenerShowTitle() " + diff + " [ms], Text id= " + this.selectedTitleId); | |
101 } | |
102 } | |
103 | |
104 | |
105 public void listenerShowWitness0(ActionEvent event){ | |
106 SelectItem0 item = (SelectItem0)getRequestBean("witnessItem"); | |
107 if (item != null) { | |
108 this.redirect(null, "?textId=" + selectedTitleId + "&witnessId=" + item.getValue() + "#witnesses"); | |
109 } | |
110 } | |
111 | |
112 | |
113 public void showWitness(Long selectedWitnessId) { | |
114 | |
115 this.selectedWitnessId = selectedWitnessId; | |
116 | |
117 if (this.selectedWitnessId != null) { | |
118 this.witnessItems = SelectItem0.valueChange(witnessItems, selectedWitnessId); | |
119 Entity entWitness = getWrapper().getEntityById(selectedWitnessId); | |
120 | |
121 if (entWitness != null) { | |
122 this.witness = new WitnessTemplate(entWitness, getWrapper(), true); | |
123 } | |
124 } | |
125 } | |
126 | |
127 /** | |
128 * This method is called from the result of the simple search. It will set the title(text) into the currentText to be edited. | |
129 * @return | |
130 */ | |
131 public String actionEditTitle() { | |
132 if(this.selectedTitleId != null){ | |
133 getSessionBean().editEntity(getWrapper().getEntityById(selectedTitleId)); | |
134 return "entry_edit_entity"; | |
135 } | |
136 return ""; | |
137 } | |
138 | |
139 /** | |
140 * This method is called from the result of the simple search. It will set | |
141 * the witness into the currentWitness to be edited. | |
142 * | |
143 * @return | |
144 */ | |
145 public String actionEditWitness() { | |
146 if (this.selectedWitnessId != null) { | |
147 getSessionBean().editEntity(getWrapper().getEntityById(selectedWitnessId)); | |
148 return "entry_edit_entity"; | |
149 } | |
150 return ""; | |
151 } | |
152 | |
153 //Privacity titles | |
154 public void changePrivacity4Title(ActionEvent event){ | |
155 try { | |
156 if(selectedTitleId != null){ | |
157 List<Entity> saveList = PrivacityUtils.changePrivacity4Title(getWrapper().getEntityById(selectedTitleId), null, getWrapper()); | |
158 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
159 this.showTitle(selectedTitleId); | |
160 } | |
161 } catch (Exception e) { | |
162 logger.error(e.getMessage(), e); | |
163 printInternalError(e); | |
164 } | |
165 } | |
166 | |
167 //Privacity witnesses | |
168 public void changePrivacity4Witness(ActionEvent event){ | |
169 try { | |
170 if(selectedWitnessId != null){ | |
171 List<Entity> saveList = PrivacityUtils.changePrivacity4Witness(getWrapper().getEntityById(selectedWitnessId), null, getWrapper()); | |
172 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
173 this.showWitness(selectedWitnessId); | |
174 } | |
175 } catch (Exception e) { | |
176 logger.error(e.getMessage(), e); | |
177 printInternalError(e); | |
178 } | |
179 | |
180 } | |
181 | |
182 private void changeAllWitnesses(boolean privacity) throws Exception{ | |
183 List<Entity> saveList = new ArrayList<Entity>(); | |
184 for(SelectItem item : witnessItems){ | |
185 Long id = (Long)item.getValue(); | |
186 Entity witness = getWrapper().getEntityById(id); | |
187 saveList.addAll(PrivacityUtils.changePrivacity4Witness(witness, privacity, getWrapper())); | |
188 } | |
189 getWrapper().saveEntityListAsNodeWithoutContent(saveList, getUserName()); | |
190 this.showWitness(selectedWitnessId); | |
191 } | |
192 | |
193 public void listenerMakeAllWitnessesPublic(ActionEvent event){ | |
194 try { | |
195 this.changeAllWitnesses(true); | |
196 } catch (Exception e) { | |
197 logger.error(e.getMessage(), e); | |
198 printInternalError(e); | |
199 } | |
200 } | |
201 | |
202 public void listenerMakeAllWitnessesPrivate(ActionEvent event){ | |
203 try { | |
204 this.changeAllWitnesses(false); | |
205 } catch (Exception e) { | |
206 logger.error(e.getMessage(), e); | |
207 printInternalError(e); | |
208 } | |
209 | |
210 } | |
211 | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
212 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
213 public void changeShowWitnessesWithScans() { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
214 if (this.selectedTitleId != null) { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
215 showTitle(this.selectedTitleId); |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
216 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
217 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
218 |
1 | 219 public int getWitnessItemsSize() { |
220 if(witnessItems != null) | |
221 return witnessItems.size(); | |
222 return 0; | |
223 } | |
224 | |
225 public TitleTemplate getTitle() { | |
226 return title; | |
227 } | |
228 | |
229 public WitnessTemplate getWitness() { | |
230 return witness; | |
231 } | |
232 | |
233 public List<SelectItem0> getWitnessItems() { | |
234 return witnessItems; | |
235 } | |
236 | |
237 public Long getSelectedWitnessId() { | |
238 return selectedWitnessId; | |
239 } | |
240 | |
241 public Long getSelectedTitleId() { | |
242 return selectedTitleId; | |
243 } | |
244 | |
245 public void setSelectedWitnessId(Long selectedWitnessId) { | |
246 this.selectedWitnessId = selectedWitnessId; | |
247 } | |
248 | |
249 public void setSelectedTitleId(Long selectedTitleId) { | |
250 this.selectedTitleId = selectedTitleId; | |
251 } | |
72
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
252 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
253 public boolean isShowWitnessesWithScans() { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
254 return showWitnessesWithScans; |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
255 } |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
256 |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
257 public void setShowWitnessesWithScans(boolean showWitnessesWithScans) { |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
258 this.showWitnessesWithScans = showWitnessesWithScans; |
70207f24937e
cleaned displayAuthor. added filter for witnesses with scans.
casties
parents:
60
diff
changeset
|
259 } |
1 | 260 } |