Mercurial > hg > ismi-richfaces
changeset 145:62d5276ed785
move suggestedTextTypes to CurrentTextBean and read types from definition.
clean city type handling.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 10 Jul 2017 15:54:54 +0200 |
parents | 6911b522c6e2 |
children | 29bd63f749c6 |
files | src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java src/main/webapp/entry/text.xhtml |
diffstat | 5 files changed, 47 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java Mon Jun 26 18:15:02 2017 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/AbstractISMIBean.java Mon Jul 10 15:54:54 2017 +0200 @@ -650,12 +650,18 @@ } } - public void fillList(List<SelectItem> list, String[] array) { - list.add(new SelectItem("")); + public static void fillList(List<SelectItem> list, String[] array) { + list.add(new SelectItem("", "-- choose --")); for (int i = 0; i < array.length; i++) { list.add(new SelectItem(array[i])); } + } + public static void fillList(List<SelectItem> list, List<String> items) { + list.add(new SelectItem("", "-- choose --")); + for (String item : items) { + list.add(new SelectItem(item)); + } } public boolean isWarning() {
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java Mon Jun 26 18:15:02 2017 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/ApplicationBean.java Mon Jul 10 15:54:54 2017 +0200 @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import org.mpi.openmind.cache.WrapperService; import org.mpi.openmind.configuration.ConfigurationService; +import org.mpi.openmind.repository.bo.Attribute; import org.mpi.openmind.repository.bo.Entity; import org.mpi.openmind.repository.services.ServiceRegistry; import org.mpi.openmind.search.SearchService; @@ -135,7 +136,6 @@ private static List<SelectItem> scripts = new ArrayList<SelectItem>(); private static List<SelectItem> sourcesOfInformation = new ArrayList<SelectItem>(); private static List<SelectItem> suggestedLanguages = new ArrayList<SelectItem>(); - private static List<SelectItem> suggestedTextTypes = new ArrayList<SelectItem>(); private static List<SelectItem> suggestedBoolean = new ArrayList<SelectItem>(); @@ -234,23 +234,6 @@ suggestedLanguages.add(new SelectItem(langs[i])); } - String[] tts = new String[] { - "First-order prose composition (or compilation) [matn]", - "First-order verse composition (didactic poem)", - "Second-order composition (Commentary) [sharh]", - "Third-order composition (Supercommentary)", - "Fourth-order composition (Gloss)", - "Fifth-order composition (Supergloss)", - "Sixth-order composition", "Seventh-order composition", - "Rearrangement", "Abridgement (epitome)", "Versification", - "Translation", "Paraphrase", "Supplement" }; - Arrays.sort(tts); - - suggestedTextTypes.add(new SelectItem("", "-- choose --")); - for(int i = 0; i < tts.length; i++){ - suggestedTextTypes.add(new SelectItem(tts[i])); - } - yes_no.add(new SelectItem("", "-- choose --")); yes_no.add(new SelectItem("yes")); yes_no.add(new SelectItem("no")); @@ -369,10 +352,6 @@ return suggestedLanguages; } - public List<SelectItem> getSuggestedTextTypes(){ - return suggestedTextTypes; - } - public List<SelectItem> getSuggestedBoolean(){ return suggestedBoolean; }
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java Mon Jun 26 18:15:02 2017 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentCityBean.java Mon Jul 10 15:54:54 2017 +0200 @@ -48,7 +48,6 @@ public void reset(){ super.reset(); this.entity = new Entity(Node.TYPE_ABOX, PLACE, false); - this.suggestedTypes = new ArrayList<SelectItem>(); this.placesPartOfThis = new ArrayList<SelectableObject<Entity>>(); //this.peopleLivedIn = new ArrayList<SelectableObject<Entity>>(); @@ -56,14 +55,13 @@ //setDefinition(getDefinition(PLACE)); setDefObjectClass(PLACE); - // old types - String[] types = new String[]{"city","institution", "city_part", "region"}; - // get new types from definition + // get types from definition + this.suggestedTypes = new ArrayList<SelectItem>(); Attribute typeAtt = getWrapper().getDefAttributeByOwnValue(PLACE, "type"); if (typeAtt != null) { - types = typeAtt.getPossibleValuesList().toArray(types); + List<String> types = typeAtt.getPossibleValuesList(); + fillList(suggestedTypes, types); } - fillList(suggestedTypes, types); registerChecker(getCountryLo(), "Country not valid!"); }
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java Mon Jun 26 18:15:02 2017 +0200 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentTextBean.java Mon Jul 10 15:54:54 2017 +0200 @@ -73,6 +73,26 @@ private Long idSubject; private Entity subject; + private static List<SelectItem> suggestedTextTypes = new ArrayList<SelectItem>(); + /* + String[] tts = new String[] { + "First-order prose composition (or compilation) [matn]", + "First-order verse composition (didactic poem)", + "Second-order composition (Commentary) [sharh]", + "Third-order composition (Supercommentary)", + "Fourth-order composition (Gloss)", + "Fifth-order composition (Supergloss)", + "Sixth-order composition", "Seventh-order composition", + "Rearrangement", "Abridgement (epitome)", "Versification", + "Translation", "Paraphrase", "Supplement" }; + Arrays.sort(tts); + + suggestedTextTypes.add(new SelectItem("", "-- choose --")); + for(int i = 0; i < tts.length; i++){ + suggestedTextTypes.add(new SelectItem(tts[i])); + } + */ + public static String main_subject = "main_subject"; public static String sub_subject = "sub_subject"; public static String type = "type"; @@ -189,6 +209,14 @@ registerChecker(commentaryLo, "Commentary is not valid!"); registerChecker(translationLo, "Translation is not valid!"); registerChecker(versionLo, "Version is not valid!"); + + // create list of text types from definition + suggestedTextTypes = new ArrayList<SelectItem>(); + Attribute typeAtt = getWrapper().getDefAttributeByOwnValue(AbstractISMIBean.TEXT, "text_type"); + if (typeAtt != null) { + List<String> types = typeAtt.getPossibleValuesList(); + AbstractISMIBean.fillList(suggestedTextTypes, types); + } //getPopup().setRendered(false); } @@ -941,4 +969,9 @@ public void setRomanizedPrimaAlias(String romanizedPrimaAlias) { this.romanizedPrimaAlias = romanizedPrimaAlias; } + + public List<SelectItem> getSuggestedTextTypes(){ + return suggestedTextTypes; + } + }
--- a/src/main/webapp/entry/text.xhtml Mon Jun 26 18:15:02 2017 +0200 +++ b/src/main/webapp/entry/text.xhtml Mon Jul 10 15:54:54 2017 +0200 @@ -146,7 +146,7 @@ <h:outputText value="Text Type" /> <h:selectOneMenu partialSubmit="true" value="#{CurrentText.attributes['text_type']}"> - <f:selectItems value="#{ApplicationBean1.suggestedTextTypes}" /> + <f:selectItems value="#{CurrentText.suggestedTextTypes}" /> </h:selectOneMenu> <h:outputText />