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

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

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

revision 1.3 by joko, Sun Jan 19 03:15:43 2003 UTC revision 1.6 by joko, Tue May 13 16:34:26 2003 UTC
# Line 2  Line 2 
2  ##    $Id$  ##    $Id$
3  ##    ------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
4  ##    $Log$  ##    $Log$
5    ##    Revision 1.6  2003/05/13 16:34:26  joko
6    ##    don't use GUID when building xpq filter
7    ##
8    ##    Revision 1.5  2003/05/13 08:06:13  joko
9    ##    filled "sub sendQuery": query xml document via XPath
10    ##
11    ##    Revision 1.4  2003/02/11 05:17:24  joko
12    ##    + fix: childnode metadata now gets set propery
13    ##
14  ##    Revision 1.3  2003/01/19 03:15:43  joko  ##    Revision 1.3  2003/01/19 03:15:43  joko
15  ##    + modified header  ##    + modified header
16  ##  ##
# Line 22  use base ("Data::Storage::Handler::Abstr Line 31  use base ("Data::Storage::Handler::Abstr
31    
32  use Data::Dumper;  use Data::Dumper;
33  #use Data::Storage::Result::Files;  #use Data::Storage::Result::Files;
34    use Data::Storage::Result::Hash;
35    
36  # get logger instance  # get logger instance
37  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
# Line 48  sub getChildNodes { Line 58  sub getChildNodes {
58    #print "======\n";    #print "======\n";
59    $logger->debug( __PACKAGE__ . "->getChildNodes()" );    $logger->debug( __PACKAGE__ . "->getChildNodes()" );
60    #print Dumper($self->{locator});    #print Dumper($self->{locator});
61      my @keys = keys %{$self->{locator}->{files}};
62      $self->{meta}->{childnodes} = \@keys;
63    return $self->{locator}->{files};    return $self->{locator}->{files};
64  }  }
65    
# Line 57  sub getFileByName { Line 69  sub getFileByName {
69    return $self->{locator}->{files}->{$name};    return $self->{locator}->{files}->{$name};
70  }  }
71    
72    # Query xml file by default.
73    # FIXME: Move most code one level deeper into Data::Storage::Handler::XML.
74  sub sendQuery {  sub sendQuery {
75    # transform query to searchrules    # transform query to searchrules
76    # addSearchRule( ... )    # addSearchRule( ... )
# Line 64  sub sendQuery { Line 78  sub sendQuery {
78    # addSearchRule( ... )    # addSearchRule( ... )
79    # runSearch( ... )    # runSearch( ... )
80    # returnSearchResult( ... )    # returnSearchResult( ... )
81      
82      my $self = shift;
83      my $query = shift;
84      
85      print __PACKAGE__ . ": sendQuery(" . Dumper($query) . ")";
86      
87        my $file = $query->{node};
88        # NEW [2003-04-23]: DataItem compatibility
89        $file ||= $query->{options}->{GUID};
90        
91        if (!$file) {
92          print "Filename was empty!", "\n";
93          return;
94        }
95      
96        # --- from OEF::YAA::Jobs ---
97        # issue the query
98          
99          # V1 - from YAA::Xyz, hardcoded, won't work here
100          #my $xpq = "*/target[\@name=\"$name\"]";
101          
102          # V2 - more generic: XPath query builder (three way fallback)
103          my $xpq;
104          
105          $xpq = $query->{options}->{filter}->{xpq} if ref $query->{options}->{filter};
106          
107          # map a GUID to a xml-name attribute which is searched anywhere ('*/*')
108          #$xpq = '*/' . $query->{options}->{GUID} if (!$xpq && $query->{options}->{GUID});
109          #$xpq = '*/*[@name="' . $query->{options}->{GUID} . '"]' if (!$xpq && $query->{options}->{GUID});
110          
111          $xpq = '*' if !$xpq;
112          #print "xpq: $xpq", "\n";
113          
114          #$xpq = '*/source/select[@key="SOC"]';
115          # decode somehow(?) special escaped quote (") which could reach us as (e.g.):
116          # 'xpq' => '*[@key=\\"SOC\\"]'
117          $xpq =~ s!\\"!"!g;
118          
119          my $mdbe = DesignPattern::Object->fromPackage('Data::Storage::Handler::XML', filename => $file );
120          $mdbe->sendQuery($xpq);
121    
122          # V1 - first attempts
123          #my $subtree = $mdbe->toSimpleTree();
124    
125          # V2 - will cause major behavior change in result!
126          $mdbe->circumflex('result');
127          my $subtree = $mdbe->toEasyTree();
128          $subtree = $subtree->{content}->[0];
129        # --- from OEF::YAA::Jobs ---
130    
131        # V1 - direct mode
132        print "subtree: " . Dumper($subtree);
133        #return $subtree;
134    
135        #print Dumper($query);
136        print "xpq: $xpq", "\n";
137      
138        # V2 - wrapped via a result object providing a more generic api to e.g. iterate through items
139        my $result = Data::Storage::Result::Hash->new( RESULTHANDLE => $subtree );
140        return $result;
141    
142  }  }
143    
144  sub addSearchRule {  sub addSearchRule {
# Line 75  sub runSearch { Line 150  sub runSearch {
150  }  }
151    
152  1;  1;
153    __END__

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

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