<commit_before>"use strict";

define(['js/Widgets/DiagramDesigner/Connection',
        'js/Widgets/DiagramDesigner/DiagramDesignerWidget.Constants'], function (Connection,
                                                   DiagramDesignerWidgetConstants) {

    var DiagramDesignerWidget;

    DiagramDesignerWidget = function () {

    };

    DiagramDesignerWidget.prototype.createConnection = function (objD) {
        var connectionId = this._getGuid("C_"),
            objDescriptor = _.extend({}, objD),
            sourceId = objDescriptor.srcObjId,
            sourceSubcomponentId = objDescriptor.srcSubCompId,
            targetId = objDescriptor.dstObjId,
            targetSubcomponentId = objDescriptor.dstSubCompId,
            newComponent;

        this.logger.debug("Creating connection component with parameters: " + JSON.stringify(objDescriptor));

        objDescriptor.designerCanvas = this;

        this.connectionIds.push(connectionId);

        //add to accounting queues for performance optimization
        this._insertedConnectionIDs.push(connectionId);

        //accounting connection info
        this.connectionEndIDs[connectionId] = {"srcObjId": sourceId,
                                              "srcSubCompId": sourceSubcomponentId,
                                              "dstObjId": targetId,
                                              "dstSubCompId": targetSubcomponentId};


        this._saveConnectionIDbyEndID(connectionId, sourceId, sourceSubcomponentId);
        this._saveConnectionIDbyEndID(connectionId, targetId, targetSubcomponentId);

        newComponent = this.items[connectionId] = new Connection(connectionId);
        newComponent._initialize(objDescriptor);
        return newComponent;
    };

    DiagramDesignerWidget.prototype.updateConnection = function (id, objDescriptor) {
        var srcObjId = objDescriptor.srcObjId,
            srcSubCompId = objDescriptor.srcSubCompId,
            dstObjId = objDescriptor.dstObjId,
            dstSubCompId = objDescriptor.dstSubCompId;

        this.logger.debug("Updating connection component with ID: '" + id + "'");

        //add to accounting queues for performance optimization
        this._updatedConnectionIDs.push(id);

        /* check if any endpoint of the connection has been changed */
        //check SOURCE
        if (srcObjId !== this.connectionEndIDs[id].srcObjId &&
            srcSubCompId !== this.connectionEndIDs[id].srcSubCompId) {

            //remove connection from source list
            this._removeConnectionIDfromEnd(id, true);

            //account the new
            this._saveConnectionIDbyEndID(id, srcObjId, srcSubCompId);
        }

        //check TARGET
        if (dstObjId !== this.connectionEndIDs[id].dstObjId &&
            dstSubCompId !== this.connectionEndIDs[id].dstSubCompId) {

            //remove connection from target list
            this._removeConnectionIDfromEnd(id, false);

            //account the new
            this._saveConnectionIDbyEndID(id, dstObjId, dstSubCompId);
        }

        //accounting connection info
        this.connectionEndIDs[id] = {"srcObjId": srcObjId,
            "srcSubCompId": srcSubCompId,
            "dstObjId": dstObjId,
            "dstSubCompId": dstSubCompId};

        this.items[id].update(objDescriptor);
    };
<commit_msg>bugfix: when connection's end changes it has to update the accounting colelctions<commit_after>"use strict";

define(['js/Widgets/DiagramDesigner/Connection',
        'js/Widgets/DiagramDesigner/DiagramDesignerWidget.Constants'], function (Connection,
                                                   DiagramDesignerWidgetConstants) {

    var DiagramDesignerWidget;

    DiagramDesignerWidget = function () {

    };

    DiagramDesignerWidget.prototype.createConnection = function (objD) {
        var connectionId = this._getGuid("C_"),
            objDescriptor = _.extend({}, objD),
            sourceId = objDescriptor.srcObjId,
            sourceSubcomponentId = objDescriptor.srcSubCompId,
            targetId = objDescriptor.dstObjId,
            targetSubcomponentId = objDescriptor.dstSubCompId,
            newComponent;

        this.logger.debug("Creating connection component with parameters: " + JSON.stringify(objDescriptor));

        objDescriptor.designerCanvas = this;

        this.connectionIds.push(connectionId);

        //add to accounting queues for performance optimization
        this._insertedConnectionIDs.push(connectionId);

        //accounting connection info
        this.connectionEndIDs[connectionId] = {"srcObjId": sourceId,
                                              "srcSubCompId": sourceSubcomponentId,
                                              "dstObjId": targetId,
                                              "dstSubCompId": targetSubcomponentId};


        this._saveConnectionIDbyEndID(connectionId, sourceId, sourceSubcomponentId);
        this._saveConnectionIDbyEndID(connectionId, targetId, targetSubcomponentId);

        newComponent = this.items[connectionId] = new Connection(connectionId);
        newComponent._initialize(objDescriptor);
        return newComponent;
    };

    DiagramDesignerWidget.prototype.updateConnection = function (id, objDescriptor) {
        var srcObjId = objDescriptor.srcObjId,
            srcSubCompId = objDescriptor.srcSubCompId,
            dstObjId = objDescriptor.dstObjId,
            dstSubCompId = objDescriptor.dstSubCompId;

        this.logger.debug("Updating connection component with ID: '" + id + "'");

        //add to accounting queues for performance optimization
        this._updatedConnectionIDs.push(id);

        /* check if any endpoint of the connection has been changed */
        //check SOURCE
        if (srcObjId !== this.connectionEndIDs[id].srcObjId ||
            srcSubCompId !== this.connectionEndIDs[id].srcSubCompId) {

            //remove connection from source list
            this._removeConnectionIDfromEnd(id, true);

            //account the new
            this._saveConnectionIDbyEndID(id, srcObjId, srcSubCompId);
        }

        //check TARGET
        if (dstObjId !== this.connectionEndIDs[id].dstObjId ||
            dstSubCompId !== this.connectionEndIDs[id].dstSubCompId) {

            //remove connection from target list
            this._removeConnectionIDfromEnd(id, false);

            //account the new
            this._saveConnectionIDbyEndID(id, dstObjId, dstSubCompId);
        }

        //accounting connection info
        this.connectionEndIDs[id] = {"srcObjId": srcObjId,
            "srcSubCompId": srcSubCompId,
            "dstObjId": dstObjId,
            "dstSubCompId": dstSubCompId};

        this.items[id].update(objDescriptor);
    };

{'fraction_non_alphanumeric': 0.08771411695215593, 'fraction_numerical': 0.0, 'mean_word_length': 2.336453201970443, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '376533', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1653, 'n_words': 333}