Mercurial > gemma
diff pkg/imports/ubn.go @ 2195:3437ceee1529
Uploaded bottleneck import: Implemented in terms of normal bottleneck import.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 12 Feb 2019 11:54:12 +0100 |
parents | 4b9496752d89 |
children | cfc523c70e90 |
line wrap: on
line diff
--- a/pkg/imports/ubn.go Tue Feb 12 11:09:55 2019 +0100 +++ b/pkg/imports/ubn.go Tue Feb 12 11:54:12 2019 +0100 @@ -18,6 +18,10 @@ "database/sql" "errors" "os" + "path/filepath" + + "gemma.intevation.de/gemma/pkg/soap" + "gemma.intevation.de/gemma/pkg/soap/ifbn" ) type UploadedBottleneck struct { @@ -40,10 +44,8 @@ func (ubnJobCreator) Create() Job { return new(UploadedBottleneck) } func (ubnJobCreator) Depends() []string { - return []string{ - "gauges", - "bottlenecks", - } + // Same as normal bottleneck import. + return bnJobCreator{}.Depends() } // StageDone moves the imported bottleneck out of the staging area. @@ -52,8 +54,8 @@ tx *sql.Tx, id int64, ) error { - // TODO: Implement me! - return nil + // Same as normal bottleneck import. + return bnJobCreator{}.StageDone(ctx, tx, id) } // CleanUp of a uploaded bottleneck import removes the temp dir. @@ -68,6 +70,23 @@ conn *sql.Conn, feedback Feedback, ) (interface{}, error) { - // TODO: Implement me! - return nil, errors.New("Not implemented, yet!") + + fetch := func(feedback Feedback) ([]*ifbn.BottleNeckType, error) { + var dst ifbn.Export_bn_by_isrsResponse + if err := soap.ValidateFile( + filepath.Join(ubn.Dir, "data.xml"), + "IFBN.xsd", + &dst, + ); err != nil { + return nil, err + } + + if dst.Export_bn_by_isrsResult == nil { + return nil, errors.New("No bottlenecks found") + } + + return dst.Export_bn_by_isrsResult.BottleNeckType, nil + } + + return storeBottlenecks(ctx, fetch, importID, conn, feedback) }