[MODEXPW-48] Remove uploaded edit records if user cancel editing Created: 27/Sep/21  Updated: 23/Dec/21  Resolved: 23/Dec/21

Status: Closed
Project: mod-data-export-worker
Components: None
Affects versions: None
Fix versions: 1.3.0

Type: Story Priority: P3
Reporter: Magda Zacharska Assignee: Aliaksei Harbuz
Resolution: Done Votes: 0
Labels: bulk-edit-pilot
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Attachments: Microsoft Word 3bdba2a7-0be6-481c-a668-eb57c55e2260_userIds.csv     PNG File rollback_changes.PNG     PNG File rollback_success.PNG     PNG File updated.PNG     Microsoft Word userIds.csv    
Issue links:
Defines
defines UXPROD-3318 User records - bulk edit - pilot impl... Closed
Requires
is required by UIBULKED-20 Bulk edit confirmation modal Closed
Sprint: Firebird Sprint 129, Firebird Sprint 130
Story Points: 5
Development Team: Firebird

 Description   

Purpose/Overview:
Once the user uploads the file with the changes, the user can still cancel the process on the confirmation modal. If the bulk edit is canceled, then there is no need to store the records anymore

Requirements/Scope:

  1. Once the user clicks the Cancel button in the UI the uploaded records are removed

Approach:
1) Runned Job should be able to be aborted
2) If the Job was interrupted the backup file(file copy) is applied to roll back the changes
3) It is not necessary to process the entire file copy to roll back the changes. If the user has canceled the records updating when only 3% of a file was processed we have to roll back processed lines only.
4) New endpoint for the changes rollback is required. /bulk-edit/jobId/roll-back

Acceptance criteria:

  • The records from the canceled bulk edit are not stored


 Comments   
Comment by Aliaksei Harbuz [ 23/Dec/21 ]

Verifying at folio snapshot environment:

1) Get job id to for get users information: 

POST /data-export-spring/jobs HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
Content-Type: application/json
X-Okapi-Token: ${token}
X-Okapi-Tenant: diku
Content-Length: 135{
  "type": "BULK_EDIT_IDENTIFIERS",
  "exportTypeSpecificParameters": {},
  "identifierType": "BARCODE",
  "entityType": "USER"
}

 2) Upload file with users identifiers(userIds.csv) using job id from previous response :  

POST /bulk-edit/3bdba2a7-0be6-481c-a668-eb57c55e2260/upload HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
X-Okapi-Token: ${token}
X-Okapi-Tenant: diku
Content-Length: 214
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/D:/TEST_DATA/MODEXPW-48/check_testing/userIds.csv"
Content-Type: text/csv(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW

3) Gen link to download user's information:  

GET /data-export-spring/jobs/3bdba2a7-0be6-481c-a668-eb57c55e2260 HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
Content-Type: application/json
X-Okapi-Token: ${token}
X-Okapi-Tenant: diku

Response:  

{
    "id": "3bdba2a7-0be6-481c-a668-eb57c55e2260",
    "name": "000001",
    "source": "diku_admin",
    "isSystemSource": false,
    "type": "BULK_EDIT_IDENTIFIERS",
    "exportTypeSpecificParameters": {},
    "status": "SUCCESSFUL",
    "files": [
        "https://folio-snapshot-export.s3.us-east-1.amazonaws.com/3bdba2a7-0be6-481c-a668-eb57c55e2260_userIds.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA2VGNPE73JV77RBGE%2F20211223%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211223T113624Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=23c6cbd4c3dd70b7978e24608626824af52398790181f762997c6d4ea77ed2d9"
    ],
    "startTime": 1640259383977,
    "endTime": 1640259384521,
    "metadata": {
        "createdDate": 1640259357611,
        "createdByUserId": "54b7bc03-4d85-5b78-97b9-23e5a7c5635e",
        "createdByUsername": "diku_admin",
        "updatedDate": 1640259384803,
        "updatedByUserId": "54b7bc03-4d85-5b78-97b9-23e5a7c5635e",
        "updatedByUsername": "diku_admin"
    },
    "identifierType": "BARCODE",
    "entityType": "USER"
}

 Download file by link in files: 3bdba2a7-0be6-481c-a668-eb57c55e2260_userIds.csv.

4) Update user information in file from previous step

5) Get job id to update users: 

POST /data-export-spring/jobs HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
Content-Type: application/json
X-Okapi-Token: ${token}
X-Okapi-Tenant: diku
Content-Length: 130{
  "type": "BULK_EDIT_UPDATE",
  "exportTypeSpecificParameters": {},
  "identifierType": "BARCODE",
  "entityType": "USER"
}

Response :  

{
    "id": "5904fd29-ee57-4f66-a186-462641a1aacd",
    "name": "000003",
    "source": "diku_admin",
    "isSystemSource": false,
    "type": "BULK_EDIT_UPDATE",
    "exportTypeSpecificParameters": {},
    "status": "SCHEDULED",
    "metadata": {
        "createdDate": 1640260003779,
        "createdByUserId": "54b7bc03-4d85-5b78-97b9-23e5a7c5635e",
        "createdByUsername": "diku_admin",
        "updatedDate": 1640260003779,
        "updatedByUserId": "54b7bc03-4d85-5b78-97b9-23e5a7c5635e",
        "updatedByUsername": "diku_admin"
    },
    "identifierType": "BARCODE",
    "entityType": "USER"
}

5) Upload updated 3bdba2a7-0be6-481c-a668-eb57c55e2260_userIds.csv using job id from previous step:  

POST /bulk-edit/5904fd29-ee57-4f66-a186-462641a1aacd/upload HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
X-Okapi-Token: ${token}
X-Okapi-Tenant: diku
Content-Length: 251
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="/D:/TEST_DATA/MODEXPW-48/check_testing/3bdba2a7-0be6-481c-a668-eb57c55e2260_userIds.csv"
Content-Type: text/csv(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW

 6) Investigate of updated user in users apps:

7)  Execute rollback endpoint for used job id :  

POST /bulk-edit/5904fd29-ee57-4f66-a186-462641a1aacd/roll-back HTTP/1.1
Host: folio-snapshot-okapi.dev.folio.org:443
X-Okapi-Token: ${token} 
X-Okapi-Tenant: diku

 

8) Check users that was previously updated at users app : 

The user information become as before changes.

Generated at Thu Feb 08 22:30:20 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.