IMPORT FROM V7 SPECS

CASES
- https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3503


REQUIREMENTS

- EMPTY DESTINATION DATABASE - IMPORTER will assume there is no pre-existing data that can conflict
    - DB MUST BE ERASED FIRST OR IMPORT WILL FAIL (excluding fundamental things like license key, stock locales etc)
- LImited area of concern: rather than trying to do all types of import, I'm going to write this as if it's all for v7 only
    - only when I write the next importer will I see if there are any savings of combining objects, but for now small classes with single responsibility
- Import v7 data into RAVEN via datadump plugin for v7
- ROUTE: endpoint to allow upload of v7 datadump zip file .
- ROUTE: endpoint to allow delete of uploaded datadump file.
- ROUTE: endpoint to Show list of datadump files uploaded.
- ROUTE: endpoint to trigger non-selective import of specified datadump file (import all)

- FUTURE - ROUTE: endpoint to download a picklist collection of objects found in dump suitable for user to then select specific objects (or type of objects) to import 
- FUTURE - ROUTE: endpoint to trigger selective import from an uploaded datadump file 
    - future thing if required because user always has option of editing zip file and removing what is not required to be imported
    - Supports specifying what to import so can just pick clients or something.
        - Pick by name of folder I guess within zip since each object type is in it's own folder
  

- IMPORT 
    - user selects all or collection of folders to import from zip
        - User is returned a jobid that the client can use to display the activity log
    - Importer opens the archive file and iterates the folders
    - Each type of object has a corresponding biz object that handles importing that type
        - So, for example, each client json is handed off to a corresponding ClientBiz for import
        - Importer updates the opslog as it's doing the import with summary information (3 clients imported successfully etc)
- Should close api while it's doing the import.
- Datadump files should be in backup files folder


ROLES
- Ops ful, biz full can submit jobs
- OpsLImited and biz limited can view the jobs (already coded)


OBJECTS
    - [ImportAyaNova7Controller]
    - [ImportAyaNova7Biz] object to back controller routes, submit job, run job and pass off import to each biz object in turn that implements: 
    - [IImportAyaNova7Object] interface for each biz object (e.g. ClientBiz) 
        - Import(AyaTypeAndID,JSONDATAfromimportfile)
        

    

OPERATION SEQUENCE

The upload / delete / show list of datadump files part is standard api stuff and doesn't need special handling nor locking the server
Importing   
    - Triggered by ops user remotely by selecting datadump file for import




SCHEMA


- It would be helpful to have a importmap table that is used temporarily during import to store a map of v7Guid's with their imported RAVEN type and id
- This way it can be a lookup table to quickly set other imported data, i.e. client id's to match to units being imported.
IMPORTMAP
    - ObjectType
    - ObjectId
    - v7Guid



NOTES FOR DOCS
- Only an empty database is supported for import
- Only one shot import, can't import again later
- LOCALES
    - MUST be a default translation set before import because new raven keys will be added to imported v7 translation using the default translation only
- IMPORTED USERS
    - In order to ensure security imported users are not imported ready to login but rather must be edited individually after import:
        - All users are imported with Active status set to false and must be individually edited and set to Active=true as required
        - login and passwords are not imported and need to be individually set after import as required
        - no Authorization Role is set and therefore no rights to anything.  A role needs to be set after import for each user
- TAGS, the following objects are imported as tags and suffixed with a period and then short versions of the object type in the tag name
    - Region
    - UnitModelCategory
    - UnitServiceType
    - WorkorderItemType
    - ClientGroup
    - WorkorderCategory
    - PartCategory
    - DispatchZone
    - ScheduleableUserGroup


- CUSTOM FIELDS
    - RAVEN custom fields start with 1 not zero like in v7
    - Import v7 custom0 to RAVEN custom1
