diff --git a/dtos/schedulejob.go b/dtos/schedulejob.go index 538702bd..83fbd483 100644 --- a/dtos/schedulejob.go +++ b/dtos/schedulejob.go @@ -16,24 +16,26 @@ import ( ) type ScheduleJob struct { - DBTimestamp `json:",inline"` - Id string `json:"id,omitempty" validate:"omitempty,uuid"` - Name string `json:"name" validate:"edgex-dto-none-empty-string"` - Definition ScheduleDef `json:"definition" validate:"required"` - Actions []ScheduleAction `json:"actions" validate:"required,gt=0,dive"` - AdminState string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` - Labels []string `json:"labels,omitempty"` - Properties map[string]any `json:"properties,omitempty"` + DBTimestamp `json:",inline"` + Id string `json:"id,omitempty" validate:"omitempty,uuid"` + Name string `json:"name" validate:"edgex-dto-none-empty-string"` + Definition ScheduleDef `json:"definition" validate:"required"` + AutoTriggerMissedRecords bool `json:"autoTriggerMissedRecords,omitempty"` + Actions []ScheduleAction `json:"actions" validate:"required,gt=0,dive"` + AdminState string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` + Labels []string `json:"labels,omitempty"` + Properties map[string]any `json:"properties,omitempty"` } type UpdateScheduleJob struct { - Id *string `json:"id" validate:"required_without=Name,edgex-dto-uuid"` - Name *string `json:"name" validate:"required_without=Id,edgex-dto-none-empty-string"` - Definition *ScheduleDef `json:"definition" validate:"omitempty"` - Actions []ScheduleAction `json:"actions,omitempty"` - AdminState *string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` - Labels []string `json:"labels,omitempty"` - Properties map[string]any `json:"properties,omitempty"` + Id *string `json:"id" validate:"required_without=Name,edgex-dto-uuid"` + Name *string `json:"name" validate:"required_without=Id,edgex-dto-none-empty-string"` + Definition *ScheduleDef `json:"definition" validate:"omitempty"` + AutoTriggerMissedRecords *bool `json:"autoTriggerMissedRecords,omitempty"` + Actions []ScheduleAction `json:"actions,omitempty"` + AdminState *string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` + Labels []string `json:"labels,omitempty"` + Properties map[string]any `json:"properties,omitempty"` } // Validate satisfies the Validator interface @@ -201,6 +203,7 @@ func ToScheduleJobModel(dto ScheduleJob) models.ScheduleJob { model.Id = dto.Id model.Name = dto.Name model.Definition = ToScheduleDefModel(dto.Definition) + model.AutoTriggerMissedRecords = dto.AutoTriggerMissedRecords model.Actions = ToScheduleActionModels(dto.Actions) model.AdminState = models.AssignAdminState(dto.AdminState) model.Labels = dto.Labels @@ -215,6 +218,7 @@ func FromScheduleJobModelToDTO(model models.ScheduleJob) ScheduleJob { dto.Id = model.Id dto.Name = model.Name dto.Definition = FromScheduleDefModelToDTO(model.Definition) + dto.AutoTriggerMissedRecords = model.AutoTriggerMissedRecords dto.Actions = FromScheduleActionModelsToDTOs(model.Actions) dto.AdminState = string(model.AdminState) dto.Labels = model.Labels diff --git a/dtos/schedulejob_test.go b/dtos/schedulejob_test.go index 26efbc60..65e23e35 100644 --- a/dtos/schedulejob_test.go +++ b/dtos/schedulejob_test.go @@ -120,20 +120,22 @@ var scheduleCronDefModel = models.CronScheduleDef{ var ( scheduleJob = ScheduleJob{ - DBTimestamp: DBTimestamp{}, - Id: TestUUID, - Name: jobName, - Definition: scheduleIntervalDef, - Actions: []ScheduleAction{scheduleActionEdgeXMessageBus}, - AdminState: testAdminState, + DBTimestamp: DBTimestamp{}, + Id: TestUUID, + Name: jobName, + Definition: scheduleIntervalDef, + AutoTriggerMissedRecords: true, + Actions: []ScheduleAction{scheduleActionEdgeXMessageBus}, + AdminState: testAdminState, } scheduleJobModel = models.ScheduleJob{ - DBTimestamp: models.DBTimestamp{}, - Id: TestUUID, - Name: jobName, - Definition: scheduleIntervalDefModel, - Actions: []models.ScheduleAction{scheduleActionEdgeXMessageBusModel}, - AdminState: models.AdminState(testAdminState), + DBTimestamp: models.DBTimestamp{}, + Id: TestUUID, + Name: jobName, + Definition: scheduleIntervalDefModel, + AutoTriggerMissedRecords: true, + Actions: []models.ScheduleAction{scheduleActionEdgeXMessageBusModel}, + AdminState: models.AdminState(testAdminState), } ) diff --git a/models/schedulejob.go b/models/schedulejob.go index d5d1f901..07b8d911 100644 --- a/models/schedulejob.go +++ b/models/schedulejob.go @@ -15,25 +15,27 @@ import ( type ScheduleJob struct { DBTimestamp - Id string - Name string - Definition ScheduleDef - Actions []ScheduleAction - AdminState AdminState - Labels []string - Properties map[string]any + Id string + Name string + Definition ScheduleDef + AutoTriggerMissedRecords bool + Actions []ScheduleAction + AdminState AdminState + Labels []string + Properties map[string]any } func (scheduleJob *ScheduleJob) UnmarshalJSON(b []byte) error { var alias struct { DBTimestamp - Id string - Name string - Definition any - Actions []any - AdminState AdminState - Labels []string - Properties map[string]any + Id string + Name string + Definition any + AutoTriggerMissedRecords bool + Actions []any + AdminState AdminState + Labels []string + Properties map[string]any } if err := json.Unmarshal(b, &alias); err != nil { @@ -55,14 +57,15 @@ func (scheduleJob *ScheduleJob) UnmarshalJSON(b []byte) error { } *scheduleJob = ScheduleJob{ - DBTimestamp: alias.DBTimestamp, - Id: alias.Id, - Name: alias.Name, - Definition: def, - Actions: actions, - AdminState: alias.AdminState, - Labels: alias.Labels, - Properties: alias.Properties, + DBTimestamp: alias.DBTimestamp, + Id: alias.Id, + Name: alias.Name, + Definition: def, + AutoTriggerMissedRecords: alias.AutoTriggerMissedRecords, + Actions: actions, + AdminState: alias.AdminState, + Labels: alias.Labels, + Properties: alias.Properties, } return nil } diff --git a/models/schedulejob_test.go b/models/schedulejob_test.go index 993579c5..443ba0a6 100644 --- a/models/schedulejob_test.go +++ b/models/schedulejob_test.go @@ -195,21 +195,23 @@ var deviceControlAction = DeviceControlAction{ func scheduleJobWithINTERVALScheduleDef() ScheduleJob { return ScheduleJob{ - DBTimestamp: DBTimestamp{}, - Id: ExampleUUID, - Name: TestScheduleJobName, - Definition: intervalScheduleDef, - Actions: []ScheduleAction{}, + DBTimestamp: DBTimestamp{}, + Id: ExampleUUID, + Name: TestScheduleJobName, + Definition: intervalScheduleDef, + AutoTriggerMissedRecords: true, + Actions: []ScheduleAction{}, } } func scheduleJobWithCRONScheduleDef() ScheduleJob { return ScheduleJob{ - DBTimestamp: DBTimestamp{}, - Id: ExampleUUID, - Name: TestScheduleJobName, - Definition: cronScheduleDef, - Actions: []ScheduleAction{}, + DBTimestamp: DBTimestamp{}, + Id: ExampleUUID, + Name: TestScheduleJobName, + Definition: cronScheduleDef, + AutoTriggerMissedRecords: false, + Actions: []ScheduleAction{}, } } @@ -225,21 +227,23 @@ func scheduleJobWithEDGEXMESSAGEBUSScheduleAction() ScheduleJob { func scheduleJobWithRESTScheduleAction() ScheduleJob { return ScheduleJob{ - DBTimestamp: DBTimestamp{}, - Id: ExampleUUID, - Name: TestScheduleJobName, - Definition: intervalScheduleDef, - Actions: []ScheduleAction{restAction}, + DBTimestamp: DBTimestamp{}, + Id: ExampleUUID, + Name: TestScheduleJobName, + Definition: intervalScheduleDef, + AutoTriggerMissedRecords: true, + Actions: []ScheduleAction{restAction}, } } func scheduleJobWithDEVICECONTROLScheduleAction() ScheduleJob { return ScheduleJob{ - DBTimestamp: DBTimestamp{}, - Id: ExampleUUID, - Name: TestScheduleJobName, - Definition: intervalScheduleDef, - Actions: []ScheduleAction{deviceControlAction}, + DBTimestamp: DBTimestamp{}, + Id: ExampleUUID, + Name: TestScheduleJobName, + Definition: intervalScheduleDef, + AutoTriggerMissedRecords: false, + Actions: []ScheduleAction{deviceControlAction}, } }