1
|
1 package de.mpiwg.itgroup.ismi.entry.beans;
|
|
2
|
|
3 import java.io.Serializable;
|
|
4 import java.util.ArrayList;
|
|
5 import java.util.HashMap;
|
|
6 import java.util.HashSet;
|
|
7 import java.util.List;
|
|
8 import java.util.Map;
|
|
9
|
|
10 import javax.faces.context.FacesContext;
|
|
11 import javax.faces.event.ActionEvent;
|
|
12 import javax.faces.event.ValueChangeEvent;
|
|
13 import javax.faces.model.SelectItem;
|
|
14
|
|
15 import org.apache.commons.lang.StringUtils;
|
|
16 import org.apache.log4j.Logger;
|
|
17 import org.mpi.openmind.cache.WrapperService;
|
|
18 import org.mpi.openmind.repository.bo.Attribute;
|
|
19 import org.mpi.openmind.repository.bo.Entity;
|
|
20 import org.mpi.openmind.repository.bo.Node;
|
|
21 import org.mpi.openmind.repository.bo.Relation;
|
|
22 import org.mpi.openmind.security.SecurityService;
|
|
23 import org.mpi.openmind.security.bo.User;
|
|
24 import org.mpiwg.itgroup.escidoc.bo.ESciDocItem;
|
|
25 import org.mpiwg.itgroup.escidoc.bo.Publication;
|
|
26 import org.mpiwg.itgroup.escidoc.utils.ESciDocItemDataTable;
|
|
27 import org.mpiwg.itgroup.escidoc.utils.SelectedESciDocItems;
|
|
28
|
|
29 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
|
|
30 import de.mpiwg.itgroup.ismi.entry.dataBeans.SimpleSearchCache;
|
|
31 import de.mpiwg.itgroup.ismi.util.guiComponents.Reference;
|
|
32 import de.mpiwg.itgroup.ismi.util.guiComponents.ReferenceTable;
|
|
33 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusChecker;
|
|
34 import de.mpiwg.itgroup.ismi.util.guiComponents.StatusImage;
|
|
35 import de.mpiwg.itgroup.ismi.utils.SelectableObject;
|
|
36
|
|
37 /**
|
|
38 *
|
|
39 * @author jurzua
|
|
40 */
|
|
41 public class AbstractISMIBean extends AbstractBean implements Serializable{
|
|
42
|
|
43 private static final long serialVersionUID = 9193140306343947209L;
|
|
44
|
|
45 private static Logger logger = Logger.getLogger(AbstractISMIBean.class);
|
|
46
|
|
47 public static String WITNESS = "WITNESS";
|
|
48 public static String TEXT = "TEXT";
|
|
49 public static String PERSON = "PERSON";
|
|
50 public static String COLLECTION = "COLLECTION";
|
|
51 public static String CODEX = "CODEX";
|
|
52 public static String REPOSITORY = "REPOSITORY";
|
|
53 public static String ALIAS = "ALIAS";
|
|
54 public static String PLACE = "PLACE";
|
|
55 public static String SUBJECT = "SUBJECT";
|
|
56 public static String REFERENCE = "REFERENCE";
|
|
57 public static String ROLE = "ROLE";
|
|
58 public static String DIGITALIZATION = "DIGITALIZATION";
|
|
59 public static String FLORUIT_DATE = "FLORUIT_DATE";
|
|
60
|
|
61 public static String is_digitalization_of = "is_digitalization_of";
|
|
62 public static String is_part_of = "is_part_of";
|
|
63 public static String is_in = "is_in";
|
|
64 public static String has_subject = "has_subject";
|
|
65 public static String misattributed_to = "misattributed_to";
|
|
66 public static String lived_in = "lived_in";
|
|
67 public static String owned_by = "owned_by";
|
|
68 public static String has_role = "has_role";
|
|
69 public static String was_student_of = "was_student_of";
|
|
70 public static String is_alias_name_of = "is_alias_name_of";
|
|
71 public static String is_prime_alias_name_of = "is_prime_alias_name_of";
|
|
72 public static String is_alias_title_of = "is_alias_title_of";
|
|
73 public static String is_prime_alias_title_of = "is_prime_alias_title_of";
|
|
74 public static String alias = "alias";
|
|
75 public static String has_floruit_date = "has_floruit_date";
|
|
76
|
|
77 public static String rel_was_created_by = "was_created_by";
|
|
78 public static String rel_was_copied_by = "was_copied_by";
|
|
79 public static String is_exemplar_of = "is_exemplar_of";
|
|
80 public static String is_possible_exemplar_of = "is_possible_exemplar_of";
|
|
81 public static String rel_had_patron = "had_patron";
|
|
82 public static String rel_has_title_written_as = "has_title_written_as";
|
|
83 public static String rel_has_author_written_as = "has_author_written_as";
|
|
84 public static String rel_is_reference_of = "is_reference_of";
|
|
85
|
|
86 public static String rel_was_studied_by = "was_studied_by";
|
|
87
|
|
88 public static String PAGE_EDITOR = "entry_edit_entity";
|
|
89 public static String PAGE_SIMPLE_SEARCH = "simple_search";
|
|
90 public static String PAGE_MERGE = "general_merge";
|
|
91
|
|
92 //some attributes names
|
|
93 public static String name = "name";
|
|
94 public static String name_translit = "name_translit";
|
|
95 public static String full_title_translit = "full_title_translit";
|
|
96
|
|
97 public static int MAX_SUGGEST = 25;
|
|
98
|
|
99 protected boolean selectedSaveAsNew = false;
|
|
100
|
|
101 private HashSet<StatusChecker> statusChecker = new HashSet<StatusChecker>();
|
|
102 private boolean warning = false;
|
|
103 private String warningMessage = "";
|
|
104 private boolean displayWarning = false;
|
|
105
|
|
106 //private PanelPopup popup = new PanelPopup();
|
|
107 //private String popupText = "";
|
|
108
|
|
109 private String currentId;
|
|
110 private String currentIdMsg;
|
|
111
|
|
112 // used in the new version
|
|
113 private Boolean create_error = false;
|
|
114 private String selectedWitnessID = "0";
|
|
115 private boolean showWitness;
|
|
116 private boolean showTitle = false;
|
|
117
|
|
118 private Map<String, String> attributes = new HashMap<String, String>();
|
|
119 protected String defObjectClass = null;
|
|
120
|
|
121 protected String displayUrl;
|
|
122
|
|
123 protected Entity entity;
|
|
124
|
|
125 protected long start;
|
|
126
|
|
127 public String save(){
|
|
128 logger.info("*************** START Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************");
|
|
129 this.start = System.currentTimeMillis();
|
|
130 return null;
|
|
131 }
|
|
132
|
|
133 protected void saveEnd(){
|
|
134 logger.info("*************** END Saving "+ this.defObjectClass + " [ID=" + entity.getId() +", user"+ getUserName() +"] *********************\n");
|
|
135 }
|
|
136
|
|
137 public Entity getEntity() {
|
|
138 if (this.entity == null) {
|
|
139 this.entity = new Entity();
|
|
140 this.entity.setObjectClass(defObjectClass);
|
|
141 this.entity.setLightweight(false);
|
|
142 this.loadAttributes(this.entity);
|
|
143 }
|
|
144 return entity;
|
|
145 }
|
|
146
|
|
147 protected void printSuccessSavingEntity(){
|
|
148 this.addGeneralMsg("The entity was successfully saved!");
|
|
149 this.addGeneralMsg("Its ID is " + this.entity.getId());
|
|
150 }
|
|
151
|
|
152 public void setEntity(Entity entity) {
|
|
153 this.entity = entity;
|
|
154 }
|
|
155
|
|
156 public String getSaveButtonLabel(){
|
|
157 if(entity.isPersistent())
|
|
158 return "Save";
|
|
159 return "Create";
|
|
160 }
|
|
161
|
|
162 public boolean isRenderSaveButton(){
|
|
163 //#{(CurrentText.entity.id == null and Session.canCreate) || (CurrentText.entity.id != null and Session.canEdit)}
|
|
164 if((!entity.isPersistent() && getSessionBean().isCanCreate()) ||
|
|
165 entity.isPersistent() && getSessionBean().isCanEdit())
|
|
166 return true;
|
|
167 return false;
|
|
168 }
|
|
169
|
|
170 public String clearAction(){
|
|
171 System.out.println("clearAction");
|
|
172 this.entity = new Entity(Node.TYPE_ABOX, this.defObjectClass, false);
|
|
173 this.setEntity(this.entity);
|
|
174 return PAGE_EDITOR;
|
|
175 }
|
|
176
|
|
177 public String actionReloadEntity(){
|
|
178 Long id = null;
|
|
179 try{
|
|
180 id = new Long(this.getCurrentId());
|
|
181 }catch (Exception e) {}
|
|
182
|
|
183 if(id != null){
|
|
184 Entity tmp = getWrapper().getEntityById(id);
|
|
185 if(tmp != null && tmp.getObjectClass().equals(this.defObjectClass)){
|
|
186 this.setEntity(tmp);
|
|
187 }else{
|
|
188 this.setCurrentIdMsg("Entity no found!");
|
|
189 }
|
|
190 }else{
|
|
191 this.setCurrentIdMsg("ID is not valid!");
|
|
192 }
|
|
193 return PAGE_EDITOR;
|
|
194 }
|
|
195
|
|
196 public String getDisplayUrl() {
|
|
197 return displayUrl;
|
|
198 }
|
|
199
|
|
200 public void setDisplayUrl(String displayUrl) {
|
|
201 this.displayUrl = displayUrl;
|
|
202 }
|
|
203
|
|
204 public static String generateDisplayUrl(Entity author, Entity title, Entity witness, String rootUrl){
|
|
205 //example: ?personId=414996&textId=36650&witnessId=66802#witnesses
|
|
206 StringBuilder sb = new StringBuilder();
|
|
207 if(author != null && author.isPersistent()){
|
|
208 sb.append(rootUrl + "/search/displayAuthor.xhtml?");
|
|
209 sb.append("personId=" + author.getId());
|
|
210 if(title != null && title.isPersistent()){
|
|
211 sb.append("&textId=" + title.getId());
|
|
212 if(witness != null && witness.isPersistent()){
|
|
213 sb.append("&witness=" + witness.getId());
|
|
214 sb.append("#witnesses");
|
|
215 }else{
|
|
216 sb.append("#titles");
|
|
217 }
|
|
218 }
|
|
219 }else if(title != null && title.isPersistent()){
|
|
220 sb.append(rootUrl + "/search/displayTitle.xhtml?");
|
|
221 sb.append("&textId=" + title.getId());
|
|
222 if(witness != null && witness.isPersistent()){
|
|
223 sb.append("&witness=" + witness.getId());
|
|
224 sb.append("#witnesses");
|
|
225 }else{
|
|
226 sb.append("#titles");
|
|
227 }
|
|
228
|
|
229 }
|
|
230 return sb.toString();
|
|
231 }
|
|
232
|
|
233 //********************************
|
|
234 //**** PUBLICATIONS END NOTE *****
|
|
235 //********************************
|
|
236
|
|
237 private ReferenceTable endNoteRefTable = new ReferenceTable();
|
|
238
|
|
239 protected void loadEndNoteRefs(){
|
|
240 this.endNoteRefTable.loadRefs(getEntRefs());
|
|
241 }
|
|
242
|
|
243 public ReferenceTable getEndNoteRefTable() {
|
|
244 return endNoteRefTable;
|
|
245 }
|
|
246
|
|
247 public void setEndNoteRefTable(ReferenceTable endNoteRefTable) {
|
|
248 this.endNoteRefTable = endNoteRefTable;
|
|
249 }
|
|
250
|
|
251 private List<Entity> getEntRefs(){
|
|
252 List<Entity> rs = new ArrayList<Entity>();
|
|
253 for (Relation rel : this.entity.getTargetRelations()) {
|
|
254 if (rel.getOwnValue().equals(rel_is_reference_of)) {
|
|
255 rs.add(getWrapper().getEntityByIdWithContent(rel.getSourceId()));
|
|
256 }
|
|
257 }
|
|
258 return rs;
|
|
259 }
|
|
260
|
|
261 //********************************
|
|
262 //**** PUBLICATIONS ESciDOC ******
|
|
263 //********************************
|
|
264
|
|
265 private ESciDocItemDataTable refDataTable = new ESciDocItemDataTable(this);
|
|
266 protected SelectedESciDocItems selectedItems = new SelectedESciDocItems();
|
|
267
|
|
268 public ESciDocItemDataTable getRefDataTable() {
|
|
269 return refDataTable;
|
|
270 }
|
|
271
|
|
272 public void setRefDataTable(ESciDocItemDataTable refDataTable) {
|
|
273 this.refDataTable = refDataTable;
|
|
274 }
|
|
275
|
|
276 public void listenerRemoveReference(ActionEvent event){
|
|
277 List<String> pubIdList = new ArrayList<String>();
|
|
278 for(String pubId : this.selectedItems.getMap().keySet()){
|
|
279 if(this.selectedItems.getMap().get(pubId)){
|
|
280 pubIdList.add(pubId);
|
|
281 }
|
|
282 }
|
|
283 for(String pubId : pubIdList){
|
|
284 this.selectedItems.removeById(pubId);
|
|
285 }
|
|
286 }
|
|
287
|
|
288 public void loadReferences(Entity currentEntity){
|
|
289 this.loadReferences(currentEntity, new ArrayList<String>());
|
|
290 }
|
|
291
|
|
292 public void loadReferences(Entity currentEntity, List<String> idsNoFound){
|
|
293 this.selectedItems.setList(new ArrayList<ESciDocItem>());
|
|
294 boolean escidocRespondOK = true;
|
|
295 try{
|
|
296
|
|
297 for (Relation rel : currentEntity.getTargetRelations()) {
|
|
298 if (rel.getOwnValue().equals(rel_is_reference_of)) {
|
|
299 Entity source = getWrapper().getEntityByIdWithContent(rel.getSourceId());
|
|
300 ESciDocItem item = getAppBean().getRefCache().getItem(source.getOwnValue());
|
|
301 if(item == null){
|
|
302 item = new ESciDocItem(source.getOwnValue());
|
|
303 item.setErrorLoading(ESciDocItem.ESCIDOC_ERROR_ID_NO_FOUND);
|
|
304 idsNoFound.add(source.getOwnValue());
|
|
305 }
|
|
306
|
|
307 /*Publication pub = ESciDocHandler.getPublicationById(source.getOwnValue());
|
|
308 if(pub == null){
|
|
309 pub = new Publication(source.getOwnValue());
|
|
310 pub.setErrorLoading(Publication.ESCIDOC_ERROR_ID_NO_FOUND);
|
|
311 idsNoFound.add(source.getOwnValue());
|
|
312 }
|
|
313 */
|
|
314 Attribute att = source.getAttributeByName("additional_information");
|
|
315 if(att != null){
|
|
316 item.getPublication().setAdditionalInformation(att.getOwnValue());
|
|
317 }
|
|
318 item.getPublication().setEntity(source);
|
|
319 this.selectedItems.addESciDocItem(item);
|
|
320 }
|
|
321 }
|
|
322 }catch (Exception e) {
|
|
323 escidocRespondOK = false;
|
|
324 }
|
|
325 this.reportEscidocError(escidocRespondOK, idsNoFound);
|
|
326 }
|
|
327
|
|
328
|
|
329
|
|
330 protected void reportEscidocError(boolean escidocRespondOK, List<String> idsNoFound){
|
|
331 if(!escidocRespondOK){
|
|
332 addGeneralMsg("The references could not be loaded. The server did not respond.");
|
|
333 addGeneralMsg("Exception connecting to http://escidoc.mpiwg-berlin.mpg.de:8080 ");
|
|
334 }
|
|
335
|
|
336 if(!idsNoFound.isEmpty()){
|
|
337 addGeneralMsg("The following references were not found in Pubman server:");
|
|
338 StringBuilder sb = new StringBuilder();
|
|
339 int count = 0;
|
|
340 for(String id : idsNoFound){
|
|
341 if(count > 0){
|
|
342 sb.append(", ");
|
|
343 }
|
|
344 sb.append(id);
|
|
345 }
|
|
346 addGeneralMsg(sb.toString());
|
|
347 }
|
|
348
|
|
349 }
|
|
350
|
|
351 protected void prepareEndNoteRefs2Save() throws Exception{
|
|
352 //REFERENCE -> is_reference_of -> WITNESS
|
|
353 this.entity.removeAllTargetRelationsByName(rel_is_reference_of);
|
|
354 for(SelectableObject<Reference> so : this.endNoteRefTable.list){
|
|
355 Reference ref = so.getObj();
|
|
356
|
|
357 Entity entRef = ref.getEnt();
|
|
358 getWrapper().saveAssertion(entRef, getUserName());
|
|
359 //entity can be no persistent, therefore the assignment of the relation should be done after the save
|
|
360 entRef.addSourceRelation(rel_is_reference_of, entity);
|
|
361 //new Relation(entRef, entity, rel_is_reference_of);
|
|
362 }
|
|
363 }
|
|
364
|
|
365 protected Entity prepareESciDocRefs2Save(Entity currentEntity) throws Exception{
|
|
366 //REFERENCE -> is_reference_of -> WITNESS
|
|
367 currentEntity.removeAllTargetRelationsByName(rel_is_reference_of);
|
|
368 for(ESciDocItem item : this.selectedItems.getList()){
|
|
369 Publication pub = item.getPublication();
|
|
370 if(pub.getEntity() == null){
|
|
371 Entity pubEntity = new Entity(Node.TYPE_ABOX, REFERENCE, false);
|
|
372 pubEntity.setOwnValue(pub.getObjid());
|
|
373 pubEntity.addAttribute(new Attribute("id", "escidoc-objid", pub.getObjid()));
|
|
374 if(StringUtils.isNotEmpty(pub.getAdditionalInformation())){
|
|
375 pubEntity.addAttribute(new Attribute("additional_information", "text", pub.getAdditionalInformation()));
|
|
376 }
|
|
377 pubEntity = getWrapper().saveEntity(pubEntity, getUserName());
|
|
378 pub.setEntity(pubEntity);
|
|
379 }else{
|
|
380 if(pub.getEntity().getAttributeByName("additional_information") != null){
|
|
381 pub.getEntity().getAttributeByName("additional_information").setOwnValue(pub.getAdditionalInformation());
|
|
382 }else{
|
|
383 pub.getEntity().addAttribute(new Attribute("additional_information", "text", pub.getAdditionalInformation()));
|
|
384 }
|
|
385 pub.setEntity(getWrapper().saveEntity(pub.getEntity(), getUserName()));
|
|
386 }
|
|
387 Relation rel = new Relation(pub.getEntity(), currentEntity, rel_is_reference_of);
|
|
388 }
|
|
389 return currentEntity;
|
|
390 }
|
|
391
|
|
392 public static de.mpiwg.itgroup.ismi.util.guiComponents.Calendar updateCalendar(Attribute att){
|
|
393 de.mpiwg.itgroup.ismi.util.guiComponents.Calendar calendar = null;
|
|
394 if(att != null && StringUtils.isNotEmpty(att.getOwnValue())){
|
|
395 calendar = new de.mpiwg.itgroup.ismi.util.guiComponents.Calendar(att.getOwnValue());
|
|
396 }else{
|
|
397 calendar = new de.mpiwg.itgroup.ismi.util.guiComponents.Calendar();
|
|
398 }
|
|
399 return calendar;
|
|
400 }
|
|
401
|
|
402 protected void loadAttributes(Entity entity) {
|
|
403 attributes = new HashMap<String, String>();
|
|
404 if (entity != null) {
|
|
405 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) {
|
|
406 Attribute originalAtt = entity.getAttributeByName(defAtt
|
|
407 .getOwnValue());
|
|
408 String attValue = (originalAtt != null) ? originalAtt
|
|
409 .getOwnValue() : "";
|
|
410 attributes.put(defAtt.getOwnValue(), attValue);
|
|
411 }
|
|
412 } else {
|
|
413 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) {
|
|
414 attributes.put(defAtt.getOwnValue(), "");
|
|
415 }
|
|
416 }
|
|
417 }
|
|
418
|
|
419 public void reset(){
|
|
420 this.setSelectedSaveAsNew(false);
|
|
421 this.setCurrentId("");
|
|
422 this.setCurrentIdMsg("");
|
|
423 this.setAttributes(new HashMap<String, String>());
|
|
424 this.selectedItems = new SelectedESciDocItems();
|
|
425 this.displayUrl = null;
|
|
426 this.endNoteRefTable = new ReferenceTable();
|
|
427 }
|
|
428
|
|
429 public boolean isSelectedSaveAsNew() {
|
|
430 return selectedSaveAsNew;
|
|
431 }
|
|
432
|
|
433 public void setSelectedSaveAsNew(boolean selectedSaveAsNew) {
|
|
434 this.selectedSaveAsNew = selectedSaveAsNew;
|
|
435 }
|
|
436
|
|
437 /**
|
|
438 * <p>
|
|
439 * "Entity -> CurrentEntity"
|
|
440 * </p>
|
|
441 * <p>
|
|
442 * This method updates the attributes of the given entity with the
|
|
443 * attributes of the attributes Map<String, String>.
|
|
444 * </p>
|
|
445 *
|
|
446 * @return the input's entity with updated attributes.
|
|
447 */
|
|
448 public Entity updateEntityAttributes(Entity entity) {
|
|
449 if (entity == null) {
|
|
450 entity = new Entity(Node.TYPE_ABOX, false);
|
|
451 //entity.setObjectClass(getDefinition().getOwnValue());
|
|
452 entity.setObjectClass(this.defObjectClass);
|
|
453 }
|
|
454 //for (Attribute defAtt : getDefinition(entity).getAttributes()) {
|
|
455 for (Attribute defAtt : getWrapper().getDefAttributes(this.defObjectClass)) {
|
|
456 Attribute att = entity.getAttributeByName(defAtt.getOwnValue());
|
|
457 if (StringUtils.isNotEmpty(this.attributes
|
|
458 .get(defAtt.getOwnValue()))) {
|
|
459 if (att == null) {
|
|
460 att = new Attribute(defAtt);
|
|
461 entity.addAttribute(att);
|
|
462 }
|
|
463 att.setOwnValue(this.attributes.get(defAtt.getOwnValue()));
|
|
464 att.setObjectClass(defAtt.getOwnValue());
|
|
465 } else if (att != null) {
|
|
466 // the attribute must be deleted.
|
|
467 entity.getAttributes().remove(att);
|
|
468 }
|
|
469 }
|
|
470 return entity;
|
|
471 }
|
|
472
|
|
473 protected List<SelectItem> updateSuggestedPersonByRole(String searchWord, String objClass, String attName, String role){
|
|
474 List<Attribute> attList = getWrapper().getAttributesByDefByAttName(objClass, attName, searchWord.toString(), -1);
|
|
475
|
|
476 List<SelectItem> suggestedItems = new ArrayList<SelectItem>();
|
|
477 if (attList == null)
|
|
478 return suggestedItems;
|
|
479
|
|
480 int count = 0;
|
|
481 for (Attribute att : attList) {
|
|
482 if(getCache().roleContainsPersonId(role, att.getSourceId())){
|
|
483 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]","description: " + att);
|
|
484 suggestedItems.add(item);
|
|
485 count++;
|
|
486 if(count == MAX_SUGGEST)
|
|
487 break;
|
|
488 }
|
|
489 }
|
|
490 return suggestedItems;
|
|
491 }
|
|
492
|
|
493 protected List<SelectItem> updateSuggestedItems(ValueChangeEvent event,
|
|
494 String objClass, String attName) {
|
|
495 return updateSuggestedItems((String) event.getNewValue(), objClass,
|
|
496 attName);
|
|
497 }
|
|
498
|
|
499 protected List<SelectItem> updateSuggestedItems(String searchWord,
|
|
500 String objClass, String attName) {
|
|
501
|
|
502 List<Attribute> attList = getWrapper().getAttributesByDefByAttName(objClass, attName, searchWord.toString(), MAX_SUGGEST);
|
|
503
|
|
504 List<SelectItem> suggestedItems = new ArrayList<SelectItem>();
|
|
505 if (attList == null)
|
|
506 return suggestedItems;
|
|
507
|
|
508 for (Attribute att : attList) {
|
|
509 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]",
|
|
510 "description: " + att);
|
|
511 suggestedItems.add(item);
|
|
512 }
|
|
513 return suggestedItems;
|
|
514 }
|
|
515
|
|
516 protected SimpleSearchCache getCache(){
|
|
517 return getAppBean().getSimpleSearchCache();
|
|
518 }
|
|
519
|
|
520 protected List<SelectItem> updateSuggestedItems(String objClass,
|
|
521 String firstName, String firstValue, String secondName,
|
|
522 String secondValue) {
|
|
523
|
|
524 List<Attribute> attList =
|
|
525 getWrapper().
|
|
526 searchAttribute(firstName, firstValue, secondName, secondValue, objClass, MAX_SUGGEST);
|
|
527
|
|
528 List<SelectItem> suggestedItems = new ArrayList<SelectItem>();
|
|
529 if (attList == null)
|
|
530 return suggestedItems;
|
|
531
|
|
532 for (Attribute att : attList) {
|
|
533 SelectItem item = new SelectItem(att, att.getOwnValue() + " [" + att.getSourceId() + "]");
|
|
534 suggestedItems.add(item);
|
|
535 }
|
|
536 return suggestedItems;
|
|
537 }
|
|
538
|
|
539 public Map<String, String> getAttributes() {
|
|
540 return attributes;
|
|
541 }
|
|
542
|
|
543 public void setAttributes(Map<String, String> attributes) {
|
|
544 this.attributes = attributes;
|
|
545 }
|
|
546
|
|
547 /**
|
|
548 * <p>
|
|
549 * This method plays the role of a small cache to get quickly the
|
|
550 * definitions.
|
|
551 * </p>
|
|
552 * TODO this method must be implemented into a bean in session context and
|
|
553 * research by every beans.
|
|
554 *
|
|
555 * @param assertion
|
|
556 * @return
|
|
557 */
|
|
558 public Entity getLWDefinition(Entity assertion) {
|
|
559 return getWrapper().getDefinition(assertion.getObjectClass());
|
|
560 }
|
|
561
|
|
562 public Entity getLWDefinition(String objClass) {
|
|
563 return getWrapper().getDefinition(objClass);
|
|
564 }
|
|
565
|
|
566 /**
|
|
567 * <p>
|
|
568 * Returns the target's entity of a relation. The returned target is no
|
|
569 * light weight.
|
|
570 * <p>
|
|
571 *
|
|
572 * @param rel
|
|
573 * @param target
|
|
574 * @return
|
|
575 */
|
|
576 protected Entity getTargetRelation(Relation rel) {
|
|
577 Entity target = rel.getTarget();
|
|
578 if (target == null) {
|
|
579 target = getWrapper().getEntityById(rel.getTargetId());
|
|
580 rel.setTarget(target);
|
|
581 } else if (target.isLightweight()) {
|
|
582 target = getWrapper().getEntityContent(target);
|
|
583 }
|
|
584 return target;
|
|
585 }
|
|
586
|
|
587 protected Attribute getTargetAttribute(Entity target, String name) {
|
|
588 Attribute att = getWrapper().getAttributeByName(target.getId(), name);
|
|
589
|
|
590 if (att == null) {
|
|
591 att = new Attribute();
|
|
592 att.setOwnValue(target.getOwnValue());
|
|
593 }
|
|
594 return att;
|
|
595 }
|
|
596
|
|
597 protected WrapperService getWrapper() {
|
|
598 return getAppBean().getWrapper();
|
|
599 }
|
|
600
|
|
601 /**
|
|
602 * <p>
|
|
603 * Return the <code>FacesContext</code> instance for the current request.
|
|
604 */
|
|
605 protected FacesContext context() {
|
|
606 return (FacesContext.getCurrentInstance());
|
|
607 }
|
|
608
|
|
609 public void setCreate_error(Boolean create_error) {
|
|
610 this.create_error = create_error;
|
|
611 }
|
|
612
|
|
613 public Boolean getCreate_error() {
|
|
614 return create_error;
|
|
615 }
|
|
616
|
|
617 /**
|
|
618 * Eine Liste <code>toBeRestricted</code> wird so eingeschraenkt, dass nur
|
|
619 * noch die jenigen uebrig bleiben, die �ber die Relation
|
|
620 * <code>relation</code> mit einem der Elemente aus
|
|
621 * <code>contraintIds</code> verbunden sind.
|
|
622 *
|
|
623 * @param toBeRestricted
|
|
624 * @param constraintIds
|
|
625 * @param relation
|
|
626 * @param mode
|
|
627 * @return
|
|
628 */
|
|
629 protected List<SelectItem> restrictList(List<SelectItem> toBeRestricted,
|
|
630 List<String> constraintIds, String relation, String mode) {
|
|
631
|
|
632 List<SelectItem> newList = new ArrayList<SelectItem>();
|
|
633
|
|
634 for (SelectItem s : toBeRestricted) {
|
|
635 Entity ent = getWrapper().getEntityById(
|
|
636 Long.valueOf((String) s.getValue()));
|
|
637 if (s.getValue().equals("0")) {
|
|
638 newList.add(s);
|
|
639 continue;
|
|
640 }
|
|
641
|
|
642 List<Relation> rels;
|
|
643 if (mode.equals("target")) {
|
|
644 rels = ent.getTargetRelations();
|
|
645 } else if (mode.equals("source")) {
|
|
646 rels = ent.getSourceRelations();
|
|
647 } else {
|
|
648 System.err.println("restrict List - mode not defined:" + mode);
|
|
649 return null;
|
|
650 }
|
|
651
|
|
652 for (Relation r : rels) {
|
|
653 if (r.getObjectClass().equals(relation)) {
|
|
654 Long id;
|
|
655 if (mode.equals("target")) {
|
|
656 id = r.getSource().getId();
|
|
657 } else if (mode.equals("source")) {
|
|
658 id = r.getTarget().getId();
|
|
659 } else {
|
|
660 System.err.println("restrict List - mode not defined:"
|
|
661 + mode);
|
|
662 return null;
|
|
663 }
|
|
664 if (constraintIds.contains(String.valueOf(id))) {
|
|
665 newList.add(s);
|
|
666 }
|
|
667 }
|
|
668 }
|
|
669 }
|
|
670
|
|
671 return newList;
|
|
672 }
|
|
673
|
|
674 public String getSelectedWitnessID() {
|
|
675 return selectedWitnessID;
|
|
676 }
|
|
677
|
|
678 public void setShowWitness(boolean showWitness) {
|
|
679 this.showWitness = showWitness;
|
|
680 }
|
|
681
|
|
682 public boolean isShowWitness() {
|
|
683 return showWitness;
|
|
684 }
|
|
685
|
|
686 public void setShowTitle(boolean showTitle) {
|
|
687 this.showTitle = showTitle;
|
|
688 }
|
|
689
|
|
690 public boolean isShowTitle() {
|
|
691 return showTitle;
|
|
692 }
|
|
693 /*
|
|
694 public PanelPopup getPopup() {
|
|
695 return popup;
|
|
696 }
|
|
697
|
|
698 public void setPopup(PanelPopup popup) {
|
|
699 this.popup = popup;
|
|
700 }
|
|
701
|
|
702 public String getPopupText() {
|
|
703 return popupText;
|
|
704 }
|
|
705
|
|
706 public void setPopupText(String popupText) {
|
|
707 this.popupText = popupText;
|
|
708 }*/
|
|
709
|
|
710
|
|
711 public String getUserName(){
|
|
712 User user = getSessionUser();
|
|
713 if(user == null)
|
|
714 return "";
|
|
715 else
|
|
716 return user.getEmail();
|
|
717 }
|
|
718
|
|
719 public User getSessionUser() {
|
|
720 SessionBean bean = getSessionBean();
|
|
721 if(bean != null){
|
|
722 return bean.getUser();
|
|
723 }else{
|
|
724 return null;
|
|
725 }
|
|
726 }
|
|
727
|
|
728 public void fillList(List<SelectItem> list, String[] array) {
|
|
729 list.add(new SelectItem(""));
|
|
730 for (int i = 0; i < array.length; i++) {
|
|
731 list.add(new SelectItem(array[i]));
|
|
732 }
|
|
733
|
|
734 }
|
|
735
|
|
736 public boolean isWarning() {
|
|
737 return warning;
|
|
738 }
|
|
739
|
|
740 public void setWarning(boolean warning) {
|
|
741 this.warning = warning;
|
|
742 }
|
|
743
|
|
744 public void setWarningMessage(String warningMessage) {
|
|
745 this.warningMessage = warningMessage;
|
|
746 }
|
|
747
|
|
748 public String getWarningMessage() {
|
|
749 return warningMessage;
|
|
750 }
|
|
751
|
|
752 public void setDisplayWarning(boolean displayWarning) {
|
|
753 this.displayWarning = displayWarning;
|
|
754 }
|
|
755
|
|
756 public boolean isDisplayWarning() {
|
|
757 return displayWarning;
|
|
758 }
|
|
759
|
|
760 public void registerChecker(StatusChecker sc) {
|
|
761 statusChecker.add(sc);
|
|
762 }
|
|
763
|
|
764 public void registerChecker(ListenerObject lo, String message) {
|
|
765 registerChecker(lo.statusImage, message);
|
|
766
|
|
767 }
|
|
768
|
|
769 public void registerChecker(StatusChecker sc, String message) {
|
|
770 sc.setMessage(message);
|
|
771 statusChecker.add(sc);
|
|
772 }
|
|
773
|
|
774 class CheckResults {
|
|
775 List<String> errors = new ArrayList<String>();
|
|
776 List<String> warnings = new ArrayList<String>();
|
|
777 public boolean hasErrors = false;
|
|
778 public boolean hasWarnings = false;
|
|
779
|
|
780 }
|
|
781
|
|
782 public CheckResults getCheckResults() {
|
|
783 CheckResults cr = new CheckResults();
|
|
784
|
|
785 for (StatusChecker sc : statusChecker) {
|
|
786 if (sc.getStatus().equals("false")) {
|
|
787 cr.hasErrors = true;
|
|
788 cr.errors.add(sc.getMessage());
|
|
789 } else if (sc.getStatus().equals("unset")) {
|
|
790 cr.hasWarnings = true;
|
|
791 cr.warnings.add(sc.getMessage());
|
|
792 }
|
|
793 }
|
|
794 return cr;
|
|
795 }
|
|
796
|
|
797 protected ListenerObject changeValue(String ownvalue, ListenerObject lo, String suggestType, String suggestAttributeName,
|
|
798 List<SelectItem> restrictedItems) {
|
|
799 if (restrictedItems != null) {
|
|
800 lo.suggestedItems = restrictedItems;}
|
|
801
|
|
802 if (ownvalue == null || ownvalue.equals(""))
|
|
803 lo.statusImage.setStatus("unset");
|
|
804 else
|
|
805 lo.statusImage.setStatus("false");
|
|
806 lo.entity = null;
|
|
807 // setze erst mal den Eigenwert auf das eingebene.
|
|
808 Attribute at = new Attribute();
|
|
809 at.setOwnValue(ownvalue);
|
|
810 lo.attribute = at;
|
|
811 Entity element = null;
|
|
812 if (lo.suggestedItems != null) // schaue in der liste der vorgebenen Ereignisse nach.
|
|
813 for (SelectItem item : lo.suggestedItems) {
|
|
814 if (item.getLabel().equals(ownvalue)) {
|
|
815 if (Attribute.class.isInstance(item.getValue())){ // entweder es ist schon ein attribute
|
|
816 lo.attribute = (Attribute) item.getValue();
|
|
817 element = getWrapper().getEntityById(
|
|
818 lo.attribute.getSourceId());
|
|
819 }else{ //oder ein paar wert / id// = (Attribute) item.getValue();
|
|
820 element = getWrapper().getEntityById(Long.valueOf((String) item.getValue()));
|
|
821 lo.setEntityAndAttribute(element, suggestAttributeName);
|
|
822 }
|
|
823 if (element != null) {
|
|
824 if(element.isLightweight()){
|
|
825 element = getWrapper().getEntityByIdWithContent(element.getId());
|
|
826 }
|
|
827 lo.entity = element;
|
|
828 lo.statusImage.setStatus("ok");
|
|
829 }
|
|
830 break;
|
|
831 }
|
|
832
|
|
833 } else {
|
|
834 //juc *** List<Entity> ents = getWrapper().getLightweightConceptsByAttribute(null, suggestType, suggestAttributeName, ownvalue, 1, false);
|
|
835 List<Entity> ents = getWrapper().getEntitiesByAtt(suggestType, suggestAttributeName, ownvalue, 1, false);
|
|
836 if (ents.size()==1){
|
|
837 lo.setEntityAndAttribute(ents.get(0),suggestAttributeName);
|
|
838 lo.statusImage.setStatus("ok");
|
|
839 }
|
|
840
|
|
841 }
|
|
842 return lo;
|
|
843
|
|
844 }
|
|
845
|
|
846
|
|
847
|
|
848 protected ListenerObject changeValuePersonByRole(ValueChangeEvent event, ListenerObject lo, String role){
|
|
849 if (event.getNewValue() == null) {
|
|
850 return lo;
|
|
851 }else if(StringUtils.isEmpty(event.getNewValue().toString()) && (event.getOldValue() == null || StringUtils.isEmpty(event.getOldValue().toString()))){
|
|
852 //if the old and new value are empty, then return
|
|
853 return lo;
|
|
854 }
|
|
855 if (event.getNewValue().equals(event.getOldValue())) {
|
|
856 return lo;
|
|
857 }
|
|
858
|
|
859 String ownValue = (String) event.getNewValue();
|
|
860
|
|
861 if(StringUtils.isEmpty(ownValue))
|
|
862 lo.statusImage.setStatus("unset");
|
|
863 else
|
|
864 lo.statusImage.setStatus("false");
|
|
865
|
|
866 lo.entity = null;
|
|
867 // setze erst mal den Eigenwert auf das eingebene.
|
|
868 Attribute at = new Attribute();
|
|
869 at.setOwnValue(ownValue);
|
|
870 lo.attribute = at;
|
|
871 for (SelectItem item : lo.suggestedItems) {
|
|
872 if (StringUtils.isNotEmpty(item.getLabel()) &&
|
|
873 item.getLabel().equals(ownValue)) {
|
|
874 //System.out.println("item.getValue()= " + item.getValue());
|
|
875 lo.attribute = (Attribute) item.getValue();
|
|
876 Entity element = getWrapper().getEntityById(
|
|
877 lo.attribute.getSourceId());
|
|
878
|
|
879 if (element != null) {
|
|
880 if(element.isLightweight()){
|
|
881 element = getWrapper().getEntityByIdWithContent(element.getId());
|
|
882 }
|
|
883 lo.entity = element;
|
|
884 lo.statusImage.setStatus(StatusImage.STATUS_OK);
|
|
885 }
|
|
886 break;
|
|
887 }
|
|
888
|
|
889 }
|
|
890
|
|
891 //juc lo.suggestedItems = updateSuggestedPersonByRole(ownValue, PERSON, "name", role);
|
|
892 lo.suggestedItems = updateSuggestedPersonByRole(ownValue, PERSON, "name_translit", role);
|
|
893
|
|
894
|
|
895 return lo;
|
|
896 }
|
|
897
|
|
898 protected ListenerObject changeValue(String ownvalue, ListenerObject lo,
|
|
899 String suggestType, String suggestAttributeName) {
|
|
900
|
|
901 return changeValue(ownvalue, lo, suggestType, suggestAttributeName,
|
|
902 null);
|
|
903 }
|
|
904
|
|
905 protected ListenerObject changeListener(ValueChangeEvent event,
|
|
906 ListenerObject lo, String suggestType, String suggestAttributeName,
|
|
907 String restrictingAttributeName, String restrictingAttributeValue) {
|
|
908 try {
|
|
909 if (event.getNewValue() == null) {
|
|
910 return lo;
|
|
911 }else if(StringUtils.isEmpty(event.getNewValue().toString()) && (event.getOldValue() == null || StringUtils.isEmpty(event.getOldValue().toString()))){
|
|
912 //if the old and new value are empty, then return
|
|
913 return lo;
|
|
914 }
|
|
915 if (event.getNewValue().equals(event.getOldValue())) {
|
|
916 return lo;
|
|
917 }
|
|
918
|
|
919 String ownvalue = (String) event.getNewValue();
|
|
920
|
|
921 if(StringUtils.isEmpty(ownvalue))
|
|
922 lo.statusImage.setStatus(StatusImage.STATUS_UNSET);
|
|
923 else
|
|
924 lo.statusImage.setStatus(StatusImage.STATUS_FALSE);
|
|
925
|
|
926 lo.entity = null;
|
|
927 // setze erst mal den Eigenwert auf das eingebene.
|
|
928 Attribute at = new Attribute();
|
|
929 at.setOwnValue(ownvalue);
|
|
930 lo.attribute = at;
|
|
931 for (SelectItem item : lo.suggestedItems) {
|
|
932 if (StringUtils.isNotEmpty(item.getLabel()) &&
|
|
933 item.getLabel().equals(ownvalue)) {
|
|
934 //System.out.println("item.getValue()= " + item.getValue());
|
|
935 lo.attribute = (Attribute) item.getValue();
|
|
936 Entity element = getWrapper().getEntityById(
|
|
937 lo.attribute.getSourceId());
|
|
938
|
|
939 if (element != null) {
|
|
940 if(element.isLightweight()){
|
|
941 element = getWrapper().getEntityByIdWithContent(element.getId());
|
|
942 }
|
|
943 lo.entity = element;
|
|
944 lo.statusImage.setStatus(StatusImage.STATUS_OK);
|
|
945 }
|
|
946 break;
|
|
947 }
|
|
948
|
|
949 }
|
|
950
|
|
951 if (restrictingAttributeName == null) {
|
|
952 lo.suggestedItems = this.updateSuggestedItems(event,
|
|
953 suggestType, suggestAttributeName);
|
|
954 } else {
|
|
955 lo.suggestedItems = this.updateSuggestedItems(suggestType,
|
|
956 suggestAttributeName, event.getNewValue().toString(),
|
|
957 restrictingAttributeName, restrictingAttributeValue);
|
|
958 }
|
|
959
|
|
960 } catch (Exception e) {
|
|
961 e.printStackTrace();
|
|
962 }
|
|
963 return lo;
|
|
964 }
|
|
965
|
|
966 protected void generateSecundaryOW(Entity entity, String user) throws Exception{
|
|
967 List<Entity> nodeList = new ArrayList<Entity>();
|
|
968
|
|
969 long start = System.currentTimeMillis();
|
|
970 if(entity.getObjectClass().equals(PLACE)){
|
|
971 this.generateOW4City(entity, nodeList, user);
|
|
972 long medium = System.currentTimeMillis();
|
|
973 System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
|
|
974 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
|
|
975 System.out.println("Save time: " + (System.currentTimeMillis() - medium));
|
|
976 }else if(entity.getObjectClass().equals(REPOSITORY)){
|
|
977 this.generateOW4Repository(entity, nodeList, new HashMap<String, String>(), user);
|
|
978 long medium = System.currentTimeMillis();
|
|
979 System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
|
|
980 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
|
|
981 System.out.println("Save time: " + (System.currentTimeMillis() - medium));
|
|
982 }else if(entity.getObjectClass().equals(COLLECTION)){
|
|
983 this.generateOW4Collection(entity, nodeList, new HashMap<String, String>(), user);
|
|
984 long medium = System.currentTimeMillis();
|
|
985 System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
|
|
986 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
|
|
987 System.out.println("Save time: " + (System.currentTimeMillis() - medium));
|
|
988 }else if(entity.getObjectClass().equals(CODEX)){
|
|
989 this.generateOW4Codex(entity, nodeList, new HashMap<String, String>(), user);
|
|
990 long medium = System.currentTimeMillis();
|
|
991 System.out.println("nodeList.size(): " + nodeList.size() + " time: " + (medium - start));
|
|
992 getWrapper().saveEntityListAsNodeWithoutContent(nodeList, user);
|
|
993 System.out.println("Save time: " + (System.currentTimeMillis() - medium));
|
|
994 }else if(entity.getObjectClass().equals(TEXT)){
|
|
995 generateOW4Text(entity, user);
|
|
996 long medium = System.currentTimeMillis();
|
|
997 System.out.println("Saving witnessList time: " + (medium - start));
|
|
998 }
|
|
999 //TODO PERSON and TEXT
|
|
1000 }
|
|
1001
|
|
1002 private void generateOW4City(Entity city, List<Entity> nodeList, String user){
|
|
1003 Map<String, String> map = new HashMap<String, String>();
|
|
1004 map.put(PLACE, city.getOwnValue());
|
|
1005
|
|
1006 List<Entity> repoList = getWrapper().getSourcesForTargetRelation(city, is_in, REPOSITORY, -1);
|
|
1007 for(Entity repo : repoList){
|
|
1008 this.generateOW4Repository(repo, nodeList, map, user);
|
|
1009 }
|
|
1010 }
|
|
1011
|
|
1012 private void generateOW4Repository(Entity repository, List<Entity> nodeList, Map<String, String> map, String user){
|
|
1013 if(map.size() == 0){
|
|
1014 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1);
|
|
1015 map.put(PLACE, ((placeList.size() > 0) ? placeList.get(0).getOwnValue() : ""));
|
|
1016 }
|
|
1017
|
|
1018 map.put(REPOSITORY, repository.getOwnValue());
|
|
1019 List<Entity> collectionList = getWrapper().getSourcesForTargetRelation(repository, is_part_of, COLLECTION, -1);
|
|
1020 for(Entity collection : collectionList){
|
|
1021 this.generateOW4Collection(collection, nodeList, map, user);
|
|
1022 }
|
|
1023 }
|
|
1024
|
|
1025 private void generateOW4Collection(Entity collection, List<Entity> nodeList, Map<String, String> map, String user){
|
|
1026 if(map.size() == 0){
|
|
1027 List<Entity> repoList = getWrapper().getTargetsForSourceRelation(collection, is_part_of, REPOSITORY, 1);
|
|
1028 map.put(REPOSITORY, (repoList.size() > 0) ? repoList.get(0).getOwnValue() : "");
|
|
1029 if(repoList.size() > 0){
|
|
1030 Entity repository = repoList.get(0);
|
|
1031 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1);
|
|
1032 map.put(PLACE, (placeList.size() > 0) ? placeList.get(0).getOwnValue() : "");
|
|
1033 }else{
|
|
1034 map.put(REPOSITORY, "");
|
|
1035 map.put(PLACE, "");
|
|
1036 }
|
|
1037 }
|
|
1038
|
|
1039 map.put(COLLECTION, collection.getOwnValue());
|
|
1040 List<Entity> list = getWrapper().getSourcesForTargetRelation(collection, is_part_of, CODEX, -1);
|
|
1041 for(Entity codex : list){
|
|
1042 //update ow codex
|
|
1043 Attribute att = getWrapper().getAttributeByName(codex.getId(), "identifier");
|
|
1044 if(att != null){
|
|
1045 codex.setOwnValue(collection.getOwnValue() + "_" + att.getOwnValue());
|
|
1046 nodeList.add(codex);
|
|
1047 }
|
|
1048 this.generateOW4Codex(codex, nodeList, map, user);
|
|
1049 }
|
|
1050 }
|
|
1051
|
|
1052 private void generateOW4Codex(Entity codex, List<Entity> nodeList, Map<String, String> map, String user){
|
|
1053 if(map.size() == 0){
|
|
1054 List<Entity> collList = getWrapper().getTargetsForSourceRelation(codex, is_part_of, COLLECTION, 1);
|
|
1055 map.put(COLLECTION, (collList.size() > 0 ) ? collList.get(0).getOwnValue() : "");
|
|
1056 if(collList.size() > 0){
|
|
1057 Entity collection = collList.get(0);
|
|
1058 List<Entity> repoList = getWrapper().getTargetsForSourceRelation(collection, is_part_of, REPOSITORY, 1);
|
|
1059 map.put(REPOSITORY, (repoList.size() > 0) ? repoList.get(0).getOwnValue() : "");
|
|
1060 if(repoList.size() > 0){
|
|
1061 Entity repository = repoList.get(0);
|
|
1062 List<Entity> placeList = getWrapper().getTargetsForSourceRelation(repository, is_in, PLACE, 1);
|
|
1063 map.put(PLACE, (placeList.size() > 0) ? placeList.get(0).getOwnValue() : "");
|
|
1064 }else{
|
|
1065 map.put(PLACE, "");
|
|
1066 }
|
|
1067 }else{
|
|
1068 map.put(COLLECTION, "");
|
|
1069 map.put(REPOSITORY, "");
|
|
1070 map.put(PLACE, "");
|
|
1071 }
|
|
1072 }
|
|
1073 List<Entity> list = getWrapper().getSourcesForTargetRelation(codex, is_part_of, WITNESS, -1);
|
|
1074 String placeText = (StringUtils.isNotEmpty(map.get(PLACE))) ? "_" + map.get(PLACE) : "";
|
|
1075 String repoText = (StringUtils.isNotEmpty(map.get(REPOSITORY))) ? "_" + map.get(REPOSITORY) : "";
|
|
1076 String codexText = (codex != null) ? "_" + codex.getOwnValue() : "";
|
|
1077
|
|
1078 for(Entity witness : list){
|
|
1079 List<Entity> textList = getWrapper().getTargetsForSourceRelation(witness, "is_exemplar_of", TEXT, -1);
|
|
1080 String textName = (textList.size() > 0) ? textList.get(0).getOwnValue() : "";
|
|
1081 witness.setOwnValue(textName + placeText + repoText + codexText);
|
|
1082 nodeList.add(witness);
|
|
1083 }
|
|
1084 }
|
|
1085
|
|
1086 private void generateOW4Text(Entity text, String user) throws Exception{
|
|
1087 List<Entity> witnessList = getWrapper().getSourcesForTargetRelation(text, "is_exemplar_of", WITNESS, -1);
|
|
1088 List<Entity> listToSave = new ArrayList<Entity>();
|
|
1089 for(Entity witness : witnessList){
|
|
1090 List<Entity> list = getWrapper().getTargetsForSourceRelation(witness, "is_part_of", "CODEX", 1);
|
|
1091 if(list.size() > 0){
|
|
1092 Entity codex = list.get(0);
|
|
1093 list = getWrapper().getTargetsForSourceRelation(codex, "is_part_of", "COLLECTION", 1);
|
|
1094 if(list.size() > 0){
|
|
1095 Entity collection = list.get(0);
|
|
1096 list = getWrapper().getTargetsForSourceRelation(collection, "is_part_of", "REPOSITORY", 1);
|
|
1097 if(list.size() > 0){
|
|
1098 Entity repository = list.get(0);
|
|
1099 list = getWrapper().getTargetsForSourceRelation(repository, "is_in", "PLACE", 1);
|
|
1100 if(list.size() > 0){
|
|
1101 Entity city = list.get(0);
|
|
1102 witness.setOwnValue(text.getOwnValue() + "_" + city.getOwnValue() + "_" + repository.getOwnValue() + "_" + codex.getOwnValue());
|
|
1103 listToSave.add(witness);
|
|
1104 }
|
|
1105 }
|
|
1106 }
|
|
1107 }
|
|
1108 getWrapper().saveEntityListAsNodeWithoutContent(listToSave, user);
|
|
1109 }
|
|
1110 }
|
|
1111
|
|
1112 protected SecurityService getSecurityService() {
|
|
1113 return getAppBean().getSecurityService();
|
|
1114 }
|
|
1115
|
|
1116 protected ListenerObject changeListener(ValueChangeEvent event,
|
|
1117 ListenerObject lo, String suggestType, String suggestAttributeName) {
|
|
1118
|
|
1119 return changeListener(event, lo, suggestType, suggestAttributeName,
|
|
1120 null, null);
|
|
1121 }
|
|
1122
|
|
1123 public String getCurrentId() {
|
|
1124 return currentId;
|
|
1125 }
|
|
1126
|
|
1127 public void setCurrentId(String currentId) {
|
|
1128 this.currentId = currentId;
|
|
1129 }
|
|
1130
|
|
1131 public String getCurrentIdMsg() {
|
|
1132 return currentIdMsg;
|
|
1133 }
|
|
1134
|
|
1135 public void setCurrentIdMsg(String currentIdMsg) {
|
|
1136 this.currentIdMsg = currentIdMsg;
|
|
1137 }
|
|
1138
|
|
1139 public SelectedESciDocItems getSelectedItems() {
|
|
1140 return selectedItems;
|
|
1141 }
|
|
1142
|
|
1143 public void setSelectedItems(SelectedESciDocItems selectedItems) {
|
|
1144 this.selectedItems = selectedItems;
|
|
1145 }
|
|
1146
|
|
1147 public String getDefObjectClass() {
|
|
1148 return defObjectClass;
|
|
1149 }
|
|
1150
|
|
1151 public void setDefObjectClass(String defObjectClass) {
|
|
1152 this.defObjectClass = defObjectClass;
|
|
1153 }
|
|
1154 }
|