@@ -38,12 +38,14 @@ use Toolkit_helpers qw (logger);
3838sub 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
141163sub 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" ,
0 commit comments