/*-
* ============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.
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
@Override
public ToscaParameter toAuthorative() {
- ToscaParameter toscaParameter = new ToscaParameter();
+ var toscaParameter = new ToscaParameter();
toscaParameter.setName(key.getLocalName());
}
}
- @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) {