impr(draw/BpmnRenderer): improve naming of methods
This commit is contained in:
parent
0a061e2060
commit
bcf6e1900e
|
@ -191,37 +191,62 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
function renderEventContent(data, p) {
|
||||
|
||||
var throwEvent = isThrowObject(data.id);
|
||||
var path;
|
||||
|
||||
if (checkSemantic(data.id, 'bpmn:MessageEventDefinition')) {
|
||||
path = renderer('bpmn:MessageEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:TimerEventDefinition')) {
|
||||
path = renderer('bpmn:TimerEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:ConditionalEventDefinition')) {
|
||||
path = renderer('bpmn:ConditionalEventDefinition')(p, data);
|
||||
} else if (checkSemantic(data.id, 'bpmn:SignalEventDefinition')) {
|
||||
path = renderer('bpmn:SignalEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:CancelEventDefinition') &&
|
||||
checkSemantic(data.id, 'bpmn:TerminateEventDefinition') && !bpmnRegistry.getSemantic(data.id).parallelMultiple) {
|
||||
path = renderer('bpmn:MultipleEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:CancelEventDefinition') &&
|
||||
checkSemantic(data.id, 'bpmn:TerminateEventDefinition') && !!bpmnRegistry.getSemantic(data.id).parallelMultiple) {
|
||||
path = renderer('bpmn:ParallelMultipleEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:EscalationEventDefinition')) {
|
||||
path = renderer('bpmn:EscalationEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:LinkEventDefinition')) {
|
||||
path = renderer('bpmn:LinkEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:ErrorEventDefinition')) {
|
||||
path = renderer('bpmn:ErrorEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:CancelEventDefinition')) {
|
||||
path = renderer('bpmn:CancelEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:CompensateEventDefinition')) {
|
||||
path = renderer('bpmn:CompensateEventDefinition')(p, data, throwEvent);
|
||||
} else if (checkSemantic(data.id, 'bpmn:TerminateEventDefinition')) {
|
||||
path = renderer('bpmn:TerminateEventDefinition')(p, data, throwEvent);
|
||||
var event = bpmnRegistry.getSemantic(data);
|
||||
var isThrowing = isThrowEvent(event);
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
|
||||
return renderer('bpmn:MessageEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
return path;
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
|
||||
return renderer('bpmn:TimerEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
|
||||
return renderer('bpmn:ConditionalEventDefinition')(p, data);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
|
||||
return renderer('bpmn:SignalEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
||||
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
|
||||
return renderer('bpmn:MultipleEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
||||
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
|
||||
return renderer('bpmn:ParallelMultipleEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
|
||||
return renderer('bpmn:EscalationEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
|
||||
return renderer('bpmn:LinkEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
|
||||
return renderer('bpmn:ErrorEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
|
||||
return renderer('bpmn:CancelEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
|
||||
return renderer('bpmn:CompensateEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
|
||||
return renderer('bpmn:TerminateEventDefinition')(p, data, isThrowing);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var handlers = {
|
||||
|
@ -236,11 +261,11 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return circle;
|
||||
},
|
||||
'bpmn:MessageEventDefinition': function(p, data, throwEvent) {
|
||||
'bpmn:MessageEventDefinition': function(p, data, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_MESSAGE');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var stroke = throwEvent ? 'White' : 'Black';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
var stroke = isThrowing ? 'White' : 'Black';
|
||||
|
||||
var messagePath = drawPath(p, pathData);
|
||||
messagePath.attr({
|
||||
|
@ -279,10 +304,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return timerPath;
|
||||
},
|
||||
'bpmn:EscalationEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:EscalationEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_ESCALATION');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var escalationPath = drawPath(p, pathData);
|
||||
escalationPath.attr({
|
||||
|
@ -312,10 +337,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return linkPath;
|
||||
},
|
||||
'bpmn:ErrorEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:ErrorEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_ERROR');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var errorPath = drawPath(p, pathData);
|
||||
errorPath.attr({
|
||||
|
@ -325,10 +350,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return errorPath;
|
||||
},
|
||||
'bpmn:CancelEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:CancelEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_CANCEL');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var cancelPath = drawPath(p, pathData);
|
||||
cancelPath.attr({
|
||||
|
@ -338,10 +363,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return cancelPath;
|
||||
},
|
||||
'bpmn:CompensateEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:CompensateEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_COMPENSATION');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var compensationPath = drawPath(p, pathData);
|
||||
compensationPath.attr({
|
||||
|
@ -351,10 +376,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return compensationPath;
|
||||
},
|
||||
'bpmn:SignalEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:SignalEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_SIGNAL');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var signalPath = drawPath(p, pathData);
|
||||
signalPath.attr({
|
||||
|
@ -364,10 +389,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
|
||||
return signalPath;
|
||||
},
|
||||
'bpmn:MultipleEventDefinition': function(p, event, throwEvent) {
|
||||
'bpmn:MultipleEventDefinition': function(p, event, isThrowing) {
|
||||
var pathData = pathMap.getRawPath('EVENT_MULTIPLE');
|
||||
|
||||
var fill = throwEvent ? 'Black' : 'None';
|
||||
var fill = isThrowing ? 'Black' : 'None';
|
||||
|
||||
var multiplePath = drawPath(p, pathData);
|
||||
multiplePath.attr({
|
||||
|
@ -592,8 +617,10 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
return dataStore;
|
||||
},
|
||||
'bpmn:BoundaryEvent': function(p, data) {
|
||||
renderer('bpmn:IntermediateInterruptedEvent')(p, data);
|
||||
return renderEventContent(data, p);
|
||||
return renderer('bpmn:IntermediateInterruptedEvent')(p, data);
|
||||
},
|
||||
'label': function(p, data) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -624,31 +651,15 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
|||
*
|
||||
* @return {boolean} true if element is of the given semantic type
|
||||
*/
|
||||
function checkSemantic(id, semanticType) {
|
||||
function isTypedEvent(event, eventDefinitionType, filter) {
|
||||
|
||||
var semantic = bpmnRegistry.getSemantic(id);
|
||||
|
||||
if(!semantic || !semantic.eventDefinitions) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var match = false;
|
||||
_.forEach(semantic.eventDefinitions, function(eventDefinition) {
|
||||
if(eventDefinition.$type === semanticType) {
|
||||
match = true;
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
return _.any(event.eventDefinitions, function(definition) {
|
||||
return definition.$type === eventDefinitionType && (!filter || _.all([ definition ], filter));
|
||||
});
|
||||
return match;
|
||||
}
|
||||
|
||||
function isThrowObject(id) {
|
||||
|
||||
var semantic = bpmnRegistry.getSemantic(id);
|
||||
|
||||
return (semantic.$type === 'bpmn:IntermediateThrowEvent') || (semantic.$type === 'bpmn:EndEvent');
|
||||
function isThrowEvent(event) {
|
||||
return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue