Implement validation and hierarchical get
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / utils / ToscaUtils.java
index 3906922..cc04319 100644 (file)
@@ -52,14 +52,18 @@ public final class ToscaUtils {
 
     // @formatter:off
     private static final Set<PfConceptKey> PREDEFINED_TOSCA_DATA_TYPES = Set.of(
-            new PfConceptKey("string",    PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("integer",   PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("float",     PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("boolean",   PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("timestamp", PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("null",      PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("list",      PfKey.NULL_KEY_VERSION),
-            new PfConceptKey("map",       PfKey.NULL_KEY_VERSION)
+            new PfConceptKey("string",                       PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("integer",                      PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("float",                        PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("boolean",                      PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("timestamp",                    PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("null",                         PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("list",                         PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("map",                          PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("scalar-unit.size",             PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("scalar-unit.time",             PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("scalar-unit.frequency",        PfKey.NULL_KEY_VERSION),
+            new PfConceptKey("tosca.datatypes.TimeInterval", PfKey.NULL_KEY_VERSION)
         );
     // @formatter:on
 
@@ -242,17 +246,18 @@ public final class ToscaUtils {
      * Get the entity tree from a concept container for a given entity key.
      *
      * @param entityTypes the concept container containing entity types
-     * @param searchKey the key to search for
+     * @param entityName the name of the entity
+     * @param entityVersion the version of the entity
      */
     public static void getEntityTree(
             @NonNull final PfConceptContainer<? extends PfConcept, ? extends PfNameVersion> entityTypes,
-            @NonNull final PfConceptKey searchKey) {
+            final String entityName, final String entityVersion) {
 
         PfValidationResult result = new PfValidationResult();
 
         @SuppressWarnings("unchecked")
         Set<JpaToscaEntityType<?>> filteredEntitySet =
-                (Set<JpaToscaEntityType<?>>) entityTypes.getAll(searchKey.getName(), searchKey.getVersion());
+                (Set<JpaToscaEntityType<?>>) entityTypes.getAll(entityName, entityVersion);
         for (JpaToscaEntityType<?> filteredEntityType : filteredEntitySet) {
             filteredEntitySet.addAll(ToscaUtils.getEntityTypeAncestors(entityTypes, filteredEntityType, result));
         }