+ /**
+ * Validate that the referenced data types exist for a collection of data type keys.
+ *
+ * @param dataTypeKeyCollection the data type key collection
+ * @param result where the results are added
+ */
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Validate that all policy types referenced in policies exist.
+ *
+ * @param result where the results are added
+ */
+ private void validatePolicyTypesInPolicies(BeanValidationResult result) {
+ if (topologyTemplate == null || topologyTemplate.getPolicies() == null
+ || topologyTemplate.getPolicies().getConceptMap().isEmpty()) {
+ return;
+ }
+
+ if (policyTypes == null || policyTypes.getConceptMap().isEmpty()) {
+ addResult(result, "policyTypes", policyTypes,
+ "no policy types are defined on the service template for the policies in the topology template");
+ return;
+ }
+
+ for (JpaToscaPolicy policy : topologyTemplate.getPolicies().getAll(null)) {
+ if (policyTypes.get(policy.getType()) == null) {
+ addResult(result, "policy type", policy.getType().getId(), NOT_FOUND);
+ }
+ }