- /**
- * For generating target type, we scan for matchable properties
- * and use those to build the policy.
- *
- * @param properties Properties section of policy
- * @param policyTypes Collection of policy Type to find matchable metadata
- * @return {@code Pair<TargetType, Integer>} Returns a TargetType and a Total Weight of matchables.
- */
- protected Pair<TargetType, Integer> generateTargetType(Map<String, Object> properties,
- Collection<ToscaPolicyType> policyTypes) {
- TargetType targetType = new TargetType();
- //
- // Iterate the properties
- //
- int totalWeight = findMatchableFromMap(properties, policyTypes, targetType);
- LOGGER.info("Total weight is {}", totalWeight);
- return Pair.of(targetType, totalWeight);
- }
-
- @SuppressWarnings("unchecked")
- protected int findMatchableFromList(List<Object> listProperties, Collection<ToscaPolicyType> policyTypes,
- TargetType targetType) {
- LOGGER.info("findMatchableFromList {}", listProperties);
- int totalWeight = 0;
- for (Object property : listProperties) {
- if (property instanceof List) {
- totalWeight += findMatchableFromList((List<Object>) property, policyTypes, targetType);
- } else if (property instanceof Map) {
- totalWeight += findMatchableFromMap((Map<String, Object>) property, policyTypes, targetType);
- }
+ @Override
+ public ToscaPolicyType retrievePolicyType(String derivedFrom) {
+ ToscaServiceTemplate template = this.findPolicyType(new ToscaPolicyTypeIdentifier(derivedFrom, "1.0.0"));
+ if (template == null) {
+ LOGGER.error("Could not retrieve Policy Type {}", derivedFrom);
+ return null;