func (t *Tag) Create() { if !t.Exists() { printDebug(fmt.Sprint("Creating tag", t.name, t.key)) c := make(chan string) defer close(c) keyid := t.key.GetId() printDebug(fmt.Sprint("tag keyid is ", keyid)) t.agent.Write(func(sc *storage.StorageCore) { tv := sc.CreateVertex(storage.GenerateUuid(), t.name) kv := sc.GetVertex(keyid) sc.CreateEdge(storage.GenerateUuid(), TAG_EDGE, kv, tv, nil) c <- tv.Id() }) t.id = <-c } }
func (j *Job) Assign(e Export) { eid := e.GetId() c := make(chan bool) j.agent.Write(func(sc *storage.StorageCore) { jv := sc.GetVertex(j.request.Uuid) ev := sc.GetVertex(eid) if ev != nil && jv != nil { sc.CreateEdge(storage.GenerateUuid(), DOING_JOB_EDGE, jv, ev, nil) } c <- true }) <-c return }
func (j *Job) Create() { imp := GetImportById(j.request.ImportId, j.agent) if imp.Exists() { printDebug(fmt.Sprint("Creating Job")) c := make(chan string) defer close(c) j.agent.Write(func(sc *storage.StorageCore) { jv := sc.CreateVertex(j.request.Uuid, jobproperties{j.request, j.result}) iv := sc.GetVertex(j.request.ImportId) sc.CreateEdge(storage.GenerateUuid(), AWAITING_JOB_EDGE, jv, iv, nil) c <- "" }) <-c } }
func (t *Tag) LinkExport(e *Export) { if t.Exists() { c := make(chan string) defer close(c) eid := e.GetId() printDebug(fmt.Sprint("linking tag and key ", t.id, eid)) tagid := t.GetId() t.agent.Write(func(sc *storage.StorageCore) { ev := sc.GetVertex(eid) tv := sc.GetVertex(tagid) sc.CreateEdge(storage.GenerateUuid(), TAG_EDGE, tv, ev, nil) c <- "" }) <-c printDebug(fmt.Sprint("linking tag and key sucess")) } }