Search in sources :

Example 1 with ToscaContext

use of alien4cloud.tosca.context.ToscaContext in project alien4cloud by alien4cloud.

the class ToscaWithDependenciesBuilder method buildNodeTypeWithDependencies.

private TypeWithDependenciesResult buildNodeTypeWithDependencies(NodeType nodeType) {
    TypeWithDependenciesResult result = new TypeWithDependenciesResult();
    result.setToscaType(nodeType);
    for (CapabilityDefinition capabilityDefinition : nodeType.getCapabilities()) {
        result.add(ToscaContext.getOrFail(CapabilityType.class, capabilityDefinition.getType()));
    }
    for (RequirementDefinition requirementDefinition : nodeType.getRequirements()) {
        CapabilityType capabilityType = ToscaContext.get(CapabilityType.class, requirementDefinition.getType());
        if (capabilityType != null) {
            result.add(capabilityType);
        } else {
            // requirements are authorized to be a node type rather than a capability type TODO is it still possible in TOSCA ?
            result.add(ToscaContext.get(NodeType.class, requirementDefinition.getType()));
        }
    }
    result.setDependencies(ToscaContext.get().getDependencies());
    // Fetch data types for the given type
    DataTypesFetcher.getDataTypesDependencies(Collections.singleton(nodeType), ToscaContext::get).values().forEach(result::add);
    return result;
}
Also used : CapabilityType(org.alien4cloud.tosca.model.types.CapabilityType) ToscaContext(alien4cloud.tosca.context.ToscaContext) NodeType(org.alien4cloud.tosca.model.types.NodeType) CapabilityDefinition(org.alien4cloud.tosca.model.definitions.CapabilityDefinition) RequirementDefinition(org.alien4cloud.tosca.model.definitions.RequirementDefinition)

Aggregations

ToscaContext (alien4cloud.tosca.context.ToscaContext)1 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)1 RequirementDefinition (org.alien4cloud.tosca.model.definitions.RequirementDefinition)1 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)1 NodeType (org.alien4cloud.tosca.model.types.NodeType)1