blob: 4e579c9e9fe7ed0ec1a92d72e480ee4c829fb26b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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";
}
}
|