Mercurial > hg > ismi-richfaces
changeset 89:a142159f09c1
working on better place editing.
author | casties |
---|---|
date | Mon, 10 Oct 2016 19:58:35 +0200 |
parents | 8d93f3a0108f |
children | 72b877076f43 |
files | src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java src/main/webapp/entry/place.xhtml |
diffstat | 2 files changed, 39 insertions(+), 47 deletions(-) [+] |
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();
--- a/src/main/webapp/entry/place.xhtml Thu Oct 06 19:03:56 2016 +0200 +++ b/src/main/webapp/entry/place.xhtml Mon Oct 10 19:58:35 2016 +0200 @@ -11,10 +11,10 @@ <ui:composition> <h:panelGrid> - <h:outputText value="City - #{CurrentCity.entity.ownValue}" + <h:outputText value="Place - #{CurrentCity.entity.ownValue}" rendered="#{!empty CurrentCity.entity.ownValue}" styleClass="titlePanel"/> - <h:outputText value="City" + <h:outputText value="Place" rendered="#{empty CurrentCity.entity.ownValue}" styleClass="titlePanel"/> </h:panelGrid> @@ -22,26 +22,29 @@ <h:panelGrid columns="3" styleClass="createPanel" columnClasses="createPanelFirstColumn" id="placePanel"> - <h:outputText value="Country/is part of " /> - <ismi:autocomplete lo="#{CurrentCity.countryLo}" /> - <h:panelGrid> - <h:commandButton alt="edit" image="#{ApplicationBean1.editImage}" - rendered="#{!empty CurrentCity.countryLo.entity.id}" - actionListener="#{CurrentCity.editThisCountryAction}" /> - </h:panelGrid> - - <h:outputText id="name" value="City/Place Name" /> + <h:outputText id="name" value="Name" /> <h:inputText size="100" value="#{CurrentCity.attributes['name']}" /> <h:outputText /> - <h:outputText value="Type (choose region for country)" /> + <h:outputText value="Type" /> <h:selectOneListbox size="4" partialSubmit="true" value="#{CurrentCity.attributes['type']}"> <f:selectItems value="#{CurrentCity.suggestedTypes}" /> </h:selectOneListbox> <h:outputText /> - <h:outputText value="Places part of this"/> + <h:outputText value="This place is part of" /> + <ismi:autocomplete lo="#{CurrentCity.countryLo}" /> + <h:panelGrid> + <h:commandButton alt="edit" image="#{ApplicationBean1.editImage}" + rendered="#{!empty CurrentCity.countryLo.entity.id}" + actionListener="#{CurrentCity.editThisCountryAction}" /> + <h:commandButton alt="edit" image="#{ApplicationBean1.imgRemove16}" + rendered="#{!empty CurrentCity.countryLo.entity.id}" + actionListener="#{CurrentCity.removeThisCountryAction}" /> + </h:panelGrid> + + <h:outputText value="Places that are part of this"/> <h:panelGrid columns="2" id="placePartOfThisPanel"> <rich:dataGrid var="place" style="border:none;" value="#{CurrentCity.placesPartOfThis}"> @@ -61,37 +64,7 @@ render="placePartOfThisPanel" rendered="#{!empty CurrentCity.placesPartOfThis}"/> </h:panelGrid> - - <h:outputText value="People, who lived here"/> - <h:panelGrid columns="2" id="peopleLivedInPanel"> - <rich:dataGrid var="place" style="border:none;" - value="#{CurrentCity.peopleLivedIn}"> - <h:column style="border:none;"> - <h:selectBooleanCheckbox - value="#{place.selected}" /> - </h:column> - <h:column> - <h:outputText value="#{place.label}" /> - </h:column> - <h:column> - <h:outputLink value="#{ApplicationBean1.root}/search/displayAuthor.xhtml?personId=#{place.obj.id}" - title="Display this person"> - <h:graphicImage url="#{ApplicationBean1.displayImage}" /> - </h:outputLink> - </h:column> - </rich:dataGrid> - - </h:panelGrid> - <h:panelGrid columns="1"> - <a4j:commandButton - value="Remove" - actionListener="#{CurrentCity.listenerRemovePeopleLivedIn}" - render="peopleLivedInPanel" - rendered="#{!empty CurrentCity.peopleLivedIn}"/> - </h:panelGrid> - - </h:panelGrid> <ismi:refWidget entityForm="#{CurrentCity}" /> @@ -105,7 +78,7 @@ onclick="#{ApplicationBean1.JSConfirmationCleanForm}" /> <h:outputText rendered="#{CurrentCity.create_error}" - value="City already exists - not saved!" /> + value="Place already exists - not saved!" /> <!-- Unity Warning --> <h:panelGrid id="placeUnityWarningPP">