summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl
diff options
context:
space:
mode:
authorda490c <dave.adams@amdocs.com>2018-03-22 00:32:52 -0400
committerda490c <dave.adams@amdocs.com>2018-03-22 09:34:25 -0400
commitba31685194c77ef140411531299696ae701385d4 (patch)
tree912f7d5b3378901ccabb8df52b26866d74572f10 /sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl
parentef7f255958e541ffaec0fd2a977440dd7b6fd6b8 (diff)
Convert Sparky to Spring-Boot
Issue-ID: AAI-599 Change-Id: If474dd02794f442fdddcd90f62fb75e0d6b907e7 Signed-off-by: da490c <dave.adams@amdocs.com>
Diffstat (limited to 'sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl')
-rw-r--r--sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl41
1 files changed, 41 insertions, 0 deletions
diff --git a/sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl b/sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl
new file mode 100644
index 0000000..67ed571
--- /dev/null
+++ b/sparkybe-onap-service/src/test/resources/es_test_scripts/prepareGeoEntityBulkImport.pl
@@ -0,0 +1,41 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $filename = $ARGV[0];
+my $outputfile= $ARGV[1];
+
+open my $fh_input, '<', $filename or die "Cannot open $filename: $!";
+open my $fh_output, '>', $outputfile or die "Cannot open $outputfile: $!";
+
+while ( my $line = <$fh_input> ) {
+ chomp ($line);
+
+ if ( $line =~ /(.*)(\".*\")(.*)/ ) {
+
+ # we have seen examples of the status field containing quoted comma-delimited
+ # strings which is messing up parsing of the record data which is supposed to be
+ # comma-separated at the field level. This little block converts sections of
+ # this type of data into a single-quoted-string with a semi-colon delimiter instead.
+
+ my $beforeBadStr = $1;
+ my $badStr = $2;
+ my $afterBadStr = $3;
+
+ $badStr =~ s/,/;/g;
+ $badStr =~ s/"/'/g;
+
+ $line = $beforeBadStr . $badStr . $afterBadStr ;
+
+ }
+
+ my @row = split(",", $line);
+ print $fh_output "{\"index\":{\"_index\":\"topographicalsearchindex-localhost\",\"_type\":\"default\"}\n";
+ print $fh_output "{\"pkey\": \"$row[0]\", \"entityType\": \"$row[1]\", \"location\" : {\"lat\": \"$row[3]\", \"lon\": \"$row[2]\"}, \"selfLink\": \"$row[4]\"}\n";
+
+}
+
+close($fh_input);
+close($fh_output);
+