Mercurial > hg > ismi-richfaces
annotate src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java @ 116:ca36b24a22f7
add misattribution to displayAuthor. small cleanups.
author | casties |
---|---|
date | Thu, 22 Dec 2016 16:56:17 +0100 |
parents | d172201d24ad |
children | aef031e76278 |
rev | line source |
---|---|
1 | 1 package de.mpiwg.itgroup.ismi.util.guiComponents; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import javax.faces.event.ActionEvent; | |
7 | |
8 import org.mpi.openmind.repository.bo.Entity; | |
9 | |
10 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | |
11 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | |
12 import de.mpiwg.itgroup.ismi.utils.SelectableObject; | |
13 | |
116
ca36b24a22f7
add misattribution to displayAuthor. small cleanups.
casties
parents:
91
diff
changeset
|
14 public class MisattributionTable extends AbstractISMIBean { |
1 | 15 private static final long serialVersionUID = -2756216426560705499L; |
16 | |
91 | 17 private List<SelectableObject<Misattribution>> list = new ArrayList<SelectableObject<Misattribution>>(); |
1 | 18 |
91 | 19 private Misattribution misatt; |
1 | 20 |
21 private ListenerObject lo = new ListenerObject(PERSON, "name_translit"); | |
22 //private String attName; | |
23 //private String oc; | |
24 | |
91 | 25 public MisattributionTable(){ |
1 | 26 /* |
27 this.attName = attName; | |
28 this.oc = oc; | |
29 */ | |
30 } | |
31 | |
32 public void listenerRemove(ActionEvent event){ | |
91 | 33 List<SelectableObject<Misattribution>> toDelete = new ArrayList<SelectableObject<Misattribution>>(); |
1 | 34 |
91 | 35 for(SelectableObject<Misattribution> so : this.list){ |
1 | 36 if(so.isSelected()){ |
37 toDelete.add(so); | |
38 } | |
39 } | |
91 | 40 for(SelectableObject<Misattribution> so : toDelete){ |
1 | 41 this.list.remove(so); |
42 } | |
43 } | |
44 | |
45 public void listenerEditRef(ActionEvent event){ | |
91 | 46 SelectableObject<Misattribution> so = |
47 (SelectableObject<Misattribution>)getRequestBean("item"); | |
1 | 48 if(so != null){ |
49 this.misatt = so.getObj(); | |
50 } | |
51 } | |
52 | |
53 public void listenerSaveRef(ActionEvent event){ | |
54 this.misatt = null; | |
55 } | |
56 | |
57 public void listenerCancel(ActionEvent event){ | |
58 //@TODO | |
59 } | |
60 | |
61 public void listenerCreate(ActionEvent event){ | |
62 if(this.lo.entity != null & this.lo.entity.isPersistent()){ | |
63 this.create(this.lo.entity); | |
64 } | |
65 } | |
66 | |
67 public void load(Entity misattEntity){ | |
68 if(!containsEntity(misattEntity)){ | |
69 //TODO sort | |
70 //Collections.sort(this.misattList); | |
71 try { | |
91 | 72 this.list.add(new SelectableObject<Misattribution>(Misattribution.load(misattEntity, getWrapper(), getUserName()))); |
1 | 73 } catch (Exception e) { |
74 addErrorMsg(e.getMessage()); | |
75 e.printStackTrace(); | |
76 } | |
77 }else{ | |
78 addGeneralMsg("This entity has been already inserted!"); | |
79 } | |
80 } | |
81 | |
82 public void create(Entity person){ | |
83 try { | |
91 | 84 this.list.add(new SelectableObject<Misattribution>(Misattribution.create(person, getWrapper(), getUserName()))); |
1 | 85 } catch (Exception e) { |
86 addErrorMsg(e.getMessage()); | |
87 e.printStackTrace(); | |
88 } | |
89 } | |
90 | |
91 private boolean containsEntity(Entity ent){ | |
91 | 92 for(SelectableObject<Misattribution> so : this.list){ |
1 | 93 if(so.getObj().getPerson() != null && so.getObj().getPerson().getId().equals(ent.getId())){ |
94 return true; | |
95 } | |
96 } | |
97 return false; | |
98 } | |
99 | |
100 /* | |
101 public void listenerChanged(ValueChangeEvent event) { | |
102 this.lo = changeListener(event, lo, this.oc, this.attName); | |
103 if(lo.entity != null && lo.entity.isPersistent()){ | |
104 lo.statusImage.setStatus(StatusImage.STATUS_OK); | |
105 }else{ | |
106 lo.statusImage.setStatus(StatusImage.STATUS_UNSET); | |
107 } | |
108 } | |
109 */ | |
110 | |
111 | |
91 | 112 /** |
113 * Save all misattributions. | |
114 * | |
115 * @param text | |
116 * @return | |
117 * @throws Exception | |
118 */ | |
1 | 119 public Entity saveMisattributions(Entity text) throws Exception{ |
91 | 120 for(Misattribution misatt : this.getMisattList()){ |
1 | 121 text = misatt.saveAndGetMisattribution(text); |
122 } | |
123 return text; | |
124 } | |
125 | |
126 | |
116
ca36b24a22f7
add misattribution to displayAuthor. small cleanups.
casties
parents:
91
diff
changeset
|
127 private List<Misattribution> getMisattList() { |
91 | 128 List<Misattribution> list = new ArrayList<Misattribution>(); |
129 for(SelectableObject<Misattribution> so : this.list){ | |
1 | 130 list.add(so.getObj()); |
131 } | |
132 return list; | |
133 } | |
134 | |
91 | 135 public List<SelectableObject<Misattribution>> getList() { |
1 | 136 return list; |
137 } | |
138 | |
91 | 139 public void setList(List<SelectableObject<Misattribution>> list) { |
1 | 140 this.list = list; |
141 } | |
142 | |
91 | 143 public Misattribution getMisatt() { |
1 | 144 return misatt; |
145 } | |
146 | |
91 | 147 public void setMisatt(Misattribution misatt) { |
1 | 148 this.misatt = misatt; |
149 } | |
150 | |
151 public ListenerObject getLo() { | |
152 return lo; | |
153 } | |
154 | |
155 public void setLo(ListenerObject lo) { | |
156 this.lo = lo; | |
157 } | |
158 } |