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;
}
Aggregations