1 |
################################# |
############################################ |
2 |
# |
# |
3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.15 2002/12/05 13:55:21 joko |
7 |
|
# + now utilizing 'object2hash' instead of 'var_deref' |
8 |
|
# + played around with having fresh-objects - no progress.... |
9 |
|
# |
10 |
|
# Revision 1.14 2002/12/05 09:40:30 jonen |
11 |
|
# + added option->{destroy} at getObject for unloading all instance |
12 |
|
# |
13 |
|
# Revision 1.13 2002/12/05 07:59:04 joko |
14 |
|
# + now using Tie::SecureHash as a base for the COREHANDLE |
15 |
|
# + former public COREHANDLE becomes private _COREHANDLE now |
16 |
|
# + sub getCOREHANDLE |
17 |
|
# |
18 |
|
# Revision 1.12 2002/12/04 11:34:49 joko |
19 |
|
# - $schema_tangram doesn't have to be in class? |
20 |
|
# |
21 |
|
# Revision 1.11 2002/12/04 08:54:08 jonen |
22 |
|
# + untested bugfix: undef($object) after transform to hash at getObjectAsHash |
23 |
|
# |
24 |
|
# Revision 1.10 2002/12/03 15:53:23 joko |
25 |
|
# + small bugfix regarding object hierarchy |
26 |
|
# |
27 |
|
# Revision 1.9 2002/12/03 05:29:40 joko |
28 |
|
# + sub getObject |
29 |
|
# + sub getObjectAsHash |
30 |
|
# |
31 |
|
# Revision 1.8 2002/12/01 22:25:51 joko |
32 |
|
# + now utilizing metadata from storage locator when connecting to DBI in "raw"-mode |
33 |
|
# |
34 |
|
# Revision 1.7 2002/12/01 04:46:19 joko |
35 |
|
# + sub eraseAll |
36 |
|
# |
37 |
|
# Revision 1.6 2002/11/29 05:02:30 joko |
38 |
|
# - sub getNewPerlObjectByPkgName (moved to libp.pm) |
39 |
|
# + sub getMetaInfo |
40 |
|
# - sub existsChildNode (moved to Abstract.pm) |
41 |
|
# + sub getListUnfiltered |
42 |
|
# + sub getListFiltered |
43 |
|
# + sub createCursor |
44 |
|
# + sub createSet |
45 |
|
# + sub sendQuery |
46 |
|
# |
47 |
# Revision 1.5 2002/11/17 06:35:18 joko |
# Revision 1.5 2002/11/17 06:35:18 joko |
48 |
# + locator metadata can now be reached via ->{locator} |
# + locator metadata can now be reached via ->{locator} |
49 |
# - getChildNodes is now wrapped via COREHANDLE |
# - getChildNodes is now wrapped via COREHANDLE |
66 |
# Revision 1.1 2002/10/10 03:44:07 cvsjoko |
# Revision 1.1 2002/10/10 03:44:07 cvsjoko |
67 |
# + new |
# + new |
68 |
# |
# |
69 |
# |
############################################ |
70 |
################################# |
|
71 |
|
|
72 |
package Data::Storage::Handler::Tangram; |
package Data::Storage::Handler::Tangram; |
73 |
|
|
74 |
use strict; |
use strict; |
75 |
use warnings; |
use warnings; |
76 |
|
|
77 |
|
use base ("Data::Storage::Handler"); |
78 |
use base ("Data::Storage::Handler::Abstract"); |
use base ("Data::Storage::Handler::Abstract"); |
79 |
|
|
80 |
use Tangram; |
use Tangram; |
81 |
use Data::Dumper; |
use Data::Dumper; |
82 |
|
use libp qw( getNewPerlObjectByPkgName ); |
83 |
|
use Data::Storage::Result::Tangram; |
84 |
|
use Data::Compare::Struct qw( isEmpty ); |
85 |
|
use Data::Transform::Deep qw( object2hash ); |
86 |
|
use Data::Transform::Encode qw( var2utf8 ); |
87 |
|
|
88 |
|
|
89 |
# get logger instance |
# get logger instance |
90 |
my $logger = Log::Dispatch::Config->instance; |
my $logger = Log::Dispatch::Config->instance; |
91 |
|
|
92 |
|
|
93 |
our $metainfo = { |
# this holds the complete instantiated schema from tangram |
94 |
'disconnectMethod' => 'disconnect', |
my $schema_tangram; |
|
}; |
|
95 |
|
|
96 |
sub getNewPerlObjectByPkgName { |
sub getMetaInfo { |
97 |
my $pkgname = shift; |
my $self = shift; |
98 |
my $args = shift; |
$logger->debug( __PACKAGE__ . "->getMetaInfo()" ); |
99 |
$logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" ); |
return { |
100 |
my $evstring = "use $pkgname;"; |
'disconnectMethod' => 'disconnect', |
101 |
eval($evstring); |
}; |
|
$@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval $evstring: " . $@ ); |
|
|
return $pkgname->new($args); |
|
102 |
} |
} |
103 |
|
|
104 |
sub _initSchema { |
sub _initSchema { |
105 |
my $self = shift; |
my $self = shift; |
106 |
$logger->debug( __PACKAGE__ . "->_initSchema()" ); |
$logger->debug( __PACKAGE__ . "->_initSchema()" ); |
107 |
#if (!$self->{schema_tangram}) { |
#if (!$schema_tangram) { |
108 |
my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); |
my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); |
109 |
$self->{schema_tangram} = $obj->getSchema(); |
$schema_tangram = $obj->getSchema(); |
110 |
#} |
#} |
111 |
if (!$self->{schema_tangram}) { |
if (!$schema_tangram) { |
112 |
$logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" ); |
$logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" ); |
113 |
return 0; |
return 0; |
114 |
} |
} |
135 |
|
|
136 |
return unless $self->_initSchema(); |
return unless $self->_initSchema(); |
137 |
|
|
138 |
|
# create the main tangram storage object |
139 |
#$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn ); |
#$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn ); |
140 |
$self->{COREHANDLE} = Tangram::Relational->connect( $self->{schema_tangram}, $dsn ); |
$self->{_COREHANDLE} = Tangram::Relational->connect( $schema_tangram, $dsn ); |
141 |
|
|
142 |
|
#print "connect", "\n"; |
143 |
|
#my $core = $self->{_COREHANDLE}; |
144 |
|
#print Dumper($core); |
145 |
|
|
146 |
|
# some attempts for configuring the wrapped underlying dbi..... |
147 |
#$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage(); |
#$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage(); |
148 |
#$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE(); |
#$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE(); |
149 |
#$self->_configureUnderlyingStorage; |
#$self->_configureUnderlyingStorage; |
150 |
|
|
151 |
|
# ..... encapsulation wins! |
152 |
$self->configureCOREHANDLE(); |
$self->configureCOREHANDLE(); |
153 |
|
|
154 |
$self->{locator}->{status}->{connected} = 1; |
$self->{locator}->{status}->{connected} = 1; |
167 |
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
168 |
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
169 |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
170 |
|
|
171 |
|
# todo: should we retrieve information from the schema here |
172 |
|
# rather than poorly getting table names from underlying dbi? |
173 |
my $storage = $self->_getSubLayerHandle(); |
my $storage = $self->_getSubLayerHandle(); |
174 |
@nodes = @{$storage->getChildNodes()}; |
@nodes = @{$storage->getChildNodes()}; |
175 |
#$storage->_configureCOREHANDLE(); |
#$storage->_configureCOREHANDLE(); |
177 |
#print Dumper($self); |
#print Dumper($self); |
178 |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
179 |
|
|
180 |
$storage->disconnect(); |
# TODO: REVIEW |
181 |
|
#$storage->disconnect(); |
182 |
|
|
183 |
$self->{meta}->{childnodes} = \@nodes; |
$self->{meta}->{childnodes} = \@nodes; |
184 |
|
|
187 |
} |
} |
188 |
|
|
189 |
|
|
|
sub existsChildNode { |
|
|
my $self = shift; |
|
|
my $nodename = shift; |
|
|
$logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); |
|
|
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
|
|
#print Dumper($self->{meta}->{childnodes}); |
|
|
return grep $nodename, @{$self->{meta}->{childnodes}}; |
|
|
} |
|
|
|
|
|
|
|
190 |
sub testIntegrity { |
sub testIntegrity { |
191 |
|
|
192 |
my $self = shift; |
my $self = shift; |
247 |
foreach my $key (keys %{$self->{dbi}}) { |
foreach my $key (keys %{$self->{dbi}}) { |
248 |
my $val = $self->{dbi}->{$key}; |
my $val = $self->{dbi}->{$key}; |
249 |
print "entry: $key; $val", "\n"; |
print "entry: $key; $val", "\n"; |
250 |
$self->{COREHANDLE}->{db}->{$key} = $val; |
$self->{_COREHANDLE}->{db}->{$key} = $val; |
251 |
} |
} |
252 |
#print Dumper($self->{COREHANDLE}->{db}); |
#print Dumper($self->{COREHANDLE}->{db}); |
253 |
} |
} |
263 |
|
|
264 |
# apply configured modifications |
# apply configured modifications |
265 |
if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) { |
if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) { |
266 |
$self->{COREHANDLE}->{db}->trace($self->{dbi}->{trace_level}, $self->{dbi}->{trace_file}); |
$self->{_COREHANDLE}->{db}->trace($self->{dbi}->{trace_level}, $self->{dbi}->{trace_file}); |
267 |
} |
} |
268 |
if (exists $self->{dbi}->{RaiseError}) { |
if (exists $self->{dbi}->{RaiseError}) { |
269 |
$self->{COREHANDLE}->{db}->{RaiseError} = $self->{dbi}->{RaiseError}; |
$self->{_COREHANDLE}->{db}->{RaiseError} = $self->{dbi}->{RaiseError}; |
270 |
} |
} |
271 |
if (exists $self->{dbi}->{PrintError}) { |
if (exists $self->{dbi}->{PrintError}) { |
272 |
$self->{COREHANDLE}->{db}->{PrintError} = $self->{dbi}->{PrintError}; |
$self->{_COREHANDLE}->{db}->{PrintError} = $self->{dbi}->{PrintError}; |
273 |
} |
} |
274 |
if (exists $self->{dbi}->{HandleError}) { |
if (exists $self->{dbi}->{HandleError}) { |
275 |
$self->{COREHANDLE}->{db}->{HandleError} = $self->{dbi}->{HandleError}; |
$self->{_COREHANDLE}->{db}->{HandleError} = $self->{dbi}->{HandleError}; |
276 |
} |
} |
277 |
|
|
278 |
} |
} |
282 |
my $args = shift; |
my $args = shift; |
283 |
|
|
284 |
my $dsn = $self->{locator}->{dbi}->{dsn}; |
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
#my $dsn = $self->{dbi}->{dsn}; |
|
285 |
|
|
286 |
$logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" ); |
$logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" ); |
287 |
|
|
288 |
my $ok; |
my $ok; |
289 |
# TODO: is this DBI->connect okay here like it is? regarding errors.....??? |
if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) { |
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
|
|
PrintError => 0, |
|
|
} ) ) { |
|
|
|
|
290 |
return unless $self->_initSchema(); |
return unless $self->_initSchema(); |
291 |
|
$ok = Tangram::Relational->deploy($schema_tangram, $dbh ); |
|
$ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh ); |
|
292 |
$dbh->disconnect(); |
$dbh->disconnect(); |
293 |
} |
} |
294 |
return $ok; |
return $ok; |
298 |
|
|
299 |
my $self = shift; |
my $self = shift; |
300 |
my $dsn = $self->{locator}->{dbi}->{dsn}; |
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
#my $dsn = $self->{dbi}->{dsn}; |
|
301 |
|
|
302 |
$logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" ); |
$logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" ); |
303 |
|
|
304 |
my $ok; |
my $ok; |
305 |
if ( my $dbh = DBI->connect($dsn, '', '', { |
if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) { |
|
#PrintError => 0, |
|
|
#RaiseError => 0, |
|
|
} ) ) { |
|
306 |
|
|
307 |
return unless $self->_initSchema(); |
return unless $self->_initSchema(); |
308 |
|
|
309 |
#use Data::Dumper; print Dumper($self); |
#use Data::Dumper; print Dumper($self); |
310 |
$self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11"); |
$self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11"); |
311 |
|
|
312 |
$ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh ); |
$ok = Tangram::Relational->retreat($schema_tangram, $dbh ); |
313 |
$ok = 2; # answer is "maybe" for now since Tangram::Relational->retreat doesn't seem to return a valid status |
|
314 |
# idea: test this by checking for count of tables in database - |
# answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because... |
315 |
# problem with this: there may be some left not having been included to the schema |
# - ... Tangram::Relational->retreat doesn't seem to return a valid status |
316 |
|
# - possible improvement: |
317 |
|
# - test this by checking for count of tables in database |
318 |
|
# - problem with this: there may be some left not having been included to the schema |
319 |
|
# - maybe better: use "->getChildNodes"? |
320 |
|
$ok = 2; |
321 |
|
|
322 |
$dbh->disconnect(); |
$dbh->disconnect(); |
323 |
|
|
324 |
} |
} |
325 |
return $ok; |
return $ok; |
326 |
} |
} |
345 |
return $res; |
return $res; |
346 |
} |
} |
347 |
|
|
348 |
|
sub getListUnfiltered { |
349 |
|
my $self = shift; |
350 |
|
my $nodename = shift; |
351 |
|
my @results; |
352 |
|
$logger->debug( __PACKAGE__ . "->getListUnfiltered( nodename => '" . $nodename . "' )" ); |
353 |
|
# get set of objects from odbms by object name |
354 |
|
my $object_set = $self->{_COREHANDLE}->remote($nodename); |
355 |
|
@results = $self->{_COREHANDLE}->select($object_set); |
356 |
|
return \@results; |
357 |
|
} |
358 |
|
|
359 |
|
sub getListFiltered { |
360 |
|
my $self = shift; |
361 |
|
|
362 |
|
# redirect to unfiltered mode |
363 |
|
#return $self->getListUnfiltered(@_); |
364 |
|
|
365 |
|
my $nodename = shift; |
366 |
|
my $filters = shift; |
367 |
|
my @results; |
368 |
|
$logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $nodename . "' )" ); |
369 |
|
|
370 |
|
#print Dumper($filters); |
371 |
|
|
372 |
|
my @tfilters; |
373 |
|
|
374 |
|
foreach my $filter (@$filters) { |
375 |
|
|
376 |
|
# get filter - TODO: for each filter |
377 |
|
#my $filter = $filters->[0]; |
378 |
|
|
379 |
|
# build filter |
380 |
|
my $lexpr = $filter->{key}; |
381 |
|
#my $op = $filter->{op}; |
382 |
|
my $op = '='; |
383 |
|
my $rexpr = $filter->{val}; |
384 |
|
my $tight = 100; |
385 |
|
|
386 |
|
# my $tfilter = Tangram::Filter->new( |
387 |
|
# expr => "t1.$lexpr $op '$rexpr'", |
388 |
|
# tight => $tight, |
389 |
|
# objects => $objects, |
390 |
|
# ); |
391 |
|
|
392 |
|
# HACK: build eval-string (sorry) to get filtered list - please give advice here |
393 |
|
push @tfilters, '$remote->{' . $filter->{key} . '}' . " $filter->{op} '$filter->{val}'"; |
394 |
|
|
395 |
|
} |
396 |
|
|
397 |
|
my $tfilter = join(' & ', @tfilters); |
398 |
|
|
399 |
|
# get set of objects from odbms by object name |
400 |
|
my $remote = $self->{_COREHANDLE}->remote($nodename); |
401 |
|
|
402 |
|
# was: |
403 |
|
#@results = $self->{COREHANDLE}->select($object_set, $tfilter); |
404 |
|
|
405 |
|
# is: |
406 |
|
# HACK: build eval-string (sorry) to get filtered list - please give advice here |
407 |
|
my $evalstring = 'return $self->{_COREHANDLE}->select($remote, ' . $tfilter . ');'; |
408 |
|
|
409 |
|
# get filtered list/set |
410 |
|
@results = eval($evalstring); |
411 |
|
die $@ if $@; |
412 |
|
|
413 |
|
return \@results; |
414 |
|
} |
415 |
|
|
416 |
|
sub createCursor { |
417 |
|
my $self = shift; |
418 |
|
my $node = shift; |
419 |
|
my $cmdHandle = $self->{_COREHANDLE}->cursor($node); |
420 |
|
my $result = Data::Storage::Result::Tangram->new( RESULTHANDLE => $cmdHandle ); |
421 |
|
return $result; |
422 |
|
} |
423 |
|
|
424 |
|
sub createSet { |
425 |
|
my $self = shift; |
426 |
|
my @objects = @_; |
427 |
|
my $rh = Set::Object->new(); |
428 |
|
foreach (@objects) { |
429 |
|
#print Dumper($_); |
430 |
|
$rh->insert($_) if !isEmpty($_); |
431 |
|
} |
432 |
|
#print Dumper($rh->members()); |
433 |
|
my $result = Data::Storage::Result::Tangram->new( RESULTHANDLE => $rh ); |
434 |
|
return $result; |
435 |
|
} |
436 |
|
|
437 |
|
sub sendQuery { |
438 |
|
my $self = shift; |
439 |
|
my $query = shift; |
440 |
|
#my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';"; |
441 |
|
#my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql); |
442 |
|
|
443 |
|
#print Dumper($query); |
444 |
|
|
445 |
|
# HACK: special case: querying by id does not translate into a common tangram query |
446 |
|
# just load the object by given id(ent) |
447 |
|
if ($query->{criterias}->[0]->{key} eq 'id' && $query->{criterias}->[0]->{op} eq 'eq') { |
448 |
|
#print "LOAD!!!", "\n"; |
449 |
|
#exit; |
450 |
|
#return Set::Object->new( $self->{COREHANDLE}->load($query->{criterias}->[0]->{val}) ); |
451 |
|
my $ident = $query->{criterias}->[0]->{val}; |
452 |
|
#print "load obj", "\n"; |
453 |
|
#return $self->createSet() if $ident == 5; |
454 |
|
my $object = $self->{_COREHANDLE}->load($ident); |
455 |
|
#print "get id", "\n"; |
456 |
|
my $oid = $self->{_COREHANDLE}->id($object); |
457 |
|
return $self->createSet($object); |
458 |
|
#return $self->createSet( $self->{COREHANDLE}->load('300090018') ); |
459 |
|
} |
460 |
|
|
461 |
|
die("This should not be reached for now - redirect to \$self->getListFiltered() here!"); |
462 |
|
|
463 |
|
# TODO: do a common tangram query here |
464 |
|
|
465 |
|
my @crits; |
466 |
|
foreach (@{$query->{criterias}}) { |
467 |
|
my $op = ''; |
468 |
|
$op = '=' if lc $_->{op} eq 'eq'; |
469 |
|
push @crits, "$_->{key}$op'$_->{val}'"; |
470 |
|
} |
471 |
|
my $subnodes = {}; |
472 |
|
map { $subnodes->{$_}++ } @{$query->{subnodes}}; |
473 |
|
# HACK: this is hardcoded ;( expand possibilities! |
474 |
|
#my $crit = join(' AND ', @crits); |
475 |
|
#my $sql = hash2Sql($query->{node}, $subnodes, 'SELECT', $crit); |
476 |
|
#return $self->sendCommand($sql); |
477 |
|
#my $h = $self->{COREHANDLE}->remote($query->{node}); |
478 |
|
#my $res = $self->{COREHANDLE}->select($h, $h->{); |
479 |
|
return $self->createCursor($query->{node}); |
480 |
|
} |
481 |
|
|
482 |
|
sub eraseAll { |
483 |
|
my $self = shift; |
484 |
|
my $classname = shift; |
485 |
|
my $remote = $self->{_COREHANDLE}->remote($classname); |
486 |
|
my @objs = $self->{_COREHANDLE}->select($remote); |
487 |
|
$self->{_COREHANDLE}->erase(@objs); |
488 |
|
} |
489 |
|
|
490 |
|
sub createDb { |
491 |
|
my $self = shift; |
492 |
|
my $storage = $self->_getSubLayerHandle(); |
493 |
|
return $storage->createDb(); |
494 |
|
} |
495 |
|
|
496 |
|
sub getObject { |
497 |
|
my $self = shift; |
498 |
|
my $oid = shift; |
499 |
|
my $options = shift; |
500 |
|
# TODO: create a deep_unload method |
501 |
|
# unload($oid) will only unload object, not deep object hashes |
502 |
|
$self->{_COREHANDLE}->unload() if($options->{destroy}); |
503 |
|
# TODO: review this |
504 |
|
#if (!$self->{COREHANDLE}) { return; } |
505 |
|
return $self->{_COREHANDLE}->load($oid); |
506 |
|
} |
507 |
|
|
508 |
|
sub getObjectAsHash { |
509 |
|
my $self = shift; |
510 |
|
my $oid = shift; |
511 |
|
my $options = shift; |
512 |
|
my $obj = $self->getObject($oid, $options); |
513 |
|
|
514 |
|
# build options (a callback to unload autovivified objects) for 'expand' |
515 |
|
# TODO: use $logger to write to debug here! |
516 |
|
my $cb; # = sub {}; |
517 |
|
=pod |
518 |
|
if ($options->{destroy}) { |
519 |
|
$options->{cb}->{destroy} = sub { |
520 |
|
print "================ DESTROY", "\n"; |
521 |
|
my $object = shift; |
522 |
|
#print Dumper($object); |
523 |
|
$self->{_COREHANDLE}->unload($object); |
524 |
|
#undef($object); |
525 |
|
}; |
526 |
|
} |
527 |
|
=cut |
528 |
|
|
529 |
|
my $hash = object2hash($obj, $options); |
530 |
|
#$options->{cb}->{destroy}->($obj); |
531 |
|
#$self->{_COREHANDLE}->unload($obj); |
532 |
|
|
533 |
|
# convert values in hash to utf8 to be ready for (e.g.) encapsulation in XML |
534 |
|
# now done in object2hash |
535 |
|
#var2utf8($hash) if ($options->{utf8}); |
536 |
|
|
537 |
|
# old (wrong) attempts to get rid of used instances, if requested |
538 |
|
#$obj->clear_refs; |
539 |
|
#$self->{COREHANDLE}->unload($obj) if($options->{destroy}); |
540 |
|
#$obj->DESTROY; |
541 |
|
#undef($obj) if($options->{destroy}); |
542 |
|
|
543 |
|
return $hash; |
544 |
|
} |
545 |
|
|
546 |
|
sub getSchema { |
547 |
|
return $schema_tangram; |
548 |
|
} |
549 |
|
|
550 |
|
sub getCOREHANDLE { |
551 |
|
my $self = shift; |
552 |
|
return $self->{_COREHANDLE}; |
553 |
|
} |
554 |
|
|
555 |
1; |
1; |