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