3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.12 2003/01/30 22:28:21 joko |
7 |
|
# + implemented new concrete methods |
8 |
|
# |
9 |
|
# Revision 1.11 2002/12/19 16:31:05 joko |
10 |
|
# + sub dropDb |
11 |
|
# + sub rebuildDb |
12 |
|
# |
13 |
|
# Revision 1.10 2002/12/15 02:02:22 joko |
14 |
|
# + fixed logging-message |
15 |
|
# |
16 |
# Revision 1.9 2002/12/05 07:58:20 joko |
# Revision 1.9 2002/12/05 07:58:20 joko |
17 |
# + now using Tie::SecureHash as a base for the COREHANDLE |
# + now using Tie::SecureHash as a base for the COREHANDLE |
18 |
# + former public COREHANDLE becomes private _COREHANDLE now |
# + former public COREHANDLE becomes private _COREHANDLE now |
193 |
sub sendQuery { |
sub sendQuery { |
194 |
my $self = shift; |
my $self = shift; |
195 |
my $query = shift; |
my $query = shift; |
196 |
|
|
197 |
|
$logger->debug( __PACKAGE__ . "->sendQuery" ); |
198 |
|
|
199 |
#my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';"; |
#my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';"; |
200 |
#my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql); |
#my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql); |
201 |
my @crits; |
my @crits; |
215 |
sub eraseAll { |
sub eraseAll { |
216 |
my $self = shift; |
my $self = shift; |
217 |
my $classname = shift; |
my $classname = shift; |
218 |
|
$logger->debug( __PACKAGE__ . "->eraseAll" ); |
219 |
my $sql = "DELETE FROM $classname"; |
my $sql = "DELETE FROM $classname"; |
220 |
$self->sendCommand($sql); |
$self->sendCommand($sql); |
221 |
} |
} |
269 |
return $self->{_COREHANDLE}; |
return $self->{_COREHANDLE}; |
270 |
} |
} |
271 |
|
|
272 |
|
sub dropDb { |
273 |
|
my $self = shift; |
274 |
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
275 |
|
|
276 |
|
$logger->debug( __PACKAGE__ . "->dropDb( dsn $dsn )" ); |
277 |
|
|
278 |
|
$dsn =~ s/database=(.+?);//; |
279 |
|
my $database_name = $1; |
280 |
|
|
281 |
|
my $ok; |
282 |
|
|
283 |
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
284 |
|
PrintError => 0, |
285 |
|
} ) ) { |
286 |
|
if ($database_name) { |
287 |
|
if ($dbh->do("DROP DATABASE $database_name;")) { |
288 |
|
$ok = 1; |
289 |
|
} |
290 |
|
} |
291 |
|
|
292 |
|
$dbh->disconnect(); |
293 |
|
|
294 |
|
} |
295 |
|
|
296 |
|
return $ok; |
297 |
|
} |
298 |
|
|
299 |
|
sub rebuildDb { |
300 |
|
my $self = shift; |
301 |
|
$logger->info( __PACKAGE__ . "->rebuildDb()" ); |
302 |
|
my @results; |
303 |
|
|
304 |
|
# sum up results (bool (0/1)) in array |
305 |
|
#push @results, $self->retreatSchema(); |
306 |
|
push @results, $self->dropDb(); |
307 |
|
push @results, $self->createDb(); |
308 |
|
#push @results, $self->deploySchema(); |
309 |
|
|
310 |
|
# scan array for "bad ones" |
311 |
|
my $res = 1; |
312 |
|
map { |
313 |
|
$res = 0 if (!$_); |
314 |
|
} @results; |
315 |
|
|
316 |
|
return $res; |
317 |
|
} |
318 |
|
|
319 |
|
sub testAvailability { |
320 |
|
my $self = shift; |
321 |
|
my $status = $self->testDsn(); |
322 |
|
$self->{locator}->{status}->{available} = $status; |
323 |
|
return $status; |
324 |
|
} |
325 |
|
|
326 |
|
sub testDsn { |
327 |
|
my $self = shift; |
328 |
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
329 |
|
my $result; |
330 |
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
331 |
|
PrintError => 0, |
332 |
|
} ) ) { |
333 |
|
|
334 |
|
# TODO: REVIEW |
335 |
|
$dbh->disconnect(); |
336 |
|
|
337 |
|
return 1; |
338 |
|
} else { |
339 |
|
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
1; |
1; |
344 |
|
__END__ |