summaryrefslogtreecommitdiffstats
path: root/models-base/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-12-17 12:10:21 +0000
committerliamfallon <liam.fallon@est.tech>2020-12-23 11:11:05 +0000
commitb87e0242ce1a957740ee988bec3b82e3628adbed (patch)
tree0d75dce2189f7daf719293620a01af7afc83bc15 /models-base/src/main
parent12fce55a66848bcc7f71430324b3a9051b8ce0d4 (diff)
Add Service Template TOSCA handling
Today we can only handle a single service template in the database. We should be able to handle multiple service templates and assign arbitrary policy types and policies to maned and versioned service templates. This review brings in the Java API in models provider for handling service templates in this way and uses a simplistic single-teplate implementation in models-tosca, that will work but still only handles a single service template under the hood. Issue-ID: POLICY-2900 Change-Id: Ia02dea8abe44b7f407e685090a4b8e0360889653 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-base/src/main')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java4
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java18
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java15
3 files changed, 26 insertions, 11 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 4c2cf0c4f..d2015eb7e 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
@@ -198,9 +198,9 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex
}
incomingConceptEntry.getValue().setName(findConceptField(conceptKey, conceptKey.getName(),
- incomingConceptEntry.getValue(), PfNameVersion::getName));
+ incomingConceptEntry.getValue(), PfNameVersion::getDefinedName));
incomingConceptEntry.getValue().setVersion(findConceptField(conceptKey, conceptKey.getVersion(),
- incomingConceptEntry.getValue(), PfNameVersion::getVersion));
+ incomingConceptEntry.getValue(), PfNameVersion::getDefinedVersion));
C jpaConcept = getConceptNewInstance();
// This cast allows us to call the fromAuthorative method
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java b/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java
index f9fde53e5..4e4177004 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java
@@ -38,6 +38,24 @@ public interface PfNameVersion {
public void setVersion(final String version);
/**
+ * Get the defined name for a concept, return null if no name is defined.
+ *
+ * @return the defined name
+ */
+ public default String getDefinedName() {
+ return getName();
+ }
+
+ /**
+ * Get the defined version for a concept, return null if no version is defined.
+ *
+ * @return the defined version
+ */
+ public default String getDefinedVersion() {
+ return getVersion();
+ }
+
+ /**
* Compare two name version implementation objects.
*
* @param left the left name/version implementation
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
index f7e29f1b4..342fbab73 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java
@@ -56,8 +56,7 @@ public interface PfObjectFilter<T> {
}
/**
- * Gets a predicate used to filter an item in a list by exactly matching an extracted value
- * with some text.
+ * Gets a predicate used to filter an item in a list by exactly matching an extracted value with some text.
*
* @param text the desired text to check against, or {@code null} if to accept everything
* @param extractor function to extract the value, to be matched, from a list item
@@ -73,11 +72,9 @@ public interface PfObjectFilter<T> {
}
/**
- * Gets a predicate used to filter an item in a list by comparing the start of an
- * extracted value with a prefix.
+ * Gets a predicate used to filter an item in a list by comparing the start of an extracted value with a prefix.
*
- * @param prefix the desired prefix to check against, or {@code null} if to accept
- * everything
+ * @param prefix the desired prefix to check against, or {@code null} if to accept everything
* @param extractor function to extract the value, to be matched, from a list item
* @return a predicate to match a prefix with a value from a list item
*/
@@ -94,8 +91,7 @@ public interface PfObjectFilter<T> {
}
/**
- * Gets a predicate used to filter an item in a list by matching an extracted value
- * with a regular expression.
+ * Gets a predicate used to filter an item in a list by matching an extracted value with a regular expression.
*
* @param pattern regular expression to match, or {@code null} if to accept everything
* @param extractor function to extract the value, to be matched, from a list item
@@ -140,7 +136,8 @@ public interface PfObjectFilter<T> {
* The list is sorted so if the last element name is the same as the current element name, the current
* element should be removed.
*/
- if (!((PfNameVersion) curElement).getName().equals(((PfNameVersion) lastElement).getName())) {
+ if (PfUtils.compareObjects(((PfNameVersion) curElement).getName(),
+ ((PfNameVersion) lastElement).getName()) != 0) {
// have a new name - done comparing with the old "current"
++icur;
}