Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6b7eb9df TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | +--------------------------------------------------------------------+ | |
906a298c | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * This class generates data for the schema located in Contact.sql | |
20 | * | |
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 | |
24 | * | |
25 | * Data generation is a bit tricky since the data generated | |
26 | * randomly in one table could be used as a FKEY in another | |
27 | * table. | |
28 | * | |
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. | |
32 | * | |
33 | * | |
34 | * | |
35 | * | |
36 | * Some numbers | |
37 | * | |
38 | * Domain ID's - 1 to NUM_DOMAIN | |
39 | * | |
40 | * Context - 3/domain | |
41 | * | |
42 | * Contact - 1 to NUM_CONTACT | |
375fffa8 | 43 | * 80% - Individual |
6a488035 TO |
44 | * 10% - Household |
45 | * 10% - Organization | |
46 | * | |
47 | * Contact to Domain distribution should be equal. | |
48 | * | |
49 | * | |
50 | * Contact Individual = 1 to 0.8*NUM_CONTACT | |
51 | * | |
52 | * Contact Household = 0.8*NUM_CONTACT to 0.9*NUM_CONTACT | |
53 | * | |
54 | * Contact Organization = 0.9*NUM_CONTACT to NUM_CONTACT | |
55 | * | |
56 | * Assumption is that each household contains 4 individuals | |
57 | * | |
58 | */ | |
59 | ||
60 | /** | |
61 | * | |
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. | |
69 | * | |
70 | */ | |
71 | ||
72 | ||
73 | require_once '../civicrm.config.php'; | |
07e41513 | 74 | CRM_Core_Config::singleton(); |
627456b5 | 75 | |
721e8594 | 76 | echo ("Starting data generation on " . date("F dS h:i:s A") . "\n"); |
07e41513 | 77 | try { |
38b93530 TO |
78 | // Generate reproducible data-set |
79 | // $gcd = new CRM_Core_CodeGen_GenerateData('1234', strtotime(date('Y') . '-01-01 02:03:04')); | |
80 | // Generate unique data-set | |
81 | $gcd = new CRM_Core_CodeGen_GenerateData(time(), time()); | |
07e41513 TO |
82 | $gcd->generateAll(); |
83 | } | |
84 | catch (Exception $e) { | |
85 | echo CRM_Core_Error::formatTextException($e); | |
86 | } | |
721e8594 | 87 | echo ("Ending data generation on " . date("F dS h:i:s A") . "\n"); |