use File::Spec;
use File::Basename;
use DBI;
+use Cwd qw/abs_path getcwd/;
-my ($dbhost, $dbport, $dbname, $dbuser, $dbpw, $help, $admin_user, $admin_pw);
+my ($dbhost, $dbport, $dbname, $dbuser, $dbpw, $help, $admin_user, $admin_pw, $load_all, $load_concerto);
my $config_file = '';
my $build_db_sh = '';
my $offline_file = '';
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+my $cwd = getcwd();
+
# Get the directory for this script
-my $script_dir = dirname($0);
+my $script_dir = abs_path(dirname($0));
+
+# Set the location and base file for sample data
+my $_sample_dir = abs_path(File::Spec->catdir($script_dir, '../../tests/datasets/sql/'));
+my $_sample_all = 'load_all.sql';
+my $_sample_concerto = 'load_concerto.sql';
=over
chdir($script_dir);
}
+=item load_sample_data() - Loads sample bib records, copies, users, and transactions
+=cut
+sub load_sample_data {
+ my $settings = shift;
+
+ my $load_script = $_sample_all;
+ chdir($_sample_dir);
+ if ($load_concerto) {
+ $load_script = $_sample_concerto;
+ }
+ $ENV{'PGUSER'} = $settings->{user};
+ $ENV{'PGPASSWORD'} = $settings->{pw};
+ $ENV{'PGPORT'} = $settings->{port};
+ $ENV{'PGHOST'} = $settings->{host};
+ $ENV{'PGDATABASE'} = $settings->{db};
+ my @output = `psql -f $load_script 2>&1`;
+ print @output;
+ chdir($cwd);
+}
+
=item set_admin_account() - Sets the administrative user's user name and password
=cut
sub set_admin_account {
GetOptions("create-schema" => \$cschema,
"create-database" => \$cdatabase,
+ "load-all-sample" => \$load_all,
+ "load-concerto-sample" => \$load_concerto,
"create-offline" => \$offline,
"update-config" => \$uconfig,
"config-file=s" => \$config_file,
if ($admin_user && $admin_pw) {
set_admin_account($admin_user, $admin_pw, \%settings);
}
+if ($load_all || $load_concerto) {
+ load_sample_data(\%settings);
+}
if ($offline) { create_offline_config($offline_file, \%settings); }
-if ((!$cdatabase && !$cschema && !$uconfig && !$offline && !$admin_pw) || $help) {
+if ((!$cdatabase && !$cschema && !$load_all && !$load_concerto && !$uconfig && !$offline && !$admin_pw) || $help) {
print <<HERE;
SYNOPSIS
Creates the database itself, provided the user and password options
represent a superuser.
+ --load-all-sample
+ Loads all sample data, including bibliographic records, call numbers,
+ copies, users, and transactions.
+
+ --load-concerto-sample
+ Loads a subset of sample data that includes just 100 bibliographic
+ records, and associated call numbers and copies.
+
SERVICE OPTIONS
--service
Specify "all" or one or more of the following services to update:
--- /dev/null
+New feature: loading sample data
+================================
+One common need for people evaluating Evergreen, as well as for developers,
+writers, and testers, is a set of sample data that can be easily loaded into
+the Evergreen database and provide a consistent set of results for testing
+and training purposes.
+
+This release features sets of sample data consisting of:
+
+* 100 bibliographic records retrievable via a "concerto" keyword search
+* 100 French bibliographic records
+* Associated call numbers, copies, parts, and conjoined items
+* Patron accounts, including some recently expired patrons
+* Circulation transactions, including some holds and some overdue items
+
+To load the sample data into a freshly installed Evergreen database, you can
+pass the following arguments to the `eg_db_config` script (either when you are
+creating the initial database schema, or as a separate call after creating the
+database schema):
+
+* `--load-all-sample`: Loads all sample data, including bibliographic records,
+ call numbers, copies, users, and transactions.
+* `--load-concerto-sample`: Loads a subset of sample data that includes just
+ 100 bibliographic records, and associated call numbers and copies.