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