diff options
author | liamfallon <liam.fallon@est.tech> | 2021-01-04 12:15:18 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2021-01-06 14:20:06 +0000 |
commit | f2b0318f53abf9f2345a5cdca74f3dd635aa9b60 (patch) | |
tree | 0a5d64add719e43596f95b9415db04257c037988 /models-tosca/src/main | |
parent | 8ad3f95cdcec48b8315a5febfd4ec07bae7aabba (diff) |
Changed identifiers to concept identifiers
The policy models tosca classes ToscaPolicyIdentifier and
ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA
concept, not just TOSCA policies so they are renamed to
ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion
respectively.
The class ToscaPolicyTypeIdentifier is redundant and is replaced by
ToscaConceptIdentifier.
Issue-ID: POLICY-2900
Change-Id: Id0a37c42ea4e74f07b47e1694c4f8291c35879c9
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java) | 17 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java) | 21 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java | 10 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java | 92 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java | 10 |
5 files changed, 25 insertions, 125 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java index ba1042851..36e460e83 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.java @@ -1,9 +1,9 @@ -/* +/*- * ============LICENSE_START======================================================= * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,11 +29,11 @@ import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ValidationResult; /** - * Identifies a policy. Both the name and version must be non-null. + * Identifies a concept. Both the name and version must be non-null. */ @Data @NoArgsConstructor -public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier> { +public class ToscaConceptIdentifier implements Comparable<ToscaConceptIdentifier> { @NonNull private String name; @@ -42,19 +42,18 @@ public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier> private String version; - public ToscaPolicyIdentifier(@NonNull String name, @NonNull String version) { + public ToscaConceptIdentifier(@NonNull String name, @NonNull String version) { this.name = name; this.version = version; } - public ToscaPolicyIdentifier(ToscaPolicyIdentifier source) { + public ToscaConceptIdentifier(ToscaConceptIdentifier source) { this.name = source.name; this.version = source.version; } /** - * Validates that appropriate fields are populated for an incoming call to the PAP - * REST API. + * Validates that appropriate fields are populated for an incoming call to the PAP REST API. * * @return the validation result */ @@ -68,7 +67,7 @@ public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier> } @Override - public int compareTo(ToscaPolicyIdentifier other) { + public int compareTo(ToscaConceptIdentifier other) { if (this == other) { return 0; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java index 29bff911f..c23c04fe8 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifierOptVersion.java @@ -3,7 +3,7 @@ * ONAP Policy Models * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,47 +21,40 @@ package org.onap.policy.models.tosca.authorative.concepts; -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; /** - * Policy identifier with an optional version; only the "name" is required. + * Concept identifier with an optional version; only the "name" is required. */ @Data @NoArgsConstructor -public class ToscaPolicyIdentifierOptVersion implements Comparable<ToscaPolicyIdentifierOptVersion> { +public class ToscaConceptIdentifierOptVersion implements Comparable<ToscaConceptIdentifierOptVersion> { @NonNull - @ApiModelProperty(name = "policy-id") - @SerializedName("policy-id") private String name; - @ApiModelProperty(name = "policy-version") - @SerializedName("policy-version") private String version; - - public ToscaPolicyIdentifierOptVersion(@NonNull String name, String version) { + public ToscaConceptIdentifierOptVersion(@NonNull String name, String version) { this.name = name; this.version = version; } - public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifierOptVersion source) { + public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifierOptVersion source) { this.name = source.name; this.version = source.version; } - public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifier source) { + public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifier source) { this.name = source.getName(); this.version = source.getVersion(); } @Override - public int compareTo(ToscaPolicyIdentifierOptVersion other) { + public int compareTo(ToscaConceptIdentifierOptVersion other) { if (this == other) { return 0; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java index c98a844e5..491b478a4 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,8 +76,8 @@ public class ToscaPolicy extends ToscaEntity { * * @return this policy's identifier */ - public ToscaPolicyIdentifier getIdentifier() { - return new ToscaPolicyIdentifier(getName(), getVersion()); + public ToscaConceptIdentifier getIdentifier() { + return new ToscaConceptIdentifier(getName(), getVersion()); } /** @@ -85,7 +85,7 @@ public class ToscaPolicy extends ToscaEntity { * * @return this policy's type identifier */ - public ToscaPolicyTypeIdentifier getTypeIdentifier() { - return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion()); + public ToscaConceptIdentifier getTypeIdentifier() { + return new ToscaConceptIdentifier(getType(), getTypeVersion()); } } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java deleted file mode 100644 index 32dd7cbd7..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP Policy Models - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.authorative.concepts; - -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ValidationResult; - -/** - * Identifies a policy type. Both the name and version must be non-null. - */ -@Data -@NoArgsConstructor -public class ToscaPolicyTypeIdentifier implements Comparable<ToscaPolicyTypeIdentifier> { - - @NonNull - private String name; - - @NonNull - private String version; - - - public ToscaPolicyTypeIdentifier(@NonNull String name, @NonNull String version) { - this.name = name; - this.version = version; - } - - public ToscaPolicyTypeIdentifier(ToscaPolicyTypeIdentifier source) { - this.name = source.name; - this.version = source.version; - } - - /** - * Validates that appropriate fields are populated for an incoming call to the PAP - * REST API. - * - * @return the validation result - */ - public ValidationResult validatePapRest() { - BeanValidationResult result = new BeanValidationResult("group", this); - - result.validateNotNull("name", name); - result.validateNotNull("version", version); - - return result; - } - - @Override - public int compareTo(ToscaPolicyTypeIdentifier other) { - if (this == other) { - return 0; - } - - if (other == null) { - return 1; - } - - int result = ObjectUtils.compare(getName(), other.getName()); - if (result != 0) { - return result; - } - - return ObjectUtils.compare(getVersion(), other.getVersion()); - } - - @Override - public String toString() { - return this.name + " " + this.version; - } -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java index c0a5cdf75..594a5c348 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -269,11 +269,11 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp public void fromAuthorative(ToscaServiceTemplate toscaServiceTemplate) { super.fromAuthorative(toscaServiceTemplate); - if (PfKey.NULL_KEY_NAME.equals(getKey().getName())) { + if (toscaServiceTemplate.getDefinedName() == null) { getKey().setName(DEFAULT_NAME); } - if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) { + if (toscaServiceTemplate.getDefinedVersion() == null) { getKey().setVersion(DEFAULT_VERSION); } @@ -476,8 +476,8 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp * @param dataTypeKeyCollection the data type key collection * @param result where the results are added */ - private void validateReferencedDataTypesExists( - final Collection<PfConceptKey> dataTypeKeyCollection, final BeanValidationResult result) { + private void validateReferencedDataTypesExists(final Collection<PfConceptKey> dataTypeKeyCollection, + final BeanValidationResult result) { for (PfConceptKey dataTypeKey : dataTypeKeyCollection) { if (dataTypes == null || dataTypes.get(dataTypeKey) == null) { addResult(result, "data type", dataTypeKey.getId(), NOT_FOUND); |