Пример #1
0
class GempakGridCycleQuery():
    def __init__(self, aPlugin):
        self.plugin = aPlugin
        self.queryResults = ArrayList()
        self.GSQ = GempakSqlQuery.GempakSqlQuery()
        self.GSQ.setReturnText()
        self.convert = GempakConvert()

#
# Set parameters of the metadata catalog query
#

    def setParameters(self, aParms):
        parms = aParms.split("|")
        self.model = parms[0].upper()
        self.cycle = self.convert.dattimToDbtime(parms[1].upper()).replace(
            ' ', '_')
        #print "model=", self.model
        #print "cycle=", self.cycle

#
# Generates a list of responses in XML format
#

    def makeResponse(self):
        retStr = self.convert.dbtimeToDattim((self.queryResult).split("/")[2])
        #print "returning time=", retStr
        return ResponseMessageGeneric(retStr)

#
# Executes the query and calls appropriate response functions
#

    def execute(self):
        #
        # construct the SQL query to execute
        #
        myQuery = "SELECT datauri FROM " + self.plugin + " WHERE datauri LIKE '%" + \
                   self.cycle + "%' AND datauri ~* '/" + self.model + "/' LIMIT 1"
        #print "myQuery:", myQuery

        #
        # set the SQL query
        #
        self.GSQ.setQuery(myQuery)
        self.queryResult = self.GSQ.execute()
        #print "self.queryResult=", self.queryResult
        #
        # process the results of the query
        #
        if self.queryResult is None:
            return self.makeNullResponse("Query returned no results")
        else:
            return self.makeResponse()
Пример #2
0
class GempakGridCycleQuery():
    
    def __init__(self, aPlugin):
        self.plugin = aPlugin
        self.queryResults = ArrayList()
        self.GSQ = GempakSqlQuery.GempakSqlQuery()
        self.GSQ.setReturnText()
        self.convert = GempakConvert()
    
#
# Set parameters of the metadata catalog query
#
    def setParameters (self, aParms):
        parms = aParms.split("|")
        self.model=parms[0].upper()
        self.cycle = self.convert.dattimToDbtime(parms[1].upper()).replace (' ', '_')
        #print "model=", self.model
        #print "cycle=", self.cycle
        
#
# Generates a list of responses in XML format
#
    def makeResponse(self):
        retStr = self.convert.dbtimeToDattim((self.queryResult).split("/")[2])
        #print "returning time=", retStr
        return ResponseMessageGeneric(retStr)
    
#
# Executes the query and calls appropriate response functions
#    
    def execute(self):
        #
        # construct the SQL query to execute
        #
        myQuery = "SELECT datauri FROM " + self.plugin + " WHERE datauri LIKE '%" + \
                   self.cycle + "%' AND datauri ~* '/" + self.model + "/' LIMIT 1"
        #print "myQuery:", myQuery
        
        #
        # set the SQL query
        # 
        self.GSQ.setQuery(myQuery)
        self.queryResult = self.GSQ.execute()
        #print "self.queryResult=", self.queryResult
        #
        # process the results of the query
        #
        if self.queryResult is None:
            return self.makeNullResponse("Query returned no results")
        else:
            return self.makeResponse()
Пример #3
0
    def makeResponse(self):
        convert = GempakConvert(self.pluginName, self.queryResults)
        convert2 = GempakConvert() 
        convertSt = convert.getStrings()
        returnStr = ''

        for s in convertSt:
            retTime = convert2.dbtimeToDattim(s)
            #
            # add only unique times
            #
            if returnStr.find(retTime) == -1:
                returnStr=returnStr+retTime+'|'
        
        #
        # sort times before returning
        #
        if self.returnText:
            return "|".join(sorted(returnStr[0:-1].split("|")))
        else:
            return ResponseMessageGeneric("|".join(sorted(returnStr[0:-1].split("|"))))
Пример #4
0
    def makeResponse(self):
        convert = GempakConvert(self.pluginName, self.queryResults)
        convert2 = GempakConvert()
        convertSt = convert.getStrings()
        returnStr = ''

        for s in convertSt:
            retTime = convert2.dbtimeToDattim(s)
            #
            # add only unique times
            #
            if returnStr.find(retTime) == -1:
                returnStr = returnStr + retTime + '|'

        #
        # sort times before returning
        #
        if self.returnText:
            return "|".join(sorted(returnStr[0:-1].split("|")))
        else:
            return ResponseMessageGeneric("|".join(
                sorted(returnStr[0:-1].split("|"))))
Пример #5
0
 def setGdattim(self, aDbTime):
     convert = GempakConvert()
     aGdattim = convert.dbtimeToDattim(aDbTime.replace('_', ' '))
     #print aGdattim
     self.Dgdriv.setGdattim (aGdattim)
Пример #6
0
 def setGdattim(self, aDbTime):
     convert = GempakConvert()
     aGdattim = convert.dbtimeToDattim(aDbTime.replace('_', ' '))
     #print aGdattim
     self.Dgdriv.setGdattim(aGdattim)