Vinod Kumar S
Committed by Gerrit Code Review

[ONOS-3875] Code Framework for YangUtils

Change-Id: I3844f8eca6f061900367637fb671cb828a8e6d09
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
36 <module>misc</module> 36 <module>misc</module>
37 <module>netty</module> 37 <module>netty</module>
38 <module>nio</module> 38 <module>nio</module>
39 + <module>yangutils</module>
39 <module>osgi</module> 40 <module>osgi</module>
40 <module>rest</module> 41 <module>rest</module>
41 <module>thirdparty</module> 42 <module>thirdparty</module>
......
1 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 + <modelVersion>4.0.0</modelVersion>
4 +
5 + <parent>
6 + <groupId>org.onosproject</groupId>
7 + <artifactId>onlab-utils</artifactId>
8 + <version>1.5.0-SNAPSHOT</version>
9 + <relativePath>../pom.xml</relativePath>
10 + </parent>
11 +
12 + <artifactId>yangutils-maven-plugin</artifactId>
13 + <version>1.0.0</version>
14 + <name>onos-yang-utils-plugin</name>
15 + <packaging>maven-plugin</packaging>
16 +
17 + <properties>
18 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19 + </properties>
20 +
21 + <dependencies>
22 + <dependency>
23 + <groupId>org.apache.maven</groupId>
24 + <artifactId>maven-core</artifactId>
25 + <version>3.2.5</version>
26 + </dependency>
27 + <dependency>
28 + <groupId>org.apache.maven</groupId>
29 + <artifactId>maven-plugin-api</artifactId>
30 + <version>3.2.5</version>
31 + </dependency>
32 + <dependency>
33 + <groupId>org.apache.maven.plugin-tools</groupId>
34 + <artifactId>maven-plugin-annotations</artifactId>
35 + <version>3.4</version>
36 + <scope>provided</scope>
37 + </dependency>
38 + <dependency>
39 + <groupId>org.apache.felix</groupId>
40 + <artifactId>maven-scr-plugin</artifactId>
41 + <version>1.9.0</version>
42 + <scope>compile</scope>
43 + </dependency>
44 + <dependency>
45 + <groupId>org.apache.maven</groupId>
46 + <artifactId>maven-artifact</artifactId>
47 + <version>2.0.8</version>
48 + </dependency>
49 + <dependency>
50 + <groupId>org.apache.maven</groupId>
51 + <artifactId>maven-project</artifactId>
52 + <version>2.0.8</version>
53 + </dependency>
54 + <dependency>
55 + <groupId>org.assertj</groupId>
56 + <artifactId>assertj-core</artifactId>
57 + <version>1.7.0</version>
58 + <scope>test</scope>
59 + </dependency>
60 + <dependency>
61 + <groupId>org.apache.maven.plugin-testing</groupId>
62 + <artifactId>maven-plugin-testing-harness</artifactId>
63 + <version>2.1</version>
64 + <scope>test</scope>
65 + </dependency>
66 + <dependency>
67 + <groupId>org.apache.maven</groupId>
68 + <artifactId>maven-model</artifactId>
69 + <version>3.2.5</version>
70 + </dependency>
71 + <dependency>
72 + <groupId>org.apache.maven</groupId>
73 + <artifactId>maven-compat</artifactId>
74 + <version>3.2.5</version>
75 + <scope>test</scope>
76 + </dependency>
77 + <dependency>
78 + <groupId>org.mockito</groupId>
79 + <artifactId>mockito-core</artifactId>
80 + <version>1.9.5</version>
81 + <scope>test</scope>
82 + </dependency>
83 + <dependency>
84 + <groupId>junit</groupId>
85 + <artifactId>junit</artifactId>
86 + <version>4.12</version>
87 + <scope>test</scope>
88 + </dependency>
89 + <dependency>
90 + <groupId>org.sonatype.plexus</groupId>
91 + <artifactId>plexus-build-api</artifactId>
92 + <version>0.0.7</version>
93 + <scope>provided</scope>
94 + </dependency>
95 + <dependency>
96 + <groupId>commons-io</groupId>
97 + <artifactId>commons-io</artifactId>
98 + <version>1.3.2</version>
99 + </dependency>
100 + <dependency>
101 + <groupId>commons-configuration</groupId>
102 + <artifactId>commons-configuration</artifactId>
103 + <version>1.10</version>
104 + </dependency>
105 + <dependency>
106 + <groupId>org.onosproject</groupId>
107 + <artifactId>onlab-junit</artifactId>
108 + <version>1.5.0-SNAPSHOT</version>
109 + <scope>test</scope>
110 + </dependency>
111 + <dependency>
112 + <groupId>org.antlr</groupId>
113 + <artifactId>antlr4-runtime</artifactId>
114 + <version>4.5</version>
115 + </dependency>
116 + <dependency>
117 + <groupId>org.apache.maven.plugins</groupId>
118 + <artifactId>maven-surefire-plugin</artifactId>
119 + <version>2.19.1</version>
120 + </dependency>
121 + <dependency>
122 + <groupId>org.sonatype.aether</groupId>
123 + <artifactId>aether-api</artifactId>
124 + <version>1.8</version>
125 + </dependency>
126 + <dependency>
127 + <groupId>org.sonatype.aether</groupId>
128 + <artifactId>aether-util</artifactId>
129 + <version>1.8</version>
130 + </dependency>
131 + <dependency>
132 + <groupId>org.codehaus.mojo</groupId>
133 + <artifactId>build-helper-maven-plugin</artifactId>
134 + <version>1.10</version>
135 + </dependency>
136 + </dependencies>
137 +
138 + <build>
139 + <plugins>
140 + <plugin>
141 + <groupId>org.antlr</groupId>
142 + <artifactId>antlr4-maven-plugin</artifactId>
143 + <version>4.5</version>
144 + <executions>
145 + <execution>
146 + <phase>generate-sources</phase>
147 + <goals>
148 + <goal>antlr4</goal>
149 + </goals>
150 + </execution>
151 + </executions>
152 + <configuration>
153 + <sourceDirectory>src/main/resources</sourceDirectory>
154 + <outputDirectory>target/generated-sources/org/onosproject/yangutils/parser/antlrgencode</outputDirectory>
155 + <visitor>true</visitor>
156 + <listener>true</listener>
157 + </configuration>
158 + </plugin>
159 + <plugin>
160 + <groupId>org.codehaus.mojo</groupId>
161 + <artifactId>build-helper-maven-plugin</artifactId>
162 + <version>1.10</version>
163 + <executions>
164 + <execution>
165 + <id>add-source</id>
166 + <phase>generate-sources</phase>
167 + <goals>
168 + <goal>add-source</goal>
169 + </goals>
170 + <configuration>
171 + <sources>
172 + <source>target/generated-sources/org/onosproject/yangutils/parser/antlrgencode</source>
173 + </sources>
174 + </configuration>
175 + </execution>
176 + </executions>
177 + </plugin>
178 + <plugin>
179 + <groupId>org.apache.maven.plugins</groupId>
180 + <artifactId>maven-javadoc-plugin</artifactId>
181 + <version>2.10.3</version>
182 + <configuration>
183 + <excludePackageNames>
184 + *.org.onosproject.yangutils.parser.antlrgencode
185 + </excludePackageNames>
186 + </configuration>
187 + </plugin>
188 + <plugin>
189 + <groupId>org.apache.felix</groupId>
190 + <artifactId>maven-bundle-plugin</artifactId>
191 + <extensions>true</extensions>
192 + <configuration>
193 + <instructions>
194 + <Export-Package>
195 + org.onosproject.yangutils.parser.*
196 + </Export-Package>
197 + </instructions>
198 + </configuration>
199 + </plugin>
200 + <plugin>
201 + <groupId>org.apache.maven.plugins</groupId>
202 + <artifactId>maven-plugin-plugin</artifactId>
203 + <version>3.4</version>
204 + <configuration>
205 + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
206 + </configuration>
207 + <executions>
208 + <execution>
209 + <phase>generate-sources</phase>
210 + <goals>
211 + <goal>descriptor</goal>
212 + </goals>
213 + </execution>
214 + </executions>
215 + </plugin>
216 + </plugins>
217 + </build>
218 +</project>
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.yangutils.datamodel;
17 +
18 +/**
19 + * Node type in data model tree corresponding to YANG schema.
20 + */
21 +public enum YangNodeType {
22 + /**
23 + * Node contains module information.
24 + */
25 + MODULE_NODE,
26 +
27 + /**
28 + * Node contains sub module information.
29 + */
30 + SUB_MODULE_NODE,
31 +
32 + /**
33 + * Node contains "YANG's typedef" information.
34 + */
35 + TYPEDEF_NODE,
36 +
37 + /**
38 + * Node contains "YANG's type" information.
39 + */
40 + TYPE_NODE,
41 +
42 + /**
43 + * Node contains "YANG's choice" information.
44 + */
45 + CHOICE_NODE,
46 +
47 + /**
48 + * Node contains "YANG's case" information.
49 + */
50 + CASE_NODE,
51 +
52 + /**
53 + * Node contains "YANG's enumeration" information.
54 + */
55 + ENUMERATION_NODE,
56 +
57 + /**
58 + * Node contains grouping information.
59 + */
60 + GROUPING_NODE,
61 +
62 + /**
63 + * Node contains "YANG's uses" information.
64 + */
65 + USES_NODE,
66 +
67 + /**
68 + * Node contains augmentation information.
69 + */
70 + AUGMENT_NODE,
71 +
72 + /**
73 + * Node contains "YANG's container" information.
74 + */
75 + CONTAINER_NODE,
76 +
77 + /**
78 + * Node contains "YANG's list" information.
79 + */
80 + LIST_NODE
81 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.yangutils.datamodel.exceptions;
17 +
18 +/**
19 + * Base class for exceptions in data model operations.
20 + */
21 +public class DataModelException extends Exception {
22 +
23 + private static final long serialVersionUID = 201601270658L;
24 +
25 + /**
26 + * Constructor to create a data model exception with message.
27 + *
28 + * @param message the detail of exception in string
29 + */
30 + public DataModelException(String message) {
31 + super(message);
32 + }
33 +
34 + /**
35 + * Constructor to create exception from message and cause.
36 + *
37 + * @param message the detail of exception in string
38 + * @param cause underlying cause of the error
39 + */
40 + public DataModelException(final String message, final Throwable cause) {
41 + super(message, cause);
42 + }
43 +
44 + /**
45 + * Constructor to create exception from cause.
46 + *
47 + * @param cause underlying cause of the error
48 + */
49 + public DataModelException(final Throwable cause) {
50 + super(cause);
51 + }
52 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 + * use this file except in compliance with the License. You may obtain a copy of
6 + * the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 + * License for the specific language governing permissions and limitations under
14 + * the License.
15 + */
16 +/**
17 + * Custom data model exceptions.
18 + */
19 +package org.onosproject.yangutils.datamodel.exceptions;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 + * use this file except in compliance with the License. You may obtain a copy of
6 + * the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 + * License for the specific language governing permissions and limitations under
14 + * the License.
15 + */
16 +
17 +/**
18 + * Maintains application's schema information.
19 + */
20 +package org.onosproject.yangutils.datamodel;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 + * use this file except in compliance with the License. You may obtain a copy of
6 + * the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 + * License for the specific language governing permissions and limitations under
14 + * the License.
15 + */
16 +
17 +/**
18 + * Parse the YANG information from ANTLR generated parse tree.
19 + */
20 +package org.onosproject.yangutils.parser.impl;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 + * use this file except in compliance with the License. You may obtain a copy of
6 + * the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 + * License for the specific language governing permissions and limitations under
14 + * the License.
15 + */
16 +
17 +/**
18 + * Interfaces to process YANG information from ANTLR generated listeners.
19 + */
20 +package org.onosproject.yangutils.parser;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.plugin.manager;
18 +
19 +import org.apache.maven.plugin.AbstractMojo;
20 +import org.apache.maven.plugin.MojoExecutionException;
21 +import org.apache.maven.plugin.MojoFailureException;
22 +import org.apache.maven.plugins.annotations.LifecyclePhase;
23 +import org.apache.maven.plugins.annotations.Mojo;
24 +import org.apache.maven.plugins.annotations.ResolutionScope;
25 +
26 +/**
27 +* ONOS YANG utility maven plugin.
28 +* Goal of plugin is yang2java
29 +* Execution phase in generate-sources
30 +* requiresDependencyResolution at compile time
31 +*/
32 +@Mojo(name = "yang2java", defaultPhase = LifecyclePhase.GENERATE_SOURCES,
33 + requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
34 +public class YangUtilManager extends AbstractMojo {
35 +
36 + @Override
37 + public void execute() throws MojoExecutionException, MojoFailureException {
38 + //TODO: implement the MOJO plugin
39 + }
40 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * YANG utility maven plugin.
19 + */
20 +package org.onosproject.yangutils.plugin.manager;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Translator to generate class definition corresponding to YANG definition.
19 + */
20 +package org.onosproject.yangutils.translator;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Generates java class definition from data model.
19 + */
20 +package org.onosproject.yangutils.translator.tojava;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * File system utilities implementation.
19 + */
20 +package org.onosproject.yangutils.utils.io.impl;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * File system utilities.
19 + */
20 +package org.onosproject.yangutils.utils.io;
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Utilities for YANG maven plugin.
19 + */
20 +package org.onosproject.yangutils.utils;