Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/MisattributionTable.java @ 91:d172201d24ad
more comments and refactorings.
author | casties |
---|---|
date | Wed, 12 Oct 2016 20:50:30 +0200 |
parents | src/main/java/de/mpiwg/itgroup/ismi/util/guiComponents/EndNoteMisattributionTable.java@2e911857a759 |
children | ca36b24a22f7 |
comparison
equal
deleted
inserted
replaced
90:72b877076f43 | 91:d172201d24ad |
---|---|
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 | |
14 public class MisattributionTable extends AbstractISMIBean{ | |
15 private static final long serialVersionUID = -2756216426560705499L; | |
16 | |
17 private List<SelectableObject<Misattribution>> list = new ArrayList<SelectableObject<Misattribution>>(); | |
18 | |
19 private Misattribution misatt; | |
20 | |
21 private ListenerObject lo = new ListenerObject(PERSON, "name_translit"); | |
22 //private String attName; | |
23 //private String oc; | |
24 | |
25 public MisattributionTable(){ | |
26 /* | |
27 this.attName = attName; | |
28 this.oc = oc; | |
29 */ | |
30 } | |
31 | |
32 public void listenerRemove(ActionEvent event){ | |
33 List<SelectableObject<Misattribution>> toDelete = new ArrayList<SelectableObject<Misattribution>>(); | |
34 | |
35 for(SelectableObject<Misattribution> so : this.list){ | |
36 if(so.isSelected()){ | |
37 toDelete.add(so); | |
38 } | |
39 } | |
40 for(SelectableObject<Misattribution> so : toDelete){ | |
41 this.list.remove(so); | |
42 } | |
43 } | |
44 | |
45 public void listenerEditRef(ActionEvent event){ | |
46 SelectableObject<Misattribution> so = | |
47 (SelectableObject<Misattribution>)getRequestBean("item"); | |
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 { | |
72 this.list.add(new SelectableObject<Misattribution>(Misattribution.load(misattEntity, getWrapper(), getUserName()))); | |
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 { | |
84 this.list.add(new SelectableObject<Misattribution>(Misattribution.create(person, getWrapper(), getUserName()))); | |
85 } catch (Exception e) { | |
86 addErrorMsg(e.getMessage()); | |
87 e.printStackTrace(); | |
88 } | |
89 } | |
90 | |
91 private boolean containsEntity(Entity ent){ | |
92 for(SelectableObject<Misattribution> so : this.list){ | |
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 | |
112 /** | |
113 * Save all misattributions. | |
114 * | |
115 * @param text | |
116 * @return | |
117 * @throws Exception | |
118 */ | |
119 public Entity saveMisattributions(Entity text) throws Exception{ | |
120 for(Misattribution misatt : this.getMisattList()){ | |
121 text = misatt.saveAndGetMisattribution(text); | |
122 } | |
123 return text; | |
124 } | |
125 | |
126 | |
127 private List<Misattribution> getMisattList(){ | |
128 List<Misattribution> list = new ArrayList<Misattribution>(); | |
129 for(SelectableObject<Misattribution> so : this.list){ | |
130 list.add(so.getObj()); | |
131 } | |
132 return list; | |
133 } | |
134 | |
135 public List<SelectableObject<Misattribution>> getList() { | |
136 return list; | |
137 } | |
138 | |
139 public void setList(List<SelectableObject<Misattribution>> list) { | |
140 this.list = list; | |
141 } | |
142 | |
143 public Misattribution getMisatt() { | |
144 return misatt; | |
145 } | |
146 | |
147 public void setMisatt(Misattribution misatt) { | |
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 } |