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%2FJpaToscaProperty.java;h=48ee9d4a2f182c2ba20d1ef75ea496b075bc5556;hb=ec488290e3aa12cc7fcdf44cc7744bceae89af7f;hp=e2b6e6f937417d7ca6974e0d91843bc44934eb6d;hpb=69bc7db0edc751d3936b92c4bdf1ee74dfa4da57;p=policy%2Fmodels.git diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java index e2b6e6f93..48ee9d4a2 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,10 @@ package org.onap.policy.models.tosca.simple.concepts; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; - +import java.util.Map; +import java.util.Map.Entry; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.EmbeddedId; @@ -33,13 +35,11 @@ import javax.persistence.Entity; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; 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.Assertions; +import org.onap.policy.common.utils.coder.YamlJsonTranslator; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; @@ -86,11 +86,14 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative constraints; + private List constraints = new ArrayList<>(); @Column private JpaToscaEntrySchema entrySchema; + @ElementCollection + private Map metadata = new LinkedHashMap<>(); + /** * The Default Constructor creates a {@link JpaToscaProperty} object with a null key. */ @@ -110,7 +113,7 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative(copyConcept.constraints) : null); + this.entrySchema = (copyConcept.entrySchema != null ? new JpaToscaEntrySchema(copyConcept.entrySchema) : null); + this.metadata = (copyConcept.metadata != null ? new LinkedHashMap<>(copyConcept.metadata) : null); } /** @@ -147,9 +160,12 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative toscaConstraints = new ArrayList<>(); @@ -164,6 +180,10 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative(metadata)); + } + return toscaProperty; } @@ -180,9 +200,14 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative(); @@ -194,6 +219,12 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative(toscaProperty.getMetadata()); + } + } @Override @@ -226,6 +257,12 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative metadataEntry : metadata.entrySet()) { + metadataEntry.setValue(metadataEntry.getValue().trim()); + } + } } @Override @@ -234,14 +271,14 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative newConstraints = new ArrayList<>(); - for (final JpaToscaConstraint constraint : constraints) { - newConstraints.add(constraint); // Constraints are immutable - } - copy.setConstraints(newConstraints); - } - - copy.setEntrySchema(entrySchema != null ? new JpaToscaEntrySchema(entrySchema) : null); - - return copy; - } }