aboutsummaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-07-06 17:08:08 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2020-09-02 06:59:38 +0000
commit1ec3dde2067e0181faa8e5098219c93126638aef (patch)
treef09dced5babfa16da8653c5bb464172f5d4ac9c3 /common-be/src
parent930ed2515529bd7ff054b083816587b6d46f56b5 (diff)
Support for defining attributes on a node_type
This commit aims to add support of attributes on node_type. It is first of several commits to cover all support. It includes: - new classes: AttributeDefinition ComponentInstanceAttribute IAttributeInputCommon IAttributeInputCommon AttributeDataDefinition MapAttributesDataDefinition - support of 'Import of VFC with attributes' - TCs fix for changed code Next commit(s) will cover: - support of "Onboarding packages with attributes" - support of "Download TOSCA Artifacts - Tosca Model" - support of "Import onboarded VSP" Change-Id: I0167abc58e8aeef3d631833cc323e466f8e71492 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3200
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java52
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java149
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java77
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java2
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java56
6 files changed, 144 insertions, 194 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
new file mode 100644
index 0000000000..b619c66ee0
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/AttributeDataDefinition.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.sdc.be.datatypes.elements;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class AttributeDataDefinition extends ToscaDataDefinition{
+
+ private String uniqueId;
+ private String name;
+ private SchemaDefinition schema;
+ private String value;
+
+ public AttributeDataDefinition(final AttributeDataDefinition attributeDataDefinition) {
+ super();
+ this.setUniqueId(attributeDataDefinition.getUniqueId());
+ this.setName(attributeDataDefinition.getName());
+ this.setSchema(attributeDataDefinition.getSchema());
+ this.setValue(attributeDataDefinition.getValue());
+ }
+
+ public String getParentUniqueId() {
+ return getOwnerId();
+ }
+
+ public void setParentUniqueId(final String parentUniqueId) {
+ setOwnerId(parentUniqueId);
+ }
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
index 2b3b5fbbbf..80eadc2489 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinition.java
@@ -20,8 +20,19 @@
package org.openecomp.sdc.be.datatypes.elements;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.commons.lang3.builder.HashCodeExclude;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+@Getter
+@Setter
+@EqualsAndHashCode
+@ToString
+@NoArgsConstructor
public class ConsumerDataDefinition extends ToscaDataDefinition {
// ECOMP Consumer Name - UTF-8 string up to 255 characters containing the
@@ -55,10 +66,6 @@ public class ConsumerDataDefinition extends ToscaDataDefinition {
private Long consumerDetailsLastupdatedtime;
private String lastModfierAtuid;
- public ConsumerDataDefinition() {
-
- }
-
public ConsumerDataDefinition(ConsumerDataDefinition a) {
this.consumerName = a.consumerName;
this.consumerPassword = a.consumerPassword;
@@ -69,138 +76,4 @@ public class ConsumerDataDefinition extends ToscaDataDefinition {
}
- public String getConsumerName() {
- return consumerName;
- }
-
- public void setConsumerName(String consumerName) {
- this.consumerName = consumerName;
- }
-
- public String getConsumerPassword() {
- return consumerPassword;
- }
-
- public void setConsumerPassword(String consumerPassword) {
- this.consumerPassword = consumerPassword;
- }
-
- public String getConsumerSalt() {
- return consumerSalt;
- }
-
- public void setConsumerSalt(String consumerSalt) {
- this.consumerSalt = consumerSalt;
- }
-
- public Long getConsumerLastAuthenticationTime() {
- return consumerLastAuthenticationTime;
- }
-
- public void setConsumerLastAuthenticationTime(Long consumerLastAuthenticationTime) {
- this.consumerLastAuthenticationTime = consumerLastAuthenticationTime;
- }
-
- public Long getConsumerDetailsLastupdatedtime() {
- return consumerDetailsLastupdatedtime;
- }
-
- public void setConsumerDetailsLastupdatedtime(Long consumerDetailsLastupdatedtime) {
- this.consumerDetailsLastupdatedtime = consumerDetailsLastupdatedtime;
- }
-
- public String getLastModfierAtuid() {
- return lastModfierAtuid;
- }
-
- public void setLastModfierAtuid(String lastModfierAtuid) {
- this.lastModfierAtuid = lastModfierAtuid;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("ConsumerDataDefinition [").append("consumerName=").append(consumerName).append(",")
- .append("consumerPassword=").append(consumerPassword).append(",").append("consumerSalt=")
- .append(consumerSalt).append(",").append("consumerLastAuthenticationTime=")
- .append(consumerLastAuthenticationTime).append(",").append("consumerDetailsLastupdatedtime=")
- .append(consumerDetailsLastupdatedtime).append(",").append("lastModfierAtuid=").append(lastModfierAtuid)
- .append("]");
- return sb.toString();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((consumerName == null) ? 0 : consumerName.hashCode());
- result = prime * result + ((consumerPassword == null) ? 0 : consumerPassword.hashCode());
- result = prime * result + ((consumerSalt == null) ? 0 : consumerSalt.hashCode());
- result = prime * result
- + ((consumerLastAuthenticationTime == null) ? 0 : consumerLastAuthenticationTime.hashCode());
- result = prime * result
- + ((consumerDetailsLastupdatedtime == null) ? 0 : consumerDetailsLastupdatedtime.hashCode());
- result = prime * result + ((lastModfierAtuid == null) ? 0 : lastModfierAtuid.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ConsumerDataDefinition other = (ConsumerDataDefinition) obj;
- if (consumerName == null) {
- if (other.consumerName != null) {
- return false;
- }
- } else if (!consumerName.equals(other.consumerName)) {
- return false;
- }
- if (consumerPassword == null) {
- if (other.consumerPassword != null) {
- return false;
- }
- } else if (!consumerPassword.equals(other.consumerPassword)) {
- return false;
- }
-
- if (consumerSalt == null) {
- if (other.consumerSalt != null) {
- return false;
- }
- } else if (!consumerSalt.equals(other.consumerSalt)) {
- return false;
- }
-
- if (consumerLastAuthenticationTime == null) {
- if (other.consumerLastAuthenticationTime != null) {
- return false;
- }
- } else if (!consumerLastAuthenticationTime.equals(other.consumerLastAuthenticationTime)) {
- return false;
- }
-
- if (consumerDetailsLastupdatedtime == null) {
- if (other.consumerDetailsLastupdatedtime != null) {
- return false;
- }
- } else if (!consumerDetailsLastupdatedtime.equals(other.consumerDetailsLastupdatedtime)) {
- return false;
- }
-
- if (lastModfierAtuid == null) {
- return other.lastModfierAtuid == null;
- } else {
- return lastModfierAtuid.equals(other.lastModfierAtuid);
- }
-
- }
-
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
new file mode 100644
index 0000000000..31c791681c
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/MapAttributesDataDefinition.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.datatypes.elements;
+
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MapAttributesDataDefinition extends MapDataDefinition<AttributeDataDefinition> {
+
+ private String parentName;
+
+ public MapAttributesDataDefinition(MapDataDefinition cdt, String parentName) {
+ super(cdt);
+ this.parentName = parentName;
+ }
+
+ @JsonCreator
+ public MapAttributesDataDefinition(Map<String, AttributeDataDefinition> mapToscaDataDefinition) {
+ super(mapToscaDataDefinition);
+ }
+
+ /**
+ * Copy Constructor
+ */
+ public MapAttributesDataDefinition(MapAttributesDataDefinition toBeDeepCopiedMapPropertiesDataDefinition) {
+ this.parentName = toBeDeepCopiedMapPropertiesDataDefinition.parentName;
+ this.toscaPresentation = toBeDeepCopiedMapPropertiesDataDefinition.toscaPresentation == null ? null : new HashMap(toBeDeepCopiedMapPropertiesDataDefinition.toscaPresentation);
+ this.mapToscaDataDefinition = toBeDeepCopiedMapPropertiesDataDefinition.mapToscaDataDefinition == null ? null : new HashMap(toBeDeepCopiedMapPropertiesDataDefinition.mapToscaDataDefinition);
+ }
+
+ public MapAttributesDataDefinition() {
+ super();
+
+ }
+
+ @JsonValue
+ @Override
+ public Map<String, AttributeDataDefinition> getMapToscaDataDefinition() {
+ return mapToscaDataDefinition;
+ }
+
+
+ public void setMapToscaDataDefinition(Map<String, AttributeDataDefinition> mapToscaDataDefinition) {
+ this.mapToscaDataDefinition = mapToscaDataDefinition;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
+
+
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 027519500f..2dca70cad1 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -248,6 +248,8 @@ public enum JsonPresentationFields {
GET_INPUT("get_input", null),
GET_OPERATION_OUTPUT("get_operation_output", null),
+ ATTRIBUTES("attributes", null),
+
TOSCA_DEFINITIONS_VERSION("tosca_definitions_version", null);
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
index 4637231de6..c1e6dbaa43 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.datatypes.tosca;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import fj.data.Either;
+import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import java.util.HashMap;
@@ -133,4 +134,5 @@ public abstract class ToscaDataDefinition {
return false;
}
+ public void setSchema(final SchemaDefinition schemaDef){};
}
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java
deleted file mode 100644
index b8b55369c5..0000000000
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/elements/ConsumerDataDefinitionTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.datatypes.elements;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.junit.Assert.assertThat;
-
-public class ConsumerDataDefinitionTest {
-
- private ConsumerDataDefinition createTestSubject() {
- return new ConsumerDataDefinition();
- }
-
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ConsumerDataDefinition.class,
- hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty", "type", "version"));
- }
-
- @Test
- public void testEquals() throws Exception {
- ConsumerDataDefinition testSubject;
- Object obj = null;
- boolean result;
-
- // test 1
- testSubject = createTestSubject();
- obj = null;
- result = testSubject.equals(obj);
- Assert.assertEquals(false, result);
- result = testSubject.equals(testSubject);
- Assert.assertEquals(true, result);
- result = testSubject.equals(new ConsumerDataDefinition(testSubject));
- Assert.assertEquals(true, result);
- }
-}