Committed by
Gerrit Code Review
[ONOS-2563]Optimize RFC 7047's code.
Change-Id: I000f2b802420e4f47ce320f6ed021049bd2fd83e
Showing
23 changed files
with
996 additions
and
1208 deletions
... | @@ -16,25 +16,25 @@ | ... | @@ -16,25 +16,25 @@ |
16 | package org.onosproject.ovsdb.rfc.error; | 16 | package org.onosproject.ovsdb.rfc.error; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | - * AbnormalSchema exception is thrown when the received schema is invalid. | 19 | + * AbnormalJsonNodeException exception is thrown when the received JsonNode is invalid. |
20 | */ | 20 | */ |
21 | -public class AbnormalSchemaException extends RuntimeException { | 21 | +public class AbnormalJsonNodeException extends RuntimeException { |
22 | private static final long serialVersionUID = 8328377718334680368L; | 22 | private static final long serialVersionUID = 8328377718334680368L; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | - * Constructs a AbnormalSchemaException object. | 25 | + * Constructs a AbnormalJsonNodeException object. |
26 | * @param message error message | 26 | * @param message error message |
27 | */ | 27 | */ |
28 | - public AbnormalSchemaException(String message) { | 28 | + public AbnormalJsonNodeException(String message) { |
29 | super(message); | 29 | super(message); |
30 | } | 30 | } |
31 | 31 | ||
32 | /** | 32 | /** |
33 | - * Constructs a AbnormalSchemaException object. | 33 | + * Constructs a AbnormalJsonNodeException object. |
34 | * @param message error message | 34 | * @param message error message |
35 | * @param cause Throwable | 35 | * @param cause Throwable |
36 | */ | 36 | */ |
37 | - public AbnormalSchemaException(String message, Throwable cause) { | 37 | + public AbnormalJsonNodeException(String message, Throwable cause) { |
38 | super(message, cause); | 38 | super(message, cause); |
39 | } | 39 | } |
40 | 40 | ... | ... |
1 | -/* | ||
2 | - * Copyright 2015 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.ovsdb.rfc.error; | ||
17 | - | ||
18 | -/** | ||
19 | - * This exception is thrown when the argument is not supported. | ||
20 | - */ | ||
21 | -public class ArgumentException extends RuntimeException { | ||
22 | - private static final long serialVersionUID = 4950089877540156797L; | ||
23 | - | ||
24 | - /** | ||
25 | - * Constructs a ArgumentException object. | ||
26 | - * @param message error message | ||
27 | - */ | ||
28 | - public ArgumentException(String message) { | ||
29 | - super(message); | ||
30 | - } | ||
31 | - | ||
32 | - /** | ||
33 | - * Constructs a ArgumentException object. | ||
34 | - * @param message error message | ||
35 | - * @param cause Throwable | ||
36 | - */ | ||
37 | - public ArgumentException(String message, Throwable cause) { | ||
38 | - super(message, cause); | ||
39 | - } | ||
40 | -} |
ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/JsonParsingException.java
deleted
100644 → 0
1 | -/* | ||
2 | - * Copyright 2015 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.ovsdb.rfc.error; | ||
17 | - | ||
18 | -/** | ||
19 | - * The JsonParsingException is thrown when JSON could not be successfully | ||
20 | - * parsed. | ||
21 | - */ | ||
22 | -public class JsonParsingException extends RuntimeException { | ||
23 | - private static final long serialVersionUID = 1424752181911923235L; | ||
24 | - | ||
25 | - /** | ||
26 | - * Constructs a JsonParsingException object. | ||
27 | - * @param message error message | ||
28 | - */ | ||
29 | - public JsonParsingException(String message) { | ||
30 | - super(message); | ||
31 | - } | ||
32 | - | ||
33 | - /** | ||
34 | - * Constructs a JsonParsingException object. | ||
35 | - * @param message error message | ||
36 | - * @param cause Throwable | ||
37 | - */ | ||
38 | - public JsonParsingException(String message, Throwable cause) { | ||
39 | - super(message, cause); | ||
40 | - } | ||
41 | - | ||
42 | - /** | ||
43 | - * Constructs a JsonParsingException object. | ||
44 | - * @param cause Throwable | ||
45 | - */ | ||
46 | - public JsonParsingException(Throwable cause) { | ||
47 | - super(cause); | ||
48 | - } | ||
49 | - | ||
50 | - /** | ||
51 | - * Constructs a JsonParsingException object. | ||
52 | - * @param message error message | ||
53 | - * @param cause Throwable | ||
54 | - * @param enableSuppression enable Suppression | ||
55 | - * @param writableStackTrace writable StackTrace | ||
56 | - */ | ||
57 | - public JsonParsingException(String message, Throwable cause, | ||
58 | - boolean enableSuppression, | ||
59 | - boolean writableStackTrace) { | ||
60 | - super(message, cause, enableSuppression, writableStackTrace); | ||
61 | - } | ||
62 | -} |
ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/TypedSchemaException.java
deleted
100644 → 0
1 | -/* | ||
2 | - * Copyright 2015 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.ovsdb.rfc.error; | ||
17 | - | ||
18 | -/** | ||
19 | - * This is a generic exception thrown by the Typed Schema utilities. | ||
20 | - */ | ||
21 | -public class TypedSchemaException extends RuntimeException { | ||
22 | - private static final long serialVersionUID = -1452257990783176715L; | ||
23 | - | ||
24 | - /** | ||
25 | - * Constructs a TypedSchemaException object. | ||
26 | - * @param message error message | ||
27 | - */ | ||
28 | - public TypedSchemaException(String message) { | ||
29 | - super(message); | ||
30 | - } | ||
31 | - | ||
32 | - /** | ||
33 | - * Constructs a TypedSchemaException object. | ||
34 | - * @param message error message | ||
35 | - * @param cause Throwable | ||
36 | - */ | ||
37 | - public TypedSchemaException(String message, Throwable cause) { | ||
38 | - super(message, cause); | ||
39 | - } | ||
40 | -} |
ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedEncodingException.java
deleted
100644 → 0
1 | -package org.onosproject.ovsdb.rfc.error; | ||
2 | - | ||
3 | -/** | ||
4 | - * This exception is thrown when the encoding does not meet UTF-8 in RFC7047. | ||
5 | - */ | ||
6 | -public class UnsupportedEncodingException extends RuntimeException { | ||
7 | - private static final long serialVersionUID = -4865311369828520666L; | ||
8 | - | ||
9 | - /** | ||
10 | - * Constructs a UnsupportedEncodingException object. | ||
11 | - * @param message error message | ||
12 | - */ | ||
13 | - public UnsupportedEncodingException(String message) { | ||
14 | - super(message); | ||
15 | - } | ||
16 | -} |
... | @@ -16,26 +16,26 @@ | ... | @@ -16,26 +16,26 @@ |
16 | package org.onosproject.ovsdb.rfc.error; | 16 | package org.onosproject.ovsdb.rfc.error; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | - * This exception is thrown when a result does not meet any of the known formats | 19 | + * This exception is thrown when the caller invoke the unsupported method or |
20 | - * in RFC7047. | 20 | + * use the encoding is not supported. |
21 | */ | 21 | */ |
22 | -public class UnknownResultException extends RuntimeException { | 22 | +public class UnsupportedException extends RuntimeException { |
23 | private static final long serialVersionUID = 1377011546616825375L; | 23 | private static final long serialVersionUID = 1377011546616825375L; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | - * Constructs a UnknownResultException object. | 26 | + * Constructs a UnsupportedException object. |
27 | * @param message error message | 27 | * @param message error message |
28 | */ | 28 | */ |
29 | - public UnknownResultException(String message) { | 29 | + public UnsupportedException(String message) { |
30 | super(message); | 30 | super(message); |
31 | } | 31 | } |
32 | 32 | ||
33 | /** | 33 | /** |
34 | - * Constructs a UnknownResultException object. | 34 | + * Constructs a UnsupportedException object. |
35 | * @param message error message | 35 | * @param message error message |
36 | * @param cause Throwable | 36 | * @param cause Throwable |
37 | */ | 37 | */ |
38 | - public UnknownResultException(String message, Throwable cause) { | 38 | + public UnsupportedException(String message, Throwable cause) { |
39 | super(message, cause); | 39 | super(message, cause); |
40 | } | 40 | } |
41 | } | 41 | } | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ovsdb.rfc.error; | 16 | package org.onosproject.ovsdb.rfc.error; |
17 | 17 | ||
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | ||
19 | 18 | ||
20 | /** | 19 | /** |
21 | * This exception is used when the a table or row is accessed though a typed | 20 | * This exception is used when the a table or row is accessed though a typed |
... | @@ -47,15 +46,9 @@ public class VersionMismatchException extends RuntimeException { | ... | @@ -47,15 +46,9 @@ public class VersionMismatchException extends RuntimeException { |
47 | * @param fromVersion the initial version | 46 | * @param fromVersion the initial version |
48 | * @return message | 47 | * @return message |
49 | */ | 48 | */ |
50 | - public static String createFromMessage(String actualVersion, | 49 | + public static String createFromMessage(String actualVersion, String fromVersion) { |
51 | - String fromVersion) { | 50 | + String message = "The fromVersion should less than the actualVersion.\n fromVersion: " |
52 | - String message = toStringHelper("VersionMismatchException") | 51 | + + fromVersion + ".\n" + "actualVersion: " + actualVersion; |
53 | - .addValue("The fromVersion should less than the actualVersion.\n" | ||
54 | - + "fromVersion: " | ||
55 | - + fromVersion | ||
56 | - + ".\n" | ||
57 | - + "actualVersion: " + actualVersion) | ||
58 | - .toString(); | ||
59 | return message; | 52 | return message; |
60 | } | 53 | } |
61 | 54 | ||
... | @@ -66,13 +59,8 @@ public class VersionMismatchException extends RuntimeException { | ... | @@ -66,13 +59,8 @@ public class VersionMismatchException extends RuntimeException { |
66 | * @return message | 59 | * @return message |
67 | */ | 60 | */ |
68 | public static String createToMessage(String actualVersion, String toVersion) { | 61 | public static String createToMessage(String actualVersion, String toVersion) { |
69 | - String message = toStringHelper("VersionMismatchException") | 62 | + String message = "The toVersion should greater than the actualVersion.\n" |
70 | - .addValue("The toVersion should greater than the required version.\n" | 63 | + + "toVersion: " + toVersion + ".\n" + " actualVersion: " + actualVersion; |
71 | - + "toVersion: " | ||
72 | - + toVersion | ||
73 | - + ".\n" | ||
74 | - + "Actual Version: " + actualVersion) | ||
75 | - .toString(); | ||
76 | return message; | 64 | return message; |
77 | } | 65 | } |
78 | } | 66 | } | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.message; | 16 | +package org.onosproject.ovsdb.rfc.message; |
17 | - | 17 | + |
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | 18 | +import static com.google.common.base.MoreObjects.toStringHelper; |
19 | -import static com.google.common.base.Preconditions.checkNotNull; | 19 | +import static com.google.common.base.Preconditions.checkNotNull; |
20 | - | 20 | + |
21 | -import java.util.Objects; | 21 | +import java.util.Objects; |
22 | - | 22 | + |
23 | -import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter; | 23 | +import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter; |
24 | - | 24 | + |
25 | -import com.fasterxml.jackson.databind.JsonNode; | 25 | +import com.fasterxml.jackson.databind.JsonNode; |
26 | -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | 26 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
27 | - | 27 | + |
28 | -/** | 28 | +/** |
29 | - * The "update" notification is sent by the server to the client to report | 29 | + * The "update" notification is sent by the server to the client to report |
30 | - * changes in tables that are being monitored following a "monitor" request. The | 30 | + * changes in tables that are being monitored following a "monitor" request. The |
31 | - * "params" of the result JsonNode. | 31 | + * "params" of the result JsonNode. |
32 | - */ | 32 | + */ |
33 | -@JsonDeserialize(converter = UpdateNotificationConverter.class) | 33 | +@JsonDeserialize(converter = UpdateNotificationConverter.class) |
34 | -public final class UpdateNotification { | 34 | +public final class UpdateNotification { |
35 | - private final Object context; | 35 | + private final Object jsonValue; |
36 | - private final JsonNode tbUpdatesJsonNode; | 36 | + private final JsonNode tbUpdatesJsonNode; |
37 | - | 37 | + |
38 | - /** | 38 | + /** |
39 | - * Constructs a UpdateNotification object. | 39 | + * Constructs a UpdateNotification object. |
40 | - * @param context the "json-value" in "params" of the result JsonNode | 40 | + * @param jsonValue the "json-value" in "params" of the result JsonNode |
41 | - * @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode | 41 | + * @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode |
42 | - */ | 42 | + */ |
43 | - public UpdateNotification(Object context, JsonNode tbUpdatesJsonNode) { | 43 | + public UpdateNotification(Object jsonValue, JsonNode tbUpdatesJsonNode) { |
44 | - checkNotNull(context, "context cannot be null"); | 44 | + checkNotNull(jsonValue, "jsonValue cannot be null"); |
45 | - checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null"); | 45 | + checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null"); |
46 | - this.context = context; | 46 | + this.jsonValue = jsonValue; |
47 | - this.tbUpdatesJsonNode = tbUpdatesJsonNode; | 47 | + this.tbUpdatesJsonNode = tbUpdatesJsonNode; |
48 | - } | 48 | + } |
49 | - | 49 | + |
50 | - /** | 50 | + /** |
51 | - * Return context. | 51 | + * Return context. |
52 | - * @return context | 52 | + * @return context |
53 | - */ | 53 | + */ |
54 | - public Object context() { | 54 | + public Object jsonValue() { |
55 | - return context; | 55 | + return jsonValue; |
56 | - } | 56 | + } |
57 | - | 57 | + |
58 | - /** | 58 | + /** |
59 | - * Return tbUpdatesJsonNode. | 59 | + * Return tbUpdatesJsonNode. |
60 | - * @return tbUpdatesJsonNode | 60 | + * @return tbUpdatesJsonNode |
61 | - */ | 61 | + */ |
62 | - public JsonNode tbUpdatesJsonNode() { | 62 | + public JsonNode tbUpdatesJsonNode() { |
63 | - return tbUpdatesJsonNode; | 63 | + return tbUpdatesJsonNode; |
64 | - } | 64 | + } |
65 | - | 65 | + |
66 | - @Override | 66 | + @Override |
67 | - public int hashCode() { | 67 | + public int hashCode() { |
68 | - return Objects.hash(context, tbUpdatesJsonNode); | 68 | + return Objects.hash(jsonValue, tbUpdatesJsonNode); |
69 | - } | 69 | + } |
70 | - | 70 | + |
71 | - @Override | 71 | + @Override |
72 | - public boolean equals(Object obj) { | 72 | + public boolean equals(Object obj) { |
73 | - if (this == obj) { | 73 | + if (this == obj) { |
74 | - return true; | 74 | + return true; |
75 | - } | 75 | + } |
76 | - if (obj instanceof UpdateNotification) { | 76 | + if (obj instanceof UpdateNotification) { |
77 | - final UpdateNotification other = (UpdateNotification) obj; | 77 | + final UpdateNotification other = (UpdateNotification) obj; |
78 | - return Objects.equals(this.context, other.context) | 78 | + return Objects.equals(this.jsonValue, other.jsonValue) |
79 | - && Objects.equals(this.tbUpdatesJsonNode, | 79 | + && Objects.equals(this.tbUpdatesJsonNode, |
80 | - other.tbUpdatesJsonNode); | 80 | + other.tbUpdatesJsonNode); |
81 | - } | 81 | + } |
82 | - return false; | 82 | + return false; |
83 | - } | 83 | + } |
84 | - | 84 | + |
85 | - @Override | 85 | + @Override |
86 | - public String toString() { | 86 | + public String toString() { |
87 | - return toStringHelper(this).add("context", context) | 87 | + return toStringHelper(this).add("jsonValue", jsonValue) |
88 | - .add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString(); | 88 | + .add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString(); |
89 | - } | 89 | + } |
90 | -} | 90 | +} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.notation; | 16 | +package org.onosproject.ovsdb.rfc.notation; |
17 | - | 17 | + |
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | 18 | +import static com.google.common.base.MoreObjects.toStringHelper; |
19 | -import static com.google.common.base.Preconditions.checkNotNull; | 19 | +import static com.google.common.base.Preconditions.checkNotNull; |
20 | - | 20 | + |
21 | -import java.util.Objects; | 21 | +import java.util.Objects; |
22 | - | 22 | + |
23 | -import org.onosproject.ovsdb.rfc.schema.ColumnSchema; | 23 | +/** |
24 | - | 24 | + * Column is the basic element of the OpenVswitch database. |
25 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 25 | + */ |
26 | - | 26 | +public final class Column { |
27 | -/** | 27 | + private final String columnName; |
28 | - * Column is the basic element of the OpenVswitch database. | 28 | + private final Object data; |
29 | - */ | 29 | + |
30 | -public final class Column { | 30 | + /** |
31 | - @JsonIgnore | 31 | + * Column constructor. |
32 | - private final ColumnSchema schema; | 32 | + * @param columnName the column name |
33 | - private final Object data; | 33 | + * @param obj the data of the column |
34 | - | 34 | + */ |
35 | - /** | 35 | + public Column(String columnName, Object obj) { |
36 | - * Column constructor. | 36 | + checkNotNull(columnName, "columnName cannot be null"); |
37 | - * @param schema the column schema | 37 | + checkNotNull(obj, "data cannot be null"); |
38 | - * @param obj the data of the column | 38 | + this.columnName = columnName; |
39 | - */ | 39 | + this.data = obj; |
40 | - public Column(ColumnSchema schema, Object obj) { | 40 | + } |
41 | - checkNotNull(schema, "schema cannot be null"); | 41 | + |
42 | - checkNotNull(obj, "data cannot be null"); | 42 | + /** |
43 | - this.schema = schema; | 43 | + * Returns column data. |
44 | - this.data = obj; | 44 | + * @return column data |
45 | - } | 45 | + */ |
46 | - | 46 | + public Object data() { |
47 | - /** | 47 | + return data; |
48 | - * Returns column data. | 48 | + } |
49 | - * @return column data | 49 | + |
50 | - */ | 50 | + /** |
51 | - public Object data() { | 51 | + * Returns columnName. |
52 | - return data; | 52 | + * @return columnName |
53 | - } | 53 | + */ |
54 | - | 54 | + public String columnName() { |
55 | - /** | 55 | + return columnName; |
56 | - * Returns ColumnSchema. | 56 | + } |
57 | - * @return ColumnSchema | 57 | + |
58 | - */ | 58 | + @Override |
59 | - public ColumnSchema schema() { | 59 | + public int hashCode() { |
60 | - return schema; | 60 | + return Objects.hash(columnName, data); |
61 | - } | 61 | + } |
62 | - | 62 | + |
63 | - @Override | 63 | + @Override |
64 | - public int hashCode() { | 64 | + public boolean equals(Object obj) { |
65 | - return Objects.hash(schema, data); | 65 | + if (this == obj) { |
66 | - } | 66 | + return true; |
67 | - | 67 | + } |
68 | - @Override | 68 | + if (obj instanceof Column) { |
69 | - public boolean equals(Object obj) { | 69 | + final Column other = (Column) obj; |
70 | - if (this == obj) { | 70 | + return Objects.equals(this.columnName, other.columnName) |
71 | - return true; | 71 | + && Objects.equals(this.data, other.data); |
72 | - } | 72 | + } |
73 | - if (obj instanceof Column) { | 73 | + return false; |
74 | - final Column other = (Column) obj; | 74 | + } |
75 | - return Objects.equals(this.schema, other.schema) | 75 | + |
76 | - && Objects.equals(this.data, other.data); | 76 | + @Override |
77 | - } | 77 | + public String toString() { |
78 | - return false; | 78 | + return toStringHelper(this).add("columnName", columnName) |
79 | - } | 79 | + .add("data", data).toString(); |
80 | - | 80 | + } |
81 | - @Override | 81 | +} |
82 | - public String toString() { | ||
83 | - return toStringHelper(this).add("schema", schema).add("data", data) | ||
84 | - .toString(); | ||
85 | - } | ||
86 | -} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.notation; | 16 | +package org.onosproject.ovsdb.rfc.notation; |
17 | - | 17 | + |
18 | -import static com.google.common.base.MoreObjects.toStringHelper; | 18 | +import static com.google.common.base.MoreObjects.toStringHelper; |
19 | -import static com.google.common.base.Preconditions.checkNotNull; | 19 | +import static com.google.common.base.Preconditions.checkNotNull; |
20 | - | 20 | + |
21 | -import java.util.Collection; | 21 | +import java.util.Collection; |
22 | -import java.util.List; | 22 | +import java.util.Map; |
23 | -import java.util.Map; | 23 | +import java.util.Objects; |
24 | -import java.util.Objects; | 24 | + |
25 | - | 25 | +import com.google.common.collect.Maps; |
26 | -import org.onosproject.ovsdb.rfc.schema.ColumnSchema; | 26 | + |
27 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 27 | +/** |
28 | - | 28 | + * Row is the basic element of the OpenVswitch's table. |
29 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 29 | + */ |
30 | -import com.google.common.collect.Maps; | 30 | +public final class Row { |
31 | - | 31 | + private String tableName; |
32 | -/** | 32 | + private Map<String, Column> columns; |
33 | - * Row is the basic element of the OpenVswitch's table. | 33 | + |
34 | - */ | 34 | + /** |
35 | -public final class Row { | 35 | + * Row constructor. |
36 | - @JsonIgnore | 36 | + */ |
37 | - private TableSchema tableSchema; | 37 | + public Row() { |
38 | - private Map<String, Column> columns; | 38 | + this.columns = Maps.newHashMap(); |
39 | - | 39 | + } |
40 | - /** | 40 | + |
41 | - * Row constructor. | 41 | + /** |
42 | - */ | 42 | + * Row constructor. |
43 | - public Row() { | 43 | + * @param tableName table name |
44 | - this.columns = Maps.newHashMap(); | 44 | + */ |
45 | - } | 45 | + public Row(String tableName) { |
46 | - | 46 | + checkNotNull(tableName, "tableName cannot be null"); |
47 | - /** | 47 | + this.tableName = tableName; |
48 | - * Row constructor. | 48 | + this.columns = Maps.newHashMap(); |
49 | - * @param tableSchema TableSchema entity | 49 | + } |
50 | - */ | 50 | + |
51 | - public Row(TableSchema tableSchema) { | 51 | + /** |
52 | - checkNotNull(tableSchema, "tableSchema cannot be null"); | 52 | + * Row constructor. |
53 | - this.tableSchema = tableSchema; | 53 | + * @param tableName table name |
54 | - this.columns = Maps.newHashMap(); | 54 | + * @param columns Map of Column entity |
55 | - } | 55 | + */ |
56 | - | 56 | + public Row(String tableName, Map<String, Column> columns) { |
57 | - /** | 57 | + checkNotNull(tableName, "table name cannot be null"); |
58 | - * Row constructor. | 58 | + checkNotNull(columns, "columns cannot be null"); |
59 | - * @param tableSchema TableSchema entity | 59 | + this.tableName = tableName; |
60 | - * @param columns List of Column entity | 60 | + this.columns = columns; |
61 | - */ | 61 | + } |
62 | - public Row(TableSchema tableSchema, List<Column> columns) { | 62 | + |
63 | - checkNotNull(tableSchema, "tableSchema cannot be null"); | 63 | + /** |
64 | - checkNotNull(columns, "columns cannot be null"); | 64 | + * Returns tableName. |
65 | - this.tableSchema = tableSchema; | 65 | + * @return tableName |
66 | - this.columns = Maps.newHashMap(); | 66 | + */ |
67 | - for (Column column : columns) { | 67 | + public String tableName() { |
68 | - this.columns.put(column.schema().name(), column); | 68 | + return tableName; |
69 | - } | 69 | + } |
70 | - } | 70 | + |
71 | - | 71 | + /** |
72 | - /** | 72 | + * Set tableName value. |
73 | - * Returns tableSchema. | 73 | + * @param tableName table name |
74 | - * @return tableSchema | 74 | + */ |
75 | - */ | 75 | + public void setTableName(String tableName) { |
76 | - public TableSchema getTableSchema() { | 76 | + this.tableName = tableName; |
77 | - return tableSchema; | 77 | + } |
78 | - } | 78 | + |
79 | - | 79 | + /** |
80 | - /** | 80 | + * Returns Column by ColumnSchema. |
81 | - * Set tableSchema value. | 81 | + * @param columnName column name |
82 | - * @param tableSchema TableSchema entity | 82 | + * @return Column |
83 | - */ | 83 | + */ |
84 | - public void setTableSchema(TableSchema tableSchema) { | 84 | + public Column getColumn(String columnName) { |
85 | - this.tableSchema = tableSchema; | 85 | + return columns.get(columnName); |
86 | - } | 86 | + } |
87 | - | 87 | + |
88 | - /** | 88 | + /** |
89 | - * Returns Column by ColumnSchema. | 89 | + * Returns Collection of Column. |
90 | - * @param schema ColumnSchema entity | 90 | + * @return Collection of Column |
91 | - * @return Column | 91 | + */ |
92 | - */ | 92 | + public Collection<Column> getColumns() { |
93 | - public Column getColumn(ColumnSchema schema) { | 93 | + return columns.values(); |
94 | - return (Column) columns.get(schema.name()); | 94 | + } |
95 | - } | 95 | + |
96 | - | 96 | + /** |
97 | - /** | 97 | + * add Column. |
98 | - * Returns Collection of Column. | 98 | + * @param columnName column name |
99 | - * @return Collection of Column | 99 | + * @param data Column entity |
100 | - */ | 100 | + */ |
101 | - public Collection<Column> getColumns() { | 101 | + public void addColumn(String columnName, Column data) { |
102 | - return columns.values(); | 102 | + this.columns.put(columnName, data); |
103 | - } | 103 | + } |
104 | - | 104 | + |
105 | - /** | 105 | + @Override |
106 | - * add Column. | 106 | + public int hashCode() { |
107 | - * @param columnName column name | 107 | + return Objects.hash(tableName, columns); |
108 | - * @param data Column entity | 108 | + } |
109 | - */ | 109 | + |
110 | - public void addColumn(String columnName, Column data) { | 110 | + @Override |
111 | - this.columns.put(columnName, data); | 111 | + public boolean equals(Object obj) { |
112 | - } | 112 | + if (this == obj) { |
113 | - | 113 | + return true; |
114 | - @Override | 114 | + } |
115 | - public int hashCode() { | 115 | + if (obj instanceof Row) { |
116 | - return Objects.hash(tableSchema, columns); | 116 | + final Row other = (Row) obj; |
117 | - } | 117 | + return Objects.equals(this.tableName, other.tableName) |
118 | - | 118 | + && Objects.equals(this.columns, other.columns); |
119 | - @Override | 119 | + } |
120 | - public boolean equals(Object obj) { | 120 | + return false; |
121 | - if (this == obj) { | 121 | + } |
122 | - return true; | 122 | + |
123 | - } | 123 | + @Override |
124 | - if (obj instanceof Row) { | 124 | + public String toString() { |
125 | - final Row other = (Row) obj; | 125 | + return toStringHelper(this).add("tableName", tableName) |
126 | - return Objects.equals(this.tableSchema, other.tableSchema) | 126 | + .add("columns", columns).toString(); |
127 | - && Objects.equals(this.columns, other.columns); | 127 | + } |
128 | - } | 128 | +} |
129 | - return false; | ||
130 | - } | ||
131 | - | ||
132 | - @Override | ||
133 | - public String toString() { | ||
134 | - return toStringHelper(this).add("tableSchema", tableSchema).add("columns", columns).toString(); | ||
135 | - } | ||
136 | -} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.operations; | 16 | +package org.onosproject.ovsdb.rfc.operations; |
17 | - | 17 | + |
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | - | 19 | + |
20 | -import java.util.List; | 20 | +import java.util.List; |
21 | - | 21 | + |
22 | -import org.onosproject.ovsdb.rfc.notation.Condition; | 22 | +import org.onosproject.ovsdb.rfc.notation.Condition; |
23 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 23 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
24 | - | 24 | + |
25 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 25 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
26 | -import com.fasterxml.jackson.annotation.JsonProperty; | 26 | +import com.fasterxml.jackson.annotation.JsonProperty; |
27 | - | 27 | + |
28 | -/** | 28 | +/** |
29 | - * delete operation.Refer to RFC 7047 Section 5.2. | 29 | + * delete operation.Refer to RFC 7047 Section 5.2. |
30 | - */ | 30 | + */ |
31 | -public final class Delete implements Operation { | 31 | +public final class Delete implements Operation { |
32 | - | 32 | + |
33 | - @JsonIgnore | 33 | + @JsonIgnore |
34 | - private final TableSchema tableSchema; | 34 | + private final TableSchema tableSchema; |
35 | - private final String op; | 35 | + private final String op; |
36 | - private final List<Condition> where; | 36 | + private final List<Condition> where; |
37 | - | 37 | + |
38 | - /** | 38 | + /** |
39 | - * Constructs a Delete object. | 39 | + * Constructs a Delete object. |
40 | - * @param schema TableSchema entity | 40 | + * @param schema TableSchema entity |
41 | - * @param where the List of Condition entity | 41 | + * @param where the List of Condition entity |
42 | - */ | 42 | + */ |
43 | - public Delete(TableSchema schema, List<Condition> where) { | 43 | + public Delete(TableSchema schema, List<Condition> where) { |
44 | - checkNotNull(schema, "TableSchema cannot be null"); | 44 | + checkNotNull(schema, "TableSchema cannot be null"); |
45 | - checkNotNull(where, "where is not null"); | 45 | + checkNotNull(where, "where is not null"); |
46 | - this.tableSchema = schema; | 46 | + this.tableSchema = schema; |
47 | - this.op = Operations.DELETE.op(); | 47 | + this.op = Operations.DELETE.op(); |
48 | - this.where = where; | 48 | + this.where = where; |
49 | - } | 49 | + } |
50 | - | 50 | + |
51 | - /** | 51 | + /** |
52 | - * Returns the where member of delete operation. | 52 | + * Returns the where member of delete operation. |
53 | - * @return the where member of delete operation | 53 | + * @return the where member of delete operation |
54 | - */ | 54 | + */ |
55 | - public List<Condition> getWhere() { | 55 | + public List<Condition> getWhere() { |
56 | - return where; | 56 | + return where; |
57 | - } | 57 | + } |
58 | - | 58 | + |
59 | - @Override | 59 | + @Override |
60 | - public String getOp() { | 60 | + public String getOp() { |
61 | - return op; | 61 | + return op; |
62 | - } | 62 | + } |
63 | - | 63 | + |
64 | - @Override | 64 | + @Override |
65 | - public TableSchema getTableSchema() { | 65 | + public TableSchema getTableSchema() { |
66 | - return tableSchema; | 66 | + return tableSchema; |
67 | - } | 67 | + } |
68 | - | 68 | + |
69 | - /** | 69 | + /** |
70 | - * For the use of serialization. | 70 | + * For the use of serialization. |
71 | - * @return the table member of update operation | 71 | + * @return the table member of update operation |
72 | - */ | 72 | + */ |
73 | - @JsonProperty | 73 | + @JsonProperty |
74 | - public String getTable() { | 74 | + public String getTable() { |
75 | - return (tableSchema == null) ? null : tableSchema.name(); | 75 | + return tableSchema.name(); |
76 | - } | 76 | + } |
77 | -} | 77 | +} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.operations; | 16 | +package org.onosproject.ovsdb.rfc.operations; |
17 | - | 17 | + |
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | - | 19 | + |
20 | -import java.util.Collection; | 20 | +import java.util.Collection; |
21 | -import java.util.Map; | 21 | +import java.util.Map; |
22 | - | 22 | + |
23 | -import org.onosproject.ovsdb.rfc.notation.Column; | 23 | +import org.onosproject.ovsdb.rfc.notation.Column; |
24 | -import org.onosproject.ovsdb.rfc.notation.Row; | 24 | +import org.onosproject.ovsdb.rfc.notation.Row; |
25 | -import org.onosproject.ovsdb.rfc.schema.ColumnSchema; | 25 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
26 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 26 | +import org.onosproject.ovsdb.rfc.utils.TransValueUtil; |
27 | -import org.onosproject.ovsdb.rfc.utils.TransValueUtil; | 27 | + |
28 | - | 28 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
29 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 29 | +import com.fasterxml.jackson.annotation.JsonProperty; |
30 | -import com.fasterxml.jackson.annotation.JsonProperty; | 30 | +import com.google.common.collect.Maps; |
31 | -import com.google.common.collect.Maps; | 31 | + |
32 | - | 32 | +/** |
33 | -/** | 33 | + * insert operation.Refer to RFC 7047 Section 5.2. |
34 | - * insert operation.Refer to RFC 7047 Section 5.2. | 34 | + */ |
35 | - */ | 35 | +public final class Insert implements Operation { |
36 | -public final class Insert implements Operation { | 36 | + |
37 | - | 37 | + @JsonIgnore |
38 | - @JsonIgnore | 38 | + private final TableSchema tableSchema; |
39 | - private final TableSchema tableSchema; | 39 | + private final String op; |
40 | - private final String op; | 40 | + @JsonProperty("uuid-name") |
41 | - @JsonProperty("uuid-name") | 41 | + private final String uuidName; |
42 | - private final String uuidName; | 42 | + private final Map<String, Object> row; |
43 | - private final Map<String, Object> row; | 43 | + |
44 | - | 44 | + /** |
45 | - /** | 45 | + * Constructs a Insert object. |
46 | - * Constructs a Insert object. | 46 | + * @param schema TableSchema entity |
47 | - * @param schema TableSchema entity | 47 | + * @param uuidName uuid-name |
48 | - * @param uuidName uuid-name | 48 | + * @param row Row entity |
49 | - * @param row Row entity | 49 | + */ |
50 | - */ | 50 | + public Insert(TableSchema schema, String uuidName, Row row) { |
51 | - public Insert(TableSchema schema, String uuidName, Row row) { | 51 | + checkNotNull(schema, "TableSchema cannot be null"); |
52 | - checkNotNull(schema, "TableSchema cannot be null"); | 52 | + checkNotNull(uuidName, "uuid name cannot be null"); |
53 | - checkNotNull(uuidName, "uuid name cannot be null"); | 53 | + checkNotNull(row, "row cannot be null"); |
54 | - checkNotNull(row, "row cannot be null"); | 54 | + this.tableSchema = schema; |
55 | - this.tableSchema = schema; | 55 | + this.op = Operations.INSERT.op(); |
56 | - this.op = Operations.INSERT.op(); | 56 | + this.uuidName = uuidName; |
57 | - this.uuidName = uuidName; | 57 | + this.row = Maps.newHashMap(); |
58 | - this.row = Maps.newHashMap(); | 58 | + generateOperationRow(row); |
59 | - generateOperationRow(row); | 59 | + } |
60 | - } | 60 | + |
61 | - | 61 | + /** |
62 | - /** | 62 | + * Row entity convert into the row format of insert operation. Refer to RFC |
63 | - * Row entity convert into the row format of insert operation. Refer to RFC | 63 | + * 7047 Section 5.2. |
64 | - * 7047 Section 5.2. | 64 | + * @param row Row entity |
65 | - * @param row Row entity | 65 | + */ |
66 | - */ | 66 | + private void generateOperationRow(Row row) { |
67 | - private void generateOperationRow(Row row) { | 67 | + Collection<Column> columns = row.getColumns(); |
68 | - Collection<Column> columns = row.getColumns(); | 68 | + for (Column column : columns) { |
69 | - for (Column column : columns) { | 69 | + String columnName = column.columnName(); |
70 | - ColumnSchema columnSchema = column.schema(); | 70 | + Object value = column.data(); |
71 | - Object value = column.data(); | 71 | + Object formatValue = TransValueUtil.getFormatData(value); |
72 | - Object untypedValue = TransValueUtil.getFormatData(value); | 72 | + this.row.put(columnName, formatValue); |
73 | - this.row.put(columnSchema.name(), untypedValue); | 73 | + } |
74 | - } | 74 | + } |
75 | - } | 75 | + |
76 | - | 76 | + /** |
77 | - /** | 77 | + * Returns the uuid-name member of insert operation. |
78 | - * Returns the uuid-name member of insert operation. | 78 | + * @return the uuid-name member of insert operation |
79 | - * @return the uuid-name member of insert operation | 79 | + */ |
80 | - */ | 80 | + public String getUuidName() { |
81 | - public String getUuidName() { | 81 | + return uuidName; |
82 | - return uuidName; | 82 | + } |
83 | - } | 83 | + |
84 | - | 84 | + /** |
85 | - /** | 85 | + * Returns the row member of insert operation. |
86 | - * Returns the row member of insert operation. | 86 | + * @return the row member of insert operation |
87 | - * @return the row member of insert operation | 87 | + */ |
88 | - */ | 88 | + public Map<String, Object> getRow() { |
89 | - public Map<String, Object> getRow() { | 89 | + return row; |
90 | - return row; | 90 | + } |
91 | - } | 91 | + |
92 | - | 92 | + @Override |
93 | - @Override | 93 | + public String getOp() { |
94 | - public String getOp() { | 94 | + return op; |
95 | - return op; | 95 | + } |
96 | - } | 96 | + |
97 | - | 97 | + @Override |
98 | - @Override | 98 | + public TableSchema getTableSchema() { |
99 | - public TableSchema getTableSchema() { | 99 | + return tableSchema; |
100 | - return tableSchema; | 100 | + } |
101 | - } | 101 | + |
102 | - | 102 | + /** |
103 | - /** | 103 | + * For the use of serialization. |
104 | - * For the use of serialization. | 104 | + * @return the table member of update operation |
105 | - * @return the table member of update operation | 105 | + */ |
106 | - */ | 106 | + @JsonProperty |
107 | - @JsonProperty | 107 | + public String getTable() { |
108 | - public String getTable() { | 108 | + return tableSchema.name(); |
109 | - return (tableSchema == null) ? null : tableSchema.name(); | 109 | + } |
110 | - } | 110 | +} |
111 | -} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.operations; | 16 | +package org.onosproject.ovsdb.rfc.operations; |
17 | - | 17 | + |
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | - | 19 | + |
20 | -import java.util.List; | 20 | +import java.util.List; |
21 | - | 21 | + |
22 | -import org.onosproject.ovsdb.rfc.notation.Condition; | 22 | +import org.onosproject.ovsdb.rfc.notation.Condition; |
23 | -import org.onosproject.ovsdb.rfc.notation.Mutation; | 23 | +import org.onosproject.ovsdb.rfc.notation.Mutation; |
24 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 24 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
25 | - | 25 | + |
26 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 26 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
27 | -import com.fasterxml.jackson.annotation.JsonProperty; | 27 | +import com.fasterxml.jackson.annotation.JsonProperty; |
28 | - | 28 | + |
29 | -/** | 29 | +/** |
30 | - * mutate operation.Refer to RFC 7047 Section 5.2. | 30 | + * mutate operation.Refer to RFC 7047 Section 5.2. |
31 | - */ | 31 | + */ |
32 | -public final class Mutate implements Operation { | 32 | +public final class Mutate implements Operation { |
33 | - | 33 | + |
34 | - @JsonIgnore | 34 | + @JsonIgnore |
35 | - private final TableSchema tableSchema; | 35 | + private final TableSchema tableSchema; |
36 | - private final String op; | 36 | + private final String op; |
37 | - private final List<Condition> where; | 37 | + private final List<Condition> where; |
38 | - private final List<Mutation> mutations; | 38 | + private final List<Mutation> mutations; |
39 | - | 39 | + |
40 | - /** | 40 | + /** |
41 | - * Constructs a Mutate object. | 41 | + * Constructs a Mutate object. |
42 | - * @param schema TableSchema entity | 42 | + * @param schema TableSchema entity |
43 | - * @param where the List of Condition entity | 43 | + * @param where the List of Condition entity |
44 | - * @param mutations the List of Mutation entity | 44 | + * @param mutations the List of Mutation entity |
45 | - */ | 45 | + */ |
46 | - public Mutate(TableSchema schema, List<Condition> where, | 46 | + public Mutate(TableSchema schema, List<Condition> where, |
47 | - List<Mutation> mutations) { | 47 | + List<Mutation> mutations) { |
48 | - checkNotNull(schema, "TableSchema cannot be null"); | 48 | + checkNotNull(schema, "TableSchema cannot be null"); |
49 | - checkNotNull(mutations, "mutations cannot be null"); | 49 | + checkNotNull(mutations, "mutations cannot be null"); |
50 | - checkNotNull(where, "where cannot be null"); | 50 | + checkNotNull(where, "where cannot be null"); |
51 | - this.tableSchema = schema; | 51 | + this.tableSchema = schema; |
52 | - this.op = Operations.MUTATE.op(); | 52 | + this.op = Operations.MUTATE.op(); |
53 | - this.where = where; | 53 | + this.where = where; |
54 | - this.mutations = mutations; | 54 | + this.mutations = mutations; |
55 | - } | 55 | + } |
56 | - | 56 | + |
57 | - /** | 57 | + /** |
58 | - * Returns the mutations member of mutate operation. | 58 | + * Returns the mutations member of mutate operation. |
59 | - * @return the mutations member of mutate operation | 59 | + * @return the mutations member of mutate operation |
60 | - */ | 60 | + */ |
61 | - public List<Mutation> getMutations() { | 61 | + public List<Mutation> getMutations() { |
62 | - return mutations; | 62 | + return mutations; |
63 | - } | 63 | + } |
64 | - | 64 | + |
65 | - /** | 65 | + /** |
66 | - * Returns the where member of mutate operation. | 66 | + * Returns the where member of mutate operation. |
67 | - * @return the where member of mutate operation | 67 | + * @return the where member of mutate operation |
68 | - */ | 68 | + */ |
69 | - public List<Condition> getWhere() { | 69 | + public List<Condition> getWhere() { |
70 | - return where; | 70 | + return where; |
71 | - } | 71 | + } |
72 | - | 72 | + |
73 | - @Override | 73 | + @Override |
74 | - public String getOp() { | 74 | + public String getOp() { |
75 | - return op; | 75 | + return op; |
76 | - } | 76 | + } |
77 | - | 77 | + |
78 | - @Override | 78 | + @Override |
79 | - public TableSchema getTableSchema() { | 79 | + public TableSchema getTableSchema() { |
80 | - return tableSchema; | 80 | + return tableSchema; |
81 | - } | 81 | + } |
82 | - | 82 | + |
83 | - /** | 83 | + /** |
84 | - * For the use of serialization. | 84 | + * For the use of serialization. |
85 | - * @return the table member of update operation | 85 | + * @return the table member of update operation |
86 | - */ | 86 | + */ |
87 | - @JsonProperty | 87 | + @JsonProperty |
88 | - public String getTable() { | 88 | + public String getTable() { |
89 | - return (tableSchema == null) ? null : tableSchema.name(); | 89 | + return tableSchema.name(); |
90 | - } | 90 | + } |
91 | -} | 91 | +} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.operations; | 16 | +package org.onosproject.ovsdb.rfc.operations; |
17 | - | 17 | + |
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | - | 19 | + |
20 | -import java.util.List; | 20 | +import java.util.List; |
21 | - | 21 | + |
22 | -import org.onosproject.ovsdb.rfc.notation.Condition; | 22 | +import org.onosproject.ovsdb.rfc.notation.Condition; |
23 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 23 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
24 | - | 24 | + |
25 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 25 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
26 | -import com.fasterxml.jackson.annotation.JsonProperty; | 26 | +import com.fasterxml.jackson.annotation.JsonProperty; |
27 | - | 27 | + |
28 | -/** | 28 | +/** |
29 | - * select operation.Refer to RFC 7047 Section 5.2. | 29 | + * select operation.Refer to RFC 7047 Section 5.2. |
30 | - */ | 30 | + */ |
31 | -public final class Select implements Operation { | 31 | +public final class Select implements Operation { |
32 | - | 32 | + |
33 | - @JsonIgnore | 33 | + @JsonIgnore |
34 | - private final TableSchema tableSchema; | 34 | + private final TableSchema tableSchema; |
35 | - private final String op; | 35 | + private final String op; |
36 | - private final List<Condition> where; | 36 | + private final List<Condition> where; |
37 | - private final List<String> columns; | 37 | + private final List<String> columns; |
38 | - | 38 | + |
39 | - /** | 39 | + /** |
40 | - * Constructs a Select object. | 40 | + * Constructs a Select object. |
41 | - * @param schema TableSchema entity | 41 | + * @param schema TableSchema entity |
42 | - * @param where the List of Condition entity | 42 | + * @param where the List of Condition entity |
43 | - * @param columns the List of column name | 43 | + * @param columns the List of column name |
44 | - */ | 44 | + */ |
45 | - public Select(TableSchema schema, List<Condition> where, List<String> columns) { | 45 | + public Select(TableSchema schema, List<Condition> where, List<String> columns) { |
46 | - checkNotNull(schema, "TableSchema cannot be null"); | 46 | + checkNotNull(schema, "TableSchema cannot be null"); |
47 | - checkNotNull(where, "where cannot be null"); | 47 | + checkNotNull(where, "where cannot be null"); |
48 | - checkNotNull(columns, "columns cannot be null"); | 48 | + checkNotNull(columns, "columns cannot be null"); |
49 | - this.tableSchema = schema; | 49 | + this.tableSchema = schema; |
50 | - this.op = Operations.SELECT.op(); | 50 | + this.op = Operations.SELECT.op(); |
51 | - this.where = where; | 51 | + this.where = where; |
52 | - this.columns = columns; | 52 | + this.columns = columns; |
53 | - } | 53 | + } |
54 | - | 54 | + |
55 | - /** | 55 | + /** |
56 | - * Returns the columns member of select operation. | 56 | + * Returns the columns member of select operation. |
57 | - * @return the columns member of select operation | 57 | + * @return the columns member of select operation |
58 | - */ | 58 | + */ |
59 | - public List<String> getColumns() { | 59 | + public List<String> getColumns() { |
60 | - return columns; | 60 | + return columns; |
61 | - } | 61 | + } |
62 | - | 62 | + |
63 | - /** | 63 | + /** |
64 | - * Returns the where member of select operation. | 64 | + * Returns the where member of select operation. |
65 | - * @return the where member of select operation | 65 | + * @return the where member of select operation |
66 | - */ | 66 | + */ |
67 | - public List<Condition> getWhere() { | 67 | + public List<Condition> getWhere() { |
68 | - return where; | 68 | + return where; |
69 | - } | 69 | + } |
70 | - | 70 | + |
71 | - @Override | 71 | + @Override |
72 | - public String getOp() { | 72 | + public String getOp() { |
73 | - return op; | 73 | + return op; |
74 | - } | 74 | + } |
75 | - | 75 | + |
76 | - @Override | 76 | + @Override |
77 | - public TableSchema getTableSchema() { | 77 | + public TableSchema getTableSchema() { |
78 | - return tableSchema; | 78 | + return tableSchema; |
79 | - } | 79 | + } |
80 | - | 80 | + |
81 | - /** | 81 | + /** |
82 | - * For the use of serialization. | 82 | + * For the use of serialization. |
83 | - * @return the table member of update operation | 83 | + * @return the table member of update operation |
84 | - */ | 84 | + */ |
85 | - @JsonProperty | 85 | + @JsonProperty |
86 | - public String getTable() { | 86 | + public String getTable() { |
87 | - return (tableSchema == null) ? null : tableSchema.name(); | 87 | + return tableSchema.name(); |
88 | - } | 88 | + } |
89 | -} | 89 | +} | ... | ... |
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.operations; | 16 | +package org.onosproject.ovsdb.rfc.operations; |
17 | - | 17 | + |
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | - | 19 | + |
20 | -import java.util.Collection; | 20 | +import java.util.Collection; |
21 | -import java.util.List; | 21 | +import java.util.List; |
22 | -import java.util.Map; | 22 | +import java.util.Map; |
23 | - | 23 | + |
24 | -import org.onosproject.ovsdb.rfc.notation.Column; | 24 | +import org.onosproject.ovsdb.rfc.notation.Column; |
25 | -import org.onosproject.ovsdb.rfc.notation.Condition; | 25 | +import org.onosproject.ovsdb.rfc.notation.Condition; |
26 | -import org.onosproject.ovsdb.rfc.notation.Row; | 26 | +import org.onosproject.ovsdb.rfc.notation.Row; |
27 | -import org.onosproject.ovsdb.rfc.schema.ColumnSchema; | 27 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
28 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 28 | +import org.onosproject.ovsdb.rfc.utils.TransValueUtil; |
29 | -import org.onosproject.ovsdb.rfc.utils.TransValueUtil; | 29 | + |
30 | - | 30 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
31 | -import com.fasterxml.jackson.annotation.JsonIgnore; | 31 | +import com.fasterxml.jackson.annotation.JsonProperty; |
32 | -import com.fasterxml.jackson.annotation.JsonProperty; | 32 | +import com.google.common.collect.Maps; |
33 | -import com.google.common.collect.Maps; | 33 | + |
34 | - | 34 | +/** |
35 | -/** | 35 | + * update operation.Refer to RFC 7047 Section 5.2. |
36 | - * update operation.Refer to RFC 7047 Section 5.2. | 36 | + */ |
37 | - */ | 37 | +public final class Update implements Operation { |
38 | -public final class Update implements Operation { | 38 | + |
39 | - | 39 | + @JsonIgnore |
40 | - @JsonIgnore | 40 | + private final TableSchema tableSchema; |
41 | - private final TableSchema tableSchema; | 41 | + private final String op; |
42 | - private final String op; | 42 | + private final Map<String, Object> row; |
43 | - private final Map<String, Object> row; | 43 | + private final List<Condition> where; |
44 | - private final List<Condition> where; | 44 | + |
45 | - | 45 | + /** |
46 | - /** | 46 | + * Constructs a Update object. |
47 | - * Constructs a Update object. | 47 | + * @param schema TableSchema entity |
48 | - * @param schema TableSchema entity | 48 | + * @param row Row entity |
49 | - * @param row Row entity | 49 | + * @param where the List of Condition entity |
50 | - * @param where the List of Condition entity | 50 | + */ |
51 | - */ | 51 | + public Update(TableSchema schema, Row row, List<Condition> where) { |
52 | - public Update(TableSchema schema, Row row, List<Condition> where) { | 52 | + checkNotNull(schema, "TableSchema cannot be null"); |
53 | - checkNotNull(schema, "TableSchema cannot be null"); | 53 | + checkNotNull(row, "row cannot be null"); |
54 | - checkNotNull(row, "row cannot be null"); | 54 | + checkNotNull(where, "where cannot be null"); |
55 | - checkNotNull(where, "where cannot be null"); | 55 | + this.tableSchema = schema; |
56 | - this.tableSchema = schema; | 56 | + this.op = Operations.UPDATE.op(); |
57 | - this.op = Operations.UPDATE.op(); | 57 | + this.row = Maps.newHashMap(); |
58 | - this.row = Maps.newHashMap(); | 58 | + this.where = where; |
59 | - this.where = where; | 59 | + generateOperationRow(row); |
60 | - generateOperationRow(row); | 60 | + } |
61 | - } | 61 | + |
62 | - | 62 | + /** |
63 | - /** | 63 | + * Row entity convert into the row format of update operation. Refer to RFC |
64 | - * Row entity convert into the row format of update operation. Refer to RFC | 64 | + * 7047 Section 5.2. |
65 | - * 7047 Section 5.2. | 65 | + * @param row Row entity |
66 | - * @param row Row entity | 66 | + */ |
67 | - */ | 67 | + private void generateOperationRow(Row row) { |
68 | - private void generateOperationRow(Row row) { | 68 | + Collection<Column> columns = row.getColumns(); |
69 | - Collection<Column> columns = row.getColumns(); | 69 | + for (Column column : columns) { |
70 | - for (Column column : columns) { | 70 | + String columnName = column.columnName(); |
71 | - ColumnSchema columnSchema = column.schema(); | 71 | + Object value = column.data(); |
72 | - Object value = column.data(); | 72 | + Object formatValue = TransValueUtil.getFormatData(value); |
73 | - Object untypedValue = TransValueUtil.getFormatData(value); | 73 | + this.row.put(columnName, formatValue); |
74 | - this.row.put(columnSchema.name(), untypedValue); | 74 | + } |
75 | - } | 75 | + } |
76 | - } | 76 | + |
77 | - | 77 | + /** |
78 | - /** | 78 | + * Returns the row member of update operation. |
79 | - * Returns the row member of update operation. | 79 | + * @return the row member of update operation |
80 | - * @return the row member of update operation | 80 | + */ |
81 | - */ | 81 | + public Map<String, Object> getRow() { |
82 | - public Map<String, Object> getRow() { | 82 | + return row; |
83 | - return row; | 83 | + } |
84 | - } | 84 | + |
85 | - | 85 | + /** |
86 | - /** | 86 | + * Returns the where member of update operation. |
87 | - * Returns the where member of update operation. | 87 | + * @return the where member of update operation |
88 | - * @return the where member of update operation | 88 | + */ |
89 | - */ | 89 | + public List<Condition> getWhere() { |
90 | - public List<Condition> getWhere() { | 90 | + return where; |
91 | - return where; | 91 | + } |
92 | - } | 92 | + |
93 | - | 93 | + @Override |
94 | - @Override | 94 | + public String getOp() { |
95 | - public String getOp() { | 95 | + return op; |
96 | - return op; | 96 | + } |
97 | - } | 97 | + |
98 | - | 98 | + @Override |
99 | - @Override | 99 | + public TableSchema getTableSchema() { |
100 | - public TableSchema getTableSchema() { | 100 | + return tableSchema; |
101 | - return tableSchema; | 101 | + } |
102 | - } | 102 | + |
103 | - | 103 | + /** |
104 | - /** | 104 | + * For the use of serialization. |
105 | - * For the use of serialization. | 105 | + * @return the table member of update operation |
106 | - * @return the table member of update operation | 106 | + */ |
107 | - */ | 107 | + @JsonProperty |
108 | - @JsonProperty | 108 | + public String getTable() { |
109 | - public String getTable() { | 109 | + return tableSchema.name(); |
110 | - return (tableSchema == null) ? null : tableSchema.name(); | 110 | + } |
111 | - } | 111 | +} |
112 | -} | ... | ... |
... | @@ -17,8 +17,9 @@ package org.onosproject.ovsdb.rfc.schema.type; | ... | @@ -17,8 +17,9 @@ package org.onosproject.ovsdb.rfc.schema.type; |
17 | 17 | ||
18 | import java.util.Set; | 18 | import java.util.Set; |
19 | 19 | ||
20 | -import org.onosproject.ovsdb.rfc.error.TypedSchemaException; | 20 | +import org.onosproject.ovsdb.rfc.error.AbnormalJsonNodeException; |
21 | import org.onosproject.ovsdb.rfc.schema.type.UuidBaseType.RefType; | 21 | import org.onosproject.ovsdb.rfc.schema.type.UuidBaseType.RefType; |
22 | +import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil; | ||
22 | 23 | ||
23 | import com.fasterxml.jackson.databind.JsonNode; | 24 | import com.fasterxml.jackson.databind.JsonNode; |
24 | import com.google.common.collect.Sets; | 25 | import com.google.common.collect.Sets; |
... | @@ -29,27 +30,29 @@ import com.google.common.collect.Sets; | ... | @@ -29,27 +30,29 @@ import com.google.common.collect.Sets; |
29 | public final class BaseTypeFactory { | 30 | public final class BaseTypeFactory { |
30 | 31 | ||
31 | /** | 32 | /** |
32 | - * Constructs a BaseTypeFactory object. | 33 | + * Constructs a BaseTypeFactory object. This class should not be |
33 | - * This class should not be instantiated. | 34 | + * instantiated. |
34 | */ | 35 | */ |
35 | private BaseTypeFactory() { | 36 | private BaseTypeFactory() { |
36 | } | 37 | } |
37 | 38 | ||
38 | /** | 39 | /** |
39 | * Create a BaseType from the JsonNode. | 40 | * Create a BaseType from the JsonNode. |
40 | - * @param json the BaseType JsonNode | 41 | + * @param baseTypeJson the BaseType JsonNode |
41 | * @param keyorval the key node or value node | 42 | * @param keyorval the key node or value node |
42 | * @return BaseType | 43 | * @return BaseType |
43 | */ | 44 | */ |
44 | - public static BaseType getBaseTypeFromJson(JsonNode json, String keyorval) { | 45 | + public static BaseType getBaseTypeFromJson(JsonNode baseTypeJson, String keyorval) { |
45 | - if (json.isValueNode()) { | 46 | + if (baseTypeJson.isValueNode()) { |
46 | - String type = json.asText().trim(); | 47 | + String type = baseTypeJson.asText().trim(); |
47 | return fromTypeStr(type); | 48 | return fromTypeStr(type); |
48 | } else { | 49 | } else { |
49 | - if (!json.has(keyorval)) { | 50 | + if (!baseTypeJson.has(keyorval)) { |
50 | - throw new TypedSchemaException("not a type"); | 51 | + String message = "Abnormal BaseType JsonNode, it should contain 'key' or 'value' node but was not found" |
52 | + + ObjectMapperUtil.convertToString(baseTypeJson); | ||
53 | + throw new AbnormalJsonNodeException(message); | ||
51 | } | 54 | } |
52 | - return fromJsonNode(json.get(keyorval)); | 55 | + return fromJsonNode(baseTypeJson.get(keyorval)); |
53 | } | 56 | } |
54 | } | 57 | } |
55 | 58 | ... | ... |
... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ovsdb.rfc.schema.type; | 16 | package org.onosproject.ovsdb.rfc.schema.type; |
17 | 17 | ||
18 | -import org.onosproject.ovsdb.rfc.error.TypedSchemaException; | 18 | +import org.onosproject.ovsdb.rfc.error.AbnormalJsonNodeException; |
19 | import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil; | 19 | import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil; |
20 | 20 | ||
21 | import com.fasterxml.jackson.databind.JsonNode; | 21 | import com.fasterxml.jackson.databind.JsonNode; |
... | @@ -26,8 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode; | ... | @@ -26,8 +26,8 @@ import com.fasterxml.jackson.databind.JsonNode; |
26 | public final class ColumnTypeFactory { | 26 | public final class ColumnTypeFactory { |
27 | 27 | ||
28 | /** | 28 | /** |
29 | - * Constructs a ColumnTypeFactory object. | 29 | + * Constructs a ColumnTypeFactory object. This class should not be |
30 | - * This class should not be instantiated. | 30 | + * instantiated. |
31 | */ | 31 | */ |
32 | private ColumnTypeFactory() { | 32 | private ColumnTypeFactory() { |
33 | } | 33 | } |
... | @@ -54,20 +54,22 @@ public final class ColumnTypeFactory { | ... | @@ -54,20 +54,22 @@ public final class ColumnTypeFactory { |
54 | } | 54 | } |
55 | 55 | ||
56 | /** | 56 | /** |
57 | - * JsonNode like "flow_tables":{"type":{"key":{"maxInteger":254,"minInteger":0,"type": | 57 | + * JsonNode like |
58 | + * "flow_tables":{"type":{"key":{"maxInteger":254,"minInteger":0,"type": | ||
58 | * "integer"},"min":0,"value":{"type":"uuid","refTable":"Flow_Table"},"max": | 59 | * "integer"},"min":0,"value":{"type":"uuid","refTable":"Flow_Table"},"max": |
59 | * "unlimited"}}. | 60 | * "unlimited"}}. |
60 | - * @param json the ColumnType JsonNode | 61 | + * @param columnTypeJson the ColumnType JsonNode |
61 | * @return ColumnType | 62 | * @return ColumnType |
62 | */ | 63 | */ |
63 | - public static ColumnType getColumnTypeFromJson(JsonNode json) { | 64 | + public static ColumnType getColumnTypeFromJson(JsonNode columnTypeJson) { |
64 | - if (!json.isObject() || !json.has(Type.VALUE.type())) { | 65 | + if (!columnTypeJson.isObject() || !columnTypeJson.has(Type.VALUE.type())) { |
65 | - return createAtomicColumnType(json); | 66 | + return createAtomicColumnType(columnTypeJson); |
66 | - } else if (!json.isValueNode() && json.has(Type.VALUE.type())) { | 67 | + } else if (!columnTypeJson.isValueNode() && columnTypeJson.has(Type.VALUE.type())) { |
67 | - return createKeyValuedColumnType(json); | 68 | + return createKeyValuedColumnType(columnTypeJson); |
68 | } | 69 | } |
69 | - throw new TypedSchemaException("could not find the right column type :" | 70 | + String message = "Abnormal ColumnType JsonNode, it should be AtomicColumnType or KeyValuedColumnType" |
70 | - + ObjectMapperUtil.convertToString(json)); | 71 | + + ObjectMapperUtil.convertToString(columnTypeJson); |
72 | + throw new AbnormalJsonNodeException(message); | ||
71 | } | 73 | } |
72 | 74 | ||
73 | /** | 75 | /** |
... | @@ -76,12 +78,11 @@ public final class ColumnTypeFactory { | ... | @@ -76,12 +78,11 @@ public final class ColumnTypeFactory { |
76 | * @return AtomicColumnType entity | 78 | * @return AtomicColumnType entity |
77 | */ | 79 | */ |
78 | private static AtomicColumnType createAtomicColumnType(JsonNode json) { | 80 | private static AtomicColumnType createAtomicColumnType(JsonNode json) { |
79 | - BaseType baseType = BaseTypeFactory | 81 | + BaseType baseType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type()); |
80 | - .getBaseTypeFromJson(json, Type.KEY.type()); | ||
81 | int min = 1; | 82 | int min = 1; |
82 | int max = 1; | 83 | int max = 1; |
83 | JsonNode node = json.get("min"); | 84 | JsonNode node = json.get("min"); |
84 | - if (node != null) { | 85 | + if (node != null && node.isNumber()) { |
85 | min = node.asInt(); | 86 | min = node.asInt(); |
86 | } | 87 | } |
87 | node = json.get("max"); | 88 | node = json.get("max"); |
... | @@ -101,14 +102,12 @@ public final class ColumnTypeFactory { | ... | @@ -101,14 +102,12 @@ public final class ColumnTypeFactory { |
101 | * @return KeyValuedColumnType entity | 102 | * @return KeyValuedColumnType entity |
102 | */ | 103 | */ |
103 | private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) { | 104 | private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) { |
104 | - BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, | 105 | + BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type()); |
105 | - Type.KEY.type()); | 106 | + BaseType valueType = BaseTypeFactory.getBaseTypeFromJson(json, Type.VALUE.type()); |
106 | - BaseType valueType = BaseTypeFactory | ||
107 | - .getBaseTypeFromJson(json, Type.VALUE.type()); | ||
108 | int min = 1; | 107 | int min = 1; |
109 | int max = 1; | 108 | int max = 1; |
110 | JsonNode node = json.get("min"); | 109 | JsonNode node = json.get("min"); |
111 | - if (node != null) { | 110 | + if (node != null && node.isNumber()) { |
112 | min = node.asInt(); | 111 | min = node.asInt(); |
113 | } | 112 | } |
114 | node = json.get("max"); | 113 | node = json.get("max"); | ... | ... |
This diff is collapsed. Click to expand it.
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.tableservice; | 16 | +package org.onosproject.ovsdb.rfc.tableservice; |
17 | - | 17 | + |
18 | -import org.onosproject.ovsdb.rfc.notation.Column; | 18 | +import org.onosproject.ovsdb.rfc.notation.Column; |
19 | -import org.onosproject.ovsdb.rfc.notation.UUID; | 19 | +import org.onosproject.ovsdb.rfc.notation.UUID; |
20 | - | 20 | + |
21 | -/** | 21 | +/** |
22 | - * Representation of conversion between Ovsdb table and Row. | 22 | + * Representation of conversion between Ovsdb table and Row. |
23 | - */ | 23 | + */ |
24 | -public interface OvsdbTableService { | 24 | +public interface OvsdbTableService { |
25 | - | 25 | + |
26 | - /** | 26 | + /** |
27 | - * Get Column from row. | 27 | + * Get Column from row. |
28 | - * @param columndesc Column description | 28 | + * @param columndesc Column description |
29 | - * @return Column | 29 | + * @return Column |
30 | - */ | 30 | + */ |
31 | - public Column getColumnHandler(ColumnDescription columndesc); | 31 | + public Column getColumnHandler(ColumnDescription columndesc); |
32 | - | 32 | + |
33 | - /** | 33 | + /** |
34 | - * Get Data from row. | 34 | + * Get Data from row. |
35 | - * @param columndesc Column description | 35 | + * @param columndesc Column description |
36 | - * @return Object column data | 36 | + * @return Object column data |
37 | - */ | 37 | + */ |
38 | - public Object getDataHandler(ColumnDescription columndesc); | 38 | + public Object getDataHandler(ColumnDescription columndesc); |
39 | - | 39 | + |
40 | - /** | 40 | + /** |
41 | - * Set column data of row. | 41 | + * Set column data of row. |
42 | - * @param columndesc Column description | 42 | + * @param columndesc Column description |
43 | - * @param obj column data | 43 | + * @param obj column data |
44 | - */ | 44 | + */ |
45 | - public void setDataHandler(ColumnDescription columndesc, Object obj); | 45 | + public void setDataHandler(ColumnDescription columndesc, Object obj); |
46 | - | 46 | + |
47 | - /** | 47 | + /** |
48 | - * Returns the TableSchema from row. | 48 | + * Returns UUID which column name is _uuid. |
49 | - * @return Object TableSchema | 49 | + * @return UUID |
50 | - */ | 50 | + */ |
51 | - public Object getTbSchema(); | 51 | + public UUID getTableUuid(); |
52 | - | 52 | + |
53 | - /** | 53 | + /** |
54 | - * Returns UUID which column name is _uuid. | 54 | + * Returns UUID Column which column name is _uuid. |
55 | - * @return UUID | 55 | + * @return UUID Column |
56 | - */ | 56 | + */ |
57 | - public UUID getUuid(); | 57 | + public Column getTableUuidColumn(); |
58 | - | 58 | + |
59 | - /** | 59 | + /** |
60 | - * Returns UUID Column which column name is _uuid. | 60 | + * Returns UUID which column name is _version. |
61 | - * @return UUID Column | 61 | + * @return UUID |
62 | - */ | 62 | + */ |
63 | - public Column getUuidColumn(); | 63 | + public UUID getTableVersion(); |
64 | - | 64 | + |
65 | - /** | 65 | + /** |
66 | - * Returns UUID which column name is _version. | 66 | + * Returns UUID Column which column name is _version. |
67 | - * @return UUID | 67 | + * @return UUID Column |
68 | - */ | 68 | + */ |
69 | - public UUID getVersion(); | 69 | + public Column getTableVersionColumn(); |
70 | - | 70 | +} |
71 | - /** | ||
72 | - * Returns UUID Column which column name is _version. | ||
73 | - * @return UUID Column | ||
74 | - */ | ||
75 | - public Column getVersionColumn(); | ||
76 | -} | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | -/* | 1 | +/* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015 Open Networking Laboratory |
3 | - * | 3 | + * |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | + * You may obtain a copy of the License at |
7 | - * | 7 | + * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | + * |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | + * Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | + * See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | + * limitations under the License. |
15 | - */ | 15 | + */ |
16 | -package org.onosproject.ovsdb.rfc.utils; | 16 | +package org.onosproject.ovsdb.rfc.utils; |
17 | - | 17 | + |
18 | -import java.util.List; | 18 | +import java.util.List; |
19 | -import java.util.Set; | 19 | +import java.util.Map; |
20 | - | 20 | +import java.util.Set; |
21 | -import org.onosproject.ovsdb.rfc.message.MonitorRequest; | 21 | + |
22 | -import org.onosproject.ovsdb.rfc.message.MonitorSelect; | 22 | +import org.onosproject.ovsdb.rfc.message.MonitorRequest; |
23 | -import org.onosproject.ovsdb.rfc.operations.Operation; | 23 | +import org.onosproject.ovsdb.rfc.message.MonitorSelect; |
24 | -import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; | 24 | +import org.onosproject.ovsdb.rfc.operations.Operation; |
25 | -import org.onosproject.ovsdb.rfc.schema.TableSchema; | 25 | +import org.onosproject.ovsdb.rfc.schema.DatabaseSchema; |
26 | - | 26 | +import org.onosproject.ovsdb.rfc.schema.TableSchema; |
27 | -import com.google.common.base.Function; | 27 | + |
28 | -import com.google.common.collect.ImmutableMap; | 28 | +import com.google.common.collect.Lists; |
29 | -import com.google.common.collect.Lists; | 29 | +import com.google.common.collect.Maps; |
30 | -import com.google.common.collect.Maps; | 30 | + |
31 | - | 31 | +/** |
32 | -/** | 32 | + * Params utility class. Params of the request object, refer to RFC7047's |
33 | - * Params utility class. Params of the request object, refer to RFC7047's Section | 33 | + * Section 4.1. |
34 | - * 4.1. | 34 | + */ |
35 | - */ | 35 | +public final class ParamUtil { |
36 | -public final class ParamUtil { | 36 | + |
37 | - | 37 | + /** |
38 | - /** | 38 | + * Constructs a ParamUtil object. Utility classes should not have a public |
39 | - * Constructs a ParamUtil object. Utility classes should not have a | 39 | + * or default constructor, otherwise IDE will compile unsuccessfully. This |
40 | - * public or default constructor, otherwise IDE will compile unsuccessfully. This | 40 | + * class should not be instantiated. |
41 | - * class should not be instantiated. | 41 | + */ |
42 | - */ | 42 | + private ParamUtil() { |
43 | - private ParamUtil() { | 43 | + } |
44 | - } | 44 | + |
45 | - | 45 | + /** |
46 | - /** | 46 | + * Returns MonitorRequest, refer to RFC7047's Section 4.1.5. |
47 | - * Returns MonitorRequest, refer to RFC7047's Section 4.1.5. | 47 | + * @param tableSchema entity |
48 | - * @param tableSchema entity | 48 | + * @return MonitorRequest |
49 | - * @return MonitorRequest | 49 | + */ |
50 | - */ | 50 | + private static MonitorRequest getAllColumnsMonitorRequest(TableSchema tableSchema) { |
51 | - private static MonitorRequest getAllColumnsMonitorRequest(TableSchema tableSchema) { | 51 | + String tableName = tableSchema.name(); |
52 | - String tableName = tableSchema.name(); | 52 | + Set<String> columns = tableSchema.getColumnNames(); |
53 | - Set<String> columns = tableSchema.getColumnNames(); | 53 | + MonitorSelect select = new MonitorSelect(true, true, true, true); |
54 | - MonitorSelect select = new MonitorSelect(true, true, true, true); | 54 | + MonitorRequest monitorRequest = new MonitorRequest(tableName, columns, select); |
55 | - MonitorRequest monitorRequest = new MonitorRequest(tableName, columns, | 55 | + return monitorRequest; |
56 | - select); | 56 | + } |
57 | - return monitorRequest; | 57 | + |
58 | - } | 58 | + /** |
59 | - | 59 | + * Returns params of monitor method, refer to RFC7047's Section 4.1.5. |
60 | - /** | 60 | + * @param monotorId json-value, refer to RFC7047's Section 4.1.5. |
61 | - * Returns params of monitor method, refer to RFC7047's Section 4.1.5. | 61 | + * @param dbSchema DatabaseSchema entity |
62 | - * @param monotorId json-value, refer to RFC7047's Section 4.1.5. | 62 | + * @return List of Object, the params of monitor request |
63 | - * @param dbSchema DatabaseSchema entity | 63 | + */ |
64 | - * @return List of Object, the params of monitor request | 64 | + public static List<Object> getMonitorParams(String monotorId, DatabaseSchema dbSchema) { |
65 | - */ | 65 | + Set<String> tables = dbSchema.getTableNames(); |
66 | - public static List<Object> getMonitorParams(String monotorId, | 66 | + Map<String, MonitorRequest> mrMap = Maps.newHashMap(); |
67 | - DatabaseSchema dbSchema) { | 67 | + for (String tableName : tables) { |
68 | - Set<String> tables = dbSchema.getTableNames(); | 68 | + TableSchema tableSchema = dbSchema.getTableSchema(tableName); |
69 | - List<MonitorRequest> monitorRequests = Lists.newArrayList(); | 69 | + MonitorRequest monitorRequest = getAllColumnsMonitorRequest(tableSchema); |
70 | - for (String tableName : tables) { | 70 | + mrMap.put(tableName, monitorRequest); |
71 | - TableSchema tableSchema = dbSchema.getTableSchema(tableName); | 71 | + } |
72 | - monitorRequests.add(getAllColumnsMonitorRequest(tableSchema)); | 72 | + return Lists.newArrayList(dbSchema.name(), monotorId, mrMap); |
73 | - } | 73 | + } |
74 | - ImmutableMap<String, MonitorRequest> reqMap = Maps | 74 | + |
75 | - .uniqueIndex(monitorRequests, | 75 | + /** |
76 | - new Function<MonitorRequest, String>() { | 76 | + * Returns params of transact method, refer to RFC7047's Section 4.1.3. |
77 | - @Override | 77 | + * @param dbSchema DatabaseSchema entity |
78 | - public String apply(MonitorRequest input) { | 78 | + * @param operations operation*, refer to RFC7047's Section 4.1.3. |
79 | - return input.getTableName(); | 79 | + * @return List of Object, the params of transact request |
80 | - } | 80 | + */ |
81 | - }); | 81 | + public static List<Object> getTransactParams(DatabaseSchema dbSchema, List<Operation> operations) { |
82 | - return Lists.<Object>newArrayList(dbSchema.name(), monotorId, | 82 | + return Lists.newArrayList(dbSchema.name(), operations); |
83 | - reqMap); | 83 | + } |
84 | - } | 84 | +} |
85 | - | ||
86 | - /** | ||
87 | - * Returns params of transact method, refer to RFC7047's Section 4.1.3. | ||
88 | - * @param dbSchema DatabaseSchema entity | ||
89 | - * @param operations operation*, refer to RFC7047's Section 4.1.3. | ||
90 | - * @return List of Object, the params of transact request | ||
91 | - */ | ||
92 | - public static List<Object> getTransactParams(DatabaseSchema dbSchema, | ||
93 | - List<Operation> operations) { | ||
94 | - List<Object> lists = Lists.newArrayList((Object) dbSchema.name()); | ||
95 | - lists.addAll(operations); | ||
96 | - return lists; | ||
97 | - } | ||
98 | -} | ... | ... |
... | @@ -87,33 +87,29 @@ public final class TransValueUtil { | ... | @@ -87,33 +87,29 @@ public final class TransValueUtil { |
87 | * @param atoType AtomicColumnType entity | 87 | * @param atoType AtomicColumnType entity |
88 | * @return Object OvsdbSet or the value of JsonNode | 88 | * @return Object OvsdbSet or the value of JsonNode |
89 | */ | 89 | */ |
90 | - private static Object getValueFromAtoType(JsonNode json, | 90 | + private static Object getValueFromAtoType(JsonNode json, AtomicColumnType atoType) { |
91 | - AtomicColumnType atoType) { | ||
92 | BaseType baseType = atoType.baseType(); | 91 | BaseType baseType = atoType.baseType(); |
93 | // If "min" or "max" is not specified, If "min" is not 1 or "max" is not | 92 | // If "min" or "max" is not specified, If "min" is not 1 or "max" is not |
94 | - // 1, | 93 | + // 1, or both, and "value" is not specified, the type is a set of scalar |
95 | - // or both, and "value" is not specified, the type is a set of scalar | 94 | + // type "key". Refer to RFC 7047, Section 3.2 <type>. |
96 | - // type "key". | ||
97 | - // Refer to RFC 7047, Section 3.2 <type>. | ||
98 | if (atoType.min() != atoType.max()) { | 95 | if (atoType.min() != atoType.max()) { |
99 | Set set = Sets.newHashSet(); | 96 | Set set = Sets.newHashSet(); |
100 | if (json.isArray()) { | 97 | if (json.isArray()) { |
101 | if (json.size() == 2) { | 98 | if (json.size() == 2) { |
102 | - if (json.get(0).isTextual() | 99 | + if (json.get(0).isTextual() && "set".equals(json.get(0).asText())) { |
103 | - && "set".equals(json.get(0).asText())) { | ||
104 | for (JsonNode node : json.get(1)) { | 100 | for (JsonNode node : json.get(1)) { |
105 | - set.add(TransValueUtil.transToValue(node, baseType)); | 101 | + set.add(transToValue(node, baseType)); |
106 | } | 102 | } |
107 | } else { | 103 | } else { |
108 | - set.add(TransValueUtil.transToValue(json, baseType)); | 104 | + set.add(transToValue(json, baseType)); |
109 | } | 105 | } |
110 | } | 106 | } |
111 | } else { | 107 | } else { |
112 | - set.add(TransValueUtil.transToValue(json, baseType)); | 108 | + set.add(transToValue(json, baseType)); |
113 | } | 109 | } |
114 | return OvsdbSet.ovsdbSet(set); | 110 | return OvsdbSet.ovsdbSet(set); |
115 | } else { | 111 | } else { |
116 | - return TransValueUtil.transToValue(json, baseType); | 112 | + return transToValue(json, baseType); |
117 | } | 113 | } |
118 | } | 114 | } |
119 | 115 | ||
... | @@ -123,19 +119,15 @@ public final class TransValueUtil { | ... | @@ -123,19 +119,15 @@ public final class TransValueUtil { |
123 | * @param kvType KeyValuedColumnType entity | 119 | * @param kvType KeyValuedColumnType entity |
124 | * @return Object OvsdbMap | 120 | * @return Object OvsdbMap |
125 | */ | 121 | */ |
126 | - private static Object getValueFromKvType(JsonNode json, | 122 | + private static Object getValueFromKvType(JsonNode json, KeyValuedColumnType kvType) { |
127 | - KeyValuedColumnType kvType) { | ||
128 | if (json.isArray()) { | 123 | if (json.isArray()) { |
129 | if (json.size() == 2) { | 124 | if (json.size() == 2) { |
130 | - if (json.get(0).isTextual() | 125 | + if (json.get(0).isTextual() && "map".equals(json.get(0).asText())) { |
131 | - && "map".equals(json.get(0).asText())) { | ||
132 | Map map = Maps.newHashMap(); | 126 | Map map = Maps.newHashMap(); |
133 | for (JsonNode pairNode : json.get(1)) { | 127 | for (JsonNode pairNode : json.get(1)) { |
134 | if (pairNode.isArray() && json.size() == 2) { | 128 | if (pairNode.isArray() && json.size() == 2) { |
135 | - Object key = TransValueUtil.transToValue(pairNode | 129 | + Object key = transToValue(pairNode.get(0), kvType.keyType()); |
136 | - .get(0), kvType.keyType()); | 130 | + Object value = transToValue(pairNode.get(1), kvType.valueType()); |
137 | - Object value = TransValueUtil.transToValue(pairNode | ||
138 | - .get(1), kvType.valueType()); | ||
139 | map.put(key, value); | 131 | map.put(key, value); |
140 | } | 132 | } |
141 | } | 133 | } |
... | @@ -166,14 +158,13 @@ public final class TransValueUtil { | ... | @@ -166,14 +158,13 @@ public final class TransValueUtil { |
166 | if (valueNode.isArray()) { | 158 | if (valueNode.isArray()) { |
167 | if (valueNode.size() == 2) { | 159 | if (valueNode.size() == 2) { |
168 | if (valueNode.get(0).isTextual() | 160 | if (valueNode.get(0).isTextual() |
169 | - && "uuid".equals(valueNode.get(0).asText()) | 161 | + && ("uuid".equals(valueNode.get(0).asText()) || "named-uuid" |
170 | - || "named-uuid".equals(valueNode.get(0).asText())) { | 162 | + .equals(valueNode.get(0).asText()))) { |
171 | return UUID.uuid(valueNode.get(1).asText()); | 163 | return UUID.uuid(valueNode.get(1).asText()); |
172 | } | 164 | } |
173 | } | 165 | } |
174 | } else { | 166 | } else { |
175 | - return new RefTableRow(((UuidBaseType) baseType).getRefTable(), | 167 | + return new RefTableRow(((UuidBaseType) baseType).getRefTable(), valueNode); |
176 | - valueNode); | ||
177 | } | 168 | } |
178 | } | 169 | } |
179 | return null; | 170 | return null; | ... | ... |
-
Please register or login to post a comment