|
Odyssey
|
Public Member Functions | |
| __construct (CsvToArray $csv_obj, DbLoanCreator $db_obj, LoanGeneratorMapper $mapper) | |
| WaitForInput () | |
Protected Member Functions | |
| Set ($prop, $object) | |
| SetInputLine () | |
| SetConsoleMessage () | |
| ProcessInput () | |
| IsInputEmpty () | |
| UserHasSelectedVolume () | |
| UserHasConfirmed () | |
| GenerateLoanRecords () | |
| ParseCsv () | |
| ContinueProcessing () | |
| SetDetailTemplate () | |
| MapCsvToData () | |
| CreateSchemaRecords ($row) | |
| CreateMasterSchema ($row) | |
| CreateDetailSchema ($loan_id) | |
| InsertUserLoan ($loan_id, $user_id, $row) | |
| InsertChallengeResponses ($user_id) | |
| InsertUser ($row) | |
| GetLoanAppUserId () | |
| ReturnResponse () | |
| SuccessResponses () | |
| ErrorResponses () | |
| ResetInputValues () | |
| UpdateResponses ($response=[]) | |
| UpdateSuccessCounts ($response=[]) | |
| UpdateResponseErrors ($response=[]) | |
| AddNewErrors ($table, $error_arr) | |
| IsErrors () | |
Generates sample loans with random for local testing. Run via command line in PHP.
Usage: $obj = new LoanDataGenerator(CsvObject $csv_obj, DbLoanCreator $db_obj, LoanGeneratorMapper $mapper); $obj->execute();
You will be prompted only with "how many loans to create" and asked to confirm. When complete, it will give you the test user passwords to log in with (see DB lnappuser for login info.)
Change the random data by modifying sample-loans-05-19.csv.
Definition at line 17 of file LoanDataGenerator.php.
| LoanDataGenerator::__construct | ( | CsvToArray | $csv_obj, |
| DbLoanCreator | $db_obj, | ||
| LoanGeneratorMapper | $mapper | ||
| ) |
LoanDataGenerator constructor.
| CsvToArray | $csv_obj | instance |
| DbLoanCreator | $db_obj | instance |
| LoanGeneratorMapper | $mapper | instance |
Definition at line 66 of file LoanDataGenerator.php.
|
protected |
Helper for above to simplify code. Don't have to test values, wouldn't be here is there wasn't at least one member in $error_arr
| string | $table | |
| array | $error_arr |
Definition at line 581 of file LoanDataGenerator.php.
|
protected |
If we have reached number of lines or end of file, stop processing; if exceeded num_records, close the CSV, handle will still be open.
Definition at line 246 of file LoanDataGenerator.php.
|
protected |
Insert the schema detail records for our current loan.
| int | $loan_id |
Definition at line 355 of file LoanDataGenerator.php.
|
protected |
Create the master schema and return the ID of the inserted record. In later PHP/SQL versions, this will automatically return the record ID inserted, but can't do that here so we are doing two things in one method (which is bad.)
| array | $row |
| Exception |
Definition at line 339 of file LoanDataGenerator.php.
|
protected |
Set the master schema and get the id (see comments below.) Set the detail schema.
| array | $row | a row of data from the CSV. |
| Exception |
Definition at line 323 of file LoanDataGenerator.php.
|
protected |
Ditto, helper for ReturnResponse().
Definition at line 488 of file LoanDataGenerator.php.
|
protected |
Call up the actual generator class and get busy.
| Exception |
Definition at line 207 of file LoanDataGenerator.php.
|
protected |
Get the user id from the record we just inserted (@TODO since we are now using native pg_methods, we should change our inserts to ' ... returning userid' so we don't need this exrta query)
Definition at line 425 of file LoanDataGenerator.php.
|
protected |
Insert three random challenge responses so we can test login process.
| int | $user_id |
| Exception |
Definition at line 393 of file LoanDataGenerator.php.
|
protected |
Insert the user data for the loan. Do first so we can get a user id. (@TODO since we are now using native pg_methods, we should change our inserts to ' ... returning userid'
| $row |
Definition at line 409 of file LoanDataGenerator.php.
|
protected |
Insert the loan data. (@TODO since we are now using native pg_methods, we should change our inserts to ' ... returning userid' so we don't need this exrta query)
| int | $loan_id | |
| int | $user_id | |
| array | $row |
| Exception |
Definition at line 376 of file LoanDataGenerator.php.
|
protected |
|
protected |
Is $this->line property empty? (or zero)
Definition at line 179 of file LoanDataGenerator.php.
|
protected |
For each line of the CSV, map the data to the tables, which is an unavoidable several steps. We must first get the user insert so we can have a user ID for the question records. Then we can move on to the loan, but there is no clear way to associate our CSV fields with loan data fields to create formname_[schema record id] for the JSON. This form key pattern is what makes the data load properly in the end user loan app.
| Exception |
Definition at line 289 of file LoanDataGenerator.php.
|
protected |
Use CsvToArray to parse the CSV file into an array.
Definition at line 221 of file LoanDataGenerator.php.
|
protected |
|
protected |
When done, flush these out to return to the prompt screen.
Definition at line 508 of file LoanDataGenerator.php.
|
protected |
Compose a response that should be everything that went right. Or wrong.
Definition at line 440 of file LoanDataGenerator.php.
|
protected |
A typical setter, sets internal properties (CsvToArray, DbLoanCreator, LoanGeneratorMapper) Usually setters are public, don't think we'll need it
| string | prop property identifier |
| mixed | property to set |
Definition at line 99 of file LoanDataGenerator.php.
|
protected |
Set prompt messages. These prompts should come in this order.
| Exception |
Definition at line 124 of file LoanDataGenerator.php.
|
protected |
Get detail record ID 8 to be applied to every loan we insert. All we will need to do is swap out loan id and unset detail id for each record, see Mapper->createDetailTemplateMap()
Definition at line 267 of file LoanDataGenerator.php.
|
protected |
Set the line entered from input, if there is one.
Definition at line 110 of file LoanDataGenerator.php.
|
protected |
Helper for returnResponse(). walk the successful insert counts and create sensible message strings of them.
Definition at line 470 of file LoanDataGenerator.php.
|
protected |
Set any response errors in our response array. Walking through and adding in the event other errors are added before or after.
| array | $response |
Definition at line 562 of file LoanDataGenerator.php.
|
protected |
Update the error array and success counts.
| array | $response |
Definition at line 521 of file LoanDataGenerator.php.
|
protected |
Update the success counts, to be used in a plain-English message in ReturnResponse().
| array | $response |
Definition at line 539 of file LoanDataGenerator.php.
|
protected |
Has the user confirmed their choice?
Definition at line 197 of file LoanDataGenerator.php.
|
protected |
Has the user selected how many records to create?
Definition at line 188 of file LoanDataGenerator.php.
| LoanDataGenerator::WaitForInput | ( | ) |
Entry point. Wait for user input once started.
| Exception |
Definition at line 79 of file LoanDataGenerator.php.
1.8.15