Search in sources :

Example 16 with SubstitutionTarget

use of org.alien4cloud.tosca.model.templates.SubstitutionTarget in project alien4cloud by alien4cloud.

the class SustitutionMappingParser method parseSubstitutionTargets.

private Map<String, SubstitutionTarget> parseSubstitutionTargets(Node valueNode, ParsingContextExecution context) {
    if (!(valueNode instanceof MappingNode)) {
        // we expect a MappingNode
        context.getParsingErrors().add(new ParsingError(ErrorCode.YAML_MAPPING_NODE_EXPECTED, null, valueNode.getStartMark(), null, valueNode.getEndMark(), null));
        return null;
    }
    Map<String, SubstitutionTarget> result = Maps.newHashMap();
    MappingNode mappingNode = ((MappingNode) valueNode);
    List<NodeTuple> nodeTuples = mappingNode.getValue();
    for (NodeTuple nodeTuple : nodeTuples) {
        String key = scalarParser.parse(nodeTuple.getKeyNode(), context);
        SubstitutionTarget target = parseSubstitutionTarget(nodeTuple.getValueNode(), context);
        if (target != null) {
            result.put(key, target);
        }
    }
    return result;
}
Also used : ParsingError(alien4cloud.tosca.parser.ParsingError) MappingNode(org.yaml.snakeyaml.nodes.MappingNode) SubstitutionTarget(org.alien4cloud.tosca.model.templates.SubstitutionTarget) NodeTuple(org.yaml.snakeyaml.nodes.NodeTuple)

Aggregations

SubstitutionTarget (org.alien4cloud.tosca.model.templates.SubstitutionTarget)16 NotFoundException (alien4cloud.exception.NotFoundException)8 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)8 AlreadyExistException (alien4cloud.exception.AlreadyExistException)4 Map (java.util.Map)4 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)3 NodeType (org.alien4cloud.tosca.model.types.NodeType)3 Capability (org.alien4cloud.tosca.model.templates.Capability)2 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)2 InstanceInformation (alien4cloud.paas.model.InstanceInformation)1 ToscaTypeLoader (alien4cloud.tosca.container.ToscaTypeLoader)1 ParsingError (alien4cloud.tosca.parser.ParsingError)1 Set (java.util.Set)1 ManagedServiceUpdatedEvent (org.alien4cloud.alm.events.ManagedServiceUpdatedEvent)1 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)1 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)1 FunctionPropertyValue (org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)1 RequirementDefinition (org.alien4cloud.tosca.model.definitions.RequirementDefinition)1 PolicyTemplate (org.alien4cloud.tosca.model.templates.PolicyTemplate)1 PolicyType (org.alien4cloud.tosca.model.types.PolicyType)1