diff options
author | 2017-02-09 15:27:43 -0500 | |
---|---|---|
committer | 2017-02-09 15:28:15 -0500 | |
commit | 4c790f64daf7822de00405140d17e08f296a642f (patch) | |
tree | 1a608a463115640bc59260eef90a08a70c93880c /ajsc-aai/src/main/scripts/fix_yang_classes.pl | |
parent | 2f3dcb75d2f658fd7af04ea908c70c5104c2b9ef (diff) |
Initial OpenECOMP A&AI commit
Change-Id: I8b06519995d9dc0f220b80a6d9a71865b23e4edb
Signed-off-by: Steve Smokowski <ss835w@att.com>
Diffstat (limited to 'ajsc-aai/src/main/scripts/fix_yang_classes.pl')
-rw-r--r-- | ajsc-aai/src/main/scripts/fix_yang_classes.pl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/ajsc-aai/src/main/scripts/fix_yang_classes.pl b/ajsc-aai/src/main/scripts/fix_yang_classes.pl new file mode 100644 index 0000000..4e579c9 --- /dev/null +++ b/ajsc-aai/src/main/scripts/fix_yang_classes.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +use strict; + +use Getopt::Std; + +my %opts = (); + +getopts("n:", \%opts); + +my $namespace = ''; +if (!$opts{'n'}) { + $namespace = "http://org.openecomp.aai.inventory"; +} else { + $namespace = $opts{'n'}; +} + +my $has_xml_root_element = 0; +my $has_a_class = 0; +my @file = (); + +my $added_rel = 0; + +while (<>) { + 1 while chomp; + # we're going to read it again + + my $line = $_; + $line =~ s/(protected boolean (inMaint|isClosedLoopDisabled|isBoundToVpn|dhcpEnabled))(\;)/$1 \= false\;/i; + + push @file, $line; + + #if ($_ =~ /^import/ && $added_rel == 0) { + # push @file, "import org.openecomp.aai.domain.yang.rel.*;"; + # $added_rel = 1; + #} + if ($_ =~ /^\@XmlRootElement/) { + $has_xml_root_element = 1; + } + if ($_ =~ /^public\sclass\s(\S+)\s{/) { + $has_a_class = 1; + } +} + +if ($has_xml_root_element == 0 && $has_a_class == 1) { + my $printed_include = 0; + foreach my $line (@file) { + if ($line =~ /^import/ && $printed_include == 0) { + print "import javax.xml.bind.annotation.XmlRootElement;\n"; + + $printed_include++; + } + if ($line =~ /^public\sclass\s(\S+)\s{/) { + my $className = $1; + my @parts = $line =~ /([A-Z](?:[A-Z0-9]*(?=$|[A-Z0-9][a-z])|[a-z0-9]*))/g; + print "\@XmlRootElement(name = \"" . lc join('-', @parts) . "\", namespace = \"$namespace\")\n"; + } + print "$line\n"; + } +} else { + foreach my $line (@file) { + print "$line\n"; + } +} |