Mercurial > hg > ismi-richfaces
comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java @ 89:a142159f09c1
working on better place editing.
author | casties |
---|---|
date | Mon, 10 Oct 2016 19:58:35 +0200 |
parents | 2e911857a759 |
children | d172201d24ad |
comparison
equal
deleted
inserted
replaced
88:8d93f3a0108f | 89:a142159f09c1 |
---|---|
2 | 2 |
3 import java.io.Serializable; | 3 import java.io.Serializable; |
4 import java.util.ArrayList; | 4 import java.util.ArrayList; |
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
7 import javax.faces.event.ActionEvent; | |
7 import javax.faces.model.SelectItem; | 8 import javax.faces.model.SelectItem; |
8 | 9 |
9 import org.apache.commons.lang.StringUtils; | 10 import org.apache.commons.lang.StringUtils; |
10 import org.apache.log4j.Logger; | 11 import org.apache.log4j.Logger; |
12 import org.mpi.openmind.repository.bo.Attribute; | |
11 import org.mpi.openmind.repository.bo.Entity; | 13 import org.mpi.openmind.repository.bo.Entity; |
12 import org.mpi.openmind.repository.bo.Node; | 14 import org.mpi.openmind.repository.bo.Node; |
13 import org.mpi.openmind.repository.bo.Relation; | 15 import org.mpi.openmind.repository.bo.Relation; |
14 | 16 |
17 import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject; | |
15 import de.mpiwg.itgroup.ismi.utils.SelectableObject; | 18 import de.mpiwg.itgroup.ismi.utils.SelectableObject; |
16 | 19 |
17 | 20 |
18 public class CurrentCityBean extends CodexEditorTemplate implements Serializable{ | 21 public class CurrentCityBean extends CodexEditorTemplate implements Serializable { |
19 private static final long serialVersionUID = -8609055286714729597L; | 22 private static final long serialVersionUID = -8609055286714729597L; |
20 | 23 |
21 private static Logger logger = Logger.getLogger(CurrentCityBean.class); | 24 private static Logger logger = Logger.getLogger(CurrentCityBean.class); |
22 | 25 |
23 private List<SelectItem> suggestedTypes; | 26 private List<SelectItem> suggestedTypes; |
39 this.placesPartOfThis = new ArrayList<SelectableObject<Entity>>(); | 42 this.placesPartOfThis = new ArrayList<SelectableObject<Entity>>(); |
40 this.peopleLivedIn = new ArrayList<SelectableObject<Entity>>(); | 43 this.peopleLivedIn = new ArrayList<SelectableObject<Entity>>(); |
41 | 44 |
42 //setDefinition(getDefinition(PLACE)); | 45 //setDefinition(getDefinition(PLACE)); |
43 setDefObjectClass(PLACE); | 46 setDefObjectClass(PLACE); |
47 // old types | |
44 String[] types = new String[]{"city","institution", "city_part", "region"}; | 48 String[] types = new String[]{"city","institution", "city_part", "region"}; |
49 // get new types from definition | |
50 Attribute typeAtt = getWrapper().getDefAttributeByOwnValue(PLACE, "type"); | |
51 if (typeAtt != null) { | |
52 types = typeAtt.getPossibleValuesList().toArray(types); | |
53 } | |
45 fillList(suggestedTypes, types); | 54 fillList(suggestedTypes, types); |
46 | 55 |
47 registerChecker(getCountryLo(), "Country not valid!"); | 56 registerChecker(getCountryLo(), "Country not valid!"); |
48 } | 57 } |
49 | 58 |
125 for(SelectableObject<Entity> so : this.placesPartOfThis){ | 134 for(SelectableObject<Entity> so : this.placesPartOfThis){ |
126 Entity place = getWrapper().getEntityByIdWithContent(so.getObj().getId()); | 135 Entity place = getWrapper().getEntityByIdWithContent(so.getObj().getId()); |
127 Relation isPartOf = new Relation(place, this.entity, is_part_of); | 136 Relation isPartOf = new Relation(place, this.entity, is_part_of); |
128 } | 137 } |
129 | 138 |
139 /* | |
130 this.entity.removeAllTargetRelationsByName(lived_in); | 140 this.entity.removeAllTargetRelationsByName(lived_in); |
131 for(SelectableObject<Entity> so : this.peopleLivedIn){ | 141 for(SelectableObject<Entity> so : this.peopleLivedIn){ |
132 Entity person = getWrapper().getEntityByIdWithContent(so.getObj().getId()); | 142 Entity person = getWrapper().getEntityByIdWithContent(so.getObj().getId()); |
133 Relation livedIn = new Relation(person, this.entity, lived_in); | 143 Relation livedIn = new Relation(person, this.entity, lived_in); |
134 } | 144 } |
145 */ | |
135 | 146 |
136 //REFERENCE -> is_reference_of -> THIS | 147 //REFERENCE -> is_reference_of -> THIS |
137 //this.entity = this.prepareReferencesToSave(this.entity); | 148 //this.entity = this.prepareReferencesToSave(this.entity); |
138 this.prepareEndNoteRefs2Save(); | 149 this.prepareEndNoteRefs2Save(); |
139 | 150 |
140 //String lastAction = ""; | 151 //String lastAction = ""; |
141 if(this.isSelectedSaveAsNew()){ | 152 if(this.isSelectedSaveAsNew()){ |
142 this.entity.removeAllTargetRelations(is_in, REPOSITORY); | 153 //this.entity.removeAllTargetRelations(is_in, REPOSITORY); |
143 this.entity = getWrapper().saveEntityAsNew(this.entity, getSessionUser().getEmail()); | 154 //this.entity = getWrapper().saveEntityAsNew(this.entity, getSessionUser().getEmail()); |
144 this.setSelectedSaveAsNew(false); | 155 this.setSelectedSaveAsNew(false); |
145 //lastAction = "Save place as new entity"; | 156 //lastAction = "Save place as new entity"; |
146 }else{ | 157 }else{ |
147 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail()); | 158 this.entity = getWrapper().saveEntity(this.entity, getSessionUser().getEmail()); |
148 //lastAction = "Save place"; | 159 //lastAction = "Save place"; |
180 this.peopleLivedIn.remove(so); | 191 this.peopleLivedIn.remove(so); |
181 } | 192 } |
182 } | 193 } |
183 } | 194 } |
184 | 195 |
196 public void removeThisCountryAction(ActionEvent event) { | |
197 if (this.getCountryLo().entity != null) { | |
198 this.setCountryLo(new ListenerObject()); | |
199 } | |
200 } | |
201 | |
202 | |
203 | |
185 public String saveAsNewEntity(){ | 204 public String saveAsNewEntity(){ |
186 this.setSelectedSaveAsNew(true); | 205 this.setSelectedSaveAsNew(true); |
187 return save(); | 206 return save(); |
188 } | 207 } |
189 public List<SelectItem> getSuggestedTypes() { | 208 public List<SelectItem> getSuggestedTypes() { |