Mercurial > gemma
view pkg/imports/erdms.go @ 2902:399b03e59411
client: use UISpinnerButton in bottlenecks list and imports overview
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 02 Apr 2019 16:44:20 +0200 |
parents | eb1d119f253f |
children | e1ccc8438529 |
line wrap: on
line source
// This is Free Software under GNU Affero General Public License v >= 3.0 // without warranty, see README.md and license for details. // // SPDX-License-Identifier: AGPL-3.0-or-later // License-Filename: LICENSES/AGPL-3.0.txt // // Copyright (C) 2018, 2019 by via donau // – Österreichische Wasserstraßen-Gesellschaft mbH // Software engineering by Intevation GmbH // // Author(s): // * Sascha L. Teichmann <sascha.teichmann@intevation.de> // * Tom Gottfried <tom.gottfried@intevation.de> package imports import ( "context" "database/sql" "fmt" "strings" "gemma.intevation.de/gemma/pkg/soap" "gemma.intevation.de/gemma/pkg/soap/erdms" ) const selectUserCountriesSQL = `SELECT DISTINCT country FROM users.list_users` func getRisData( tx *sql.Tx, ctx context.Context, feedback Feedback, username string, password string, URL string, insecure bool, funcode string, ) ([]*erdms.GetRisDataXMLResponse, error) { var auth *soap.BasicAuth if username != "" { auth = &soap.BasicAuth{ Login: username, Password: password, } } client := erdms.NewRefService(URL, insecure, auth) rows, err := tx.QueryContext(ctx, selectUserCountriesSQL) if err != nil { return nil, err } defer rows.Close() var country string var countries []string var responseData []*erdms.GetRisDataXMLResponse for rows.Next() { err = rows.Scan(&country) if err != nil { return nil, err } countries = append(countries, country) request := &erdms.GetRisDataXML{ GetRisDataXMLType: &erdms.GetRisDataXMLType{ Subcode: erdms.NoNS{Text: country + "%"}, Funcode: erdms.NoNS{Text: funcode}, }, } data, err := client.GetRisDataXML(request) if err != nil { return nil, fmt.Errorf("Error requesting ERDMS service: %v", err) } responseData = append(responseData, data) } feedback.Info("Import data for countries: %s.", strings.Join(countries, ", ")) return responseData, nil }