diff --git a/db/migrations/011_batch_deletion_work_items.sql b/db/migrations/011_batch_deletion_work_items.sql index 772c2cb..98d45b8 100644 --- a/db/migrations/011_batch_deletion_work_items.sql +++ b/db/migrations/011_batch_deletion_work_items.sql @@ -68,7 +68,54 @@ begin -- Now remove the work_item_id column from deletion requests alter table deletion_requests drop column work_item_id; - + + + drop view if exists work_items_view; + + CREATE OR REPLACE VIEW public.work_items_view + AS SELECT wi.id, + wi.institution_id, + i.name AS institution_name, + i.identifier AS institution_identifier, + wi.intellectual_object_id, + io.identifier AS object_identifier, + io.alt_identifier, + io.bag_group_identifier, + io.storage_option, + io.bagit_profile_identifier, + io.source_organization, + io.internal_sender_identifier, + wi.generic_file_id, + gf.identifier AS generic_file_identifier, + wi.name, + wi.etag, + wi.bucket, + wi."user", + wi.note, + wi.action, + wi.stage, + wi.status, + wi.outcome, + wi.bag_date, + wi.date_processed, + wi.retry, + wi.node, + wi.pid, + wi.needs_admin_review, + wi.size, + wi.queued_at, + wi.stage_started_at, + wi.aptrust_approver, + wi.inst_approver, + wi.deletion_request_id, + wi.created_at, + wi.updated_at + FROM work_items wi + LEFT JOIN institutions i ON wi.institution_id = i.id + LEFT JOIN intellectual_objects io ON wi.intellectual_object_id = io.id + LEFT JOIN generic_files gf ON wi.generic_file_id = gf.id; + + end if; end $$; diff --git a/member_api_v3.yml b/member_api_v3.yml index 7f11855..73df11b 100644 --- a/member_api_v3.yml +++ b/member_api_v3.yml @@ -3,7 +3,7 @@ openapi: 3.0.0 info: title: APTrust Registry Member API description: Open API documentation for version 3 of the APTrust Member API. - version: '3.0' + version: '3.0.1' contact: email: "help@aptrust.org" license: @@ -800,6 +800,11 @@ components: type: string format: date-time description: The date and time of last known activity on this work item. This timestamp may change several times during multipart processes such as ingest. + deletion_request_id: + type: integer + format: int64 + description: The ID of the file or object deletion request related to this item. This will be null for all actions other than Delete. + nullable: false etag: type: string description: The etag of tar file uploaded for ingest. diff --git a/pgmodels/work_item_view.go b/pgmodels/work_item_view.go index e4ccbc7..f5b1041 100644 --- a/pgmodels/work_item_view.go +++ b/pgmodels/work_item_view.go @@ -86,6 +86,7 @@ type WorkItemView struct { StageStartedAt time.Time `json:"stage_started_at" pg:"stage_started_at"` APTrustApprover string `json:"aptrust_approver" pg:"aptrust_approver"` InstApprover string `json:"inst_approver" pg:"inst_approver"` + DeletionRequestID int64 `json:"deletion_request_id" pg:"deletion_request_id"` CreatedAt time.Time `json:"created_at" pg:"created_at"` UpdatedAt time.Time `json:"updated_at" pg:"updated_at"` } diff --git a/views/deletions/approved_object.html b/views/deletions/approved_object.html index f7c006d..f12c0ec 100644 --- a/views/deletions/approved_object.html +++ b/views/deletions/approved_object.html @@ -21,7 +21,7 @@

All files belonging to thes objects will be deleted from preservation storage shortly. We'll retain a tombstone record of the object and its files along with PREMIS events recording when each item was deleted and at whose request.

-

Work Item #{{ .deletionRequest.WorkItemID }} shows the status of this deletion.

+

Check the Work Items list to see the status of this deletion.

Back to Deletions List diff --git a/web/webui/deletion.go b/web/webui/deletion.go index 813fead..76ff74a 100644 --- a/web/webui/deletion.go +++ b/web/webui/deletion.go @@ -243,10 +243,18 @@ func (del *Deletion) initObjectDeletionRequest(institutionID int64, objIDs []int // CreateWorkItem creates a WorkItem describing this deletion. We call // this only if the admin approves the deletion. func (del *Deletion) CreateObjDeletionWorkItem(obj *pgmodels.IntellectualObject) error { + if del.DeletionRequest == nil || del.DeletionRequest.ID == 0 { + errMsg := "Cannot create deletion work item because deletion request id is zero." + common.Context().Log.Error().Msgf(errMsg) + return fmt.Errorf(errMsg) + } + common.Context().Log.Warn().Msgf("Creating deletion work item for object %d - %s", obj.ID, obj.Identifier) workItem, err := pgmodels.NewDeletionItem(obj, nil, del.DeletionRequest.RequestedBy, del.DeletionRequest.ConfirmedBy, del.DeletionRequest.ID) if err != nil { + common.Context().Log.Error().Msgf(err.Error()) return err } + common.Context().Log.Warn().Msgf("Created deletion work item %d with deletion request id %d", workItem.ID, workItem.DeletionRequestID) del.DeletionRequest.WorkItems = append(del.DeletionRequest.WorkItems, workItem) return nil }