summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/resource-dict/src
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict/src')
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java167
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DecryptionRule.java67
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java181
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java36
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java83
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java36
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java37
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java97
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java129
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java164
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java165
11 files changed, 1162 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
new file mode 100644
index 000000000..15576b906
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ResourceAssignment.java Purpose: Provide ResourceAssignment Custom TOSCO Model POJO bean.
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class ResourceAssignment {
+
+ private String name;
+
+ @JsonProperty("property")
+ private PropertyDefinition property;
+
+ @JsonProperty("input-param")
+ private Boolean inputParameter;
+
+ @JsonProperty("dictionary-name")
+ private String dictionaryName;
+
+ @JsonProperty("dictionary-source")
+ private String dictionarySource;
+
+ @JsonProperty("dependencies")
+ private List<String> dependencies;
+
+ @JsonProperty("version")
+ private int version;
+
+ @JsonProperty("status")
+ private String status;
+
+ @JsonProperty("message")
+ private String message;
+
+ @JsonProperty("updated-date")
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
+ private Date updatedDate;
+
+ @JsonProperty("updated-by")
+ private String updatedBy;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder("[");
+ builder.append("name = " + name);
+ builder.append(", source = " + dictionarySource);
+ if (dependencies != null) {
+ builder.append(", dependencies = " + dependencies);
+ }
+ builder.append("]");
+ return builder.toString();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public PropertyDefinition getProperty() {
+ return property;
+ }
+
+ public void setProperty(PropertyDefinition property) {
+ this.property = property;
+ }
+
+ public Boolean getInputParameter() {
+ return inputParameter;
+ }
+
+ public void setInputParameter(Boolean inputParameter) {
+ this.inputParameter = inputParameter;
+ }
+
+ public String getDictionaryName() {
+ return dictionaryName;
+ }
+
+ public void setDictionaryName(String dictionaryName) {
+ this.dictionaryName = dictionaryName;
+ }
+
+ public String getDictionarySource() {
+ return dictionarySource;
+ }
+
+ public void setDictionarySource(String dictionarySource) {
+ this.dictionarySource = dictionarySource;
+ }
+
+ public List<String> getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(List<String> dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Date getUpdatedDate() {
+ return updatedDate;
+ }
+
+ public void setUpdatedDate(Date updatedDate) {
+ this.updatedDate = updatedDate;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DecryptionRule.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DecryptionRule.java
new file mode 100644
index 000000000..be435242d
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DecryptionRule.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+/**
+ *
+ * DecryptionRule.java Purpose:
+ * @author Brinda Santh
+ */
+public class DecryptionRule {
+
+ private List<String> sources = null;
+ private String path;
+ private String rule;
+ @JsonProperty("decrypt-type")
+ private String decryptType;
+
+ public List<String> getSources() {
+ return sources;
+ }
+
+ public void setSources(List<String> sources) {
+ this.sources = sources;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getRule() {
+ return rule;
+ }
+
+ public void setRule(String rule) {
+ this.rule = rule;
+ }
+
+ public String getDecryptType() {
+ return decryptType;
+ }
+
+ public void setDecryptType(String decryptType) {
+ this.decryptType = decryptType;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
new file mode 100644
index 000000000..4dc9c89a1
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+
+import java.util.List;
+import java.util.Map;
+/**
+ *
+ * DictionaryDefinition.java Purpose:
+ * @author Brinda Santh
+ */
+public class DictionaryDefinition {
+ @JsonProperty(value = "name", required = true)
+ private String name;
+ @JsonProperty(value = "description")
+ private String description;
+
+ @JsonProperty(value = "valid-values")
+ private String validValues;
+
+ @JsonProperty(value = "sample-value")
+ private String sampleValue;
+
+ private String tags;
+ @JsonProperty(value = "updated-by")
+ private String updatedBy;
+
+ @JsonProperty(value = "resource-type", required = true)
+ private String resourceType;
+
+ @JsonProperty(value = "resource-path", required = true)
+ private String resourcePath;
+
+ @JsonProperty(value = "data-type", required = true)
+ private String dataType;
+
+ @JsonProperty("entry-schema")
+ private String entrySchema;
+
+ @JsonProperty(value = "default")
+ private Object defaultValue;
+
+ @JsonProperty(value = "source", required = true)
+ private Map<String, JsonNode> source;
+
+ @JsonProperty("candidate-dependency")
+ private Map<String, DictionaryDependency> dependency;
+
+ @JsonProperty("decryption-rules")
+ private List<DecryptionRule> decryptionRules;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getValidValues() {
+ return validValues;
+ }
+
+ public void setValidValues(String validValues) {
+ this.validValues = validValues;
+ }
+
+ public String getSampleValue() {
+ return sampleValue;
+ }
+
+ public void setSampleValue(String sampleValue) {
+ this.sampleValue = sampleValue;
+ }
+
+ public String getTags() {
+ return tags;
+ }
+
+ public void setTags(String tags) {
+ this.tags = tags;
+ }
+
+ public String getUpdatedBy() {
+ return updatedBy;
+ }
+
+ public void setUpdatedBy(String updatedBy) {
+ this.updatedBy = updatedBy;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getEntrySchema() {
+ return entrySchema;
+ }
+
+ public void setEntrySchema(String entrySchema) {
+ this.entrySchema = entrySchema;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(Object defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public Map<String, JsonNode> getSource() {
+ return source;
+ }
+
+ public void setSource(Map<String, JsonNode> source) {
+ this.source = source;
+ }
+
+ public Map<String, DictionaryDependency> getDependency() {
+ return dependency;
+ }
+
+ public void setDependency(Map<String, DictionaryDependency> dependency) {
+ this.dependency = dependency;
+ }
+
+ public List<DecryptionRule> getDecryptionRules() {
+ return decryptionRules;
+ }
+
+ public void setDecryptionRules(List<DecryptionRule> decryptionRules) {
+ this.decryptionRules = decryptionRules;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java
new file mode 100644
index 000000000..acb710584
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDependency.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import java.util.List;
+/**
+ *
+ * DictionaryDependency
+ * @author Brinda Santh
+ */
+public class DictionaryDependency {
+ private List<String> names;
+
+ public List<String> getNames() {
+ return names;
+ }
+
+ public void setNames(List<String> names) {
+ this.names = names;
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
new file mode 100644
index 000000000..23d404605
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Map;
+/**
+ *
+ * SourceDb
+ * @author Brinda Santh
+ */
+public class SourceDb {
+ @JsonProperty(value = "base", required = true)
+ private String base;
+ @JsonProperty(value = "type", required = true)
+ private String type; // SQL | PLSQL
+ @JsonProperty(value = "query", required = true)
+ private String query;
+
+ @JsonProperty("input-key-mapping")
+ private Map<String, String> inputKeyMapping;
+
+ @JsonProperty("output-key-mapping")
+ private Map<String, String> outputKeyMapping;
+
+ public String getBase() {
+ return base;
+ }
+
+ public void setBase(String base) {
+ this.base = base;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ public Map<String, String> getInputKeyMapping() {
+ return inputKeyMapping;
+ }
+
+ public void setInputKeyMapping(Map<String, String> inputKeyMapping) {
+ this.inputKeyMapping = inputKeyMapping;
+ }
+
+ public Map<String, String> getOutputKeyMapping() {
+ return outputKeyMapping;
+ }
+
+ public void setOutputKeyMapping(Map<String, String> outputKeyMapping) {
+ this.outputKeyMapping = outputKeyMapping;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
new file mode 100644
index 000000000..0a4351cca
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+/**
+ *
+ * SourceDefault
+ * @author Brinda Santh
+ */
+public class SourceDefault {
+
+ private String key;
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
new file mode 100644
index 000000000..82cb769da
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+/**
+ *
+ * SourceInput
+ * @author Brinda Santh
+ */
+public class SourceInput {
+
+ private String key;
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
new file mode 100644
index 000000000..9eb233e76
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data;
+/**
+ *
+ * SourceMdsal
+ * @author Brinda Santh
+ */
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Map;
+
+public class SourceMdsal {
+
+ @JsonProperty(value = "base", required = true)
+ private String base;
+
+ @JsonProperty(value = "type", required = true)
+ private String type; // XML | JSON
+
+ @JsonProperty(value = "url-path", required = true)
+ private String urlPath;
+
+ @JsonProperty(value = "path", required = true)
+ private String path;
+
+ @JsonProperty("input-key-mapping")
+ private Map<String, String> inputKeyMapping;
+
+ @JsonProperty("output-key-mapping")
+ private Map<String, String> outputKeyMapping;
+
+ public String getBase() {
+ return base;
+ }
+
+ public void setBase(String base) {
+ this.base = base;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getUrlPath() {
+ return urlPath;
+ }
+
+ public void setUrlPath(String urlPath) {
+ this.urlPath = urlPath;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public Map<String, String> getInputKeyMapping() {
+ return inputKeyMapping;
+ }
+
+ public void setInputKeyMapping(Map<String, String> inputKeyMapping) {
+ this.inputKeyMapping = inputKeyMapping;
+ }
+
+ public Map<String, String> getOutputKeyMapping() {
+ return outputKeyMapping;
+ }
+
+ public void setOutputKeyMapping(Map<String, String> outputKeyMapping) {
+ this.outputKeyMapping = outputKeyMapping;
+ }
+
+
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
new file mode 100644
index 000000000..9d51d8213
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+/**
+ * ResourceDictionaryUtils.java Purpose to provide ResourceDictionaryUtils
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+public class ResourceDictionaryUtils {
+
+ private ResourceDictionaryUtils() {
+ // Do nothing
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtils.class);
+
+ /**
+ * This Method is to assign the source name to the Dictionary Definition Check to see if the source
+ * definition is not present then assign, if more than one source then assign only one first source.
+ *
+ * @param resourceAssignment
+ * @param dictionaryDefinition
+ */
+ @SuppressWarnings("squid:S3776")
+ public static void populateSourceMapping(ResourceAssignment resourceAssignment,
+ DictionaryDefinition dictionaryDefinition) {
+
+ if (resourceAssignment != null && dictionaryDefinition != null
+ && StringUtils.isBlank(resourceAssignment.getDictionarySource())) {
+
+ // Overwrite the Property Definitions from Dictionary
+ setProperty(resourceAssignment, dictionaryDefinition);
+
+ Map<String, JsonNode> dictionarySource = dictionaryDefinition.getSource();
+ Map<String, DictionaryDependency> dictionaryDependencyMap = dictionaryDefinition.getDependency();
+
+ if (MapUtils.isNotEmpty(dictionarySource)) {
+ String source = findFirstSource(dictionarySource);
+
+ // Populate and Assign First Source
+ if (StringUtils.isNotBlank(source)) {
+ // Set Dictionary Source
+ resourceAssignment.setDictionarySource(source);
+
+ if (MapUtils.isNotEmpty(dictionaryDependencyMap)) {
+ // Set Dependencies
+ DictionaryDependency dictionaryDependency = dictionaryDependencyMap.get(source);
+ if (dictionaryDependency != null) {
+ resourceAssignment.setDependencies(dictionaryDependency.getNames());
+ }
+ }
+ } else {
+ resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT);
+ }
+ log.info("auto map resourceAssignment : {}", resourceAssignment);
+ }
+ }
+ }
+
+ public static <T> Optional<T> resolve(Supplier<T> resolver) {
+ try {
+ T result = resolver.get();
+ return Optional.ofNullable(result);
+ } catch (NullPointerException e) {
+ return Optional.empty();
+ }
+ }
+
+ private static String findFirstSource(Map<String, JsonNode> dictionarySource) {
+ String source = null;
+ if (MapUtils.isNotEmpty(dictionarySource)) {
+ source = dictionarySource.keySet().stream().findFirst().get();
+ }
+ return source;
+ }
+
+ /**
+ * Overriding ResourceAssignment Properties with properties defined in Dictionary
+ */
+ private static void setProperty(ResourceAssignment resourceAssignment, DictionaryDefinition dictionaryDefinition) {
+ if (StringUtils.isNotBlank(dictionaryDefinition.getDataType())) {
+ PropertyDefinition property = resourceAssignment.getProperty();
+ if (property == null) {
+ property = new PropertyDefinition();
+ }
+ property.setDefaultValue(dictionaryDefinition.getDefaultValue());
+ property.setType(dictionaryDefinition.getDataType());
+ if (StringUtils.isNotBlank(dictionaryDefinition.getEntrySchema())) {
+ EntrySchema entrySchema = new EntrySchema();
+ entrySchema.setType(dictionaryDefinition.getEntrySchema());
+ property.setEntrySchema(entrySchema);
+ }
+ resourceAssignment.setProperty(property);
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java
new file mode 100644
index 000000000..c980a0c08
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/validator/ResourceAssignmentValidator.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.validator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.StrBuilder;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+/**
+ *
+ * ResourceAssignmentValidator.java Purpose:
+ * @author Brinda Santh
+ */
+public class ResourceAssignmentValidator {
+ private static final Logger log = LoggerFactory.getLogger(ResourceAssignmentValidator.class);
+ private List<ResourceAssignment> assignments;
+ private Map<String, ResourceAssignment> resourceAssignmentMap = new HashMap();
+ private StrBuilder validationMessage = new StrBuilder();
+
+ public ResourceAssignmentValidator(List<ResourceAssignment> assignments) {
+ this.assignments = assignments;
+ }
+
+ public ResourceAssignmentValidator(NodeTemplate nodeTemplate) throws BluePrintException {
+
+ if (nodeTemplate != null && nodeTemplate.getCapabilities() != null) {
+ CapabilityAssignment capabilityAssignment =
+ nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
+ if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) {
+ Object mappingObject =
+ capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
+ if (mappingObject != null) {
+ String mappingContent = JacksonUtils.getJson(mappingObject);
+ if (StringUtils.isNotBlank(mappingContent)) {
+ this.assignments =
+ JacksonUtils.getListFromJson(mappingContent, ResourceAssignment.class);
+ } else {
+ validationMessage
+ .appendln(String.format("Failed to transform Mapping Content (%s) ", mappingContent));
+ throw new BluePrintException(
+ String.format("Failed to transform Mapping Content (%s) ", mappingContent));
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This is a validateResourceAssignment to validate the Topology Template
+ *
+ * @return boolean
+ * @throws BluePrintException
+ */
+ public boolean validateResourceAssignment() throws BluePrintException {
+ if (assignments != null && !assignments.isEmpty()) {
+ validateDuplicateDictionaryKeys();
+ validateCyclicDependency();
+ if (validationMessage.length() > 0) {
+ throw new BluePrintException("Resource Assignment Validation :" + validationMessage.toString());
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("squid:S3776")
+ private void validateDuplicateDictionaryKeys() {
+ this.assignments.forEach(resourceMapping -> {
+ if (resourceMapping != null) {
+ if (!resourceAssignmentMap.containsKey(resourceMapping.getName())) {
+ resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping);
+ } else {
+ validationMessage.appendln(String.format("Duplicate Assignment Template Key (%s) is Present",
+ resourceMapping.getName()));
+ }
+ }
+ });
+
+ if (!assignments.isEmpty()) {
+ Set<String> uniqueSet = new HashSet<>();
+ for (ResourceAssignment resourceAssignment : assignments) {
+ if (resourceAssignment != null) {
+ boolean added = uniqueSet.add(resourceAssignment.getDictionaryName());
+ if (!added) {
+ validationMessage.appendln(
+ String.format("Duplicate Assignment Dictionary Key (%s) present with Template Key (%s)",
+ resourceAssignment.getDictionaryName(), resourceAssignment.getName()));
+ }
+ }
+ }
+ }
+ }
+
+ private void validateCyclicDependency() {
+ TopologicalSortingUtils<ResourceAssignment> topologySorting = new TopologicalSortingUtils<>();
+ this.resourceAssignmentMap.forEach((mappingKey, mapping) -> {
+ if (mapping != null) {
+ if (mapping.getDependencies() != null && !mapping.getDependencies().isEmpty()) {
+ for (String dependency : mapping.getDependencies()) {
+ topologySorting.add(resourceAssignmentMap.get(dependency), mapping);
+ }
+ } else {
+ topologySorting.add(null, mapping);
+ }
+ }
+ });
+
+ if (!topologySorting.isDag()) {
+ String graph = getTopologicalGraph(topologySorting);
+ validationMessage.appendln("Cyclic Dependency :" + graph);
+ }
+ }
+
+
+ public String getTopologicalGraph(TopologicalSortingUtils<ResourceAssignment> topologySorting) {
+ StringBuilder s = new StringBuilder();
+ if (topologySorting != null) {
+ Map<ResourceAssignment, List<ResourceAssignment>> neighbors = topologySorting.getNeighbors();
+
+ neighbors.forEach((v, vs) -> {
+ if (v == null) {
+ s.append("\n * -> [");
+ List<ResourceAssignment> links = vs;
+ for (ResourceAssignment resourceAssignment : links) {
+ s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName()
+ + "),");
+ }
+ s.append("]");
+ } else {
+ s.append("\n (" + v.getDictionaryName() + ":" + v.getName() + ") -> [");
+ List<ResourceAssignment> links = vs;
+ for (ResourceAssignment resourceAssignment : links) {
+ s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName()
+ + "),");
+ }
+ s.append("]");
+ }
+ });
+ }
+ return s.toString();
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
new file mode 100644
index 000000000..22b01c4a8
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResourceDictionaryUtilsTest {
+ private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
+
+ @Test
+ public void validateSingleInputSource() {
+ try {
+ log.info(" **************** Validating validateSingleSource *****************");
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("test-input-key");
+ DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
+ dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
+
+ Map<String, JsonNode> source = new HashMap<>();
+ SourceInput sourceInput = new SourceInput();
+ source.put(ConfigModelConstant.SOURCE_INPUT, JacksonUtils.jsonNodeFromObject(sourceInput));
+ dictionaryDefinition.setSource(source);
+
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ Assert.assertNotNull("Resource assignment input source is missing ",
+ resourceAssignment.getDictionarySource());
+ Assert.assertNotNull("Resource assignment input source property is missing ",
+ resourceAssignment.getProperty());
+ Assert.assertNotNull("Resource assignment input source property type is missing ",
+ resourceAssignment.getProperty().getType());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void validateSingleDbSource() {
+ try {
+ log.info(" **************** Validating validateSingleSource *****************");
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("test-db-key");
+ DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
+ dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
+
+ Map<String, JsonNode> source = new HashMap<>();
+ SourceDb sourceDb = new SourceDb();
+ source.put(ConfigModelConstant.SOURCE_DB, JacksonUtils.jsonNodeFromObject(sourceDb));
+ dictionaryDefinition.setSource(source);
+
+ Map<String, DictionaryDependency> dependency = new HashMap<>();
+ DictionaryDependency dependencyDb = new DictionaryDependency();
+ dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name"));
+ dependency.put(ConfigModelConstant.SOURCE_DB, dependencyDb);
+ dictionaryDefinition.setDependency(dependency);
+
+ DecryptionRule decryptionRule = new DecryptionRule();
+ decryptionRule.setDecryptType("sample Type");
+ decryptionRule.setPath("$.");
+ decryptionRule.setRule("Sample Rule");
+ decryptionRule.setSources(Arrays.asList("vnf-id"));
+ dictionaryDefinition.setDecryptionRules(Arrays.asList(decryptionRule));
+
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+ Assert.assertNotNull("Resource assignment db source source is missing ",
+ resourceAssignment.getDictionarySource());
+ Assert.assertNotNull("Resource assignment db source source property is missing ",
+ resourceAssignment.getProperty());
+ Assert.assertNotNull("Resource assignment db source source property type is missing ",
+ resourceAssignment.getProperty().getType());
+
+ Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies());
+ Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2,
+ resourceAssignment.getDependencies().size());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSourceDefault() {
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("test-input-key");
+
+ DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
+ dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
+
+ Map<String, JsonNode> source = new HashMap<>();
+ SourceDefault sourceDefault = new SourceDefault();
+ source.put(ConfigModelConstant.SOURCE_DEFAULT, JacksonUtils.jsonNodeFromObject(sourceDefault));
+ dictionaryDefinition.setSource(source);
+
+ Map<String, DictionaryDependency> dependency = new HashMap<>();
+ DictionaryDependency dependencyDefault = new DictionaryDependency();
+ dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
+ dependency.put(ConfigModelConstant.SOURCE_DEFAULT, dependencyDefault);
+ dictionaryDefinition.setDependency(dependency);
+
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+
+ Assert.assertNotNull("Resource assignment default source is missing ",
+ resourceAssignment.getDictionarySource());
+ Assert.assertNotNull("Resource assignment default source property is missing ",
+ resourceAssignment.getProperty());
+ Assert.assertNotNull("Resource assignment default source property type is missing ",
+ resourceAssignment.getProperty().getType());
+ }
+
+ @Test
+ public void testSourceMdsal() {
+ ResourceAssignment resourceAssignment = new ResourceAssignment();
+ resourceAssignment.setName("test-input-key");
+ DictionaryDefinition dictionaryDefinition = new DictionaryDefinition();
+ dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING);
+
+ Map<String, JsonNode> source = new HashMap<>();
+ SourceMdsal sourceMdsal = new SourceMdsal();
+ source.put(ConfigModelConstant.SOURCE_MDSAL, JacksonUtils.jsonNodeFromObject(sourceMdsal));
+ dictionaryDefinition.setSource(source);
+
+ Map<String, DictionaryDependency> dependency = new HashMap<>();
+ DictionaryDependency dependencyMdsal = new DictionaryDependency();
+ dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"}));
+ dependency.put(ConfigModelConstant.SOURCE_MDSAL, dependencyMdsal);
+ dictionaryDefinition.setDependency(dependency);
+
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition);
+
+ Assert.assertNotNull("Resource assignment mdsal source is missing ", resourceAssignment.getDictionarySource());
+ Assert.assertNotNull("Resource assignment mdsal source property is missing ", resourceAssignment.getProperty());
+ Assert.assertNotNull("Resource assignment mdsal source property type is missing ",
+ resourceAssignment.getProperty().getType());
+ }
+
+}