From 7a7b13726c195e2944ccc59e4d5c5ade57318763 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 15 Jun 2022 15:30:40 +0100 Subject: Support TOSCA get_attribute function Adds support to TOSCA get_attribute function in the Property Assignment TOSCA Function modal. Change-Id: I73dda215a7c9d7fecf0803cc259634279c3bdfb6 Issue-ID: SDC-4053 Signed-off-by: andre.schmid --- .../sdc/be/model/AttributeDefinition.java | 13 ++++++++- .../openecomp/sdc/be/model/PropertyDefinition.java | 2 +- .../openecomp/sdc/be/model/ToscaPropertyData.java | 31 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java (limited to 'catalog-model/src/main') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java index d1bcedc8ea..be9bee0d53 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java @@ -21,9 +21,10 @@ package org.openecomp.sdc.be.model; import lombok.NoArgsConstructor; import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; @NoArgsConstructor -public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue { +public class AttributeDefinition extends AttributeDataDefinition implements IOperationParameter, IComplexDefaultValue, ToscaPropertyData { public AttributeDefinition(final AttributeDataDefinition attributeDataDefinition) { super(attributeDataDefinition); @@ -49,4 +50,14 @@ public class AttributeDefinition extends AttributeDataDefinition implements IOpe return "AttributeDefinition{" + "name=" + getName() + "uniqueId=" + getUniqueId() + "ownerId=" + getOwnerId() + "type=" + getType() + "description=" + getDescription() + "default=" + getDefaultValue() + '}'; } + + @Override + public String getSchemaType() { + final SchemaDefinition schema = getSchema(); + if (schema == null || schema.getProperty() == null) { + return null; + } + return schema.getProperty().getType(); + } + } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java index 6e313eda6c..d9add3f425 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; -public class PropertyDefinition extends PropertyDataDefinition implements IOperationParameter, IComplexDefaultValue { +public class PropertyDefinition extends PropertyDataDefinition implements IOperationParameter, IComplexDefaultValue, ToscaPropertyData { private List constraints; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java new file mode 100644 index 0000000000..14c95757c7 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ToscaPropertyData.java @@ -0,0 +1,31 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2022 Nordix Foundation. + * ================================================================================ + * 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.openecomp.sdc.be.model; + +/** + * Represents basic/common TOSCA Property, Attribute or Input methods + */ +public interface ToscaPropertyData { + String getUniqueId(); + String getType(); + String getSchemaType(); +} -- cgit 1.2.3-korg