Eliminate operational concept 82/105482/3
authortobias.pobocik <tobias.pobocik@pantheon.tech>
Tue, 18 Apr 2023 08:53:44 +0000 (10:53 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 24 Apr 2023 08:58:14 +0000 (10:58 +0200)
In sal-rest-docgen package there still resist some
remnants of bierman-02 operational data concept.

Now, we have just "data" for both "config" and "nonconfig" data.
By eliminating "config" and "operational" split we can get rid
of some unnecessary logic.

JIRA: NETCONF-992
Change-Id: I6b03e8ce43d75cb53ed14862b783d84fe03e542c
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGeneratorRFC8040.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java

index 7f2639998cf844b40749ed129408a1cc97ae6c2c..e593052a2da6ba827bedfe49e45800104342d5f8 100644 (file)
@@ -256,13 +256,10 @@ public abstract class BaseYangSwaggerGenerator {
                 LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName());
 
                 final String localName = module.getName() + ":" + node.getQName().getLocalName();
-                ArrayNode pathParams = JsonNodeFactory.instance.arrayNode();
-                String resourcePath;
-
-                if (node.isConfiguration()) { // This node's config statement is
-                    // true.
-                    resourcePath = getResourcePath("config", context);
+                final String resourcePath  = getResourcePath("data", context);
 
+                if (node.isConfiguration()) {
+                    final ArrayNode pathParams = JsonNodeFactory.instance.arrayNode();
                     /*
                      * When there are two or more top container or list nodes
                      * whose config statement is true in module, make sure that
@@ -278,11 +275,8 @@ public abstract class BaseYangSwaggerGenerator {
                     final String resolvedPath = resourcePath + "/" + createPath(node, pathParams, localName);
                     addPaths(node, deviceName, moduleName, paths, pathParams, schemaContext, true, module.getName(),
                         definitionNames, resolvedPath);
-                }
-                pathParams = JsonNodeFactory.instance.arrayNode();
-                resourcePath = getResourcePath("operational", context);
-
-                if (!node.isConfiguration()) {
+                } else  {
+                    final ArrayNode pathParams = JsonNodeFactory.instance.arrayNode();
                     final String resolvedPath = resourcePath + "/" + createPath(node, pathParams, localName);
                     addPaths(node, deviceName, moduleName, paths, pathParams, schemaContext, false, moduleName,
                         definitionNames, resolvedPath);
@@ -355,8 +349,6 @@ public abstract class BaseYangSwaggerGenerator {
 
     public abstract String getResourcePath(String resourceType, String context);
 
-    public abstract String getResourcePathPart(String resourceType);
-
     private void addPaths(final DataSchemaNode node, final Optional<String> deviceName, final String moduleName,
             final ObjectNode paths, final ArrayNode parentPathParams, final EffectiveModelContext schemaContext,
             final boolean isConfig, final String parentName, final DefinitionNames definitionNames,
index fdbb1b2f0a425e6ad3f91f0b9af4e78ece49bce0..561c07305b7d9baf784beb8327ef374ee6bf7b59 100644 (file)
@@ -31,24 +31,12 @@ public abstract class BaseYangSwaggerGeneratorRFC8040 extends BaseYangSwaggerGen
 
     @Override
     public String getResourcePath(final String resourceType, final String context) {
-        if (isData(resourceType)) {
+        if ("data".equals(resourceType)) {
             return "/" + basePath + "/data" + context;
         }
         return "/" + basePath + "/operations" + context;
     }
 
-    @Override
-    public String getResourcePathPart(final String resourceType) {
-        if (isData(resourceType)) {
-            return "data";
-        }
-        return "operations";
-    }
-
-    private static boolean isData(final String dataStore) {
-        return "config".contains(dataStore) || "operational".contains(dataStore);
-    }
-
     @Override
     protected ListPathBuilder newListPathBuilder() {
         return new ListPathBuilder() {
index f347e6bd5460a0e6992fb19897284b894baf5c3a..bc7ff0bf526730da6ed2186427a3b704b30694de 100644 (file)
@@ -209,9 +209,7 @@ public class MountPointSwagger implements DOMMountPointListener, AutoCloseable {
                 context);
 
         final ObjectNode pathsObject = JsonNodeFactory.instance.objectNode();
-        createGetPathItem("config", "Queries the config (startup) datastore on the mounted hosted.",
-                context, deviceName, pathsObject);
-        createGetPathItem("operational", "Queries the operational (running) datastore on the mounted hosted.",
+        createGetPathItem("data", "Queries the config (startup) datastore on the mounted hosted.",
                 context, deviceName, pathsObject);
         createGetPathItem("operations", "Queries the available operations (RPC calls) on the mounted hosted.",
                 context, deviceName, pathsObject);
@@ -229,7 +227,7 @@ public class MountPointSwagger implements DOMMountPointListener, AutoCloseable {
         pathItem.set("get", operationObject);
         operationObject.put(DESCRIPTION_KEY, description);
         operationObject.put(SUMMARY_KEY, HttpMethod.GET + SUMMARY_SEPARATOR + deviceName + SUMMARY_SEPARATOR
-                + swaggerGenerator.getResourcePathPart(resourceType));
+                + resourceType);
         operationObject.set(TAGS_KEY, buildTagsValue(Optional.of(deviceName), "GET root"));
         final ObjectNode okResponse = JsonNodeFactory.instance.objectNode();
         okResponse.put(DESCRIPTION_KEY, Response.Status.OK.getReasonPhrase());