# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-my $n = 100; # number of patrons to generate
+#my $n = 100; # number of patrons to generate
+my $n = 134; # staff
###############################################
# examples
-my @profiles = ( 2 );
+my @profiles = ( 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15 );
my @ident_types = ( 1, 3 );
my @home_ou = ( 4, 5, 6, 7, 8, 9 );
+
+my @prof_org;
+for my $prof (@profiles) {
+ for my $org (@home_ou) {
+ # 2 of each
+ push(@prof_org, [$prof, $org]);
+ push(@prof_org, [$prof, $org]);
+ }
+}
+# add a couple of global admins
+push(@prof_org, [13, 4]);
+push(@prof_org, [13, 6]);
###############################################
my @last_names = ();
my @adjectives = ();
my @zips = (); my %zip = {};
+my $is_staff = $ARGV[6];
+
sub gen_sql {
my ($profile, $ident_type, $usrname, $home_ou, $family_name, $passwd, $first_given_name, $second_given_name, $expire_date, $dob, $suffix) =
(shift, shift, shift, shift, shift, shift, shift, shift, shift, shift,shift);
credit_forward_balance = '0',
mailing_address = CURRVAL('actor.usr_address_id_seq')
WHERE id=CURRVAL('actor.usr_id_seq');
+SQL
+
+ if ($is_staff) {
+ print <<SQL;
+INSERT INTO permission.usr_work_ou_map (usr, work_ou)
+ VALUES (CURRVAL('actor.usr_id_seq'), $home_ou);
+
+UPDATE actor.usr usr SET usrname = LOWER(aou.shortname) || usrname
+ FROM actor.org_unit aou
+ WHERE usr.id = CURRVAL('actor.usr_id_seq') AND aou.id = $home_ou;
SQL
+ }
}
if ( ! $ARGV[0] && ! $ARGV[1] && ! $ARGV[2] && ! $ARGV[3] && ! $ARGV[4] && ! $ARGV[5] ) {
}
}
-# my $usrname;
-# while(true) {
-# my $usrname_suffix = int(rand(1000));
-# $usrname = rand(100) > 50 ? $barcode : lc($nouns[ int(rand( scalar(@nouns) )) ] . $usrname_suffix);
-# if (! defined $seen_usrname{$usrname} ) {
-# $seen_usrname{$usrname} = 1;
-# last;
-# }
-# }
-
my $fname = $gender > 50 ?
$male_names[ int(rand( scalar(@male_names) )) ] :
$female_names[ int(rand( scalar(@female_names) )) ];
my $lname = $last_names[ int(rand( scalar(@last_names) )) ];
+ my $usrname = $barcode;
+ $usrname = lc(substr($fname, 0, 1) . $lname) if $is_staff;
+ $seen_usrname{$usrname} = 1;
+
+# my $usrname;
+# while(true) {
+# my $usrname_suffix = int(rand(1000));
+# $usrname = rand(100) > 50 ? $barcode : lc($nouns[ int(rand( scalar(@nouns) )) ] . $usrname_suffix);
+# if (! defined $seen_usrname{$usrname} ) {
+# $seen_usrname{$usrname} = 1;
+# last;
+# }
+# }
+
+
+ my $prof_org = pop(@prof_org);
gen_sql(
- $profiles[ int(rand( scalar(@profiles) )) ], # profile
+ #$profiles[ int(rand( scalar(@profiles) )) ], # profile
+ $$prof_org[0],
$ident_types[ int(rand( scalar(@ident_types) )) ], # ident_type
- $barcode, # usrname
- $home_ou[ int(rand( scalar(@home_ou) )) ], # home_ou
+ $usrname,
+ #$home_ou[ int(rand( scalar(@home_ou) )) ], # home_ou
+ $$prof_org[1],
$lname, # family_name;
lc($fname . substr($lname, 0, 1) . '1234'), # passwd
$fname, # first_given_name
$barcode, # barcode
);
}
+
print "COMMIT;\n";