line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::SqlServer::DTS::Assignment::Destination;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Win32::SqlServer::DTS::Assignment::Destination - abstract class to represent a destination string of a DTS DynamicPropertiesTaskAssignment object.
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use warnings;
|
10
|
|
|
|
|
|
|
use strict;
|
11
|
|
|
|
|
|
|
use Win32::SqlServer::DTS::Application;
|
12
|
|
|
|
|
|
|
my $xml = XML::Simple->new();
|
13
|
|
|
|
|
|
|
my $config = $xml->XMLin('test-config.xml');
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $app = Win32::SqlServer::DTS::Application->new($config->{credential});
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $package =
|
18
|
|
|
|
|
|
|
$app->get_db_package(
|
19
|
|
|
|
|
|
|
{ id => '', version_id => '', name => $config->{package}, package_password => '' } );
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# checking out all destination string from all assignments from
|
22
|
|
|
|
|
|
|
# all Dynamic Property tasks of a package
|
23
|
|
|
|
|
|
|
my $iterator = $package->get_dynamic_props();
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
while ( my $dyn_prop = $iterator->() ) {
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $assign_iterator = $dyn_props->get_assignments;
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
while ( my $assignment = $assign_iterator->() ) {
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
print $assignment->get_string(), "\n";
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
C represents the destination string of a DTS DynamicPropertiesTaskAssignment object.
|
40
|
|
|
|
|
|
|
The Destination string is usually something like
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
C |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
but this will change depending on the type of object which is mean to be the target of the assignment.
|
45
|
|
|
|
|
|
|
C is a "syntatic sugar" to allow the different types of Destination string to be
|
46
|
|
|
|
|
|
|
used with a set of methods, hidding the complexity and hardwork to deal with this string.
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
C is a abstract class and it's not meant to be used directly: to instantiate objects, look
|
49
|
|
|
|
|
|
|
for the subclasses of it.
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Although is part of the package, C is B a subclass of C, so no
|
52
|
|
|
|
|
|
|
method from is inherited. Besides that, the package is not part of the original MS SQL Server API.
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 EXPORT
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Nothing.
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
27392
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
61
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
62
|
1
|
|
|
1
|
|
5
|
use base qw(Class::Accessor Class::Publisher);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1091
|
|
63
|
1
|
|
|
1
|
|
11025
|
use Carp qw(confess);
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
63
|
|
64
|
1
|
|
|
1
|
|
1190
|
use Hash::Util qw(lock_keys);
|
|
1
|
|
|
|
|
3328
|
|
|
1
|
|
|
|
|
6
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 METHODS
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 new
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The object constructor method of the class. C is implemented to setup de object with two basic attributes:
|
73
|
|
|
|
|
|
|
I and I.
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Expects as an argument the Destination string as a parameter. Subclasses of C must
|
76
|
|
|
|
|
|
|
implement the C method that parses the string and define the I property correctly.
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub new {
|
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
1
|
|
my $class = shift;
|
83
|
0
|
|
|
|
|
|
my $self;
|
84
|
0
|
|
|
|
|
|
my $string = shift;
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->{string} = undef;
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# assuming that the last part of Class name is always the target object
|
89
|
0
|
|
|
|
|
|
$self->{who} = ( split( /\:{2}/, $class ) )[-1];
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
bless $self, $class;
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$self->set_string($string);
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
lock_keys( %{$self} );
|
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $self;
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head3 initialize
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This method must be overrided by subclasses of C.
|
104
|
|
|
|
|
|
|
It should parse the I attribute and define the I attribute with the proper value.
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
C is invoked automatically by the C method during object creation.
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub initialize {
|
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
0
|
1
|
|
confess "'initialize' method must be overrided by subclasses of Win32::SqlServer::DTS::Assignment::Destination.\n";
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
}
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head3 get_destination
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the target of the Destination object, in other words, what will be modified by the related Assignment.
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice;
|
123
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(destination));
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head3 get_string
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Returns a formatted destination string where all "'" (single quotes) are stripped.
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub get_string {
|
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $fmt_string = $self->{string};
|
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$fmt_string =~ tr/\'//d;
|
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $fmt_string;
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
}
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head3 get_raw_string
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns the destination string without any formating, as it's defined by the DTS API.
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get_raw_string {
|
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return $self->{string};
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head3 set_string
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Modifies the destination string in the object. The string is validated against a regular expression before starting
|
160
|
|
|
|
|
|
|
changing the property. The regex is "C<^(\'[\w\s\(\)]+\'\;\'[\w\s\(\)]+\')(\'[\w\s\(\)]+\')*>" and it's based on the destination
|
161
|
|
|
|
|
|
|
string specification in MSDN. If the regex does not match, the method will abort program execution.
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
The programmer must be aware that invoking C will automatically execute the C method (to setup
|
164
|
|
|
|
|
|
|
other attributes related to the destination) and notify the related Ct object to modify the property
|
165
|
|
|
|
|
|
|
in it's C<_sibling> attribute, to keep all values syncronized.
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub set_string {
|
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
172
|
0
|
|
|
|
|
|
my $string = shift;
|
173
|
|
|
|
|
|
|
|
174
|
0
|
0
|
|
|
|
|
confess "'string' attribute cannot be undefined"
|
175
|
|
|
|
|
|
|
unless ( defined($string) );
|
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
confess "invalid value of destination string: $string"
|
178
|
|
|
|
|
|
|
unless ( $string =~ /^(\'[\w\s\(\)]+\'\;\'[\w\s\(\)]+\')(\'[\w\s\(\)]+\')*/ );
|
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
$self->{string} = $string;
|
181
|
0
|
|
|
|
|
|
$self->initialize();
|
182
|
0
|
|
|
|
|
|
$self->notify_subscribers('changed');
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
}
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head3 changes
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
This method tests which object is being changed by the C object.
|
189
|
|
|
|
|
|
|
Expects a object name as a parameter; returns true if it changes the same object name, false if not.
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
An valid object name is equal to one of the subclasses of C.
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Since a Dynamic Property task can hold several assignments, this method is usefull for testing if an assignment is
|
194
|
|
|
|
|
|
|
the one that you want to deal with. It's also possible to test that using the C method, like this:
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
if ( $destination->isa('Win32::SqlServer::DTS::Assignment::Destination::Connection') ) {
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
#do something
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
}
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
But that is a lot of typing. Instead, use:
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
if ( $destination->changes('Connection') ) {
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
#do something
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
}
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
The result will be the same.
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub changes {
|
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
217
|
0
|
|
|
|
|
|
my $target = shift;
|
218
|
|
|
|
|
|
|
|
219
|
0
|
0
|
|
|
|
|
if ( $target eq $self->{who} ) {
|
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
return 1;
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
}
|
224
|
|
|
|
|
|
|
else {
|
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
return 0;
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
}
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
}
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
1;
|
233
|
|
|
|
|
|
|
__END__
|