2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.tosca.simple.concepts;
23 import java.util.List;
25 import java.util.TreeMap;
26 import javax.persistence.Entity;
27 import javax.persistence.Inheritance;
28 import javax.persistence.InheritanceType;
29 import javax.persistence.Table;
31 import lombok.EqualsAndHashCode;
32 import lombok.NonNull;
33 import lombok.ToString;
34 import org.onap.policy.models.base.PfConceptContainer;
35 import org.onap.policy.models.base.PfConceptKey;
36 import org.onap.policy.models.base.PfValidationResult;
37 import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
38 import org.onap.policy.models.tosca.utils.ToscaUtils;
41 * This class is a container for TOSCA node types.
44 @Table(name = "ToscaNodeTypes")
45 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
47 @ToString(callSuper = true)
48 @EqualsAndHashCode(callSuper = true)
49 public class JpaToscaNodeTypes extends PfConceptContainer<JpaToscaNodeType, ToscaNodeType> {
50 public static final String DEFAULT_NAME = "ToscaNodeTypesSimple";
51 public static final String DEFAULT_VERSION = "1.0.0";
52 private static final long serialVersionUID = -4157979965271220098L;
55 * The Default Constructor creates a {@link JpaToscaNodeTypes} object with a null artifact key and creates an
58 public JpaToscaNodeTypes() {
59 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
63 * The Key Constructor creates a {@link JpaToscaNodeTypes} object with the given artifact key and creates an
66 * @param key the concept key
68 public JpaToscaNodeTypes(final PfConceptKey key) {
69 super(key, new TreeMap<>());
73 * This Constructor creates an concept container with all of its fields defined.
75 * @param key the concept container key
76 * @param conceptMap the concepts to be stored in the concept container
78 public JpaToscaNodeTypes(final PfConceptKey key, final Map<PfConceptKey, JpaToscaNodeType> conceptMap) {
79 super(key, conceptMap);
85 * @param copyConcept the concept to copy from
87 public JpaToscaNodeTypes(final JpaToscaNodeTypes copyConcept) {
92 * Authorative constructor.
94 * @param authorativeConceptMapList the authorative concept to copy from
96 public JpaToscaNodeTypes(final List<Map<String, ToscaNodeType>> authorativeConceptMapList) {
97 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
98 this.fromAuthorative(authorativeConceptMapList);
102 public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
103 PfValidationResult result = super.validate(resultIn);
105 // Check that all ancestors of this policy type exist
106 for (JpaToscaNodeType nodeType : this.getConceptMap().values()) {
107 ToscaUtils.getEntityTypeAncestors(this, nodeType, result);