Search in sources :

Example 36 with TEntityTemplate

use of org.eclipse.winery.model.tosca.TEntityTemplate in project winery by eclipse.

the class ToscaPatternMatcher method behaviorPatternsCompatible.

protected boolean behaviorPatternsCompatible(ToscaEntity left, ToscaEntity right) {
    // By convention, the left node is always the element to search in right.
    TEntityTemplate detectorElement = left.getTemplate();
    TEntityTemplate candidateElement = right.getTemplate();
    return behaviorPatternsCompatible(detectorElement, candidateElement);
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate)

Example 37 with TEntityTemplate

use of org.eclipse.winery.model.tosca.TEntityTemplate in project winery by eclipse.

the class ToscaPatternMatcher method isCompatible.

@Override
public boolean isCompatible(ToscaNode left, ToscaNode right) {
    // By convention, the left node is always the element to search in right.
    TEntityTemplate detectorElement = left.getTemplate();
    TEntityTemplate candidateElement = right.getTemplate();
    return isCompatible(detectorElement, candidateElement);
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate)

Example 38 with TEntityTemplate

use of org.eclipse.winery.model.tosca.TEntityTemplate in project winery by eclipse.

the class ToscaPatternMatcher method isCompatible.

@Override
public boolean isCompatible(ToscaEdge left, ToscaEdge right) {
    // By convention, the left node is always the element to search in right.
    TEntityTemplate detectorElement = left.getTemplate();
    TEntityTemplate candidateElement = right.getTemplate();
    return isCompatible(detectorElement, candidateElement);
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate)

Example 39 with TEntityTemplate

use of org.eclipse.winery.model.tosca.TEntityTemplate in project winery by eclipse.

the class ProviderRepository method breadthFirstSearch.

private List<TEntityTemplate> breadthFirstSearch(TNodeTemplate nodeTemplate, TTopologyTemplate topologyTemplate) {
    List<TEntityTemplate> topologyFragmentElements = new ArrayList<>();
    topologyFragmentElements.add(nodeTemplate);
    List<TRelationshipTemplate> outgoingRelationships = ModelUtilities.getOutgoingRelationshipTemplates(topologyTemplate, nodeTemplate);
    for (TRelationshipTemplate outgoingRelationship : outgoingRelationships) {
        Object successor = outgoingRelationship.getTargetElement().getRef();
        if (successor instanceof TNodeTemplate) {
            topologyFragmentElements.add(outgoingRelationship);
            topologyFragmentElements.addAll(breadthFirstSearch((TNodeTemplate) successor, topologyTemplate));
        }
    }
    return topologyFragmentElements;
}
Also used : TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) TRelationshipTemplate(org.eclipse.winery.model.tosca.TRelationshipTemplate) ArrayList(java.util.ArrayList) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 40 with TEntityTemplate

use of org.eclipse.winery.model.tosca.TEntityTemplate in project winery by eclipse.

the class BehaviorPatternDetection method removeIncompatibleBehaviorPatterns.

private void removeIncompatibleBehaviorPatterns(TEntityTemplate refinementElement, TEntityTemplate addedElement, RefinementCandidate refinement) {
    OTPatternRefinementModel prm = (OTPatternRefinementModel) refinement.getRefinementModel();
    List<TPolicy> addedElementPolicies = ((HasPolicies) addedElement).getPolicies();
    prm.getBehaviorPatternMappings().stream().filter(bpm -> bpm.getRefinementElement().getId().equals(refinementElement.getId())).forEach(bpm -> {
        ToscaEntity detectorElement = refinement.getDetectorGraph().getVertexOrEdge(bpm.getDetectorElement().getId()).get();
        TEntityTemplate candidateElement = getEntityCorrespondence(detectorElement, refinement.getGraphMapping());
        if (ModelUtilities.hasKvProperties(detectorElement.getTemplate()) && ModelUtilities.hasKvProperties(candidateElement)) {
            String detectorValue = ModelUtilities.getPropertiesKV(detectorElement.getTemplate()).get(bpm.getProperty().getKey());
            String candidateValue = ModelUtilities.getPropertiesKV(candidateElement).get(bpm.getProperty().getKey());
            boolean propsNotCompatible = (detectorValue != null && !detectorValue.isEmpty()) && !detectorValue.equalsIgnoreCase(candidateValue) && (!detectorValue.equals("*") || (candidateValue == null || candidateValue.isEmpty()));
            if (propsNotCompatible) {
                TPolicy behaviorPattern = ((HasPolicies) refinementElement).getPolicies().stream().filter(policy -> bpm.getBehaviorPattern().equals(policy.getName())).findFirst().get();
                addedElementPolicies.removeIf(policy -> policy.getPolicyType().equals(behaviorPattern.getPolicyType()));
            }
        }
    });
}
Also used : TPolicy(org.eclipse.winery.model.tosca.TPolicy) HasPolicies(org.eclipse.winery.model.tosca.HasPolicies) PatternDetectionUtils(org.eclipse.winery.topologygraph.matching.patterndetection.PatternDetectionUtils) TopologyFragmentRefinement(org.eclipse.winery.model.adaptation.substitution.refinement.topologyrefinement.TopologyFragmentRefinement) RefinementChooser(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementChooser) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) IToscaMatcher(org.eclipse.winery.topologygraph.matching.IToscaMatcher) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ArrayList(java.util.ArrayList) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) List(java.util.List) PatternRefinementModelId(org.eclipse.winery.model.ids.extensions.PatternRefinementModelId) ToscaEntity(org.eclipse.winery.topologygraph.model.ToscaEntity) Map(java.util.Map) OTRefinementModel(org.eclipse.winery.model.tosca.extensions.OTRefinementModel) ToscaBehaviorPatternMatcher(org.eclipse.winery.topologygraph.matching.patterndetection.ToscaBehaviorPatternMatcher) ModelUtilities(org.eclipse.winery.model.tosca.utils.ModelUtilities) PatternDetectionUtils.getEntityCorrespondence(org.eclipse.winery.topologygraph.matching.patterndetection.PatternDetectionUtils.getEntityCorrespondence) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) RefinementCandidate(org.eclipse.winery.model.adaptation.substitution.refinement.RefinementCandidate) TEntityTemplate(org.eclipse.winery.model.tosca.TEntityTemplate) TPolicy(org.eclipse.winery.model.tosca.TPolicy) HasPolicies(org.eclipse.winery.model.tosca.HasPolicies) ToscaEntity(org.eclipse.winery.topologygraph.model.ToscaEntity) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel)

Aggregations

TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)42 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)19 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)14 QName (javax.xml.namespace.QName)13 ArrayList (java.util.ArrayList)9 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 List (java.util.List)7 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)7 TPolicy (org.eclipse.winery.model.tosca.TPolicy)7 PUT (javax.ws.rs.PUT)6 OTPatternRefinementModel (org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel)6 TEntityType (org.eclipse.winery.model.tosca.TEntityType)5 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Objects (java.util.Objects)4 Collectors (java.util.stream.Collectors)4