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

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

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