ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/UserQuery.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/UserQuery.pm (file contents):
Revision 1.2 by williamc, Mon Sep 20 16:27:58 1999 UTC vs.
Revision 1.4 by williamc, Mon Oct 25 15:09:21 1999 UTC

# Line 1 | Line 1
1   #
2   #  UserQuery
3   #
4 < #  Set up and record Queries requested fromthe user
4 > #  Set up and record Queries requested from the user
5   #
6   # Interface
7   # ---------
8   # new(UserInterface)    : A new query object with a specific interface
9 + # dump(fh,expr)         : dump out parameters that match expr to filehandle
10 + # store(fh)             : dump every param to fh
11 + # restore(fh)           : restore from filehandle
12 + # params()              : return list of all params
13   # setparam(name,value)  : set a parameter
14   # setifundef(name,value) : only set param to value if undefined
15   # getparam(name)        : return value of named parameter
16   # clearquery()          : remove all queries to be asked
17 < # setquery($type,$parameter,@args) : register a query of type for $parameter
17 > # setquery($type,$parameter,$string,@args) : register a query of type for
18 > #                                               $parameter
19 > # querycheck(name, checkobject) : Set a checksum to be made on each query
20 > # addquerymessage(name,string) : Add an extra message to the query for name
21   # askuser()             : Ask user registered queries
22   # formatquery(args)     : apply formatting information for display
23   #                                 of the query . args dependent on implemtation
# Line 30 | Line 37 | sub new {
37          return $self;
38   }
39  
40 + sub dump {
41 +        my $self=shift;
42 +        my $fh=shift;
43 +        my $string=shift;
44 +
45 +        foreach $key ( %{$self->{params}} ) {
46 +          if ( $key=~/$string/ ) {
47 +                print $fh "k:".$key."\n";
48 +                print $fh "v:".$$self->{params}{$key}."\n";
49 +          }
50 +        }
51 +        print $fh "#End\n";
52 + }
53 +
54 + sub store {
55 +        my $self=shift;
56 +        my $fh=shift;
57 +
58 +        my $key;
59 +        foreach $key ( keys %{$self->{params}} ) {
60 +          print "$fh $key\n";
61 +          print $fh "k:".$key."\n";
62 +          print $fh "v:".$self->{params}{$key}."\n";
63 +        }
64 +        print $fh "#End\n";
65 + }
66 +
67 + sub restore {
68 +        my $self=shift;
69 +        my $fh=shift;
70 +
71 +        my $check="k:";
72 +        my $key="";
73 +        while ( $line=<$fh> ) {
74 +          chomp $line;
75 +          last if ( $line eq "\#End" );
76 +          if ( $line!~/^$check/ ) {
77 +                die "Data Corruption Error when restoring $self\n";
78 +          }
79 +          if ( $check eq "k:" ) {
80 +                $check="v:";
81 +                ($key=$line)=~s/k://;
82 +          }
83 +          else {
84 +                $check="k:";
85 +                ($value=$line)=~s/v://;
86 +                $self->setparam($key,$value);
87 +          }
88 +        } #end while
89 + }
90 +
91   sub setparam {
92          my $self=shift;
93          my $name=shift;
94          my $value=shift;
95  
96 +        print "Setting $name = $value\n";
97          $self->{params}{$name}=$value;
98   }
99  
100 + sub params {
101 +        my $self=shift;
102 +        
103 +        return ( keys %{$self->{params}} );
104 + }
105 +
106   sub setifundef {
107          my $self=shift;
108          my $name=shift;
# Line 77 | Line 142 | sub setquery {
142          }
143   }
144  
145 + sub querycheck {
146 +        my $self=shift;
147 +        my $name=shift;
148 +        my $check=shift;
149 +
150 +        $self->{querycheck}{$name}=$check;
151 + }
152 +
153 + sub addquerymessage {
154 +        my $self=shift;
155 +        my $name=shift;
156 +        my $string=shift;
157 +        $self->{querystring}{$name}=$self->{querystring}{$name}.$string;        
158 + }
159 +
160   sub formatquery {
161          my $self=shift;
162  
# Line 88 | Line 168 | sub askuser {
168          my $self=shift;
169          my $string=shift;
170  
171 <        $self->{UserInterface}->startform();
171 >        $self->{UserInterface}->startform($string);
172          foreach $query ( @{$self->{queries}} ) {
173 <          $self->{UserInterface}->runquery($self->{querytype}{$query},
174 <                $query, $self->{querystring}{$query},
175 <                $self->{queryvars}{$query}, $self->{queryformat}{$name});
173 >          my @rqargs=($self->{querytype}{$query}, $query,
174 >                $self->{querystring}{$query},
175 >                $self->{queryvars}{$query}, $self->{queryformat}{$query});
176 >          if ( exists $self->{querycheck}{$query} ) {
177 >             $self->{UserInterface}->runcheckedquery(  
178 >                                $self->{querycheck}{$query}, @rqargs);
179 >          }
180 >          else {
181 >             $self->{UserInterface}->runquery(@rqargs);
182 >          }
183          }
184          $self->{UserInterface}->endform($self);
185   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines