aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-03-11 15:40:58 +0900
committerarind.mondal <arind.mondal@samsung.com>2019-03-14 10:39:19 +0900
commit0898b2231fc5120861aeacc0ff36f9f305b5fb64 (patch)
tree8090109ba690bfb3e6a0b69e1b6f203f9f3c0445
parentefd0a257cf6a81a62ec18962eae1d5c1cf87bcda (diff)
reduce too many method param
Issue-ID: POLICY-1535 Change-Id: Ia6f699d315ebd214257dc64d559a0ac4685307f5 Signed-off-by: arind.mondal <arind.mondal@samsung.com>
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java91
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumBuilder.java103
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java228
3 files changed, 287 insertions, 135 deletions
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 12b415ad9..615ed2d4d 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -370,37 +371,65 @@ public final class ApexModelImpl implements ApexModel {
return eventFacade.deleteEventPar(name, version, parName);
}
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.modelapi.ApexEditorAPI#createContextAlbum(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String, java.lang.String)
- */
- @Override
- // CHECKSTYLE:OFF: checkstyle:parameterNumber
- public ApexApiResult createContextAlbum(final String name, final String version, final String scope,
- final String writable, final String contextSchemaName, final String contextSchemaVersion, final String uuid,
- final String description) {
- return contextAlbumFacade.createContextAlbum(name, version, scope, writable, contextSchemaName,
- contextSchemaVersion, uuid, description);
- }
- // CHECKSTYLE:ON: checkstyle:parameterNumber
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.apex.model.modelapi.ApexEditorAPI#updateContextAlbum(java.lang.String,
- * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String, java.lang.String)
- */
- // CHECKSTYLE:OFF: checkstyle:parameterNumber
- @Override
- public ApexApiResult updateContextAlbum(final String name, final String version, final String scope,
- final String writable, final String contextSchemaName, final String contextSchemaVersion, final String uuid,
- final String description) {
- return contextAlbumFacade.updateContextAlbum(name, version, scope, writable, contextSchemaName,
- contextSchemaVersion, uuid, description);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.modelapi.ApexEditorAPI#createContextAlbum(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ @Override
+ // CHECKSTYLE:OFF: checkstyle:parameterNumber
+ public ApexApiResult createContextAlbum(
+ final String name,
+ final String version,
+ final String scope,
+ final String writable,
+ final String contextSchemaName,
+ final String contextSchemaVersion,
+ final String uuid,
+ final String description) {
+ return contextAlbumFacade.createContextAlbum(
+ new ContextAlbumBuilder()
+ .setName(name)
+ .setVersion(version)
+ .setScope(scope)
+ .setWritable(writable)
+ .setContextSchemaName(contextSchemaName)
+ .setContextSchemaVersion(contextSchemaVersion)
+ .setUuid(uuid)
+ .setDescription(description));
+ }
+ // CHECKSTYLE:ON: checkstyle:parameterNumber
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.policy.apex.model.modelapi.ApexEditorAPI#updateContextAlbum(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ // CHECKSTYLE:OFF: checkstyle:parameterNumber
+ @Override
+ public ApexApiResult updateContextAlbum(
+ final String name,
+ final String version,
+ final String scope,
+ final String writable,
+ final String contextSchemaName,
+ final String contextSchemaVersion,
+ final String uuid,
+ final String description) {
+ return contextAlbumFacade.updateContextAlbum(
+ new ContextAlbumBuilder()
+ .setName(name)
+ .setVersion(version)
+ .setScope(scope)
+ .setWritable(writable)
+ .setContextSchemaName(contextSchemaName)
+ .setContextSchemaVersion(contextSchemaVersion)
+ .setUuid(uuid)
+ .setDescription(description));
}
// CHECKSTYLE:ON: checkstyle:parameterNumber
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumBuilder.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumBuilder.java
new file mode 100644
index 000000000..88ee64822
--- /dev/null
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumBuilder.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 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.model.modelapi.impl;
+
+public class ContextAlbumBuilder {
+ private String name;
+ private String version;
+ private String scope;
+ private String writable;
+ private String contextSchemaName;
+ private String contextSchemaVersion;
+ private String uuid;
+ private String description;
+
+ public String getName() {
+ return name;
+ }
+
+ public ContextAlbumBuilder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public ContextAlbumBuilder setVersion(String version) {
+ this.version = version;
+ return this;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public ContextAlbumBuilder setScope(String scope) {
+ this.scope = scope;
+ return this;
+ }
+
+ public String getWritable() {
+ return writable;
+ }
+
+ public ContextAlbumBuilder setWritable(String writable) {
+ this.writable = writable;
+ return this;
+ }
+
+ public String getContextSchemaName() {
+ return contextSchemaName;
+ }
+
+ public ContextAlbumBuilder setContextSchemaName(String contextSchemaName) {
+ this.contextSchemaName = contextSchemaName;
+ return this;
+ }
+
+ public String getContextSchemaVersion() {
+ return contextSchemaVersion;
+ }
+
+ public ContextAlbumBuilder setContextSchemaVersion(String contextSchemaVersion) {
+ this.contextSchemaVersion = contextSchemaVersion;
+ return this;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public ContextAlbumBuilder setUuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public ContextAlbumBuilder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
index c3617012e..920dc5eba 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextAlbumFacade.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,121 +71,140 @@ public class ContextAlbumFacade {
keyInformationFacade = new KeyInformationFacade(apexModel, apexProperties, jsonMode);
}
- /**
- * Create a context album.
- *
- * @param name name of the context album
- * @param version version of the context album, set to null to use the default version
- * @param scope of the context album
- * @param writable "true" or "t" if the context album is writable, set to null or any other
- * value for a read-only album
- * @param contextSchemaName name of the parameter context schema
- * @param contextSchemaVersion version of the parameter context schema, set to null to use the
- * latest version
- * @param uuid context album UUID, set to null to generate a UUID
- * @param description context album description, set to null to generate a description
- * @return result of the operation
- */
- // CHECKSTYLE:OFF: checkstyle:parameterNumber
- public ApexApiResult createContextAlbum(final String name, final String version, final String scope,
- final String writable, final String contextSchemaName, final String contextSchemaVersion, final String uuid,
- final String description) {
- try {
- final AxArtifactKey key = new AxArtifactKey();
- key.setName(name);
- if (version != null) {
- key.setVersion(version);
- } else {
- key.setVersion(apexProperties.getProperty("DEFAULT_CONCEPT_VERSION"));
- }
+ /**
+ * Create a context album.
+ *
+ * @param name name of the context album
+ * @param version version of the context album, set to null to use the default version
+ * @param scope of the context album
+ * @param writable "true" or "t" if the context album is writable, set to null or any other value
+ * for a read-only album
+ * @param contextSchemaName name of the parameter context schema
+ * @param contextSchemaVersion version of the parameter context schema, set to null to use the
+ * latest version
+ * @param uuid context album UUID, set to null to generate a UUID
+ * @param description context album description, set to null to generate a description
+ * @return result of the operation
+ */
+ // CHECKSTYLE:OFF: checkstyle:parameterNumber
+ public ApexApiResult createContextAlbum(ContextAlbumBuilder builder) {
+ try {
+ final AxArtifactKey key = new AxArtifactKey();
+ key.setName(builder.getName());
+ if (builder.getVersion() != null) {
+ key.setVersion(builder.getVersion());
+ } else {
+ key.setVersion(apexProperties.getProperty("DEFAULT_CONCEPT_VERSION"));
+ }
- if (apexModel.getPolicyModel().getAlbums().getAlbumsMap().containsKey(key)) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- CONCEPT + key.getId() + " already exists");
- }
+ if (apexModel.getPolicyModel().getAlbums().getAlbumsMap().containsKey(key)) {
+ return new ApexApiResult(
+ ApexApiResult.Result.CONCEPT_EXISTS, CONCEPT + key.getId() + " already exists");
+ }
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
+ final AxContextSchema schema =
+ apexModel
+ .getPolicyModel()
+ .getSchemas()
+ .get(builder.getContextSchemaName(), builder.getContextSchemaVersion());
+ if (schema == null) {
+ return new ApexApiResult(
+ ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT
+ + builder.getContextSchemaName()
+ + ':'
+ + builder.getContextSchemaVersion()
+ + DOES_NOT_EXIST);
+ }
- final AxContextAlbum contextAlbum = new AxContextAlbum(key);
- contextAlbum.setScope(scope);
- contextAlbum.setItemSchema(schema.getKey());
+ final AxContextAlbum contextAlbum = new AxContextAlbum(key);
+ contextAlbum.setScope(builder.getScope());
+ contextAlbum.setItemSchema(schema.getKey());
- if (writable != null
- && ("true".equalsIgnoreCase(writable.trim()) || "t".equalsIgnoreCase(writable.trim()))) {
- contextAlbum.setWritable(true);
- } else {
- contextAlbum.setWritable(false);
- }
+ if (builder.getWritable() != null
+ && ("true".equalsIgnoreCase(builder.getWritable().trim())
+ || "t".equalsIgnoreCase(builder.getWritable().trim()))) {
+ contextAlbum.setWritable(true);
+ } else {
+ contextAlbum.setWritable(false);
+ }
- apexModel.getPolicyModel().getAlbums().getAlbumsMap().put(key, contextAlbum);
+ apexModel.getPolicyModel().getAlbums().getAlbumsMap().put(key, contextAlbum);
- if (apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().containsKey(key)) {
- return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
- } else {
- return keyInformationFacade.createKeyInformation(name, version, uuid, description);
- }
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- }
+ if (apexModel.getPolicyModel().getKeyInformation().getKeyInfoMap().containsKey(key)) {
+ return keyInformationFacade.updateKeyInformation(
+ builder.getName(), builder.getVersion(), builder.getUuid(), builder.getDescription());
+ } else {
+ return keyInformationFacade.createKeyInformation(
+ builder.getName(), builder.getVersion(), builder.getUuid(), builder.getDescription());
+ }
+ } catch (final Exception e) {
+ return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
- // CHECKSTYLE:ON: checkstyle:parameterNumber
-
- /**
- * Update a context album.
- *
- * @param name name of the context album
- * @param version version of the context album, set to null to use the default version
- * @param scope of the context album
- * @param writable "true" or "t" if the context album is writable, set to null or any other
- * value for a read-only album
- * @param contextSchemaName name of the parameter context schema
- * @param contextSchemaVersion version of the parameter context schema, set to null to use the
- * latest version
- * @param uuid context album UUID, set to null to generate a UUID
- * @param description context album description, set to null to generate a description
- * @return result of the operation
- */
- // CHECKSTYLE:OFF: checkstyle:parameterNumber
- public ApexApiResult updateContextAlbum(final String name, final String version, final String scope,
- final String writable, final String contextSchemaName, final String contextSchemaVersion, final String uuid,
- final String description) {
- try {
- final AxContextAlbum contextAlbum = apexModel.getPolicyModel().getAlbums().get(name, version);
- if (contextAlbum == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + name + ':' + version + DOES_NOT_EXIST);
- }
+ }
+ // CHECKSTYLE:ON: checkstyle:parameterNumber
- if (scope != null) {
- contextAlbum.setScope(scope);
- }
- if (writable != null) {
- if ("true".equalsIgnoreCase(writable.trim()) || "t".equalsIgnoreCase(writable.trim())) {
- contextAlbum.setWritable(true);
- } else {
- contextAlbum.setWritable(false);
- }
- }
+ /**
+ * Update a context album.
+ *
+ * @param name name of the context album
+ * @param version version of the context album, set to null to use the default version
+ * @param scope of the context album
+ * @param writable "true" or "t" if the context album is writable, set to null or any other value
+ * for a read-only album
+ * @param contextSchemaName name of the parameter context schema
+ * @param contextSchemaVersion version of the parameter context schema, set to null to use the
+ * latest version
+ * @param uuid context album UUID, set to null to generate a UUID
+ * @param description context album description, set to null to generate a description
+ * @return result of the operation
+ */
+ // CHECKSTYLE:OFF: checkstyle:parameterNumber
+ public ApexApiResult updateContextAlbum(ContextAlbumBuilder builder) {
+ try {
+ final AxContextAlbum contextAlbum =
+ apexModel.getPolicyModel().getAlbums().get(builder.getName(), builder.getVersion());
+ if (contextAlbum == null) {
+ return new ApexApiResult(
+ ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT + builder.getName() + ':' + builder.getVersion() + DOES_NOT_EXIST);
+ }
- if (contextSchemaName != null) {
- final AxContextSchema schema =
- apexModel.getPolicyModel().getSchemas().get(contextSchemaName, contextSchemaVersion);
- if (schema == null) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
- CONCEPT + contextSchemaName + ':' + contextSchemaVersion + DOES_NOT_EXIST);
- }
- contextAlbum.setItemSchema(schema.getKey());
- }
+ if (builder.getScope() != null) {
+ contextAlbum.setScope(builder.getScope());
+ }
+ if (builder.getWritable() != null) {
+ if ("true".equalsIgnoreCase(builder.getWritable().trim())
+ || "t".equalsIgnoreCase(builder.getWritable().trim())) {
+ contextAlbum.setWritable(true);
+ } else {
+ contextAlbum.setWritable(false);
+ }
+ }
- return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
- } catch (final Exception e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
+ if (builder.getContextSchemaName() != null) {
+ final AxContextSchema schema =
+ apexModel
+ .getPolicyModel()
+ .getSchemas()
+ .get(builder.getContextSchemaName(), builder.getContextSchemaVersion());
+ if (schema == null) {
+ return new ApexApiResult(
+ ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST,
+ CONCEPT
+ + builder.getContextSchemaName()
+ + ':'
+ + builder.getContextSchemaVersion()
+ + DOES_NOT_EXIST);
}
+ contextAlbum.setItemSchema(schema.getKey());
+ }
+
+ return keyInformationFacade.updateKeyInformation(
+ builder.getName(), builder.getVersion(), builder.getUuid(), builder.getDescription());
+ } catch (final Exception e) {
+ return new ApexApiResult(ApexApiResult.Result.FAILED, e);
+ }
}
// CHECKSTYLE:ON: checkstyle:parameterNumber