Пример #1
0
    def create_get_site_info_response(self, siteArg, varArg=None):
        siteCode = siteArg.replace(self.network + ':', '')
        siteResult = self.dao.get_site_by_code(siteCode)

        if (varArg == None or varArg == ''):
            seriesResultArr = self.dao.get_series_by_sitecode(siteCode)
        else:
            varCode = varArg.replace(self.vocabulary + ':', '')
            seriesResultArr = self.dao.get_series_by_sitecode_and_varcode(
                siteCode, varCode)

        if len(seriesResultArr) == 0:
            return None

        siteInfoResponse = WaterML.SiteInfoResponseType()

        queryInfo = WaterML.QueryInfoType()
        criteria = WaterML.criteria(locationParam=siteArg,
                                    variableParam=varArg)
        queryInfo.set_criteria(criteria)
        queryInfoNote = WaterML.NoteType()
        queryInfo.add_note(queryInfoNote)
        queryInfo.set_extension('')
        siteInfoResponse.set_queryInfo(queryInfo)

        s = self.create_site_element(siteResult, seriesResultArr)
        siteInfoResponse.add_site(s)

        return siteInfoResponse
Пример #2
0
    def create_get_site_response(self, siteArg=None):

        if siteArg == None or siteArg == '':
            siteResultArr = self.dao.get_all_sites()
        else:
            siteCodesArr = siteArg.split(',')
            siteCodesArr = [
                s.replace(self.network + ':', '') for s in siteCodesArr
            ]
            siteResultArr = self.dao.get_sites_by_codes(siteCodesArr)

        if len(siteResultArr) == 0:
            return None

        siteInfoResponse = WaterML.SiteInfoResponseType()

        queryInfo = WaterML.QueryInfoType()
        #TODO: check on how this should be done for multiple sites
        criteria = WaterML.criteria(locationParam=siteArg)
        queryInfo.set_criteria(criteria)
        queryInfoNote = WaterML.NoteType()
        queryInfo.add_note(queryInfoNote)
        queryInfo.set_extension('')
        siteInfoResponse.set_queryInfo(queryInfo)

        for siteResult in siteResultArr:
            s = self.create_site_element(siteResult)
            siteInfoResponse.add_site(s)

        return siteInfoResponse