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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations)
Tue May 13 16:34:26 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
Changes since 1.5: +5 -2 lines
don't use GUID when building xpq filter

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

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