/[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.1 by joko, Tue Dec 3 15:52:53 2002 UTC revision 1.7 by joko, Fri Jun 6 03:57:25 2003 UTC
# Line 1  Line 1 
1  ##    --------------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
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
15    ##    + fix: childnode metadata now gets set propery
16    ##
17    ##    Revision 1.3  2003/01/19 03:15:43  joko
18    ##    + modified header
19    ##
20    ##    Revision 1.2  2003/01/19 02:14:11  joko
21    ##    + proposal for more abstract filesystem-query-interface
22    ##
23  ##    Revision 1.1  2002/12/03 15:52:53  joko  ##    Revision 1.1  2002/12/03 15:52:53  joko
24  ##    + initial check-in  ##    + initial check-in
25  ##  ##    ------------------------------------------------------------------------
 ##    --------------------------------------------------------------------------------  
26    
27    
28  package Data::Storage::Handler::Files;  package Data::Storage::Handler::Files;
# Line 17  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 43  sub getChildNodes { Line 61  sub getChildNodes {
61    #print "======\n";    #print "======\n";
62    $logger->debug( __PACKAGE__ . "->getChildNodes()" );    $logger->debug( __PACKAGE__ . "->getChildNodes()" );
63    #print Dumper($self->{locator});    #print Dumper($self->{locator});
64      my @keys = keys %{$self->{locator}->{files}};
65      $self->{meta}->{childnodes} = \@keys;
66    return $self->{locator}->{files};    return $self->{locator}->{files};
67  }  }
68    
# Line 52  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 {
78      # transform query to searchrules
79      # addSearchRule( ... )
80      # addSearchRule( ... )
81      # addSearchRule( ... )
82      # runSearch( ... )
83      # 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 {
149      
150    }
151    
152    sub runSearch {
153      
154    }
155    
156  1;  1;
157    __END__

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

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