File Coverage

blib/lib/Win32/SqlServer/DTS/Task.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Win32::SqlServer::DTS::Task;
2            
3             =head1 NAME
4            
5             Win32::SqlServer::DTS::Task - a Perl base class to access Microsoft SQL Server 2000 DTS tasks
6            
7             =head1 SYNOPSIS
8            
9             use Win32::SqlServer::DTS::Task;
10            
11             # $task is an already instantied class using Win32::OLE
12             my $custom_task = Win32::SqlServer::DTS::Task->new( $task->CustomTaskID, $task->CustomTask );
13            
14             # prints the custom task name
15             print $custom_task->get_name, "\n";
16            
17             =head1 DESCRIPTION
18            
19             C is an base class to be subclassed: one should not use it directly (although it may work). See
20             L for more information about the classed that uses C as part of their inheritance.
21            
22             =head2 EXPORT
23            
24             Nothing.
25            
26             =cut
27            
28 5     5   13769 use strict;
  5         6  
  5         138  
29 5     5   17 use warnings;
  5         6  
  5         100  
30 5     5   16 use Carp qw(confess);
  5         5  
  5         234  
31 5     5   17 use base qw(Win32::SqlServer::DTS);
  5         6  
  5         1651  
32             use Win32::SqlServer::DTS::TaskTypes;
33            
34             =head2 METHODS
35            
36             =head3 new
37            
38             Creates a new C object. It should be overrided by subclasses, since it defines only general attributes.
39             Expects a C object. Returns a new C object.
40            
41             One should not invoke this method directly, unless wants to extended the C API. See L for more
42             information about how to fetch C objects easialy.
43            
44             =cut
45            
46             sub new {
47            
48             my $class = shift;
49             my $task = shift;
50            
51             my $self = { _sibling => $task->CustomTask };
52            
53             bless $self, $class;
54            
55             my $sibling = $self->get_sibling;
56            
57             $self->{name} = $sibling->Name;
58             $self->{description} = $sibling->Description;
59            
60             my $type = Win32::SqlServer::DTS::TaskTypes::convert( $task->CustomTaskID );
61            
62             if ( defined($type) ) {
63            
64             $self->{type} = $type;
65             return $self;
66            
67             }
68             else {
69            
70             confess 'Type '
71             . $sibling->CustomTaskID
72             . ' is not a implemented Win32::SqlServer::DTS::Task subclasses';
73            
74             }
75            
76             }
77            
78             =head3 get_name
79            
80             Returns a string with the name of the task.
81            
82             =cut
83            
84             sub get_name {
85            
86             my $self = shift;
87             return $self->{name};
88            
89             }
90            
91             =head3 get_description
92            
93             Returns a string with the description of the task.
94            
95             =cut
96            
97             sub get_description {
98            
99             my $self = shift;
100             return $self->{description};
101            
102             }
103            
104             =head3 get_type
105            
106             Returns a string of type of the task.
107            
108             =cut
109            
110             sub get_type {
111            
112             my $self = shift;
113             return $self->{type};
114            
115             }
116            
117             =head3 get_properties
118            
119             Deprecated. This method is not as useful as it may be seen, since the to_string method does a better job reporting everything
120             about the Task.
121            
122             =head3 to_string
123            
124             Not implemented. Some tasks fetch their properties in a different manner. Use this method only
125             in subclasses from C.
126            
127             If this method is not override in subclasses it will cause the application to die. Once overrided, it will fetch
128             and return a string with all properties in a nicely manner for printing.
129            
130             =cut
131            
132             sub to_string {
133            
134             confess "print_properties must be defined in a specialized Win32::SqlServer::DTS::Task class\n";
135            
136             }
137            
138             1;
139             __END__