RPOWER Database Importer

From RPOWERWiki

Jump to: navigation, search

Contents

Application Start

  1. Initializes pun spinner
  2. Show Splashscreen, then close it after 5 seconds
  3. Loads preferences from Data_Importer.settings
  4. Creates the Roll Call Timer
  5. Starts the import thread

Import Start

  1. Check abort signal. If set, abort application. If not set, continue.
    1. If splashscreen is no longer showing and we loaded the preferences from the settings file, then continue. If either is false, then go back to Check abort signal.
      1. Check for existence of _stop.txt. If we do not find _stop.txt, continue, otherwise, go back to Check abort signal.
      2. Read Data_Importer.ini file.
      3. Check ServerIn for files. If files are found get a list of files and continue, otherwise, go back to Check abort signal.
      4. Import files one at a time

Database Creation

  1. Check if preliminary database setup has been done. This is only done once when the application is started up. If it has not been done, then we continue, otherwise, skip to file import.
  2. Verify import file API_VERSION. If not in proper range as defined by Data_Importer.settings, then log error and go to Import files one at a time.
  3. Get correct system administrator password
  4. Open Connection to database server
  5. Generate rpower user in SQL Server
  6. Create database
  7. Generate rpower user in MySQL/MariaDB
  8. Generate specific database importer user and other custom users
  9. Generate tables
  10. Register table versions
  11. Generate custom tables
  12. Insert default mid records into each table
  13. Verify MIDs
  14. Import time classes into tbl_timeclass

Import File

  1. Check for _stop.txt. If not found, continue; if found, attempt to import each file and then return to Check abort signal
  2. Get Store Serial Number from the file and generate file lock so no other importer can import files from that store
  3. Load file
  4. Verify current mid

Perform Record Deletion

  1. Get database schema
  2. If the import document is tagged "import time clock records only", then skip, otherwise perform all transaction deletions
    1. For each node in the document,
      1. Check if the node is "importable", if it has an I_Delete attribute, and if that I_Delete attribute value is not zero. If not, skip the node.
      2. If the node is a time clock node, then skip down to handle time clock updates
        1. Get the table schema from the schema document
        2. Find the record in the source table
        3. If the I_Delete status is set to delete, then create the target table delete statement
        4. Delete record from source table
        5. If delete was successful, generate a tbl_repl_log table insert statement
        6. Get the time class list
        7. Take the node and build a set of time_classed buckets for it
        8. Negate the bucket values and update time-classed records in the database
        9. Build a set of time-classed meta-buckets for the node
        10. Negate the bucket values and update time-classed meta-buckets in the database
        11. Add tbl_repl_log table insert statements for the buckets and meta-buckets
        12. Commit all tbl_repl_log insert statements to database.
  3. Handle time clock updates. This will back time clock records out of buckets (the regular import process will import the "fixed" time clock records)
    1. Get time clock table schema
    2. Check that each time clock node's I_Delete attribute is set to delete. If not, then skip.
    3. Find time clock record in tbl_time_clock table
    4. If record is found, then retrieve the record information
    5. For each record retrieved,
      1. Take the node and build a set of time_classed buckets for it
      2. Negate the bucket values and update time-classed records in the database
      3. Build a set of time-classed meta-buckets for the node
      4. Negate the bucket values and update time-classed meta-buckets in the database
      5. Add tbl_repl_log table insert statements for the buckets and meta-buckets
      6. Commit all tbl_repl_log insert statements to database.

Non-Transaction Record Import

For each record:

  1. The XML element is retrieved from the export document.
  2. Check if the I_Delete attribute is set to 1. If so, skip this record
  3. Converts the XML element to an record object
    1. Checks if the record is from a transaction table or if the force import flag is set
      1. If the record is a transaction table, then foreign keys are not checked
    2. For each attribute of the XML element:
      1. Sets the records I_Delete flag (true if I_Delete is 1, false if it is 0)
      2. Checks if the attribute is a primary key
        1. If attribute is a foreign key, the importer looks for the mid in the foreign mid list
        2. If the foreign key is not found in the foreign mid list, the source table is checked
        3. If the foreign key is not found in the source table, the cross-reference table is checked
        4. If the mid is not found in the cross-reference table, a failure flag is thrown
        5. If it is found, the foreign key is added to the foreign mid list
        6. As long as a failure flag is not thrown, the primary mid is added to the record
      3. If the attribute is a name collision field:
        1. The value is cleaned up
        2. The table's foreign keys are checked to see if this attribute is a foreign key.
        3. If the attribute is a foreign key, will search for the attribute value in the foreign mid list
        4. If the foreign key is not found in the foreign mid list, the source table is checked
        5. If the foreign key is not found in the source table, the cross-reference table is checked
        6. If the mid is not found in the cross-reference table, a failure flag is thrown
        7. If it is found, the foreign key is added to the foreign mid list
        8. As long as a failure flag is not thrown, the attribute value is added to the record
      4. If the attribute is not a primary key or a name collision field:
        1. Boolean values are handled and the value is added to the record
        2. If the attribute is a foreign key, and record is to not be deleted the foreign mid is validated
        3. If the attribute is a foreign key, will search for the attribute value in the foreign mid list
        4. If the foreign key is not found in the foreign mid list, the source table is checked
        5. If the foreign key is not found in the source table, the cross-reference table is checked
        6. If the mid is not found in the cross-reference table, a failure flag is thrown
        7. If it is found, the foreign key is added to the foreign mid list
        8. As long as a failure flag is not thrown, the attribute value is added to the record
      5. If field values are not supplied by RPOWER, the default field value is set and added to the record
      6. The timestamp field value is set and added to the record
      7. The short mid field value is set and added to the record
      8. The ticket rid field valule is set and added to the record
      9. If importing price level table records, the price level number is set and added to the record
      10. If importing payment method table records, the payment method xtype is set and added to the record
    3. Record is done being generated
  4. Queries the database using the record's name collision fields to find the MID
  5. Checks to see if the MID found is the same as the MID we are looking for
    1. If it is, the MIDFoundType flag is set to indicate the mid coming in and the mid found in the database and the name coming in and the name in the database are the same
  6. Queries the database using the MID we found to get the record data
  7. Checks the MIDFoundType to see if this record should be inserted or updated.
    1. if the MID and the Name found in the database are the same as those coming in, an Update statment is created.
  8. A SQL statement is generated, and that statement is added to an array of statements to execute.
  9. An import record is generated to keep the SQL statement, the data, and the SQL Operation result together.
  10. The commands in the statement array are executed as a single transaction.
  11. The SQL Operation result is recorded in the import record object.
  12. Return to 1 and repeat until all XML elements for this table have been processed.

Transaction Record Import

Error Logging

Generating Correction Export

Import End

  1. Force Garbage Collection, and go back to Check abort signal
Views
Personal tools