| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Win32::SqlServer::DTS::TaskTypes; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =head1 NAME | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | Win32::SqlServer::DTS::TaskTypes - a Perl abstract class to convert DTSTask types to Win32::SqlServer::DTS::Task types. | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | use Win32::SqlServer::DTS::TaskTypes; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | # $task is a DTSTask object | 
| 12 |  |  |  |  |  |  | print Win32::SqlServer::DTS::TaskTypes::convert($task->CustomTaskID), "\n"; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | C convert a value from the C method from a C object to the respective | 
| 17 |  |  |  |  |  |  | type of a C object. Since the types names are not exactly the same, this abstract class is a helper | 
| 18 |  |  |  |  |  |  | to convert those types based on a hardcoded hash table. | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | One should use this class only if intends to extend the C API or create a factory. | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =head2 EXPORT | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | Nothing. | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =cut | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 1 |  |  | 1 |  | 3 | use strict; | 
|  | 1 |  |  |  |  | 0 |  | 
|  | 1 |  |  |  |  | 24 |  | 
| 29 | 1 |  |  | 1 |  | 3 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 30 | 1 |  |  | 1 |  | 8 | use Carp qw(cluck confess); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 168 |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | our %type_convertion = ( | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | DTSDataPumpTask          => 'DataPump', | 
| 35 |  |  |  |  |  |  | DTSDynamicPropertiesTask => 'DynamicProperty', | 
| 36 |  |  |  |  |  |  | DTSExecutePackageTask    => 'ExecutePackage', | 
| 37 |  |  |  |  |  |  | DTSSendMailTask          => 'SendEmail' | 
| 38 |  |  |  |  |  |  | ); | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =head2 METHODS | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head3 convert | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | Expects the string returned from the C from a C object. Returns a string with of the | 
| 45 |  |  |  |  |  |  | respective C. | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | Beware that not all types of C objects are implemented yet. The method will return C on those | 
| 48 |  |  |  |  |  |  | cases. | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | Available types are | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =over | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =item * | 
| 55 |  |  |  |  |  |  | DTSDataPumpTask | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =item * | 
| 58 |  |  |  |  |  |  | DTSDynamicPropertiesTask | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =item * | 
| 61 |  |  |  |  |  |  | DTSExecutePackageTask | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =item * | 
| 64 |  |  |  |  |  |  | DTSSendMailTask | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =back | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =cut | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | sub convert { | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 0 |  |  | 0 | 1 |  | my $type = shift; | 
| 73 |  |  |  |  |  |  |  | 
| 74 | 0 | 0 |  |  |  |  | confess 'Type is an expected parameter' unless ( defined($type) ); | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 0 | 0 |  |  |  |  | if ( exists( $type_convertion{$type} ) ) { | 
| 77 |  |  |  |  |  |  |  | 
| 78 | 0 |  |  |  |  |  | return $type_convertion{$type}; | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  | else { | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  |  | cluck "type $type is unknow"; | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 0 |  |  |  |  |  | return undef; | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | =head3 get_perl_types | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | Returns all known task types from Perldts perspective as an array reference. | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =cut | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | sub get_perl_types { | 
| 98 |  |  |  |  |  |  |  | 
| 99 | 0 |  |  | 0 | 1 |  | return [ values(%type_convertion) ]; | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | =head3 get_types | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | Returns all known task types from MS SQL Server DTS API perspective as an array reference. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =cut | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | sub get_types { | 
| 110 |  |  |  |  |  |  |  | 
| 111 | 0 |  |  | 0 | 1 |  | return [ keys(%type_convertion) ]; | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | 1; | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | __END__ |