3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class generates data for the schema located in Contact.sql
21 * each public method generates data for the concerned table.
22 * so for example the addContactDomain method generates and adds
23 * data to the contact_domain table
25 * Data generation is a bit tricky since the data generated
26 * randomly in one table could be used as a FKEY in another
29 * In order to ensure that a randomly generated FKEY matches
30 * a field in the referened table, the field in the referenced
31 * table is always generated linearly.
38 * Domain ID's - 1 to NUM_DOMAIN
42 * Contact - 1 to NUM_CONTACT
47 * Contact to Domain distribution should be equal.
50 * Contact Individual = 1 to 0.8*NUM_CONTACT
52 * Contact Household = 0.8*NUM_CONTACT to 0.9*NUM_CONTACT
54 * Contact Organization = 0.9*NUM_CONTACT to NUM_CONTACT
56 * Assumption is that each household contains 4 individuals
62 * Note: implication of using of mt_srand(1) in constructor
63 * The data generated will be done in a consistent manner
64 * so as to give the same data during each run (but this
65 * would involve populating the entire db at one go - since
66 * mt_srand(1) is in the constructor, if one needs to be able
67 * to get consistent random numbers then the mt_srand(1) shld
68 * be in each function that adds data to each table.
72 if (!(php_sapi_name() == 'cli' ||
(is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))) {
73 header("HTTP/1.0 404 Not Found");
77 require_once '../civicrm.config.php';
78 CRM_Core_Config
::singleton();
80 echo ("Starting data generation on " . date("F dS h:i:s A") . "\n");
82 // Generate reproducible data-set
83 // $gcd = new CRM_Core_CodeGen_GenerateData('1234', strtotime(date('Y') . '-01-01 02:03:04'));
84 // Generate unique data-set
85 $gcd = new CRM_Core_CodeGen_GenerateData(time(), time());
88 catch (Exception
$e) {
89 echo CRM_Core_Error
::formatTextException($e);
91 echo ("Ending data generation on " . date("F dS h:i:s A") . "\n");