X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-tosca%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Ftosca%2Fsimple%2Fconcepts%2FJpaToscaServiceTemplate.java;h=d4e51840ba79df00fbc2d52e94d15454d7edc50a;hb=6345dce40405740dc09176c45dae03baeb939b8e;hp=aa4f231c0772382e0191152f5a316e8258a3870e;hpb=ad1cd2013f45da5764fc9610db1f679d3c3762cb;p=policy%2Fmodels.git diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java index aa4f231c0..d4e51840b 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. 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. @@ -22,13 +22,11 @@ package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; - import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -39,22 +37,20 @@ import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.OneToOne; import javax.persistence.Table; - import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; - import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; -import org.onap.policy.models.base.PfValidationMessage; -import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.base.PfValidationResult.ValidationResult; +import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** @@ -73,7 +69,7 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType { private static final long serialVersionUID = 8084846046148349401L; - public static final String DEFAULT_TOSCA_DEFINTIONS_VERISON = "tosca_simple_yaml_1_0_0"; + public static final String DEFAULT_TOSCA_DEFINTIONS_VERISON = "tosca_simple_yaml_1_1_0"; public static final String DEFAULT_NAME = "ToscaServiceTemplateSimple"; public static final String DEFAULT_VERSION = "1.0.0"; @@ -92,6 +88,36 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType()); + List> capabilityTypeMapList = capabilityTypes.toAuthorative(); + for (Map capabilityTypeMap : capabilityTypeMapList) { + toscaServiceTemplate.getCapabilityTypes().putAll(capabilityTypeMap); + } + } + + if (relationshipTypes != null) { + toscaServiceTemplate.setRelationshipTypes(new LinkedHashMap<>()); + List> relationshipTypeMapList = relationshipTypes.toAuthorative(); + for (Map relationshipTypeMap : relationshipTypeMapList) { + toscaServiceTemplate.getRelationshipTypes().putAll(relationshipTypeMap); + } + } + + if (nodeTypes != null) { + toscaServiceTemplate.setNodeTypes(new LinkedHashMap<>()); + List> nodeTypeMapList = nodeTypes.toAuthorative(); + for (Map nodeTypeMap : nodeTypeMapList) { + toscaServiceTemplate.getNodeTypes().putAll(nodeTypeMap); + } + } + if (policyTypes != null) { toscaServiceTemplate.setPolicyTypes(new LinkedHashMap<>()); List> policyTypeMapList = policyTypes.toAuthorative(); @@ -217,6 +273,21 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType dataTypeKeyCollection, final PfValidationResult result) { + private void validateReferencedDataTypesExists( + final Collection dataTypeKeyCollection, final BeanValidationResult result) { for (PfConceptKey dataTypeKey : dataTypeKeyCollection) { if (dataTypes == null || dataTypes.get(dataTypeKey) == null) { - result.addValidationMessage(new PfValidationMessage(referencingEntityKey, this.getClass(), - ValidationResult.INVALID, "referenced data type " + dataTypeKey.getId() + " not found")); + addResult(result, "data type", dataTypeKey.getId(), NOT_FOUND); } } } @@ -386,30 +486,24 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType