Esempio n. 1
0
 def getBurnScarMetaData(self, filter=None):
     name = 'BurnScarMetaData'
     criteria = {'filter': {'name': name}}
     hazardServicesConfig = HazardServicesConfig(
         configType=self.unusedArgument, configDir=self.textUtilitiesPath)
     rawOut = hazardServicesConfig.getConfigData(criteria) or {}
     return rawOut
Esempio n. 2
0
 def getPathCastConfig(self, filter=None):
     name = 'PathcastConfig'
     criteria = {'filter': {'name': name}}
     hazardServicesConfig = HazardServicesConfig(
         configType=self.unusedArgument, configDir=self.geoSpatialPath)
     rawOut = hazardServicesConfig.getConfigData(criteria) or {}
     return rawOut
Esempio n. 3
0
 def getDuplicateUGCs(self):
     name = 'DuplicateUGCs'
     criteria = {'filter': {'name': name}}
     hazardServicesConfig = HazardServicesConfig(
         configType=self.unusedArgument, configDir=self.geoSpatialPath)
     rawOut = hazardServicesConfig.getConfigData(criteria) or {}
     return rawOut
Esempio n. 4
0
 def getProductParts(self, productPart=None):
     '''
     Returns product part configuration information.
     @param productPart: The product part to retrieve config information for.
                         If this is not provided, then the entire Product Parts
                         configuration dictionary is returned. 
     @return: The dictionary of Product Parts or a specific Product Part entry 
     '''
     criteria = {'filter': {'name': 'ProductParts'}}
     hazardServicesConfig = HazardServicesConfig(
         configType=self.unusedArgument, configDir=self.textUtilitiesPath)
     rawOut = hazardServicesConfig.getConfigData(criteria) or {}
     return rawOut
Esempio n. 5
0
 def getHazardTypes(self, hazardType=None):
     '''
     Returns hazard type meta information.
     @param hazardType: The hazard type to retrieve meta information for.
                        If this is not provided, then the entire Hazard Types
                        table is returned. 
     @return: The dictionary of hazard types or a specific hazard type entry 
     '''
     hazardServicesConfig = HazardServicesConfig('hazardTypes')
     rawOut = hazardServicesConfig.getConfigData({}) or {}
     if hazardType:
         return rawOut.get(hazardType)
     return rawOut
Esempio n. 6
0
    def getConfigFile(self, criteria):
        '''
        Retrieve data from an external source.
        @param criteria: Defines the filter (and perhaps routing information)
                         for retrieving the data.
        @return: The requested data.
        '''

        info = json.loads(criteria, object_pairs_hook=collections.OrderedDict)
        info = self.as_str(info)
        dataType = info.get(DATA_TYPE_KEY)
        configDir = info.get('configDir')
        hazardServicesConfig = HazardServicesConfig(dataType,
                                                    configDir=configDir)
        rawOut = hazardServicesConfig.getConfigData(info) or {}
        return rawOut
Esempio n. 7
0
 def putData(self, criteria):
     '''
     Persist data in an external source.
     @param criteria: dataType, plus data
     '''
     info = json.loads(criteria, 'UTF-8')
     dataType = info.get(DATA_TYPE_KEY)
     if dataType in [
             SETTINGS_DATA, HAZARD_TYPES_DATA, HAZARD_CATEGORIES_DATA,
             PRODUCT_DATA, STARTUP_CONFIG_DATA
     ]:
         hazardServicesConfig = HazardServicesConfig(dataType)
         name, configData, level = info.get('name'), info.get(
             'configData'), info.get(LOCALIZATION_LEVEL)
         forSite = True if level == 'Site' else False
         hazardServicesConfig.writeConfigData(name, configData, forSite)
     else:
         self.DatabaseStorage.putData(criteria)
