Fix issues in existing entity classes
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / simple / concepts / JpaToscaParameter.java
index 216e877..552d9c1 100644 (file)
@@ -1,6 +1,8 @@
 /*-
  * ============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.
@@ -23,40 +25,36 @@ 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;
 import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.common.parameters.annotations.NotNull;
 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;
 import org.onap.policy.models.base.PfKey;
 import org.onap.policy.models.base.PfReferenceKey;
-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.base.validation.annotations.VerifyKey;
 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<ToscaParameter> {
     private static final long serialVersionUID = 1675770231921107988L;
 
     @EmbeddedId
+    @VerifyKey
+    @NotNull
     private PfReferenceKey key;
 
     @Column
+    @VerifyKey
+    @NotNull
     private PfConceptKey type;
 
     @Column
@@ -112,7 +110,7 @@ public class JpaToscaParameter extends PfConcept implements PfAuthorative<ToscaP
 
     @Override
     public ToscaParameter toAuthorative() {
-        ToscaParameter toscaParameter = new ToscaParameter();
+        var toscaParameter = new ToscaParameter();
 
         toscaParameter.setName(key.getLocalName());
 
@@ -160,25 +158,6 @@ public class JpaToscaParameter extends PfConcept implements PfAuthorative<ToscaP
         }
     }
 
-    @Override
-    public PfValidationResult validate(final PfValidationResult resultIn) {
-        PfValidationResult result = resultIn;
-
-        if (key.isNullKey()) {
-            result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
-                    "paremeter key is a null key"));
-        }
-
-        result = key.validate(result);
-
-        if (type == null || type.isNullKey()) {
-            result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
-                    "parameter type may not be null"));
-        }
-
-        return result;
-    }
-
     @Override
     public int compareTo(final PfConcept otherConcept) {
         if (otherConcept == null) {