// try to make this immuatable TO DO func NewFlowInstance(ftr *FlowTxnRequest, fi *WorkflowDef) *FlowInstance { newInstanceKey := base.CreateUUID() activities := make([]*Activity, len(fi.Activities)) for key, _ := range activities { activities[key] = &Activity{ActivitiesDef: &fi.Activities[key]} } return &FlowInstance{FlowDefKey: ftr.FlowDefKey, Activities: activities, InstanceKey: newInstanceKey, Status: "Scheduled", CreationDate: time.Now()} }
// create new object // return object key func (db *Database) PostDocRaw(v []byte) (key string, err error) { // If there's an incoming _id property, use that as the doc ID. //TO DO: will not work as v is byte array not JSON key, idFound := v["_id"].(string) //if !idFound { // key = base.CreateUUID() //} key = base.CreateUUID() _, err = db.DbHandle.PutRaw(key, v) if err != nil { key = "" } return key, err }
//TO DO: Need to see if this is needed // Creates a new document, assigning it a random doc ID. func (db *Database) PostDoc(body Body) (string, error) { // If there's an incoming _id property, use that as the doc ID. docid, idFound := body["_id"].(string) if !idFound { docid = base.CreateUUID() } jbody, err := json.Marshal(body) if err != nil { docid = "" return docid, err } _, err = db.DbHandle.PutRaw(docid, jbody) if err != nil { docid = "" } return docid, err }
func NewActivity(actkey string) *Activity { // need to derive ActivityInstanceKey newActInstanceId := base.CreateUUID() return &Activity{ActivityInstanceKey: newActInstanceId, Status: "Scheduled", CreationDate: time.Now()} }