-
Notifications
You must be signed in to change notification settings - Fork 33
/
dao.go
47 lines (41 loc) · 1.19 KB
/
dao.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package workflow
import (
"github.com/viant/endly"
"github.com/viant/endly/model"
"github.com/viant/neatly"
"github.com/viant/toolbox/data"
"github.com/viant/toolbox/url"
)
var endlyRemoteRepo = "https://raw.githubusercontent.com/viant/endly/master/%v"
var endlyLocalRepo = "mem://github.com/viant/endly/%v"
// Dao represents a workflow loader
type Dao struct {
Dao *neatly.Dao
}
// Load loads workflow into memory
func (d *Dao) Load(context *endly.Context, source *url.Resource) (*model.Workflow, error) {
resource, err := context.ExpandResource(source)
if err != nil {
return nil, err
}
result := &model.Workflow{}
var state = data.NewMap()
err = d.Dao.Load(state, resource, result)
if err == nil {
if err = result.Init(); err == nil {
err = result.Validate()
}
}
return result, err
}
// NewRepoResource returns new woorkflow repo resource, it takes context map and resource URI
func (d *Dao) NewRepoResource(context data.Map, URI string) (*url.Resource, error) {
var resource, err = d.Dao.NewRepoResource(context, URI)
return resource, err
}
// NewDao returns a new NewDao
func NewDao() *Dao {
return &Dao{
Dao: neatly.NewDao(true, endlyLocalRepo, endlyRemoteRepo, "", nil),
}
}