2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020, 2023 Nordix Foundation.
4 * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.tosca.simple.concepts;
24 import jakarta.persistence.Entity;
25 import jakarta.persistence.Inheritance;
26 import jakarta.persistence.InheritanceType;
27 import jakarta.persistence.Table;
28 import java.io.Serial;
29 import java.util.List;
31 import java.util.TreeMap;
33 import lombok.EqualsAndHashCode;
34 import lombok.NonNull;
35 import lombok.ToString;
36 import org.onap.policy.common.parameters.BeanValidationResult;
37 import org.onap.policy.models.base.PfAuthorative;
38 import org.onap.policy.models.base.PfConceptContainer;
39 import org.onap.policy.models.base.PfConceptKey;
40 import org.onap.policy.models.tosca.authorative.concepts.ToscaRequirement;
41 import org.onap.policy.models.tosca.utils.ToscaUtils;
44 * This class is a container for TOSCA requirements.
46 * @author Liam Fallon (liam.fallon@est.tech)
49 @Table(name = "ToscaRequirements")
50 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
52 @ToString(callSuper = true)
53 @EqualsAndHashCode(callSuper = true)
54 public class JpaToscaRequirements extends PfConceptContainer<JpaToscaRequirement, ToscaRequirement>
55 implements PfAuthorative<List<Map<String, ToscaRequirement>>> {
57 private static final long serialVersionUID = -7526648702327776101L;
59 public static final String DEFAULT_NAME = "ToscaRequirementsSimple";
60 public static final String DEFAULT_VERSION = "1.0.0";
63 * The Default Constructor creates a {@link JpaToscaRequirements} object with a null artifact key and creates an
66 public JpaToscaRequirements() {
67 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
71 * The Key Constructor creates a {@link JpaToscaRequirements} object with the given artifact key and creates an
74 * @param key the concept key
76 public JpaToscaRequirements(final PfConceptKey key) {
77 super(key, new TreeMap<>());
81 * This Constructor creates a concept container with all of its fields defined.
83 * @param key the concept container key
84 * @param conceptMap the concepts to be stored in the concept container
86 public JpaToscaRequirements(final PfConceptKey key, final Map<PfConceptKey, JpaToscaRequirement> conceptMap) {
87 super(key, conceptMap);
93 * @param copyConcept the concept to copy from
95 public JpaToscaRequirements(final JpaToscaRequirements copyConcept) {
100 * Authorative constructor.
102 * @param authorativeConceptMapList the authorative concept to copy from
104 public JpaToscaRequirements(final List<Map<String, ToscaRequirement>> authorativeConceptMapList) {
105 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
106 this.fromAuthorative(authorativeConceptMapList);
110 public BeanValidationResult validate(@NonNull String fieldName) {
111 BeanValidationResult result = super.validate(fieldName);
113 for (JpaToscaRequirement requirement : this.getConceptMap().values()) {
114 ToscaUtils.getEntityTypeAncestors(this, requirement, result);