/[cvs]/nfo/perl/libs/Data/Mungle/Transform/Map.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Data/Mungle/Transform/Map.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Fri Feb 21 01:49:24 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.2: +6 -3 lines
renamed core function

1 joko 1.1 ## --------------------------------------------------------------------------------
2 joko 1.3 ## $Id: Map.pm,v 1.2 2003/02/14 12:54:30 joko Exp $
3 joko 1.1 ## --------------------------------------------------------------------------------
4 joko 1.2 ## $Log: Map.pm,v $
5 joko 1.3 ## Revision 1.2 2003/02/14 12:54:30 joko
6     ## + established first code here
7     ##
8 joko 1.2 ## Revision 1.1 2003/01/19 03:27:33 joko
9     ## + initial check-in
10     ##
11 joko 1.1 ## --------------------------------------------------------------------------------
12    
13    
14     package Data::Transform::Map;
15    
16     use strict;
17     use warnings;
18    
19     use base 'DesignPattern::Object';
20    
21    
22 joko 1.2 use Data::Dumper;
23     use XML::Simple;
24 joko 1.3 use Data::Transform::Encode qw( utf8_to_latin );
25 joko 1.2 use Data::Compare::Struct qw( getRelations getDifference );
26     use Data::Transform::Deep qw( deep_copy );
27    
28    
29     sub _init {
30     my $self = shift;
31     }
32    
33     sub _touch {
34     my $self = shift;
35     if (!$self->{__meta}->{touched}++) {
36     $self->_readSelectDb();
37     }
38     }
39    
40     sub _readSelectDb {
41     my $self = shift;
42     my $data = XMLin($self->{filename});
43 joko 1.3 utf8_to_latin($data);
44 joko 1.2 $self->{db} = $data;
45     }
46    
47     sub getKeys {
48     my $self = shift;
49     my $source_key = shift;
50     my $source_type = shift;
51    
52     $self->_touch();
53    
54     my $selection = $self->{db}->{source}->{$source_key}->{select} if $source_key;
55     if ($selection) {
56     my @selections = keys %$selection;
57    
58     # TODO: filter @selections by $source_type
59    
60     return @selections;
61     }
62     }
63    
64     sub applyKeyFilter {
65    
66     my $self = shift;
67     my $filterlist = shift;
68    
69     my $data = deep_copy($self->{payload});
70    
71     # calculate intersection
72     my @list = keys %{$data};
73     my $diff = getDifference(\@list, $filterlist);
74    
75     # populate new (filtered) result just using intersected elements
76     my $result;
77     foreach my $elem (@{$diff}) {
78     #$result->{$elem} = $memory->{sports}->{$elem};
79     delete $data->{$elem};
80     }
81    
82     return $data;
83    
84     }
85 joko 1.1
86     1;
87 joko 1.2 __END__

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