aboutsummaryrefslogtreecommitdiffstats
path: root/ajsc-aai/src/main/scripts/fix_yang_classes.pl
diff options
context:
space:
mode:
Diffstat (limited to 'ajsc-aai/src/main/scripts/fix_yang_classes.pl')
-rw-r--r--ajsc-aai/src/main/scripts/fix_yang_classes.pl64
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";
+ }
+}