/[cvs]/nfo/perl/libs/Data/Storage/Handler/Tangram.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by joko, Mon Dec 16 06:46:09 2002 UTC revision 1.24 by joko, Sun Dec 22 14:13:01 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.24  2002/12/22 14:13:01  joko
7    #  + sub dropDb
8    #
9    #  Revision 1.23  2002/12/19 16:31:53  joko
10    #  +- renamed sub to 'rebuildDb'
11    #
12    #  Revision 1.22  2002/12/18 22:28:16  jonen
13    #  + added extended logging at 'getObjectByGuid()'
14    #
15    #  Revision 1.21  2002/12/16 22:20:49  jonen
16    #  + fixed bug at 'getObjectByGuid()'
17    #
18    #  Revision 1.20  2002/12/16 20:49:17  jonen
19    #  + added sub 'getObjectByGuid()'
20    #  + added functionality to use 'getObjectByGuid' at 'getObjectAsHash()'
21    #
22  #  Revision 1.19  2002/12/16 06:46:09  joko  #  Revision 1.19  2002/12/16 06:46:09  joko
23  #  + attempt to introduce a generic '_patchSchema' - cancelled!  #  + attempt to introduce a generic '_patchSchema' - cancelled!
24  #  #
# Line 355  sub retreatSchema { Line 371  sub retreatSchema {
371    return $ok;    return $ok;
372  }  }
373    
374  sub rebuildDbAndSchema {  sub rebuildDb {
375    my $self = shift;    my $self = shift;
376    $logger->info( __PACKAGE__ . "->rebuildDbAndSchema()" );    $logger->info( __PACKAGE__ . "->rebuildDb()" );
377    my @results;    my @results;
378    
379    # sum up results (bool (0/1)) in array    # sum up results (bool (0/1)) in array
# Line 549  sub getObject { Line 565  sub getObject {
565    return $object if $object;    return $object if $object;
566  }  }
567    
568    sub getObjectByGuid {
569      my $self = shift;
570      my $guid = shift;
571      my $options = shift;
572      
573      # Guid and Classname is needed
574      if(!$guid || !$options->{classname}) {
575       $logger->error( __PACKAGE__ . "->getObjectByGuid: No 'guid' OR no Classname in options hash was given but needed!" );
576        return;
577      }
578      
579      # TODO: create a deep_unload method (currently _all_ objects are unloaded)
580      # unload($oid) will only unload object, not deep object hashes
581      $self->{_COREHANDLE}->unload() if ($options->{destroy});
582    
583      # search for object with given Classname and Guid
584      my $obj_tmp = $self->{_COREHANDLE}->remote($options->{classname});
585      my @result = $self->{_COREHANDLE}->select($obj_tmp, $obj_tmp->{guid} eq $guid);
586      
587      # we searched for global unique identifer of some object,
588      # so I think we can trust there would be only one result
589      if($result[0]) {
590        return $result[0];
591      } else {
592        $logger->error( __PACKAGE__ . "->getObjectByGuid: No Object with Classname $options->{classname} and GUID $guid found!" );
593        return;
594      }
595      
596    }
597    
598  sub getObjectAsHash {  sub getObjectAsHash {
599    my $self = shift;    my $self = shift;
600    my $oid = shift;    my $oid = shift;
601    my $options = shift;    my $options = shift;  
602    my $obj = $self->getObject($oid, $options);    my $obj;
603      
604      if($options->{guid}) {
605        $obj = $self->getObjectByGuid($oid, $options);
606      } else {
607        $obj = $self->getObject($oid, $options);
608      }
609        
610    # build options (a callback to unload autovivified objects) for 'expand'    # build options (a callback to unload autovivified objects) for 'expand'
611    # TODO: use $logger to write to debug here!    # TODO: use $logger to write to debug here!
# Line 596  sub getCOREHANDLE { Line 648  sub getCOREHANDLE {
648    return $self->{_COREHANDLE};    return $self->{_COREHANDLE};
649  }  }
650    
651    sub dropDb {
652      my $self = shift;
653      my $storage = $self->_getSubLayerHandle();
654      return $storage->dropDb();
655    }
656    
657  1;  1;

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.24

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed