Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/event/beans/AbstractEvent.java @ 1:2e911857a759
(none)
author | jurzua |
---|---|
date | Wed, 29 Oct 2014 14:00:28 +0000 |
parents | |
children | 4ec8d4cfad26 |
comparison
equal
deleted
inserted
replaced
0:74df02964906 | 1:2e911857a759 |
---|---|
1 package de.mpiwg.itgroup.ismi.event.beans; | |
2 | |
3 import java.io.Serializable; | |
4 import java.util.ArrayList; | |
5 import java.util.List; | |
6 | |
7 import javax.faces.event.ActionEvent; | |
8 import javax.faces.event.AjaxBehaviorEvent; | |
9 import javax.faces.event.ValueChangeEvent; | |
10 import javax.faces.model.SelectItem; | |
11 | |
12 import org.apache.log4j.Logger; | |
13 import org.mpi.openmind.repository.bo.Entity; | |
14 | |
15 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | |
16 import de.mpiwg.itgroup.ismi.auxObjects.lo.EventTextLO; | |
17 import de.mpiwg.itgroup.ismi.entry.beans.AbstractISMIBean; | |
18 import de.mpiwg.itgroup.ismi.entry.beans.SessionBean; | |
19 import de.mpiwg.itgroup.ismi.util.guiComponents.Calendar; | |
20 | |
21 public class AbstractEvent extends AbstractISMIBean implements Serializable{ | |
22 | |
23 | |
24 /** | |
25 * | |
26 */ | |
27 private static final long serialVersionUID = 6080984991162765794L; | |
28 | |
29 protected static Logger logger = Logger.getLogger(AbstractEvent.class); | |
30 | |
31 public static String was_studied_by = "was_studied_by"; | |
32 public static String was_studied_in = "was_studied_in"; | |
33 public static String is_a_study_of = "is_a_study_of"; | |
34 public static String was_advised_by = "was_advised_by"; | |
35 public static String was_copied_for = "was_copied_for"; | |
36 public static String has_person_copying_text = "has_person_copying_text"; | |
37 public static String was_copied_in = "was_copied_in"; | |
38 public static String is_a_copy_of = "is_a_copy_of"; | |
39 public static String is_a_transfer_of = "is_a_transfer_of"; | |
40 public static String was_transferred_from = "was_transferred_from"; | |
41 public static String was_transferred_to = "was_transferred_to"; | |
42 public static String has_original_location = "has_original_location"; | |
43 public static String has_new_location = "has_new_location"; | |
44 public static String was_transferred_in = "was_transferred_in"; | |
45 | |
46 protected EventTextLO textLo = new EventTextLO(TEXT, full_title_translit, this); | |
47 protected Entity witness; | |
48 protected Long witnessId; | |
49 protected List<SelectItem> witnessList; | |
50 protected Calendar date; | |
51 | |
52 protected ListenerObject placeLo = new ListenerObject(PLACE, name); | |
53 | |
54 public AbstractEvent(Entity event){ | |
55 this.setEvent(event); | |
56 } | |
57 | |
58 protected Entity event; | |
59 /* | |
60 public void listenerChangeText(ValueChangeEvent event) { | |
61 this.text = changeListener(event, text, TEXT, full_title_translit); | |
62 this.witness = null; | |
63 if(text.entity != null && text.entity.isPersistent()){ | |
64 refreshWitnesses(text.entity); | |
65 }else{ | |
66 this.witnessList = new ArrayList<SelectItem>(); | |
67 } | |
68 }*/ | |
69 | |
70 public void refreshWitnesses(Entity text){ | |
71 this.witnessList = new ArrayList<SelectItem>(); | |
72 List<Entity> list = getWrapper().getSourcesForTargetRelation(text, is_exemplar_of, WITNESS, -1); | |
73 System.out.println("Found " + list.size() + " witnesses"); | |
74 if(list.isEmpty()){ | |
75 witnessList.add(new SelectItem(null, "This text has no witness associated")); | |
76 }else{ | |
77 witnessList.add(new SelectItem(null, "-- choose witness --")); | |
78 for(Entity ent : list){ | |
79 witnessList.add(new SelectItem(ent.getId(), ent.getOwnValue() + " ID: " + ent.getId())); | |
80 } | |
81 } | |
82 } | |
83 | |
84 public void listenerChangeWitness(ValueChangeEvent event) { | |
85 if(event.getNewValue() != null){ | |
86 try{ | |
87 Long id = (Long)event.getNewValue(); | |
88 this.witness = getWrapper().getEntityById(id); | |
89 }catch (Exception e) { | |
90 e.printStackTrace(); | |
91 } | |
92 }else{ | |
93 this.witness = null; | |
94 } | |
95 } | |
96 | |
97 protected Entity getTextOfWitness(Entity witness){ | |
98 Entity text = null; | |
99 List<Entity> list = getWrapper().getTargetsForSourceRelation(witness, is_exemplar_of, TEXT, 1); | |
100 if(list.size() > 0){ | |
101 text = list.get(0); | |
102 } | |
103 return text; | |
104 } | |
105 /* | |
106 public void listenerChangePlace(ValueChangeEvent event) { | |
107 this.place = changeListener(event, place, PLACE, name); | |
108 }*/ | |
109 | |
110 public Entity getEvent() { | |
111 return event; | |
112 } | |
113 | |
114 public void setEvent(Entity event) { | |
115 this.reset(); | |
116 this.event = event; | |
117 } | |
118 | |
119 public String getSessionUserName() { | |
120 SessionBean bean = getSessionBean(); | |
121 if(bean != null){ | |
122 return bean.getUsername(); | |
123 } | |
124 return null; | |
125 } | |
126 | |
127 public EventTextLO getTextLo() { | |
128 return textLo; | |
129 } | |
130 | |
131 public void setTextLo(EventTextLO textLo) { | |
132 this.textLo = textLo; | |
133 } | |
134 | |
135 public Entity getWitness() { | |
136 return witness; | |
137 } | |
138 | |
139 public void setWitness(Entity witness) { | |
140 this.witness = witness; | |
141 } | |
142 | |
143 public Calendar getDate() { | |
144 return date; | |
145 } | |
146 | |
147 public void setDate(Calendar date) { | |
148 this.date = date; | |
149 } | |
150 | |
151 public List<SelectItem> getWitnessList() { | |
152 return witnessList; | |
153 } | |
154 | |
155 public void setWitnessList(List<SelectItem> witnessList) { | |
156 this.witnessList = witnessList; | |
157 } | |
158 | |
159 public Long getWitnessId() { | |
160 return witnessId; | |
161 } | |
162 | |
163 public void setWitnessId(Long witnessId) { | |
164 this.witnessId = witnessId; | |
165 } | |
166 | |
167 | |
168 | |
169 public ListenerObject getPlaceLo() { | |
170 return placeLo; | |
171 } | |
172 | |
173 public void setPlaceLo(ListenerObject placeLo) { | |
174 this.placeLo = placeLo; | |
175 } | |
176 | |
177 public void test(AjaxBehaviorEvent e){ | |
178 System.out.println("test(ActionEvent e)"); | |
179 | |
180 } | |
181 | |
182 @Override | |
183 public String save(){ | |
184 logger.info("*************** START Saving "+ this.defObjectClass + " [ID=" + event.getId() +", user"+ getUserName() +"] *********************"); | |
185 this.start = System.currentTimeMillis(); | |
186 return null; | |
187 } | |
188 | |
189 @Override | |
190 protected void saveEnd(){ | |
191 logger.info("*************** END Saving "+ this.defObjectClass + " [ID=" + event.getId() +", user"+ getUserName() +"] *********************\n"); | |
192 } | |
193 | |
194 @Override | |
195 protected void printSuccessSavingEntity(){ | |
196 this.addGeneralMsg("The entity was successfully saved!"); | |
197 this.addGeneralMsg("Its ID is " + this.event.getId()); | |
198 } | |
199 } |