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

Comparing COMP/SCRAM/src/Scram/ScramProjectDB.pm (file contents):
Revision 1.5 by sashby, Wed May 30 12:47:01 2001 UTC vs.
Revision 1.7 by sashby, Fri Nov 9 14:15:15 2001 UTC

# Line 40 | Line 40 | sub file {
40          return $self->{dbfile};
41   }
42  
43 < sub getarea {
44 <        require Configuration::ConfigArea;
45 <        my $self=shift;
46 <        my $name=shift;
47 <        my $version=shift;
48 <
49 <        my $area=undef;
50 <        my $index=$self->_findlocal($name,$version);
51 <        if ( $index != -1 ) {  
52 <         my $location=$self->{projects}[$index][3];
53 <         if ( defined $self->{projectobjects}{$location} ) {
54 <           $area=$self->{projectobjects}{$location};
43 > sub getarea
44 >   {
45 >   require Configuration::ConfigArea;
46 >   my $self=shift;
47 >   my $name=shift;
48 >   my $version=shift;
49 >   my $area=undef;
50 >   my $index=$self->_findlocal($name,$version);
51 >  
52 >   if ( $index != -1 )
53 >      {
54 >      my $location=$self->{projects}[$index][3];
55 >      if ( defined $self->{projectobjects}{$location} )
56 >         {
57 >         $area=$self->{projectobjects}{$location};
58           }
59 <         else {
59 >      else
60 >         {
61           $area=Configuration::ConfigArea->new();
62           $self->verbose("Attempt to ressurect $name $version from $location");
63 <         if ( $area->bootstrapfromlocation($location) == 1 ) {
64 <           undef $area;
65 <           $self->verbose("attempt unsuccessful");
66 <         }
67 <         else {
68 <           $self->verbose("area found");
69 <           $self->{projectobjects}{$location}=$area;
63 >         if ( $area->bootstrapfromlocation($location) == 1 )
64 >            {
65 >            undef $area;
66 >                 $self->verbose("attempt unsuccessful");
67 >            }
68 >         else
69 >            {
70 >            $self->verbose("area found");
71 >            $self->{projectobjects}{$location}=$area;
72 >            }
73           }
74 +      }
75 +   else
76 +      {
77 +      # -- search in linked databases
78 +      foreach $db ( @{$self->{linkeddbs}} )
79 +         {
80 +         $self->verbose("Searching in $db->file() for $name $version");
81 +         $area=$db->getarea($name,$version);
82 +         last if (defined $area);
83           }
84 <        }
85 <        else {
86 <           # -- search in linked databases
87 <           foreach $db ( @{$self->{linkeddbs}} ) {
88 <              $self->verbose("Searching in $db->file() for $name $version");
89 <              $area=$db->getarea($name,$version);
90 <              last if (defined $area);
91 <           }
92 <        }
77 <        if ( ! defined $area ) {
78 <           $self->verbose("Area $name $version not found");
79 <        }
80 <        return $area;
81 < }
84 >      }
85 >   if ( ! defined $area )
86 >      {
87 >      $self->verbose("Area $name $version not found");
88 >      }
89 >
90 >   return $area;
91 >   }
92 >
93  
94   sub addarea {
95          my $self=shift;
# Line 134 | Line 145 | sub list {
145   sub listall {
146          my $self=shift;
147          my @list=$self->list();
148 <
148 >        
149          foreach $db ( @{$self->{linkeddbs}} ) {
150            $self->verbose("Adding list from $db");
151            push @list, $db->listall();
152          }
153 +
154          return @list;
155   }
156  
# Line 159 | Line 171 | sub removearea
171     my $self=shift;
172     my $name=shift;
173     my $version=shift;
174 <
175 <   print "DEBUG: ",$name," ",$version,"\n";
176 <   print "Not yet implemented\n";
174 >   my $vfound=0;
175 >   my $nfound=0;
176 >  
177 >   print "\n","Going to remove $name $version from the current scram database.....","\n";
178 >   print "\n";
179 >
180 >   for ( my $index=0; $index<=$#{$self->{projects}}; $index++ )
181 >      {
182 >      # Look for a project with name $name:
183 >      if  ( $self->{projects}[$index][0] eq $name )
184 >         {
185 >         $nfound=1;
186 >         # Check the version:
187 >         if ( $self->{projects}[$index][1] eq $version )
188 >            {
189 >            # We have a match for project name and version:
190 >            $vfound=1;
191 >            print "Project $name Version $version exists. Remove it? (y/n): ";
192 >            if ( ! (<STDIN>=~/y/i ) )
193 >               {
194 >               print "\n","Aborting project removal...bye.\n\n";
195 >               return 1;
196 >               }
197 >            else
198 >               {
199 >               # Remove the project:
200 >               print "\n";
201 >               print "Removing project:\t$name\t$version","\n\n";
202 >               splice(@{$self->{projects}},$index,1);
203 >               }
204 >            }
205 >         }
206 >      }
207 >  
208 >   if ( ! $nfound || ! $vfound )
209 >      {
210 >      # There was a problem finding either the
211 >      # named project or the desired version:
212 >      print "ERROR: Unable to find project $name with version $version in the database.","\n\n";
213 >      return 1;
214 >      }
215 >  
216 >   print "\n";  
217 >   # Save our new array:
218 >   $self->_save();
219 >   return 0;
220     }
221  
222   sub link {
# Line 176 | Line 231 | sub link {
231   sub unlink {
232          my $self=shift;
233          my $file=shift;
179
234          my $db;
235 +        
236          for (my $i=0; $i<=$#{$self->{linkeddbs}}; $i++ ) {
237             $db=${$self->{linkeddbs}}[$i];
238             if  ( $db->file() eq $file ) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines