/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 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.
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfKey;
import org.onap.policy.models.base.PfReferenceKey;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
+import org.onap.policy.models.base.validation.annotations.VerifyKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaParameter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
public static final String DEFAULT_LOCAL_NAME = "ToscaTopologyTemplateSimple";
@EmbeddedId
+ @VerifyKey
+ @NotNull
private PfReferenceKey key;
@Column(name = "description")
+ @NotBlank
private String description;
// @formatter:off
@ElementCollection
@Lob
- private Map<String, JpaToscaParameter> inputs;
+ private Map<@NotNull String, @NotNull @Valid JpaToscaParameter> inputs;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumns(
- {
- @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name"),
- @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
- }
- )
+ @JoinColumns({
+ @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name"),
+ @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
+ })
@SerializedName("data_types")
+ @Valid
private JpaToscaNodeTemplates nodeTemplates;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumns(
- {
- @JoinColumn(name = "policyName", referencedColumnName = "name"),
- @JoinColumn(name = "policyVersion", referencedColumnName = "version")
- }
- )
+ @JoinColumns({
+ @JoinColumn(name = "policyName", referencedColumnName = "name"),
+ @JoinColumn(name = "policyVersion", referencedColumnName = "version")
+
+ })
// @formatter:on
+ @Valid
private JpaToscaPolicies policies;
/**
@Override
public ToscaTopologyTemplate toAuthorative() {
- final ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ final var toscaTopologyTemplate = new ToscaTopologyTemplate();
toscaTopologyTemplate.setDescription(description);
if (toscaTopologyTemplate.getInputs() != null) {
inputs = new LinkedHashMap<>();
for (Map.Entry<String, ToscaParameter> toscaInputEntry : toscaTopologyTemplate.getInputs().entrySet()) {
- JpaToscaParameter jpaInput = new JpaToscaParameter(toscaInputEntry.getValue());
+ var jpaInput = new JpaToscaParameter(toscaInputEntry.getValue());
jpaInput.setKey(new PfReferenceKey(getKey(), toscaInputEntry.getKey()));
inputs.put(toscaInputEntry.getKey(), jpaInput);
}
}
}
- @Override
- public BeanValidationResult validate(@NonNull String fieldName) {
- BeanValidationResult result = new BeanValidationResult(fieldName, this);
-
- result.addResult(validateKeyNotNull("key", key));
- result.addResult(validateNotBlank("description", description, false));
-
- validateMap(result, "inputs", inputs, Validated::validateEntryValueNotNull);
-
- validateOptional(result, "nodeTemplates", nodeTemplates);
- validateOptional(result, "policies", policies);
-
- return result;
- }
-
@Override
public int compareTo(final PfConcept otherConcept) {
int result = compareToWithoutEntities(otherConcept);