Debian Codegraph @

src/modules/app_perl/lib/perl/Kamailio/VDB/Adapter/Describe.pm

raw
1 #
2 # $Id: Describe.pm 757 2007-01-05 10:56:28Z bastian $
3 #
4 # Perl module for Kamailio
5 #
6 # Copyright (C) 2007 Collax GmbH
7 # (Bastian Friedrich <[email protected]>)
8 #
9 # This file is part of Kamailio, a free SIP server.
10 #
11 # Kamailio is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version
15 #
16 # Kamailio is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #
25
26 =head1 Kamailio::VDB::Adapter::Describe
27
28 This package is intended for debug usage. It will print information about requested
29 functions and operations of a client module.
30
31 Use this module to request schema information when creating new adapters.
32
33 =cut
34
35 package Kamailio::VDB::Adapter::Describe;
36
37 use Kamailio::Constants;
38 use Kamailio qw ( log );
39
40 use Kamailio::VDB;
41 use Kamailio::VDB::Column;
42 use Kamailio::VDB::Result;
43
44 use Data::Dumper;
45
46 our @ISA = qw ( Kamailio::VDB );
47
48 sub use_table {
49 my $self = shift;
50 my $t = shift;
51
52 log(L_INFO, "About to use table $t\n");
53 return 0;
54 }
55
56 sub insert {
57 my $self = shift;
58 my $pairs = shift;
59
60 my $pairs_descr;
61
62 for my $p (@$pairs) {
63 $pairs_descr .= " (key = '".$p->key()."' type = '".$p->type()."' value = '".$p->data()."')";
64 }
65
66 log(L_INFO, "perlvdb:Describe: An insert was found with the following data: $pairs_descr\n");
67
68 return 0;
69
70 }
71
72 sub replace {
73 my $self = shift;
74 return $self->insert(@_);
75 }
76
77 sub update {
78 my $self = shift;
79
80 my $conds = shift;
81 my $pairs = shift;
82
83 my $cond_descr;
84 my $pairs_descr;
85
86 for my $c (@$conds) {
87 $cond_descr .= " (key = '".$c->key()."' op = '".$c->op()."' data = '".$c->data()."')";
88 }
89
90 log(L_INFO, "perlvdb:Describe: An update was found with the following conditions: $cond_descr\n");
91
92 for my $p (@$pairs) {
93 $pairs_descr .= " (key = '".$p->key()."' type = '".$p->type()."' value = '".$p->data()."')";
94 }
95
96 log(L_INFO, "perlvdb:Describe: The following data are to be updated: $pairs_descr\n");
97
98 return 0;
99 }
100
101 sub delete {
102 my $self = shift;
103
104 my $conds = shift;
105 my $cond_descr;
106
107 for my $c (@$conds) {
108 $cond_descr .= " (key = '".$c->key()."' op = '".$c->op()."' data = '".$c->data()."')";
109 }
110
111 log(L_INFO, "perlvdb:Describe: A delete was found with the following conditions: $cond_descr\n");
112
113 return 0;
114 }
115
116 sub query {
117 my $self = shift;
118
119 my $conds = shift;
120 my $retkeys = shift;
121 my $order = shift;
122
123 my $cond_descr;
124 my $keys_descr;
125 my @cols;
126
127 for my $c (@$conds) {
128 $cond_descr .= " (key = '".$c->key()."' op = '".$c->op()."' data = '".$c->data()."')";
129 }
130
131 log(L_INFO, "perlvdb:Describe: A query was found with the following conditions: $cond_descr\n");
132
133 for my $k (@$retkeys) {
134 $keys_descr .= " ($k)";
135 push @cols, new Kamailio::VDB::Column(DB_STRING, $k);
136 }
137 log(L_INFO, "perlvdb:Describe: The following keys were requested: $keys_descr\n");
138 log(L_INFO, "perlvdb:Describe: Order requested: '$order'\n");
139
140 return new Kamailio::VDB::Result(\@cols);
141 }
142
143 1;