Skip to content

Commit baeccf0

Browse files
author
Marcin Przepiorowski
committed
version v.2.4.17.2
2 parents c13e868 + 3fa33b6 commit baeccf0

File tree

6 files changed

+97
-38
lines changed

6 files changed

+97
-38
lines changed

bin/dx_v2p.pl

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@
108108
}
109109

110110

111-
if ( ( ( $type eq 'oracle') || ( $type eq 'mssql') ) && (! defined($targetDirectory)) ) {
112-
print "Option targetDirectory is required. \n";
113-
pod2usage(-verbose => 1, -input=>\*DATA);
114-
exit (1);
115-
}
116-
117111

118112
# this array will have all engines to go through (if -d is specified it will be only one engine)
119113
my $engine_list = Toolkit_helpers::get_engine_list($all, $dx_host, $engine_obj);
@@ -166,19 +160,21 @@
166160

167161

168162
if ( $db->setSource($source) ) {
169-
print "Problem with setting source. V2P won't be created.\n";
170-
exit(1);
163+
print "Problem with setting source. V2P won't be started.\n";
164+
$ret = $ret + 1;
165+
next;
171166
}
172167

173168
if ( $db->setTimestamp($timestamp) ) {
174169
print "Problem with setting timestamp $timestamp. V2P process won't be started.\n";
175-
exit(1);
170+
$ret = $ret + 1;
171+
next;
176172
}
177173

178174
$db->setName($dbname, $dbname);
179175

180176
if ( $db->setEnvironment($environment, $envUser) ) {
181-
print "Environment $environment or user $envUser not found. VDB won't be created\n";
177+
print "Environment $environment or user $envUser not found. V2P process won't be started\n";
182178
$ret = $ret + 1;
183179
next;
184180
}
@@ -188,22 +184,26 @@
188184

189185
if ( $db->setFileSystemLayout($targetDirectory,$archiveDirectory,$dataDirectory,$externalDirectory,$scriptDirectory,$tempDirectory, $useabsolute) ) {
190186
print "Problem with export file system layout. Is targetDiretory and dataDirectory set ?\n";
191-
exit(1);
187+
$ret = $ret + 1;
188+
next;
192189
}
193190

194191
if ( defined($template) ) {
195192
if ( $db->setTemplateV2P($template) ) {
196-
print "Template $template not found. V2P process won't be created\n";
197-
exit(1);
193+
print "Template $template not found. V2P process won't be started\n";
194+
$ret = $ret + 1;
195+
next;
198196
}
199197
}
200198

