# HG changeset patch # User Tim Englich # Date 1254729133 0 # Node ID 5ebc059064a64e4b9d80b9c7e642ed131439a008 # Parent ef157bd2fa92951032c0f8764bc56e8daf4bf9af Adding Languagetransfer to the ArtifactDatabase to the GNV-Client gnv-artifacts/trunk@181 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/Changelog --- a/gnv-artifacts/Changelog Fri Oct 02 14:24:47 2009 +0000 +++ b/gnv-artifacts/Changelog Mon Oct 05 07:52:13 2009 +0000 @@ -1,3 +1,15 @@ +2009-10-05 Tim Englich + + * src/main/java/de/intevation/gnv/artifacts/ressource/artifactMessages_en.properties Renamed: + Renamed from artifactMessages_en_EN.properties to artifactMessages_en.properties to get a + propper support for PreferedLocale + * src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java (getRessource) Edited, + * src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java (setUp) Edited, + * src/main/java/de/intevation/gnv/transition/TransitionBase.java (describe) Edited, + * src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java (createSelectBox) Edited: + Changed Method Signature from Locale to PreferedLocale[] to put all Useable Languages to + the RessourceFactory + 2009-10-02 Tim Englich * src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java Added: diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Fri Oct 02 14:24:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Mon Oct 05 07:52:13 2009 +0000 @@ -9,7 +9,6 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; -import java.util.Locale; import java.util.Map; import org.apache.log4j.Logger; @@ -359,7 +358,7 @@ * @return */ private Element createSelectBox(Document document, CallMeta callMeta) { - Locale locale = callMeta.getPreferredLocale(RessourceFactory.getInstance().getSupportedLocales()); + ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities(); String selectboxName = "product"; Iterator it = this.products.values().iterator(); @@ -368,7 +367,7 @@ Element lableNode = xmlUtilities.createXFormElement(document, "label"); - lableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, selectboxName, selectboxName)); + lableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), selectboxName, selectboxName)); selectNode.appendChild(lableNode); Element choiceNode = xmlUtilities.createXFormElement(document, "choices"); selectNode.appendChild(choiceNode); @@ -381,7 +380,7 @@ } Element choiceLableNode = xmlUtilities.createXFormElement(document, "label"); - choiceLableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, p.getName(), p.getName())); + choiceLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), p.getName(), p.getName())); itemNode.appendChild(choiceLableNode); Element choicValueNode = xmlUtilities.createXFormElement(document, "value"); diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java Fri Oct 02 14:24:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/RessourceFactory.java Mon Oct 05 07:52:13 2009 +0000 @@ -3,11 +3,12 @@ */ package de.intevation.gnv.artifacts.ressource; -import java.util.Locale; import java.util.ResourceBundle; import org.apache.log4j.Logger; +import de.intevation.artifacts.PreferredLocale; + /** * @author Tim Englich * @@ -29,8 +30,7 @@ private static String ressourceName = "artifactMessages"; private String ressourceDir = null; - - private Locale[] supportedLocales = null; + /** * Basic-Constructor of this Class */ @@ -40,8 +40,6 @@ if (ressourceDir == null){ ressourceDir = "de/intevation/gnv/artifacts/ressource"; } - supportedLocales = new Locale[1]; - supportedLocales[0] = Locale.GERMAN; } /** @@ -62,8 +60,8 @@ * @param defaultValue the Value that should be returned. * @return the translated Value */ - public String getRessource(Locale locale, String key, String defaultValue){ - ResourceBundle rb = ResourceBundle.getBundle(ressourceDir+"/"+ressourceName, locale); + public String getRessource(PreferredLocale[] preferredLocales, String key, String defaultValue){ + ResourceBundle rb = ResourceBundle.getBundle(ressourceDir+"/"+ressourceName, preferredLocales[0].getLocale()); try { return rb.getString(key); } catch (Exception e) { @@ -71,8 +69,4 @@ return defaultValue; } } - - public Locale[] getSupportedLocales(){ - return supportedLocales; - } } diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/artifactMessages_en.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/artifactMessages_en.properties Mon Oct 05 07:52:13 2009 +0000 @@ -0,0 +1,26 @@ +fis_marnet = Marnet +fis_imis = IMIS +fis_staun = STAUN +fis_modeldata = Modeldata +fis_delphin = Delphin +fis_thermosalinograph = Thermosalinograph +fis_chemusurvey = Chemusurvey +meshid= Mesh +product= Product +timeSeries= Timeseries +verticalProfile = Verticalprofile +horizontalProfile = Horizontalprofile +featureid = Object +mesh_coordinate = Coordinate Value (x y) +mesh_point = Meshpoint +measurementid = Measurement depth +parameterid = Parameter +minvalue = Minvalue +maxvalue = Maxvalue +dateid = Measurement date +vehicleid = Ship +cruiseid = Cruise +trackid = Track +surveyid = Survey Info +axisid = Axis +depthid = Depth \ No newline at end of file diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/artifactMessages_en_EN.properties --- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/ressource/artifactMessages_en_EN.properties Fri Oct 02 14:24:47 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -fis_marnet = Marnet -fis_imis = IMIS -fis_staun = STAUN -fis_modeldata = Modeldata -fis_delphin = Delphin -fis_thermosalinograph = Thermosalinograph -fis_chemusurvey = Chemusurvey -meshid= Mesh -product= Product -timeSeries= Timeseries -verticalProfile = Verticalprofile -horizontalProfile = Horizontalprofile -featureid = Object -mesh_coordinate = Coordinate Value (x y) -mesh_point = Meshpoint -measurementid = Measurement depth -parameterid = Parameter -minvalue = Minvalue -maxvalue = Maxvalue -dateid = Measurement date -vehicleid = Ship -cruiseid = Cruise -trackid = Track -surveyid = Survey Info -axisid = Axis -depthid = Depth \ No newline at end of file diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Fri Oct 02 14:24:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java Mon Oct 05 07:52:13 2009 +0000 @@ -11,7 +11,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; @@ -117,7 +116,7 @@ * @see de.intevation.gnv.transition.Transition#setup(org.w3c.dom.Node) */ public void setup(Node configuration) { - + log.debug("TransitionBase.setup"); this.id = Config.getStringXPath(configuration,"@id"); this.description = Config.getStringXPath(configuration,"@description"); @@ -254,6 +253,7 @@ } private Object getDescribeData(String name){ + log.debug("TransitionBase.getDescribeData"); if (this.descibeData != null){ Iterator it = this.descibeData.iterator(); while (it.hasNext()){ @@ -339,6 +339,7 @@ } private String prepareInputData4DateDBQuery(String value){ + log.debug("TransitionBase.prepareInputData4DateDBQuery"); if (value != null){ String[] values = value.split(","); String newValue = ""; @@ -355,6 +356,7 @@ return value; } private String prepareInputData4DBQuery(String value){ + log.debug("TransitionBase.prepareInputData4DBQuery"); if (value != null){ String[] values = value.split(","); String newValue = ""; @@ -375,6 +377,7 @@ * @param result */ protected void purifyResult(Collection result, String uuid) { + log.debug("TransitionBase.purifyResult"); if (this.descibeData == null){ this.descibeData = new ArrayList(); } @@ -392,8 +395,7 @@ * @see de.intevation.gnv.transition.Transition#describe(org.w3c.dom.Document, org.w3c.dom.Node, de.intevation.artifacts.CallMeta) */ public void describe(Document document, Node rootNode, CallMeta callMeta) { - - Locale locale = callMeta.getPreferredLocale(RessourceFactory.getInstance().getSupportedLocales()); + log.debug("TransitionBase.describe"); if(this.descibeData != null){ ArtifactXMLUtilities xmlutilities = new ArtifactXMLUtilities(); Iterator it = this.descibeData.iterator(); @@ -421,7 +423,7 @@ selectNode.setAttribute("ref", name); Element lableNode = xmlutilities.createXFormElement(document, "label"); - lableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, name, name)); + lableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), name, name)); Element choiceNode = xmlutilities.createXFormElement(document, "choices"); Collection values = (Collection)o; @@ -470,7 +472,7 @@ Element inputMinNode = xmlutilities.createXFormElement(document, "input"); inputMinNode.setAttribute("ref", "minvalue"); Element inputMinLableNode = xmlutilities.createXFormElement(document, "label"); - inputMinLableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, "minvalue", "minvalue")); + inputMinLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "minvalue", "minvalue")); inputMinNode.appendChild(inputMinLableNode); Element inputMinValueNode = xmlutilities.createXFormElement(document, "value"); @@ -480,7 +482,7 @@ Element inputMaxNode = xmlutilities.createXFormElement(document, "input"); inputMaxNode.setAttribute("ref", "maxvalue"); Element inputMaxLableNode = xmlutilities.createXFormElement(document, "label"); - inputMaxLableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, "maxvalue", "maxvalue")); + inputMaxLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), "maxvalue", "maxvalue")); inputMaxNode.appendChild(inputMaxLableNode); Element inputMaxValueNode = xmlutilities.createXFormElement(document, "value"); @@ -503,7 +505,7 @@ inputNode.setAttribute("ref", svdb.getName()); Element inputLableNode = xmlutilities.createXFormElement(document, "label"); - inputLableNode.setTextContent(RessourceFactory.getInstance().getRessource(locale, svdb.getName(), svdb.getName())); + inputLableNode.setTextContent(RessourceFactory.getInstance().getRessource(callMeta.getLanguages(), svdb.getName(), svdb.getName())); inputNode.appendChild(inputLableNode); Element inputValueNode = xmlutilities.createXFormElement(document, "value"); diff -r ef157bd2fa92 -r 5ebc059064a6 gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java --- a/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java Fri Oct 02 14:24:47 2009 +0000 +++ b/gnv-artifacts/src/test/java/de/intevation/gnv/artifacts/ressource/RessourceFactoryTestCase.java Mon Oct 05 07:52:13 2009 +0000 @@ -1,11 +1,12 @@ package de.intevation.gnv.artifacts.ressource; -import java.util.Locale; +import junit.framework.TestCase; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger; -import junit.framework.TestCase; +import de.intevation.artifactdatabase.DefaultPreferredLocale; +import de.intevation.artifacts.PreferredLocale; /** * @author Tim Englich @@ -39,9 +40,10 @@ } public void testRessurceFactoryTestCase(){ - String value = RessourceFactory.getInstance().getRessource(new Locale ("de", "DE"), "fis_modeldata", "N/N"); + ; + String value = RessourceFactory.getInstance().getRessource( new PreferredLocale[]{new DefaultPreferredLocale("de", 1.0f)}, "fis_modeldata", "N/N"); log.debug(value); - value = RessourceFactory.getInstance().getRessource(new Locale ("en", "EN"), "fis_modeldata", "N/N"); + value = RessourceFactory.getInstance().getRessource( new PreferredLocale[]{new DefaultPreferredLocale("en", 1.0f)}, "fis_modeldata", "N/N"); log.debug(value); }