diff 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
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java	Thu Oct 06 19:03:56 2016 +0200
+++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java	Mon Oct 10 19:58:35 2016 +0200
@@ -4,18 +4,21 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.faces.event.ActionEvent;
 import javax.faces.model.SelectItem;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+import org.mpi.openmind.repository.bo.Attribute;
 import org.mpi.openmind.repository.bo.Entity;
 import org.mpi.openmind.repository.bo.Node;
 import org.mpi.openmind.repository.bo.Relation;
 
+import de.mpiwg.itgroup.ismi.auxObjects.ListenerObject;
 import de.mpiwg.itgroup.ismi.utils.SelectableObject;
 
 
-public class CurrentCityBean  extends CodexEditorTemplate  implements Serializable{
+public class CurrentCityBean  extends CodexEditorTemplate  implements Serializable {
 	private static final long serialVersionUID = -8609055286714729597L;
 	
 	private static Logger logger = Logger.getLogger(CurrentCityBean.class);
@@ -41,7 +44,13 @@
 		
 		//setDefinition(getDefinition(PLACE));
 		setDefObjectClass(PLACE);
+		// old types
 		String[] types = new String[]{"city","institution", "city_part", "region"};
+		// get new types from definition
+		Attribute typeAtt = getWrapper().getDefAttributeByOwnValue(PLACE, "type");
+		if (typeAtt != null) {
+		    types = typeAtt.getPossibleValuesList().toArray(types);
+		}
 		fillList(suggestedTypes, types);
 		
 		registerChecker(getCountryLo(), "Country not valid!");
@@ -127,11 +136,13 @@
 				Relation isPartOf = new Relation(place, this.entity, is_part_of);
 			}
 			
+			/*
 			this.entity.removeAllTargetRelationsByName(lived_in);
 			for(SelectableObject<Entity> so : this.peopleLivedIn){
 				Entity person = getWrapper().getEntityByIdWithContent(so.getObj().getId());
 				Relation livedIn = new Relation(person, this.entity, lived_in);
 			}
+			*/
 			
 			//REFERENCE -> is_reference_of -> THIS
 			//this.entity = this.prepareReferencesToSave(this.entity);
@@ -139,8 +150,8 @@
 			
 			//String lastAction = "";
 			if(this.isSelectedSaveAsNew()){
-				this.entity.removeAllTargetRelations(is_in, REPOSITORY);
-				this.entity = getWrapper().saveEntityAsNew(this.entity, getSessionUser().getEmail());
+				//this.entity.removeAllTargetRelations(is_in, REPOSITORY);
+				//this.entity = getWrapper().saveEntityAsNew(this.entity, getSessionUser().getEmail());
 				this.setSelectedSaveAsNew(false);
 				//lastAction = "Save place as new entity";
 			}else{
@@ -182,6 +193,14 @@
 		}
 	}
 	
+    public void removeThisCountryAction(ActionEvent event) {
+        if (this.getCountryLo().entity != null) {
+            this.setCountryLo(new ListenerObject());
+        }
+    }	    
+
+	
+	
 	public String saveAsNewEntity(){
 		this.setSelectedSaveAsNew(true);
 		return save();