comparison src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java @ 105:e27603a39e70

small cleanups.
author casties
date Fri, 04 Nov 2016 18:10:40 +0100
parents 12af756065b5
children 71efad4fe975
comparison
equal deleted inserted replaced
104:42d0169904f3 105:e27603a39e70
54 54
55 registerChecker(getCountryLo(), "Country not valid!"); 55 registerChecker(getCountryLo(), "Country not valid!");
56 } 56 }
57 57
58 @Override 58 @Override
59 public void setEntity(Entity city) { 59 public void setEntity(Entity city) {
60 this.reset(); 60 this.reset();
61 this.entity = city; 61 this.entity = city;
62 62
63 if(this.entity.isPersistent()){ 63 if (this.entity.isPersistent()) {
64 if(city.isLightweight()){ 64 // load attributes and relations of Entity
65 this.entity = getWrapper().getEntityContent(this.entity); 65 if (city.isLightweight()) {
66 } 66 this.entity = getWrapper().getEntityContent(this.entity);
67 67 }
68 this.loadAttributes(this.entity); 68 // load entity attributes into bean
69 69 this.loadAttributes(this.entity);
70 List<Entity> list = getWrapper().getTargetsForSourceRelation(city, is_part_of, PLACE, -1); 70
71 if(list.size() > 0){ 71 /*
72 this.setCountry(list.get(0)); 72 * create list of places this place is part_of
73 if(list.size() > 1){ 73 */
74 addErrorMsg("Ontological inconsistency. This place 'is part of' " + list.size() + " other places."); 74 List<Entity> list = getWrapper().getTargetsForSourceRelation(city, is_part_of, PLACE, -1);
75 addErrorMsg("List:"); 75 if (list.size() > 0) {
76 for(Entity place : list){ 76 this.setCountry(list.get(0));
77 addErrorMsg(place.getOwnValue() + " [" + place.getId() + "]"); 77 // part_of more than one place
78 } 78 if (list.size() > 1) {
79 } 79 addErrorMsg("Ontological inconsistency. This place 'is part of' " + list.size() + " other places.");
80 } 80 addErrorMsg("List:");
81 81 for (Entity place : list) {
82 for(Entity place : getWrapper().getSourcesForTargetRelation(city, is_part_of, PLACE, -1)){ 82 addErrorMsg(place.getOwnValue() + " [" + place.getId() + "]");
83 String label = place.getOwnValue() + " [" + place.getId() + "]"; 83 }
84 this.placesPartOfThis.add(new SelectableObject<Entity>(place, label)); 84 }
85 } 85 }
86 86
87 for(Entity person : getWrapper().getSourcesForTargetRelation(city, lived_in, PERSON, -1)){ 87 /*
88 String label = person.getOwnValue() + " [" + person.getId() + "]"; 88 * create list of places that are part of this place
89 this.peopleLivedIn.add(new SelectableObject<Entity>(person, label)); 89 */
90 } 90 for (Entity place : getWrapper().getSourcesForTargetRelation(city, is_part_of, PLACE, -1)) {
91 91 String label = place.getOwnValue() + " [" + place.getId() + "]";
92 //this.loadReferences(this.entity); 92 this.placesPartOfThis.add(new SelectableObject<Entity>(place, label));
93 this.loadEndNoteRefs(); 93 }
94 94
95 this.setCurrentId(this.entity.getId().toString()); 95 // load references
96 this.checkConsistencyFromCountryToCodex(); 96 this.loadEndNoteRefs();
97 } 97
98 } 98 this.setCurrentId(this.entity.getId().toString());
99 // check consistency and set checkmark(s)
100 this.checkConsistencyFromCountryToCodex();
101 }
102 }
99 103
100 @Override 104 @Override
101 public String save(){ 105 public String save(){
102 super.save(); 106 super.save();
103 try { 107 try {
118 this.renderUnityCheckerDialog(); 122 this.renderUnityCheckerDialog();
119 this.setSelectedSaveAsNew(false); 123 this.setSelectedSaveAsNew(false);
120 return "SAVE_ERROR"; 124 return "SAVE_ERROR";
121 } 125 }
122 }else{ 126 }else{
123 this.addErrorMsg("Ths entity has not been saved, because its name was empty."); 127 this.addErrorMsg("This place has not been saved, because its name was empty.");
124 this.addErrorMsg("You must enter a name."); 128 this.addErrorMsg("You have to enter a name.");
125 return "SAVE_ERROR"; 129 return "SAVE_ERROR";
126 } 130 }
127 131
128 //this.entity.removeSourceRelation("is_part_of", this.getCountryLo().entity);
129 //replaceSourceRelation(this.entity, this.getCountryLo().entity, "PLACE", "is_part_of");
130 this.entity.replaceSourceRelation(this.getCountryLo().entity, PLACE, is_part_of); 132 this.entity.replaceSourceRelation(this.getCountryLo().entity, PLACE, is_part_of);
131 133
132 this.entity.removeAllTargetRelationsByName(is_part_of); 134 this.entity.removeAllTargetRelationsByName(is_part_of);
133 for(SelectableObject<Entity> so : this.placesPartOfThis){ 135 for(SelectableObject<Entity> so : this.placesPartOfThis){
134 Entity place = getWrapper().getEntityByIdWithContent(so.getObj().getId()); 136 Entity place = getWrapper().getEntityByIdWithContent(so.getObj().getId());
135 Relation isPartOf = new Relation(place, this.entity, is_part_of); 137 new Relation(place, this.entity, is_part_of);
136 } 138 }
137 139
138 /* 140 /*
139 this.entity.removeAllTargetRelationsByName(lived_in); 141 this.entity.removeAllTargetRelationsByName(lived_in);
140 for(SelectableObject<Entity> so : this.peopleLivedIn){ 142 for(SelectableObject<Entity> so : this.peopleLivedIn){
159 } 161 }
160 //setActionInfo(lastAction); 162 //setActionInfo(lastAction);
161 this.updateRelatedOW(this.entity, getSessionUser().getEmail()); 163 this.updateRelatedOW(this.entity, getSessionUser().getEmail());
162 this.setCurrentId(this.entity.getId().toString()); 164 this.setCurrentId(this.entity.getId().toString());
163 165
164 logger.info("Entity saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity); 166 logger.debug("Place saved - Time = " + (System.currentTimeMillis() - start) + ", " + entity);
165 this.printSuccessSavingEntity(); 167 this.printSuccessSavingEntity();
166 168
167 this.setSelectedSaveAsNew(false); 169 this.setSelectedSaveAsNew(false);
168 170
169 } catch (Exception e) { 171 } catch (Exception e) {
170 logger.error(e.getMessage(), e); 172 logger.error(e.getMessage(), e);
171 e.printStackTrace();
172 this.printInternalError(e); 173 this.printInternalError(e);
173 } 174 }
174 saveEnd(); 175 saveEnd();
175 176
176 return PAGE_EDITOR; 177 return PAGE_EDITOR;