App-Office-Contacts
view release on metacpan or search on metacpan
lib/App/Office/Contacts/Util/Import.pm view on Meta::CPAN
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_email_people_table.
# -----------------------------------------------
sub populate_fake_data
{
my($self) = @_;
$self -> populate_fake_people_table;
$self -> populate_email_addresses_table;
$self -> populate_phone_numbers_table;
$self -> populate_fake_occupation_titles_table;
$self -> populate_fake_organizations_table;
$self -> populate_email_people_table;
$self -> populate_phone_people_table;
$self -> populate_email_organizations_table;
$self -> populate_phone_organizations_table;
return 0;
} # End of populate_fake_data.
# -----------------------------------------------
sub populate_fake_occupation_titles_table
{
my($self) = @_;
my($table_name) = 'occupation_titles';
my($data) = $self -> read_a_file("fake.$table_name.txt");
# Each element of @$data is a hashref: {name => $value, upper_name => $value}.
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_fake_occupation_titles_table.
# -----------------------------------------------
sub populate_fake_organizations_table
{
my($self) = @_;
my($table_name) = 'organizations';
my($data) = $self -> read_a_file("fake.$table_name.txt");
# Each element of @$data is a hashref with these keys:
# visibility_id, communication_type_id, creator_id, role_id, homepage, name.
# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().
for (@$data)
{
$$_{upper_name} = encode('utf-8', uc $$_{name});
$$_{timestamp} = localstamp;
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_fake_organizations_table.
# -----------------------------------------------
sub populate_fake_people_table
{
my($self) = @_;
my($table_name) = 'people';
my($data) = $self -> read_a_file("fake.$table_name.txt");
# Each element of @$data is a hashref with these keys:
# visibility_id, communication_type_id, creator_id, deleted, facebook_tag, gender_id, role_id, title_id, twitter_tag, date_of_birth, given_names, homepage, name, preferred_name, surname.
# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().
for (@$data)
{
# Setting upper_given_names is for the search code.
# See App::Office::Contacts::Controller::Exporter::Search.
$$_{upper_given_names} = encode('utf-8', uc $$_{given_names});
$$_{upper_name} = encode('utf-8', uc $$_{name});
$$_{timestamp} = localstamp;
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_fake_people_table.
# -----------------------------------------------
sub populate_genders_table
{
my($self) = @_;
my($table_name) = 'genders';
my($data) = $self -> read_a_file("$table_name.txt");
# Each element of @$data is a hashref: {name => $value}.
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_genders_table.
# -----------------------------------------------
sub populate_occupation_titles_table
{
my($self) = @_;
my($table_name) = 'occupation_titles';
my($data) = $self -> read_a_file("$table_name.txt");
# Each element of @$data is a hashref: {name => $value, upper_name => $value}.
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_occupation_titles_table.
# -----------------------------------------------
sub populate_organizations_table
{
my($self) = @_;
my($table_name) = 'organizations';
my($data) = $self -> read_a_file("$table_name.txt");
# Each element of @$data is a hashref with these keys:
# visibility_id, communication_type_id, creator_id, deleted, facebook_tag, twitter_tag, role_id, homepage, name.
# Sub read_a_file() decoded the data, so we can use uc() but then have to call encode().
for (@$data)
{
$$_{upper_name} = encode('utf-8', uc $$_{name});
$$_{timestamp} = localstamp;
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_organizations_table.
# -----------------------------------------------
sub populate_phone_number_types_table
{
my($self) = @_;
my($table_name) = 'phone_number_types';
my($data) = $self -> read_a_file("$table_name.txt");
# Each element of @$data is a hashref: {name => $value}.
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_phone_number_types_table.
# -----------------------------------------------
sub populate_phone_numbers_table
{
my($self) = @_;
my($table_name) = 'phone_numbers';
my($data) = $self -> read_a_file("fake.$table_name.txt");
# Each element of @$data is a hashref with these keys:
# phone_number_type_id number
for (@$data)
{
$self -> db -> simple -> insert($table_name, $_);
}
$self -> logger -> log(debug => "Populated table $table_name");
$self -> dump($table_name);
} # End of populate_phone_numbers_table.
# -----------------------------------------------
sub populate_phone_organizations_table
{
my($self) = @_;
( run in 0.870 second using v1.01-cache-2.11-cpan-39bf76dae61 )