/*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020, 2023-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2022 Bell Canada. 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. * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.models.base; import com.google.re2j.Pattern; import jakarta.persistence.CascadeType; import jakarta.persistence.EmbeddedId; import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.MappedSuperclass; import jakarta.ws.rs.core.Response; import java.io.Serial; import java.lang.reflect.ParameterizedType; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import java.util.function.Function; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.validation.annotations.VerifyKey; // @formatter:off /** * This class is a concept container and holds a map of concepts. The {@link PfConceptContainer} class implements the * helper methods of the {@link PfConceptGetter} interface to allow {@link PfConceptContainer} instances to be retrieved * by calling methods directly on this class without referencing the contained map. * *
Validation checks that a container key is not null. An error is issued if no concepts are defined in a container.
* Each concept entry is checked to ensure that its key and value are not null and that the key matches the key in the
* map value. Each concept entry is then validated individually.
*
* @param >> {
@Serial
private static final long serialVersionUID = -324211738823208318L;
private static final String VALUE_FIELD = "value";
private static final Pattern KEY_ID_PATTERN = Pattern.compile(PfKey.KEY_ID_REGEXP);
@EmbeddedId
@VerifyKey
@NotNull
private PfConceptKey key;
@ManyToMany(cascade = CascadeType.ALL)
// @formatter:off
@JoinTable(
joinColumns = {
@JoinColumn(name = "conceptContainerMapName", referencedColumnName = "name"),
@JoinColumn(name = "concpetContainerMapVersion", referencedColumnName = "version")
},
inverseJoinColumns = {
@JoinColumn(name = "conceptContainerName", referencedColumnName = "name"),
@JoinColumn(name = "conceptContainerVersion", referencedColumnName = "version")
}
)
// @formatter:on
private Map