List of Projects OSRA - Support system Technical discussions Orphan import workflow & high-level overview

Orphan import workflow & high-level overview

Updated about 5 years ago by Nikita Avvakumov

Workflow:

1 .Upload orphan list in Excel format and store as attachment to a new PendingOrphanList
2. Parse the spreadsheet header into an array of attributes and validate each attribute. Abort import if errors found.
3. Parse each spreadsheet row into a hash that can be used as attributes to instantiate a PendingOrphan
4. Instantiate a PendingOrphan and save to the db bypassing validations
5. Repeat 3 & 4 as necessary
6. Run validations on each PendingOrphan

if errors found:

7. Generate view of PendingOrphan objects with full message errors
8. Destroy all PendingOrphans
9. Destroy PendingOrphanList

if no errors found:

7. Duplicate PendingOrphanList, save duplicate as OrphanList, destroy original if save successful
8. Duplicate each PendingOrphan, save duplicate as Orphan, destroy original if save successful
(if saves unsuccessful, stop the presses, wake up the dev team)

Good reasons to use PendingOrphans instead of Orphans with a pending=true attribute:

1. sequential numbers for OSRA ID
2. different validations can be run on Pending - i.e. ensure correctness of input data, but ignore associations, callbacks etc.

Classes based on the workflow:

1. PendingOrphanList (to put spreadsheet in the db while parsing & validations run)
2. Header/attributes parser & validator
3. Spreadsheet row -> attributes hash parser
4. PendingOrphan
5. Error log/view generator
6. Pending -> permanent “persistor" 
Revisions

comments powered by Disqus