2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019-2020 Nordix Foundation.
4 * Modifications Copyright (C) 2019 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 java.util.List;
26 import java.util.TreeMap;
27 import javax.persistence.Entity;
28 import javax.persistence.Inheritance;
29 import javax.persistence.InheritanceType;
30 import javax.persistence.Table;
32 import lombok.EqualsAndHashCode;
33 import lombok.NonNull;
34 import lombok.ToString;
35 import org.onap.policy.models.base.PfAuthorative;
36 import org.onap.policy.models.base.PfConceptContainer;
37 import org.onap.policy.models.base.PfConceptKey;
38 import org.onap.policy.models.base.PfValidationResult;
39 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
40 import org.onap.policy.models.tosca.utils.ToscaUtils;
43 * This class is a container for TOSCA data types.
45 * @author Liam Fallon (liam.fallon@est.tech)
48 @Table(name = "ToscaPolicies")
49 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
51 @ToString(callSuper = true)
52 @EqualsAndHashCode(callSuper = true)
53 public class JpaToscaPolicies extends PfConceptContainer<JpaToscaPolicy, ToscaPolicy>
54 implements PfAuthorative<List<Map<String, ToscaPolicy>>> {
55 private static final long serialVersionUID = -7526648702327776101L;
57 public static final String DEFAULT_NAME = "ToscaPoliciesSimple";
58 public static final String DEFAULT_VERSION = "1.0.0";
61 * The Default Constructor creates a {@link JpaToscaPolicies} object with a null artifact key and creates an empty
64 public JpaToscaPolicies() {
65 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
69 * The Key Constructor creates a {@link JpaToscaPolicies} object with the given artifact key and creates an empty
72 * @param key the concept key
74 public JpaToscaPolicies(final PfConceptKey key) {
75 super(key, new TreeMap<PfConceptKey, JpaToscaPolicy>());
79 * This Constructor creates an concept container with all of its fields defined.
81 * @param key the concept container key
82 * @param conceptMap the concepts to be stored in the concept container
84 public JpaToscaPolicies(final PfConceptKey key, final Map<PfConceptKey, JpaToscaPolicy> conceptMap) {
85 super(key, conceptMap);
91 * @param copyConcept the concept to copy from
93 public JpaToscaPolicies(final JpaToscaPolicies copyConcept) {
98 * Authorative constructor.
100 * @param authorativeConceptMapList the authorative concept to copy from
102 public JpaToscaPolicies(final List<Map<String, ToscaPolicy>> authorativeConceptMapList) {
103 super(new PfConceptKey(DEFAULT_NAME, DEFAULT_VERSION));
104 this.fromAuthorative(authorativeConceptMapList);
108 public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
109 PfValidationResult result = super.validate(resultIn);
111 for (JpaToscaPolicy policy : this.getConceptMap().values()) {
112 ToscaUtils.getEntityTypeAncestors(this, policy, result);