Search in sources :

Example 1 with NodeFiltersTask

use of alien4cloud.topology.task.NodeFiltersTask in project alien4cloud by alien4cloud.

the class NodeFilterValidationService method validateRequirementFilters.

/**
 * Performs validation of the node filters to check that relationships targets the filter requirements.
 */
private List<NodeFiltersTask> validateRequirementFilters(Topology topology, boolean skipInputs) {
    List<NodeFiltersTask> toReturnTaskList = Lists.newArrayList();
    Map<String, NodeTemplate> nodeTemplates = topology.getNodeTemplates();
    Map<String, NodeType> nodeTypes = topologyServiceCore.getIndexedNodeTypesFromTopology(topology, false, true, true);
    Map<String, CapabilityType> capabilityTypes = topologyServiceCore.getIndexedCapabilityTypesFromTopology(topology);
    for (Map.Entry<String, NodeTemplate> nodeTempEntry : nodeTemplates.entrySet()) {
        Map<String, RelationshipTemplate> relationshipsMap = nodeTempEntry.getValue().getRelationships();
        if (relationshipsMap == null || relationshipsMap.isEmpty()) {
            continue;
        }
        NodeType sourceNodeType = toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class, nodeTempEntry.getValue().getType(), topology.getDependencies());
        if (sourceNodeType.isAbstract()) {
            continue;
        }
        NodeFiltersTask task = new NodeFiltersTask();
        task.setNodeTemplateName(nodeTempEntry.getKey());
        task.setCode(TaskCode.NODE_FILTER_INVALID);
        task.setComponent(sourceNodeType);
        task.setNodeFiltersToSatisfy(Lists.<NodeFilterToSatisfy>newArrayList());
        validateFiltersForNode(sourceNodeType, relationshipsMap, topology, nodeTypes, capabilityTypes, task, skipInputs);
        if (!task.getNodeFiltersToSatisfy().isEmpty()) {
            toReturnTaskList.add(task);
        }
    }
    return toReturnTaskList.isEmpty() ? null : toReturnTaskList;
}
Also used : CapabilityType(org.alien4cloud.tosca.model.types.CapabilityType) NodeFiltersTask(alien4cloud.topology.task.NodeFiltersTask) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) RelationshipTemplate(org.alien4cloud.tosca.model.templates.RelationshipTemplate) NodeType(org.alien4cloud.tosca.model.types.NodeType) Map(java.util.Map)

Aggregations

NodeFiltersTask (alien4cloud.topology.task.NodeFiltersTask)1 Map (java.util.Map)1 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)1 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)1 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)1 NodeType (org.alien4cloud.tosca.model.types.NodeType)1