summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2018-11-15 14:36:02 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-15 14:36:02 +0000
commitb8398930512273f8bddae59134868be52d3a76a9 (patch)
tree8ea6ebb80c61d969042bda6e7d423688563ee909
parent383a478c451300196db8fbcdac2ca1f1ff021913 (diff)
parent5ce0ef187f67c46f11ec5e078cfa3a45ab6726c7 (diff)
Merge "Use param obj for contxt album decln"
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java144
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java32
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CliCodegenTest.java13
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java14
4 files changed, 177 insertions, 26 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
new file mode 100644
index 000000000..933ecd56f
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+public class CodeGenCliEditorBuilder {
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private String scope;
+ private boolean writable;
+ private String schemaName;
+ private String schemaVersion;
+
+ /**
+ * Set name.
+ * @param name the name of the context album
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Set version.
+ * @param version the version of the context album
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ /**
+ * Set uuid.
+ * @param uuid a UUID for the declaration
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setUuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ /**
+ * Set description.
+ * @param description a description for the context album
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * Set scope.
+ * @param scope the scope
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setScope(String scope) {
+ this.scope = scope;
+ return this;
+ }
+
+ /**
+ * Set writable.
+ * @param writable a flag for writable context
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setWritable(boolean writable) {
+ this.writable = writable;
+ return this;
+ }
+
+ /**
+ * Set schemaname.
+ * @param schemaName the name of the schema
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ return this;
+ }
+
+ /**
+ * Set schema version.
+ * @param schemaVersion the version of the declaration
+ * @return CodeGenCliEditorBuilder
+ */
+ public CodeGenCliEditorBuilder setSchemaVersion(String schemaVersion) {
+ this.schemaVersion = schemaVersion;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public boolean isWritable() {
+ return writable;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public String getSchemaVersion() {
+ return schemaVersion;
+ }
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
index 75ac1fe03..e92cce34b 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
@@ -175,28 +175,20 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new context album declaration to the model.
- *
- * @param name the name of the context album
- * @param version the version of the context album
- * @param uuid a UUID for the declaration
- * @param description a description for the context album
- * @param scope the scope
- * @param writable a flag for writable context
- * @param schemaName the name of the schema
- * @param schemaVersion the version of the declaration
+ *
+ * @param codeGenCliEditorBuilder
*/
- public void addContextAlbumDeclaration(final String name, final String version, final String uuid,
- final String description, final String scope, final boolean writable, final String schemaName,
- final String schemaVersion) {
+ public void addContextAlbumDeclaration(
+ CodeGenCliEditorBuilder codeGenCliEditorBuilder) {
final ST st = stg.getInstanceOf("ctxAlbumDecl");
- st.add(NAME, name);
- st.add(VERSION, version);
- st.add(UUID, uuid);
- st.add(DESCRIPTION, description);
- st.add(SCOPE, scope);
- st.add(WRITABLE, writable);
- st.add(SCHEMA_NAME, schemaName);
- st.add(SCHEMA_VERSION, schemaVersion);
+ st.add(NAME, codeGenCliEditorBuilder.getName());
+ st.add(VERSION, codeGenCliEditorBuilder.getVersion());
+ st.add(UUID, codeGenCliEditorBuilder.getUuid());
+ st.add(DESCRIPTION, codeGenCliEditorBuilder.getDescription());
+ st.add(SCOPE, codeGenCliEditorBuilder.getScope());
+ st.add(WRITABLE, codeGenCliEditorBuilder.isWritable());
+ st.add(SCHEMA_NAME, codeGenCliEditorBuilder.getSchemaName());
+ st.add(SCHEMA_VERSION, codeGenCliEditorBuilder.getSchemaVersion());
model.add(DECLARATION, st);
}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CliCodegenTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CliCodegenTest.java
index 13f0bc0e6..956e302c6 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CliCodegenTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CliCodegenTest.java
@@ -137,9 +137,16 @@ public class CliCodegenTest {
for (final AxContextAlbum a : policyModel.getAlbums().getAlbumsMap().values()) {
final AxArtifactKey key = a.getKey();
- codeGen.addContextAlbumDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key),
- kig.getDesc(key), a.getScope(), a.isWritable(), kig.getName(a.getItemSchema()),
- kig.getVersion(a.getItemSchema()));
+ codeGen.addContextAlbumDeclaration(
+ new CodeGenCliEditorBuilder()
+ .setName(kig.getName(key))
+ .setVersion(kig.getVersion(key))
+ .setUuid(kig.getUuid(key))
+ .setDescription(kig.getDesc(key))
+ .setScope(a.getScope())
+ .setWritable(a.isWritable())
+ .setSchemaName(kig.getName(a.getItemSchema()))
+ .setSchemaVersion(kig.getVersion(a.getItemSchema())));
}
// 5: policies
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
index 01434190b..57a3841c9 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Model2Cli.java
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
import java.util.Properties;
import org.apache.commons.lang3.Validate;
+import org.onap.policy.apex.auth.clicodegen.CodeGenCliEditorBuilder;
import org.onap.policy.apex.auth.clicodegen.CodeGeneratorCliEditor;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -184,9 +185,16 @@ public class Model2Cli {
for (final AxContextAlbum a : policyModel.getAlbums().getAlbumsMap().values()) {
final AxArtifactKey key = a.getKey();
- codeGen.addContextAlbumDeclaration(kig.getName(key), kig.getVersion(key), kig.getUuid(key),
- kig.getDesc(key), a.getScope(), a.isWritable(), kig.getName(a.getItemSchema()),
- kig.getVersion(a.getItemSchema()));
+ codeGen.addContextAlbumDeclaration(
+ new CodeGenCliEditorBuilder()
+ .setName(kig.getName(key))
+ .setVersion(kig.getVersion(key))
+ .setUuid(kig.getUuid(key))
+ .setDescription(kig.getDesc(key))
+ .setScope(a.getScope())
+ .setWritable(a.isWritable())
+ .setSchemaName(kig.getName(a.getItemSchema()))
+ .setSchemaVersion(kig.getVersion(a.getItemSchema())));
}
// 5: policies