def getHazardMetaData(datatype,
                      phenomenon,
                      significance,
                      subType=None,
                      site=None):
    """
    @param datatype: data type representing hazard metadata.  
    @param phenomenon: hazard phenomenon
    @param significance:  optional hazard significance
    @param subType: optional hazard subType
    @param site: optional site to get the metadata for
    @return: A tuple of two values, the first being an object (executable
             or not) holding the metadata (or None if there is none), and
             the second being a relative path to the localized file from
             which the metadata was sourced (or None if there is none).
    """
    if phenomenon is not None:
        if subType == "":
            subType = None
        hazardServicesConfig = HazardServicesConfig(datatype)
        searchCriteria = {'filter': {'name': 'HazardMetaData'}}
        hazardMetaDataList = hazardServicesConfig.getConfigData(
            searchCriteria) or []

        for metaDataDict in hazardMetaDataList:
            hazardTypesList = metaDataDict[HAZARD_TYPES_DATA] or []

            for hazardType in hazardTypesList:
                if phenomenon in hazardType and (significance is None or
                                                 significance in hazardType):
                    if subType is None or (subType is not None
                                           and subType in hazardType):
                        metaDataEntry = metaDataDict[CLASS_METADATA]
                        if type(metaDataEntry) is types.StringType:
                            locPath = "HazardServices/hazardMetaData/" + metaDataEntry + ".py"
                            result = importMetaData(metaDataEntry, site=site)
                            m = result.MetaData()
                            return m, locPath
                        elif metaDataEntry is None:
                            return [], None
                        else:
                            return metaDataEntry, None
    return None, None
Esempio n. 9
0
    def getData(self, criteria):
        '''
        Retrieve data from an external source.
        @param criteria: Defines the filter (and perhaps routing information)
                         for retrieving the data.
        @return: The requested data.
        '''
        info = json.loads(criteria, object_pairs_hook=collections.OrderedDict)
        info = self.as_str(info)
        dataType = info.get(DATA_TYPE_KEY)
        if dataType in [SETTINGS_DATA, HAZARD_TYPES_DATA, HAZARD_CATEGORIES_DATA, \
                        HAZARD_METADATA, PRODUCT_DATA, \
                        STARTUP_CONFIG_DATA]:
            hazardServicesConfig = HazardServicesConfig(dataType)
            rawOut = hazardServicesConfig.getConfigData(criteria) or {}
            return json.dumps(rawOut)
        elif dataType in [HAZARD_METADATA_FILTER]:

            filter = info.get(FILTER_KEY) or {}
            phenomena, sig, subType, site = \
               filter.get(PHENOMENON), filter.get(SIGNIFICANCE), filter.get(SUBTYPE), filter.get(SITE)
            return HazardMetaDataAccessor.getHazardMetaData( \
                      HAZARD_METADATA, phenomena, sig, subType=subType, site=site)
        elif dataType in [METADATA]:
            fileName = info.get(FILENAME_KEY)
            site = info.get(SITE, None)
            return HazardMetaDataAccessor.getMetaData(fileName, site=site)

        elif dataType in [CONFIG_DATA, VTEC_TABLE_DATA, VTEC_RECORDS_DATA, ALERTS_DATA, \
                          TEST_VTEC_RECORDS_DATA, VIEW_DEF_CONFIG_DATA, VIEW_CONFIG_DATA, \
                          VIEW_DEFAULT_DATA, HAZARD_INSTANCE_ALERT_CONFIG_DATA, \
                          ALERT_CONFIG_DATA]:
            return self.DatabaseStorage.getData(criteria)

        elif dataType in [
                AREA_DICTIONARY_DATA, CITY_LOCATION_DATA, SITE_INFO_DATA
        ]:
            repoEntry = self.caveEdexRepo.get(dataType)
            if repoEntry == None:
                oneLI = LocalizationInterface('')
                if dataType == SITE_INFO_DATA:
                    repoEntry = oneLI.getLocData( \
                        'textproducts/library/SiteInfo.py', 'EDEX', '', '')
                else:
                    repoEntry = oneLI.getLocData(
                        self.textUtilityRoot + str(dataType) + '.py', 'CAVE',
                        '', '')
                if repoEntry == None:
                    msg = 'No data at all for type ' + dataType
                    self.logger.error(msg)
                    repoEntry = {}
                self.caveEdexRepo[dataType] = repoEntry
            return json.dumps(self.returnFilteredData(repoEntry, info))
        elif dataType in [CALLS_TO_ACTIONS_DATA]:
            pass
        elif dataType == GFE_DATA:
            selectedTimeMS = info.get(SELECTED_TIME_MS)
            gridParm = info.get(GRID_PARAM_KEY)
            gfeAccessor = GFEAccessor(str(gridParm))
            gridDataArray = \
                   gfeAccessor.getGridDataForSelectedTime(selectedTimeMS)
            return gridDataArray
Esempio n. 10
0
 def getProductGeneratorTable(self, filter=None):
     hazardServicesConfig = HazardServicesConfig('productGeneratorTable')
     rawOut = hazardServicesConfig.getConfigData({}) or {}
     return rawOut