aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src/main/java/org
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-03-18 11:47:20 +0000
committerliamfallon <liam.fallon@est.tech>2020-03-18 11:47:23 +0000
commitf98830a4ba01188538ca0b001143f7b573ecde77 (patch)
treee1b2239a4963a55185ae4168d5df187fe4c0d2f5 /models-base/src/main/java/org
parentf116f388adff2971f802035ca96415032b5fc5fd (diff)
Return latest entity on null versions
This review amends the behaviour of "get" operations on entities to always return the latest version of an entity when the version of the search key is the null key (value of 0.0.0). Issue-ID: POLICY-2377 Change-Id: I4f7c12637c90bc1a83ce2ba5ef40e15b461a7d51 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-base/src/main/java/org')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java6
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java2
2 files changed, 6 insertions, 2 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
index 1c1e4613e..b4d51d173 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
@@ -300,7 +300,11 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
@Override
public C get(final PfConceptKey conceptKey) {
- return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKey);
+ if (conceptKey.isNullVersion()) {
+ return get(conceptKey.getName());
+ } else {
+ return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKey);
+ }
}
@Override
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
index c641a8035..033a7ddb2 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
@@ -55,7 +55,7 @@ public class PfConceptGetterImpl<C> implements PfConceptGetter<C> {
Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
// The very fist key that could have this name
- final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, "0.0.1");
+ final PfConceptKey lowestArtifactKey = new PfConceptKey(conceptKeyName, PfKey.NULL_KEY_VERSION);
// Check if we found a key for our name
PfConceptKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);