orppst / pst-gui

web based front end for the tool
Mozilla Public License 2.0
0 stars 0 forks source link

Abs 86 export import #88

Closed alan-stokes closed 6 months ago

alan-stokes commented 8 months ago

this implementation tries to do the entire upload via already created client rest APIs.

Therefore it wont handle REST exceptions very elegantly.

a better approach would be to send 1 rest request, with the proposal JSON and all supporting documents and then using a transaction from the entityManager to do the entire upload, and be able to do an transaction rollback if any errors occur. But as I don't know how to make a REST API with multiple files as well as the JSON in the body. I'll be doing the more clunky process, as I could put the JSON and then do each separate document, but any failure would still flood the system with deletes, so going to go for the full client side implementation.

export component: utilises JSON.stringify to create an json representation of the proposal and place this within the zip (its worth noting documents are already put into the zip from previous work). import component: results in the separate bits having new requests to the database to acquire their database ids and then adjusting the proposal and corresponding objects directly to reflect the new ids. It then finishes with sending the new modified objects back to the database.

AllanEngland commented 7 months ago

Ok, so I've made significant changes to how the import works, mostly on the API side of this branch.  An imported proposal is mapped to an ObservingProposal and parsed with any new organisations and people added to the database, then updateClonedReferences() is called before the new proposal is persisted.  Old links to supporting documents are pruned, following this each document in the uploaded zip file is added as a supporting document.  The uploads happen in their own transactions, so an individual one can fail (hopefully with an error reported!) without the whole import being aborted.   There are still some outstanding quirks:

AllanEngland commented 6 months ago

This is ready for someone to check, along with its associated PR for the API. Individual supporting documents can be up to 100MB each now, but there are still some minor issues that I believe are best dealt with as separate tasks.