Commit 11f8f978 authored by Romain Bioteau's avatar Romain Bioteau Committed by Romain Bioteau
Browse files

fix(validation) refine outgoing transition validation (#2444)

* do not throw a warning when at least one outgoing transition is took

Closes STUDIO-3655
parent 3a6853e5
...@@ -25,6 +25,7 @@ import org.bonitasoft.studio.validation.i18n.Messages; ...@@ -25,6 +25,7 @@ import org.bonitasoft.studio.validation.i18n.Messages;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.IValidationContext; import org.eclipse.emf.validation.IValidationContext;
import org.eclipse.osgi.util.NLS;
/** /**
* @author Baptiste Mesta * @author Baptiste Mesta
...@@ -36,9 +37,9 @@ public class OutputTransitionConstraint extends AbstractLiveValidationMarkerCons ...@@ -36,9 +37,9 @@ public class OutputTransitionConstraint extends AbstractLiveValidationMarkerCons
final EObject eObj = ctx.getTarget(); final EObject eObj = ctx.getTarget();
if (eObj instanceof SourceElement) { if (eObj instanceof SourceElement) {
final SourceElement sourceElement = (SourceElement) eObj; final SourceElement sourceElement = (SourceElement) eObj;
final Set<SequenceFlow> flowWithConditions = new HashSet<SequenceFlow>(); final Set<SequenceFlow> flowWithConditions = new HashSet<>();
final Set<SequenceFlow> flowWithoutConditions = new HashSet<SequenceFlow>(); final Set<SequenceFlow> flowWithoutConditions = new HashSet<>();
final Set<SequenceFlow> flowWithDefaultConditions = new HashSet<SequenceFlow>(); final Set<SequenceFlow> flowWithDefaultConditions = new HashSet<>();
for (final Connection c : sourceElement.getOutgoing()) { for (final Connection c : sourceElement.getOutgoing()) {
if (c instanceof SequenceFlow) { if (c instanceof SequenceFlow) {
if (((SequenceFlow) c).isIsDefault()) { if (((SequenceFlow) c).isIsDefault()) {
...@@ -50,16 +51,15 @@ public class OutputTransitionConstraint extends AbstractLiveValidationMarkerCons ...@@ -50,16 +51,15 @@ public class OutputTransitionConstraint extends AbstractLiveValidationMarkerCons
} }
} }
} }
if (!flowWithConditions.isEmpty()) { if (!flowWithConditions.isEmpty() && flowWithoutConditions.isEmpty() && flowWithDefaultConditions.isEmpty()) {
if (flowWithDefaultConditions.isEmpty()) { return ctx.createFailureStatus(NLS.bind(Messages.missingDefaultSequenceFlow, sourceElement.getName()));
return ctx.createFailureStatus(Messages.bind(Messages.missingDefaultSequenceFlow, sourceElement.getName()));
}
} }
} }
return ctx.createSuccessStatus(); return ctx.createSuccessStatus();
} }
@Override @Override
protected String getConstraintId() { protected String getConstraintId() {
return "org.bonitasoft.studio.validation.outputTransitions"; return "org.bonitasoft.studio.validation.outputTransitions";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment