示例#1
0
文件: wftxn.go 项目: mindhash/goFlow
// 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()}
}
示例#2
0
文件: crud.go 项目: mindhash/goFlow
// 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
}
示例#3
0
文件: crud.go 项目: mindhash/goFlow
//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
}
示例#4
0
文件: wftxn.go 项目: mindhash/goFlow
func NewActivity(actkey string) *Activity {
	// need to derive ActivityInstanceKey
	newActInstanceId := base.CreateUUID()
	return &Activity{ActivityInstanceKey: newActInstanceId, Status: "Scheduled", CreationDate: time.Now()}
}