From c0e6247fb8a18dc75eeda8ff2affceaf710e4842 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 12 Feb 2025 15:27:05 +0100 Subject: [PATCH] workflow scheduler create booking with a booking execution lot id --- models/booking/booking_mongo_accessor.go | 7 ++++++- models/workflow_execution/workflow_execution.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/models/booking/booking_mongo_accessor.go b/models/booking/booking_mongo_accessor.go index ed78780..ca47f7a 100644 --- a/models/booking/booking_mongo_accessor.go +++ b/models/booking/booking_mongo_accessor.go @@ -1,6 +1,7 @@ package booking import ( + "errors" "time" "cloud.o-forge.io/core/oc-lib/dbs" @@ -33,7 +34,11 @@ func (a *bookingMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) } func (a *bookingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { - return utils.GenericUpdateOne(set, id, a, &Booking{}) + if set.(*Booking).State == 0 { + return nil, 400, errors.New("state is required") + } + realSet := &Booking{State: set.(*Booking).State} + return utils.GenericUpdateOne(realSet, id, a, &Booking{}) } func (a *bookingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index 9ebc93e..f95236b 100644 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -21,7 +21,7 @@ import ( */ type WorkflowExecution struct { utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) - ExecutionsID string `json:"executions_id,omitempty" bson:"executions_id,omitempty" validate:"required"` + ExecutionsID string `json:"executions_id,omitempty" bson:"executions_id,omitempty"` ExecDate time.Time `json:"execution_date,omitempty" bson:"execution_date,omitempty" validate:"required"` // ExecDate is the execution date of the workflow, is required EndDate *time.Time `json:"end_date,omitempty" bson:"end_date,omitempty"` // EndDate is the end date of the workflow State enum.BookingStatus `json:"state" bson:"state" default:"0"` // TEMPORARY TODO DEFAULT 1 -> 0 State is the state of the workflow