20 |
release_lock |
release_lock |
21 |
get_page_header |
get_page_header |
22 |
validate_package |
validate_package |
23 |
|
make_accession |
24 |
|
insert_ch_record |
25 |
|
insert_meta_data |
26 |
|
insert_package_location |
27 |
); |
); |
28 |
|
|
29 |
sub validate_package |
sub validate_package |
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
|
sub make_accession { |
128 |
|
my ($db, $who, $source) = @_; |
129 |
|
my $dbh = $db->{_dbh}; |
130 |
|
my $timestamp = time(); |
131 |
|
my $accession_id; |
132 |
|
|
133 |
|
my $sth = $dbh->prepare(q{INSERT into accession (who, accession_date, comments, source) VALUES (?, ?,?,?)}) or die $dbh->errstr; |
134 |
|
$sth->execute($who, $timestamp, '', $source) or die $dbh->errstr; |
135 |
|
#check the result here. check what execute returne wrt errors |
136 |
|
my $accession_id = $db->get_inserted_id('accession', $sth); |
137 |
|
return $accession_id; |
138 |
|
} |
139 |
|
|
140 |
|
sub insert_ch_record { |
141 |
|
my ($db, $accession_id, $type, $meta_data, $description) = @_; |
142 |
|
my $dbh = $db->{_dbh}; |
143 |
|
my $sth = $dbh->prepare(q{INSERT into clearing_house (accession_id, type, meta_data, description) VALUES (?,?,?,?) }) or die $dbh->errstr; |
144 |
|
$sth->execute($accession_id, $type, $meta_data, $description); |
145 |
|
my $ch_id = $db->get_inserted_id('clearing_house', $sth); |
146 |
|
return $ch_id; |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
sub insert_meta_data { |
151 |
|
my ($dbh, $ch_id, $meta_data) = @_; |
152 |
|
|
153 |
|
my $sth = $dbh->prepare(q{INSERT into meta_data (ch_id, tag, value) VALUES (?, ?,?)}) or die $dbh->errstr; |
154 |
|
my @md = split (/\n/, $meta_data); |
155 |
|
for my $i (@md) { |
156 |
|
my ($tag, $value) = split(/\t/, $i); |
157 |
|
$sth->execute($ch_id, $tag, $value); |
158 |
|
} |
159 |
|
} |
160 |
|
|
161 |
|
sub insert_package_location { |
162 |
|
my ($dbh, $ch_id, $path) = @_; |
163 |
|
my $sth = $dbh->prepare(q{INSERT into package_location (ch_id, pathname) VALUES (?,?)}) or die $dbh->errstr; |
164 |
|
$sth->execute($ch_id, $path); |
165 |
|
|
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
1; |
1; |