fix(copy-paste): do NOT copy generic properties

Related to camunda/camunda-modeler#1507
This commit is contained in:
Philipp Fromme 2019-09-25 10:36:07 +02:00 committed by Niklas Kiefer
parent d55e3afe35
commit a74d838dc7
2 changed files with 48 additions and 15 deletions

View File

@ -240,6 +240,10 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
// copy model elements // copy model elements
if (isObject(property) && property.$type) { if (isObject(property) && property.$type) {
if (this._moddle.getElementDescriptor(property).isGeneric) {
return;
}
copiedProperty = self._bpmnFactory.create(property.$type); copiedProperty = self._bpmnFactory.create(property.$type);
copiedProperty.$parent = parent; copiedProperty.$parent = parent;

View File

@ -39,7 +39,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('simple', function() { describe('simple', function() {
it('should copy primitive properties', inject(function(moddleCopy, moddle) { it('should copy primitive properties', inject(function(moddle, moddleCopy) {
// given // given
var userTask = moddle.create('bpmn:UserTask', { var userTask = moddle.create('bpmn:UserTask', {
@ -56,7 +56,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should copy arrays of properties', inject(function(moddleCopy, moddle) { it('should copy arrays of properties', inject(function(moddle, moddleCopy) {
// given // given
var messageEventDefinition = moddle.create('bpmn:MessageEventDefinition'), var messageEventDefinition = moddle.create('bpmn:MessageEventDefinition'),
@ -80,7 +80,7 @@ describe('features/copy-paste/ModdleCopy', function() {
it('should NOT copy properties that are not allowed in target element', inject( it('should NOT copy properties that are not allowed in target element', inject(
function(moddleCopy, moddle) { function(moddle, moddleCopy) {
// given // given
var userTask = moddle.create('bpmn:UserTask', { var userTask = moddle.create('bpmn:UserTask', {
@ -98,7 +98,7 @@ describe('features/copy-paste/ModdleCopy', function() {
)); ));
it('should NOT copy IDs', inject(function(moddleCopy, moddle) { it('should NOT copy IDs', inject(function(moddle, moddleCopy) {
// given // given
var task = moddle.create('bpmn:Task', { var task = moddle.create('bpmn:Task', {
@ -115,7 +115,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should NOT copy references', inject(function(moddleCopy, moddle) { it('should NOT copy references', inject(function(moddle, moddleCopy) {
// given // given
var processRef = moddle.create('bpmn:Process'), var processRef = moddle.create('bpmn:Process'),
@ -169,7 +169,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should NOT copy empty extension elements', inject(function(moddleCopy, moddle) { it('should NOT copy empty extension elements', inject(function(moddle, moddleCopy) {
// given // given
var connector = moddle.create('camunda:Connector'), var connector = moddle.create('camunda:Connector'),
@ -194,7 +194,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should only copy specified properties', inject(function(moddleCopy, moddle) { it('should only copy specified properties', inject(function(moddle, moddleCopy) {
// given // given
var userTask = moddle.create('bpmn:UserTask', { var userTask = moddle.create('bpmn:UserTask', {
@ -221,7 +221,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('nested', function() { describe('nested', function() {
it('should copy documentation', inject(function(moddleCopy, moddle) { it('should copy documentation', inject(function(moddle, moddleCopy) {
// given // given
var documentation = [ var documentation = [
@ -245,7 +245,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should copy execution listener', inject(function(moddleCopy, moddle) { it('should copy execution listener', inject(function(moddle, moddleCopy) {
// given // given
var script = moddle.create('camunda:Script', { var script = moddle.create('camunda:Script', {
@ -289,7 +289,7 @@ describe('features/copy-paste/ModdleCopy', function() {
})); }));
it('should copy output parameter', inject(function(moddleCopy, moddle) { it('should copy output parameter', inject(function(moddle, moddleCopy) {
// given // given
var outputParameter = moddle.create('camunda:OutputParameter', { var outputParameter = moddle.create('camunda:OutputParameter', {
@ -360,7 +360,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:Connector', function() { describe('camunda:Connector', function() {
it('should copy if parent is message event definition and is child of end event', inject( it('should copy if parent is message event definition and is child of end event', inject(
function(moddleCopy, moddle) { function(moddle, moddleCopy) {
// given // given
var connector = moddle.create('camunda:Connector', { var connector = moddle.create('camunda:Connector', {
@ -399,7 +399,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:Field', function() { describe('camunda:Field', function() {
it('should copy if parent is message event definition and is child of end event', inject( it('should copy if parent is message event definition and is child of end event', inject(
function(moddleCopy, moddle) { function(moddle, moddleCopy) {
// given // given
var field = moddle.create('camunda:Field', { var field = moddle.create('camunda:Field', {
@ -438,7 +438,7 @@ describe('features/copy-paste/ModdleCopy', function() {
describe('camunda:FailedJobRetryTimeCycle', function() { describe('camunda:FailedJobRetryTimeCycle', function() {
it('should copy if parent is SignalEventDefinition and is intermediate throwing', inject( it('should copy if parent is SignalEventDefinition and is intermediate throwing', inject(
function(moddleCopy, moddle) { function(moddle, moddleCopy) {
// given // given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', { var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
@ -475,7 +475,7 @@ describe('features/copy-paste/ModdleCopy', function() {
it('should copy if parent is TimerEventDefinition and is catching', inject( it('should copy if parent is TimerEventDefinition and is catching', inject(
function(moddleCopy, moddle) { function(moddle, moddleCopy) {
// given // given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', { var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
@ -509,7 +509,7 @@ describe('features/copy-paste/ModdleCopy', function() {
)); ));
it('should copy if parent is call activity', inject(function(moddleCopy, moddle) { it('should copy if parent is call activity', inject(function(moddle, moddleCopy) {
// given // given
var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', { var retryCycle = moddle.create('camunda:FailedJobRetryTimeCycle', {
@ -542,6 +542,35 @@ describe('features/copy-paste/ModdleCopy', function() {
}); });
describe('generic properties', function() {
it('should not copy generic extension elements', inject(function(moddle, moddleCopy) {
// given
var genericExtensionElement = moddle.createAny('foo:property', {
value: 'foo'
});
var extensionElements = moddle.create('bpmn:ExtensionElements'),
startEvent = moddle.create('bpmn:StartEvent');
genericExtensionElement.$parent = extensionElements;
extensionElements.$parent = startEvent;
extensionElements.values = [ genericExtensionElement ];
startEvent.extensionElements = extensionElements;
// when
var endEvent = moddleCopy.copyElement(startEvent, moddle.create('bpmn:EndEvent'));
// then
expect(endEvent.extensionElements).not.to.exist;
}));
});
}); });