From 7a718bd9b82ac16e5d49a1a2fb2256682f020656 Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Thu, 6 Jan 2022 14:52:15 +0000 Subject: Fix issues in existing entity classes Issues identified in the entity classes are fixed in this review. Some fixes doesn't affect the table structure at all. Tables actually affected by some of these fixes are not really used today, and doesn't contain any data. A separate review is raised for the db-migrator changes. Change-Id: I0efdf2c5f17e12225f1b443b5fe8e27c578229f7 Issue-ID: POLICY-3871 Signed-off-by: a.sreekumar --- .../src/main/java/org/onap/policy/models/base/PfModel.java | 10 +++------- .../java/org/onap/policy/simulators/DmaapSimulatorTest.java | 3 +++ .../policy/models/pdp/persistence/concepts/JpaPdpGroup.java | 7 +++---- .../policy/models/tosca/simple/concepts/JpaToscaModel.java | 4 ++++ .../policy/models/tosca/simple/concepts/JpaToscaParameter.java | 8 +------- .../policy/models/tosca/simple/concepts/JpaToscaPolicy.java | 7 +++++++ .../models/tosca/simple/concepts/JpaToscaPolicyType.java | 9 +++++++++ .../policy/models/tosca/simple/concepts/JpaToscaProperty.java | 8 +------- .../policy/models/tosca/simple/concepts/JpaToscaTrigger.java | 8 +------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java index b7f074a5e..e7b79cadf 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 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. @@ -25,10 +26,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; +import javax.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -53,9 +51,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; * @param the type of concept on which the interface is applied. */ -@Entity -@Table(name = "PfModel") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@MappedSuperclass @Data @EqualsAndHashCode(callSuper = false) public abstract class PfModel extends PfConcept { diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java index fab041f8b..19c399db8 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/DmaapSimulatorTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019, 2022 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. @@ -18,6 +19,7 @@ package org.onap.policy.simulators; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -85,6 +87,7 @@ public class DmaapSimulatorTest { .register((infra, topic, event) -> queue.add(event)); DmaapTopicSink sink = TopicEndpointManager.getManager().getDmaapTopicSink(TOPIC); + assertThat(queue.poll(1, TimeUnit.SECONDS)).isNull(); sink.send("hello"); assertEquals("hello", queue.poll(MAX_WAIT_SEC, TimeUnit.SECONDS)); diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java index 2856bfb39..07f9261bb 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019,2021 Nordix Foundation. + * 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. @@ -90,10 +91,8 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative { // @formatter:off @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @CollectionTable(joinColumns = { - @JoinColumn(name = "pdpGroupParentKeyName", referencedColumnName = "parentKeyName"), - @JoinColumn(name = "pdpGroupParentKeyVersion", referencedColumnName = "parentKeyVersion"), - @JoinColumn(name = "pdpGroupParentLocalName", referencedColumnName = "parentLocalName"), - @JoinColumn(name = "pdpGroupLocalName", referencedColumnName = "localName") + @JoinColumn(name = "name", referencedColumnName = "name"), + @JoinColumn(name = "version", referencedColumnName = "version") }) // @formatter:on @NotNull diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java index cd6656b4c..09c406ea6 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019-2020 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. @@ -27,6 +28,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; import lombok.Data; @@ -55,6 +57,8 @@ public class JpaToscaModel extends PfModel { private static final long serialVersionUID = 8800599637708309945L; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "serviceTemplatesName", referencedColumnName = "name") + @JoinColumn(name = "serviceTemplatesVersion", referencedColumnName = "version") @Valid private JpaToscaServiceTemplates serviceTemplates; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java index 9b023dcba..552d9c15c 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2020 Nordix Foundation. * Modifications Copyright (C) 2020-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. @@ -24,10 +25,6 @@ package org.onap.policy.models.tosca.simple.concepts; import java.util.List; import javax.persistence.Column; import javax.persistence.EmbeddedId; -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; @@ -45,9 +42,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaParameter; /** * Class to represent the parameter in TOSCA definition. */ -@Entity -@Table(name = "ToscaParameter") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaParameter extends PfConcept implements PfAuthorative { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java index 76861d294..feae48e1a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2021 Nordix Foundation. + * 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. @@ -25,10 +26,12 @@ package org.onap.policy.models.tosca.simple.concepts; import java.util.LinkedHashMap; import java.util.List; +import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; import javax.persistence.Table; import javax.ws.rs.core.Response; import lombok.Data; @@ -67,6 +70,10 @@ public class JpaToscaPolicy extends JpaToscaWithTypeAndStringProperties targets; /** diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java index f6c1a7c4e..dfdf7ed9b 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * 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. @@ -24,10 +25,13 @@ package org.onap.policy.models.tosca.simple.concepts; import java.util.List; +import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -59,9 +63,14 @@ public class JpaToscaPolicyType extends JpaToscaWithToscaProperties targets; @ElementCollection + @Lob private List<@NotNull @Valid JpaToscaTrigger> triggers; /** 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 f49c0ea81..73b9faba8 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 @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2021 Nordix Foundation. + * 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. @@ -30,10 +31,6 @@ import java.util.Map; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.EmbeddedId; -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; @@ -58,9 +55,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty.Status; * @author Chenfei Gao (cgao@research.att.com) * @author Liam Fallon (liam.fallon@est.tech) */ -@Entity -@Table(name = "ToscaProperty") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaProperty extends PfConcept implements PfAuthorative { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java index 546ea073f..1e13b225c 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2021 Nordix Foundation. + * 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. @@ -28,10 +29,6 @@ import java.time.Duration; import java.util.List; import javax.persistence.Column; import javax.persistence.EmbeddedId; -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; @@ -51,9 +48,6 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; * @author Chenfei Gao (cgao@research.att.com) * @author Liam Fallon (liam.fallon@est.tech) */ -@Entity -@Table(name = "ToscaTrigger") -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaTrigger extends PfConcept { -- cgit 1.2.3-korg