use of org.alien4cloud.tosca.model.definitions.ScalarPropertyValue in project alien4cloud by alien4cloud.
the class DanglingRequirementService method setPropertiesFromFilter.
// TODO This is a workaround as right now matching does not use filter but properties.
private void setPropertiesFromFilter(NodeTemplate danglingTemplate, NodeType danglingNodeType) {
if (danglingTemplate.getNodeFilter() == null) {
return;
}
for (Entry<String, List<PropertyConstraint>> constraintEntry : safe(danglingTemplate.getNodeFilter().getProperties()).entrySet()) {
if (constraintEntry.getValue().size() == 1 && constraintEntry.getValue().get(0) instanceof EqualConstraint && ToscaTypes.isSimple(danglingNodeType.getProperties().get(constraintEntry.getKey()).getType())) {
danglingTemplate.getProperties().put(constraintEntry.getKey(), new ScalarPropertyValue(((EqualConstraint) constraintEntry.getValue().get(0)).getEqual()));
}
}
for (Entry<String, FilterDefinition> capabilityFilter : safe(danglingTemplate.getNodeFilter().getCapabilities()).entrySet()) {
Capability capability = getCapability(danglingTemplate, capabilityFilter.getKey());
CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, capability.getType());
for (Entry<String, List<PropertyConstraint>> constraintEntry : safe(capabilityFilter.getValue().getProperties()).entrySet()) {
if (constraintEntry.getValue().size() == 1 && constraintEntry.getValue().get(0) instanceof EqualConstraint && ToscaTypes.isSimple(capabilityType.getProperties().get(constraintEntry.getKey()).getType())) {
capability.getProperties().put(constraintEntry.getKey(), new ScalarPropertyValue(((EqualConstraint) constraintEntry.getValue().get(0)).getEqual()));
}
}
}
}
use of org.alien4cloud.tosca.model.definitions.ScalarPropertyValue in project yorc-a4c-plugin by ystia.
the class MappingTosca method quoteProperties.
public static void quoteProperties(final PaaSTopologyDeploymentContext ctx) {
PaaSTopology ptopo = ctx.getPaaSTopology();
for (PaaSNodeTemplate node : ptopo.getAllNodes().values()) {
NodeTemplate nt = node.getTemplate();
Map<String, AbstractPropertyValue> ntProperties = nt.getProperties();
for (String prop : ntProperties.keySet()) {
AbstractPropertyValue absval = ntProperties.get(prop);
if (absval instanceof ScalarPropertyValue) {
ScalarPropertyValue scaval = (ScalarPropertyValue) absval;
if (scaval.getValue().contains("\"")) {
scaval.setValue(scaval.getValue().replace("\"", "\\\""));
}
log.debug("Property: " + prop + "=" + ((ScalarPropertyValue) nt.getProperties().get(prop)).getValue());
}
}
}
}
Aggregations