diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/mapping/DatasetIdMapper.java b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/mapping/DatasetIdMapper.java index 9249757d46..04f5cb945e 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/mapping/DatasetIdMapper.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.grid/src/com/raytheon/uf/common/dataplugin/grid/mapping/DatasetIdMapper.java @@ -22,7 +22,6 @@ package com.raytheon.uf.common.dataplugin.grid.mapping; import javax.xml.bind.JAXBException; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManager; import com.raytheon.uf.common.localization.PathManagerFactory; @@ -55,17 +54,8 @@ public class DatasetIdMapper extends Mapper { private DatasetIdMapper() { IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonStaticBase = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.BASE); - - LocalizationContext commonStaticSite = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.SITE); - // read in the namespace map - LocalizationFile[] files = pathMgr.listFiles(new LocalizationContext[] { - commonStaticSite, commonStaticBase }, "grid" + LocalizationFile[] files = pathMgr.listStaticFiles("grid" + PathManager.SEPARATOR + "dataset" + IPathManager.SEPARATOR + "alias", new String[] { ".xml" }, true, true); for (LocalizationFile file : files) { @@ -79,12 +69,9 @@ public class DatasetIdMapper extends Mapper { } } - private static DatasetIdMapper instance; + private static final DatasetIdMapper instance = new DatasetIdMapper(); - public static synchronized DatasetIdMapper getInstance() { - if (instance == null) { - instance = new DatasetIdMapper(); - } + public static DatasetIdMapper getInstance() { return instance; } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapper.java b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapper.java index cabd2a6ac6..fc71e079f5 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapper.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.level/src/com/raytheon/uf/common/dataplugin/level/mapping/LevelMapper.java @@ -31,7 +31,6 @@ import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.MasterLevel; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.status.IUFStatusHandler; @@ -68,17 +67,8 @@ public class LevelMapper extends Mapper { private LevelMapper() { IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonStaticBase = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.BASE); - - LocalizationContext commonStaticSite = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.SITE); - // read in the namespace map - LocalizationFile[] files = pathMgr.listFiles(new LocalizationContext[] { - commonStaticSite, commonStaticBase }, "level" + LocalizationFile[] files = pathMgr.listStaticFiles("level" + IPathManager.SEPARATOR + "alias", new String[] { ".xml" }, true, true); for (LocalizationFile file : files) { @@ -193,12 +183,9 @@ public class LevelMapper extends Mapper { return result; } - private static LevelMapper instance; + private static final LevelMapper instance = new LevelMapper(); - public static synchronized LevelMapper getInstance() { - if (instance == null) { - instance = new LevelMapper(); - } + public static LevelMapper getInstance() { return instance; } diff --git a/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/lookup/ParameterLookup.java b/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/lookup/ParameterLookup.java index b57f5858f5..2c8c8f7dca 100644 --- a/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/lookup/ParameterLookup.java +++ b/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/lookup/ParameterLookup.java @@ -33,7 +33,6 @@ import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.parameter.Parameter; @@ -65,12 +64,9 @@ public class ParameterLookup { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ParameterLookup.class); - private static ParameterLookup instance; + private static final ParameterLookup instance = new ParameterLookup(); public static ParameterLookup getInstance() { - if (instance == null) { - instance = new ParameterLookup(); - } return instance; } @@ -106,18 +102,9 @@ public class ParameterLookup { } if (unmarshaller != null) { IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonStaticBase = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.BASE); - LocalizationContext commonStaticSite = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.SITE); - - LocalizationFile[] files = pathMgr.listFiles( - new LocalizationContext[] { commonStaticSite, - commonStaticBase }, "parameter" - + IPathManager.SEPARATOR + "definition", + LocalizationFile[] files = pathMgr.listStaticFiles("parameter" + + IPathManager.SEPARATOR + "definition", new String[] { ".xml" }, true, true); for (LocalizationFile file : files) { @@ -141,9 +128,11 @@ public class ParameterLookup { } } } else { - statusHandler.error("Error reading parameter defintions: " + statusHandler.error("Error reading parameter definitions: " + file.getName() + " was a " - + obj.getClass().getSimpleName()); + + obj.getClass().getSimpleName() + + " but was expecting " + + ParameterList.class.getSimpleName()); } } } diff --git a/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/mapping/ParameterMapper.java b/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/mapping/ParameterMapper.java index 3727985880..edfa2eac85 100644 --- a/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/mapping/ParameterMapper.java +++ b/edexOsgi/com.raytheon.uf.common.parameter/src/com/raytheon/uf/common/parameter/mapping/ParameterMapper.java @@ -25,7 +25,6 @@ import java.util.Set; import javax.xml.bind.JAXBException; import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.parameter.Parameter; @@ -62,17 +61,8 @@ public class ParameterMapper extends Mapper { private ParameterMapper() { IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonStaticBase = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.BASE); - - LocalizationContext commonStaticSite = pathMgr.getContext( - LocalizationContext.LocalizationType.COMMON_STATIC, - LocalizationContext.LocalizationLevel.SITE); - // read in the namespace map - LocalizationFile[] files = pathMgr.listFiles(new LocalizationContext[] { - commonStaticSite, commonStaticBase }, "parameter" + LocalizationFile[] files = pathMgr.listStaticFiles("parameter" + IPathManager.SEPARATOR + "alias", new String[] { ".xml" }, true, true); for (LocalizationFile file : files) { @@ -135,12 +125,9 @@ public class ParameterMapper extends Mapper { return ParameterLookup.getInstance().getParameter(baseName); } - private static ParameterMapper instance; + private static final ParameterMapper instance = new ParameterMapper(); - public static synchronized ParameterMapper getInstance() { - if (instance == null) { - instance = new ParameterMapper(); - } + public static ParameterMapper getInstance() { return instance; } diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/AliasNamespace.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/AliasNamespace.java index ff90a8d84f..b94b0853bc 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/AliasNamespace.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/AliasNamespace.java @@ -25,16 +25,13 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - /** * - * A AliasNamespace represents a set of alternative names for a base name. This - * list defines the alternatives within a namespace so that it is possible to - * match aliases for only a specific group. Parent namespaces can be used to - * bring all aliases from another list into this namespace. + * Represents a bidirectional map for going between base names and aliases. + * Allows for caseInsensitive aliases since some naming conventions are ambigous + * on case. The base names cannot be treated case insensitive because this would + * cause ambiguity and require case insensitive handling of base names in all + * namespaces. * *
* @@ -49,8 +46,6 @@ import javax.xml.bind.annotation.XmlRootElement; * @author bsteffen * @version 1.0 */ -@XmlAccessorType(XmlAccessType.NONE) -@XmlRootElement public class AliasNamespace { protected final boolean caseSensitive; diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/Mapper.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/Mapper.java index 9e28be25a8..4e6397b019 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/Mapper.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/mapping/Mapper.java @@ -81,7 +81,9 @@ public abstract class Mapper { Unmarshaller unmarshaller = Mapper.unmarshaller; if (unmarshaller == null) { // This will be safe if multiple threads get in before the sync - // block. + // block. This is not in a static block or ThreadLocal because this + // class is deliberately not handling any exceptions but instead + // propagates all problems to the concrete implementation. JAXBContext context = JAXBContext.newInstance(AliasList.class, Alias.class); unmarshaller = context.createUnmarshaller(); diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/GridLookupFileName.java b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/GridLookupFileName.java index 567d9f9eda..5041ffc517 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/GridLookupFileName.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/GridLookupFileName.java @@ -4,13 +4,17 @@ import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; +// TODO this logic could probably be included in the ncgribFileNameProcessor rather than in a singleton public class GridLookupFileName { /** The singleton instance of GridLookupFileName **/ private static GridLookupFileName instance; + // TODO modelname needs to be infered from filename since the file name + // processing happens before decode. private String[] modelNames = { "cmce", "gefs", "gww", "naefsBC", "naefsUS", "naefsAK", "sref" }; + // TODO this should be read from a configureable xml file, not hardcoded private String[] template = { "cmc_gep.*|cmce;cmc_gec.*|cmcec;cmc_geavg.*|cmceMean;cmc_gespr.*|cmceSpread", "gec00.*bc.*|gefscBC;gec00.*anl|gefscAnal;gec00.*[0-9]|gefsc;gep.*anl|gefsAnal;gep.*bc.*|gefsBC;geavg.*bc.*|gefsMeanBC;gespr.*bc.*|gefsSpreadBC;gespr.*|gefsSpread", @@ -36,6 +40,9 @@ public class GridLookupFileName { } private void initModels() { + // TODO instead of just building this map, all parsing should be + // happening here and regexes should be built into Pattern object so + // that we aren'y constantly reprocessing regexes for (int i = 0; i < modelNames.length; i++) { models.put(modelNames[i].toUpperCase(), template[i]); } @@ -44,18 +51,24 @@ public class GridLookupFileName { public String getModelName(String filename) { String modelname = null; + // this was commented out because file name processing should happen + // before decode so there is no pre-existing model name. // if (model.equalsIgnoreCase("gww") && gridId.equalsIgnoreCase("229")) // { // return modelname; // } // // String template = models.get(model.toUpperCase()); + // since we don't know the model name, we must process all templates. for (String template : this.template) { + // TODO do not split this for every filename, split in init String[] tokens = template.split(";"); // System.out.println ( " CMC ensemble " + "!!!\n"); for (String token : tokens) { + // TODO do not split this for every filename, split in init String[] alias = token.split("\\|"); + // TODO compile and reuse patterns. if (Pattern.matches(alias[0], filename)) { modelname = alias[1]; @@ -68,6 +81,9 @@ public class GridLookupFileName { break; } } + if (modelname != null) { + break; + } } return modelname; } diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribFileNameProcessor.java b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribFileNameProcessor.java index fa011bcc9c..b09c909c21 100644 --- a/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribFileNameProcessor.java +++ b/ncep/gov.noaa.nws.ncep.edex.plugin.ncgrib/src/gov/noaa/nws/ncep/edex/plugin/ncgrib/NcgribFileNameProcessor.java @@ -27,9 +27,11 @@ import org.apache.camel.Processor; /** * - * Processor for ncep grib files, this processor has lots of hard coded - * assumptions about file naming that need to be more generic based off ncep - * file names. + * Based off a file name for a grib file, determine the modelName, secondaryId, + * and ensembleId. It is ok not to set any headers because the decoder can find + * the modelName and ensembleId. Those fields should only be set if the filename + * has information beyond what is in the actual grib file.The grib decoder will + * not set a secondary id so if it isn't set here it will be null. * ** @@ -46,20 +48,25 @@ import org.apache.camel.Processor; */ public class NcgribFileNameProcessor implements Processor { + // TODO does this actually match all ensemble patterns? // grab all known ensemble ids private static final Pattern ENSEMBLE_ID_PATTERN = Pattern .compile("^(p|n|ctl)\\d{0,2}$"); + // TODO merge this pattern in with the patterns in GridLookupFileName // anything that ends in nest is assumed to be a nested grid identifier private static final Pattern FIREWXNEST_ID_PATTERN = Pattern .compile("^firewxnest$"); + // TODO merge this pattern in with the patterns in GridLookupFileName // anything that ends in nest is assumed to be a nested grid identifier private static final Pattern NEST_ID_PATTERN = Pattern.compile("^.*nest$"); + // TODO merge this pattern in with the patterns in GridLookupFileName // SREF gets special handling, does this apply to other models? private static final Pattern SREF_PATTERN = Pattern.compile("^sref_.*$"); + // TODO merge this pattern in with the patterns in GridLookupFileName // This is the least generic pattern ever, are there any constraints on // event names, who knows? private static final Pattern HURRICANE_PATTERN = Pattern @@ -106,6 +113,8 @@ public class NcgribFileNameProcessor implements Processor { exchange.getIn().setHeader("datasetid", datasetid); } if (secondaryid == null) { + // TODO does everything really need secondaryid or should this only + // be set for events? secondaryid = nameTokens[0]; } exchange.getIn().setHeader("secondaryid", secondaryid);