Various changes and additions for UCM and testing things
[clearscm.git] / lib / Clearcase / UCM / Project.pm
1 =pod
2
3 =head1 NAME $RCSfile: Project.pm,v $
4
5 Object oriented interface to UCM Projects
6
7 =head1 VERSION
8
9 =over
10
11 =item Author
12
13 Andrew DeFaria <Andrew@ClearSCM.com>
14
15 =item Revision
16
17 $Revision: 1.8 $
18
19 =item Created
20
21 Fri May 14 18:16:16 PDT 2010
22
23 =item Modified
24
25 $Date: 2011/11/15 02:00:58 $
26
27 =back
28
29 =head1 SYNOPSIS
30
31 Provides access to information about Clearcase UCM Projects.
32
33   my $project = new Clearcase::UCM::Project ($name, $folder, $pvob);
34
35 =head1 DESCRIPTION
36
37 This module implements a UCM Project object
38
39 =head1 ROUTINES
40
41 The following routines are exported:
42
43 =cut
44
45 package Clearcase::UCM::Project;
46
47 use strict;
48 use warnings;
49
50 sub new ($$) {
51   my ($class, $name, $folder, $pvob) = @_;
52
53 =pod
54
55 =head2 new
56
57 Construct a new Clearcase Project object.
58
59 Parameters:
60
61 =for html <blockquote>
62
63 =over
64
65 =item project
66
67 Name of project
68
69 =item folder
70
71 Folder object
72
73 =item pvob
74
75 Associated Pvob
76
77 =back
78
79 =for html </blockquote>
80
81 Returns:
82
83 =for html <blockquote>
84
85 =over
86
87 =item Clearcase Project object
88
89 =back
90
91 =for html </blockquote>
92
93 =cut
94
95   $folder = Clearcase::UCM::Folder->new('RootFolder', $pvob) unless $folder;
96
97   $class = bless {
98     name   => $name,
99     folder => $folder,
100     pvob   => $pvob,
101   }, $class; # bless
102     
103   return $class; 
104 } # new
105   
106 sub name () {
107   my ($self) = @_;
108     
109 =pod
110
111 =head2 name
112
113 Returns the name of the project
114
115 Parameters:
116
117 =for html <blockquote>
118
119 =over
120
121 =item none
122
123 =back
124
125 =for html </blockquote>
126
127 Returns:
128
129 =for html <blockquote>
130
131 =over
132
133 =item project's name
134
135 =back
136
137 =for html </blockquote>
138
139 =cut
140
141   return $self->{name};
142 } # name
143
144 sub pvob () {
145   my ($self) = @_;
146   
147 =pod
148
149 =head2 pvob
150
151 Returns the pvob of the project
152
153 Parameters:
154
155 =for html <blockquote>
156
157 =over
158
159 =item none
160
161 =back
162
163 =for html </blockquote>
164
165 Returns:
166
167 =for html <blockquote>
168
169 =over
170
171 =item project's pvob
172
173 =back
174
175 =for html </blockquote>
176
177 =cut
178
179   return $self->{pvob};
180 } # pvob
181   
182 sub create (;$) {
183   my ($self, $opts) = @_;
184
185 =pod
186
187 =head2 create
188
189 Creates a new UCM Project Object
190
191 Parameters:
192
193 =for html <blockquote>
194
195 =over
196
197 =item opts
198
199 Optional parameters for cleartool mkproject command
200
201 =back
202
203 =for html </blockquote>
204
205 Returns:
206
207 =for html <blockquote>
208
209 =over
210
211 =item $status
212
213 Status from cleartool
214
215 =item @output
216
217 Ouput from cleartool
218
219 =back
220
221 =for html </blockquote>
222
223 =cut
224
225   return (0, ()) if $self->exists;
226
227   $opts ||= '';
228
229   return $Clearcase::CC->execute(
230     "mkproject $opts -in " . $self->{folder}->name . '@' . $self->{pvob}->tag .
231     ' '                    . $self->{name}         . '@' . $self->{pvob}->tag
232   );
233 } # create
234
235 sub remove () {
236   my ($self) = @_;
237
238 =pod
239
240 =head2 remove
241
242 Removes UCM Project
243
244 Parameters:
245
246 =for html <blockquote>
247
248 =over
249
250 =for html </blockquote>
251
252 Returns:
253
254 =for html <blockquote>
255
256 =over
257
258 =item $status
259
260 Status from cleartool
261
262 =item @output
263
264 Ouput from cleartool
265
266 =back
267
268 =for html </blockquote>
269
270 =cut
271
272   return $Clearcase::CC->execute 
273     ('rmproject -f ' . $self->{name} . "\@" . $self->{pvob}->name);
274 } # rmProject
275
276 sub exists() {
277   my ($self) = @_;
278
279 =pod
280
281 =head3 exists
282
283 Returns true if the project exists - false otherwise
284
285 Parameters:
286
287 =for html <blockquote>
288
289 =over
290
291 =item none
292
293 =back
294
295 =for html </blockquote>
296
297 Returns:
298
299 =for html <blockquote>
300
301 =over
302
303 =item boolean
304
305 =back 
306
307 =for html </blockquote>
308
309 =cut
310
311   my ($status, @output) = $Clearcase::CC->execute(
312     'lsproject ' . $self->{name} . '@' . $self->{pvob}->name
313   );
314
315   return !$status;
316 } # exists
317
318 1;
319
320 =head1 DEPENDENCIES
321
322 =head2 ClearSCM Perl Modules
323
324 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
325
326 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase/UCM/Folder.pm">Clearcase::UCM::Folder</a></p>
327
328 =head1 INCOMPATABILITIES
329
330 None
331
332 =head1 BUGS AND LIMITATIONS
333
334 There are no known bugs in this module.
335
336 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
337
338 =head1 LICENSE AND COPYRIGHT
339
340 Copyright (c) 2007, ClearSCM, Inc. All rights reserved.
341
342 =cut