201199
if ( defined($map_file) ) {
202-
my $filemap_obj = new FileMap($engine_obj,$debug);
200+
my $filemap_obj = new FileMap($engine_obj,$type,$debug);
203201
$filemap_obj->loadMapFile($map_file);
204202
$filemap_obj->setSource($source);
205203
if ($filemap_obj->validate()) {
206-
die ("Problem with mapping file. V2P process won't be created.")
204+
print ("Problem with mapping file. V2P process won't be started.\n");
205+
$ret = $ret + 1;
206+
next;
207207
}
208208

209209
$db->setMapFileV2P($filemap_obj->GetMapping_rule());
@@ -217,7 +217,8 @@
217217
if (defined($concurrentfiles)) {
218218
if ($db->setFileParallelism($concurrentfiles)) {
219219
print "Problem with setting number of concurrent files\n";
220-
exit(1);
220+
$ret = $ret + 1;
221+
next;
221222
}
222223
};
223224

@@ -227,11 +228,27 @@
227228
}
228229
elsif ($type eq 'mssql') {
229230

230-
if ( $db->setFileSystemLayout($targetDirectory,$archiveDirectory,$dataDirectory,$externalDirectory,$scriptDirectory,$tempDirectory) ) {
231+
if ( $db->setFileSystemLayout($targetDirectory,$archiveDirectory,$dataDirectory,$externalDirectory,$scriptDirectory,$tempDirectory) ) {;
231232
print "Problem with export file system layout. Is targetDiretory and dataDirectory set ?\n";
232-
exit(1);
233+
$ret = $ret + 1;
234+
next;
233235
}
234236

237+
if ( defined($map_file) ) {
238+
my $filemap_obj = new FileMap($engine_obj,$type,$debug);
239+
$filemap_obj->loadMapFile($map_file);
240+
$filemap_obj->setSource($source);
241+
if ($filemap_obj->validate($db->{"NEWDB"}->{"filesystemLayout"})) {
242+
print("Problem with mapping file. V2P process won't be started.\n");
243+
$ret = $ret + 1;
244+
next;
245+
}
246+
247+
$db->setMapFileV2P($filemap_obj->GetMapping_rule());
248+
249+
}
250+
251+
235252
if (defined($norecovery)) {
236253
$db->setNoRecovery();
237254
}
@@ -341,7 +358,20 @@ =head2 V2P arguments
341358
Target VDB template name (for Oracle)
342359
343360
=item B<-mapfile>
344-
Target VDB mapping file (for Oracle)
361+
Target VDB mapping file. Use colon as separator for both MS SQL and Oracle
362+
Dxtoolkit will use a proper separator for API call.
363+
364+
365+
Oracle mapfile example:
366+
367+
# this is comment
368+
/u01:/u02
369+
370+
MS SQL mapfile example:
371+
372+
# this is comment
373+
Biscuit_Data_1.ndf : c:\\tmp\\los1\\slon_Data_1.ndf
374+
Biscuit_Bogus_1_data.ndf : c:\\tmp\\los2\\slon_Bogus_1_data.ndf
345375
346376
=item B<-instname>
347377
Target VDB instance name (for Oracle)

lib/FileMap.pm

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ use Toolkit_helpers qw (logger);
3838
sub new {
3939
my $classname = shift;
4040
my $dlpxObject = shift;
41+
my $type = shift;
4142
my $debug = shift;
4243
logger($debug, "Entering FileMap::constructor",1);
4344

4445
my %hosts;
4546
my $self = {
4647
_hosts => \%hosts,
48+
_type => $type,
4749
_dlpxObject => $dlpxObject,
4850
_debug => $debug
4951
};
@@ -66,13 +68,20 @@ sub setMapFile {
6668

6769
$self->{_mapping_rule_hash} = $mapfile;
6870

71+
my $join_char;
72+
if (lc $self->{_type} eq 'mssql') {
73+
$join_char = "?";
74+
} else {
75+
$join_char = ":";
76+
}
77+
6978
my $mapping_rule_de = '';
7079

7180
while ( my ($key,$value) = each %{$mapfile} ) {
7281
if ($mapping_rule_de eq '') {
73-
$mapping_rule_de = $key . ":" . $value;
82+
$mapping_rule_de = $key . $join_char . $value;
7483
} else {
75-
$mapping_rule_de = $mapping_rule_de . "\n" . $key . ":" . $value;
84+
$mapping_rule_de = $mapping_rule_de . "\n" . $key . $join_char . $value;
7685
}
7786
}
7887

@@ -94,12 +103,26 @@ sub loadMapFile {
94103

95104
open (my $FD, $file) or die ("Can't open file $file : $!");
96105

106+
my $split_char;
107+
108+
if (lc $self->{_type} eq 'mssql') {
109+
$split_char = ":";
110+
} else {
111+
$split_char = ":";
112+
}
113+
97114
while(my $line = <$FD>) {
98115
chomp $line;
99116
if ($line =~ m/^#/ ) {
100117
next;
101118
}
102-
my @line_split = split (":",$line);
119+
if ($line =~ m/^$/ ) {
120+
next;
121+
}
122+
my @line_split = split ($split_char,$line, 2);
123+
124+
$line_split[0] =~ s/^\s+|\s+$//g;
125+
$line_split[1] =~ s/^\s+|\s+$//g;
103126

104127
if (! defined($line_split[0])) {
105128
die ("Line $line in file $file has an error. Check if there is colon sign. Can't continue");
@@ -114,7 +137,6 @@ sub loadMapFile {
114137
}
115138

116139
close $FD;
117-
118140
$self->setMapFile(\%map_hash);
119141

120142
}
@@ -140,16 +162,22 @@ sub setSource {
140162

141163
sub validate {
142164
my $self = shift;
165+
my $filesystemLayout = shift;
143166
my %fileMapping_request;
144167
logger($self->{_debug}, "Entering FileMap::validate",1);
145168

169+
if (lc $self->{_type} eq 'mssql') {
170+
$fileMapping_request{"type"} = "MSSqlFileMappingParameters";
171+
$fileMapping_request{"filesystemLayout"} = $filesystemLayout;
172+
} else {
173+
$fileMapping_request{"type"} = "FileMappingParameters";
174+
}
175+
146176
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.9.0)) {
147-
$fileMapping_request{"type"} = "FileMappingParameters";
148177
$fileMapping_request{"mappingRules"} = $self->{_mapping_rule};
149178
$fileMapping_request{"timeflowPointParameters"}{"type"} = "TimeflowPointSemantic";
150179
$fileMapping_request{"timeflowPointParameters"}{"container"} = $self->{_source_ref};
151180
} else {
152-
$fileMapping_request{"type"} = "FileMappingParameters";
153181
$fileMapping_request{"mappingRules"} = $self->{_mapping_rule};
154182
my %timeflowhash = (
155183
"type"=>"TimeflowPointSemantic",
@@ -171,6 +199,7 @@ sub validate {
171199
$self->{mappedFiles} = $mapped_files;
172200
return 0;
173201
} else {
202+
print("Error with validation: " . $result->{error}->{details} . "\n");
174203
return 1;
175204
}
176205

lib/MSSQLVDB_obj.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,10 @@ sub setFileSystemLayout {
326326
$self->{"NEWDB"}->{"filesystemLayout"}->{"type"} = "MSSqlTimeflowFilesystemLayout";
327327
}
328328

329-
if (! defined($targetDirectory)) {
330-
return 1;
329+
if (defined($targetDirectory)) {
330+
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
331331
}
332332

333-
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
334-
335333
if (defined($dataDirectory)) {
336334
$self->{"NEWDB"}->{"filesystemLayout"}->{"dataDirectory"} = $dataDirectory;
337335
} else {
@@ -357,8 +355,12 @@ sub setFileSystemLayout {
357355

358356
if ( defined($externalDirectory)) {
359357
$self->{"NEWDB"}->{"filesystemLayout"}->{"externalDirectory"} = $externalDirectory;
358+
} else {
359+
$self->{"NEWDB"}->{"filesystemLayout"}->{"scriptDirectory"} = "external";
360360
}
361361

362+
return undef;
363+
362364
}
363365

364366

lib/OracleVDB_obj.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,11 +2505,11 @@ sub setFileSystemLayout {
25052505
$self->{"NEWDB"}->{"filesystemLayout"}->{"type"} = "OracleExportTimeflowFilesystemLayout";
25062506
}
25072507

2508-
if (! defined($targetDirectory)) {
2509-
return 1;
2508+
if (defined($targetDirectory)) {
2509+
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
25102510
}
25112511

2512-
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
2512+
25132513

25142514
if ( defined($archiveDirectory)) {
25152515
$self->{"NEWDB"}->{"filesystemLayout"}->{"archiveDirectory"} = $archiveDirectory;

lib/Toolkit_helpers.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use File::Spec;
2929

3030
use lib '../lib';
3131

32-
our $version = '2.4.17';
32+
our $version = '2.4.17.2';
3333

3434
my $tz = new Date::Manip::TZ;
3535
my $dt = new Date::Manip::Date;
@@ -485,7 +485,7 @@ sub timestamp {
485485
}
486486

487487
my $tz = new Date::Manip::TZ;
488-
my $detz = $engine->getTimezone();
488+
my $detz = timezone_fix($engine->getTimezone());
489489
my $dt = ParseDate($timestamp);
490490
if ($dt ne '') {
491491
my ($err,$date,$offset,$isdst,$abbrev) = $tz->convert_to_gmt($dt, $detz);

lib/VDB_obj.pm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,12 +1963,10 @@ sub setFileSystemLayout {
19631963

19641964
$self->{"NEWDB"}->{"filesystemLayout"}->{"type"} = "TimeflowFilesystemLayout";
19651965

1966-
if (! defined($targetDirectory)) {
1967-
return 1;
1966+
if (defined($targetDirectory)) {
1967+
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
19681968
}
19691969

1970-
$self->{"NEWDB"}->{"filesystemLayout"}->{"targetDirectory"} = $targetDirectory;
1971-
19721970
if ( defined($archiveDirectory)) {
19731971
$self->{"NEWDB"}->{"filesystemLayout"}->{"archiveDirectory"} = $archiveDirectory;
19741972
}

0 commit comments

Comments
 (0)