/** * Set value for a capability property * * @param capability the capability * @param propertyDefinition the definition of the property * @param propertyName the name of the property * @param propertyValue the value of the property */ public void setCapabilityPropertyValue(Capability capability, PropertyDefinition propertyDefinition, String propertyName, Object propertyValue) throws ConstraintValueDoNotMatchPropertyTypeException, ConstraintViolationException { if (capability.getProperties() == null) { capability.setProperties(Maps.newLinkedHashMap()); } setPropertyValue(capability.getProperties(), propertyDefinition, propertyName, propertyValue); }
@Override protected boolean doMergeNode(Topology topology, FlowExecutionContext context, String nodeTemplateId, NodePropsOverride nodePropsOverride) { final ConfigChanged configChanged = new ConfigChanged(); // play the super method first. This will process nodetemplate properties configChanged.changed = super.doMergeNode(topology, context, nodeTemplateId, nodePropsOverride); // Then process capabilities NodeTemplate nodeTemplate = topology.getNodeTemplates().get(nodeTemplateId); Iterator<Entry<String, NodeCapabilitiesPropsOverride>> capabilitiesOverrideIter = safe(nodePropsOverride.getCapabilities()).entrySet().iterator(); while (capabilitiesOverrideIter.hasNext()) { Entry<String, NodeCapabilitiesPropsOverride> overrideCapabilityProperties = capabilitiesOverrideIter.next(); Capability capability = safe(nodeTemplate.getCapabilities()).get(overrideCapabilityProperties.getKey()); if (capability == null) { // Manage clean logic configChanged.changed = true; capabilitiesOverrideIter.remove(); } else { // Merge logic // When a selected node has changed we may need to cleanup properties that where defined but are not anymore on the capability CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capability.getType()); capability.setProperties(mergeProperties(overrideCapabilityProperties.getValue().getProperties(), capability.getProperties(), capabilityType.getProperties(), s -> { configChanged.changed = true; context.log() .info("The property [" + s + "] previously specified to configure capability [" + overrideCapabilityProperties.getKey() + "] of node [" + nodeTemplateId + "] cannot be set anymore as it is already specified by the matched location resource or in the topology."); })); } } return configChanged.changed; }
locationCapability.setProperties( CollectionUtils.merge(abstractCapability.getProperties(), locationCapability.getProperties(), true, topologyNotMergedProps)); } else { locationCapability.setProperties(abstractCapability.getProperties());
toAddCapa = new Capability(); toAddCapa.setType(capa.getType()); toAddCapa.setProperties(capaProperties); } else { if (StringUtils.isBlank(toAddCapa.getType())) { Map<String, AbstractPropertyValue> nodeCapaProperties = safe(toAddCapa.getProperties()); capaProperties.putAll(nodeCapaProperties); toAddCapa.setProperties(capaProperties); toAddCapa.setProperties(properties); map.put(capa.getId(), toAddCapa);