<commit_before>/*
 *     (C) Copyright 2012 Universidad Politécnica de Madrid
 *     (C) Copyright 2012 Center for Open Middleware
 *
 *     This file is part of Wirecloud Platform.
 *
 *     Wirecloud Platform is free software: you can redistribute it and/or
 *     modify it under the terms of the GNU Affero General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 *
 *     Wirecloud is distributed in the hope that it will be useful, but WITHOUT
 *     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 *     License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with Wirecloud Platform.  If not, see
 *     <http://www.gnu.org/licenses/>.
 *
 */

/*global Wirecloud */

(function () {

    "use strict";

    /*************************************************************************
     * Constructor
     *************************************************************************/
    /**
     * OperatorInterface Class
     */
    var OperatorInterface = function OperatorInterface(wiringEditor, ioperator, manager, isMenubarRef, endPointPos) {
        var outputs, inputs, desc, label, key, anchorContext, i, isGhost;

        this.ioperator = ioperator;
        this.wiringEditor = wiringEditor;

        if ('ghost' in ioperator) {
            // Ghost Operator
            isGhost = true;
            this.ioperator.display_name = ioperator.name;
            this.ioperator.meta = {};
            this.ioperator.meta.uri = ioperator.name;
            ioperator.outputs = {};
            ioperator.inputs = {};
            for (i = 0; i < endPointPos.sources.length; i += 1) {
                ioperator.outputs[endPointPos.sources[i]] = {
                    'description': '',
                    'label': endPointPos.sources[i],
                    'name': endPointPos.sources[i]
                };
            }
            for (i = 0; i < endPointPos.targets.length; i += 1) {
                ioperator.inputs[endPointPos.targets[i]] = {
                    'description': '',
                    'label': endPointPos.targets[i],
                    'name': endPointPos.targets[i]
                };
            }
        } else {
            isGhost = false;
        }

        Wirecloud.ui.WiringEditor.GenericInterface.call(this, false, wiringEditor, this.ioperator.display_name, manager, 'ioperator', isGhost);
        if (!isMenubarRef) {
            inputs = ioperator.inputs;
            outputs = ioperator.outputs;
            //sources & targets anchors (sourceAnchor and targetAnchor)
            for (key in outputs) {
                desc = outputs[key].description;
                label = outputs[key].label;
                anchorContext = {'data': outputs[key], 'iObject': this};
                this.addSource(label, desc, outputs[key].name, anchorContext);
            }
            for (key in inputs) {
                desc = inputs[key].description;
                label = inputs[key].label;
                anchorContext = {'data': inputs[key], 'iObject': this};
                this.addTarget(label, desc, inputs[key].name, anchorContext);
            }<commit_msg>Work around some problems with ghost operators friendcodes<commit_after>/*
 *     (C) Copyright 2012 Universidad Politécnica de Madrid
 *     (C) Copyright 2012 Center for Open Middleware
 *
 *     This file is part of Wirecloud Platform.
 *
 *     Wirecloud Platform is free software: you can redistribute it and/or
 *     modify it under the terms of the GNU Affero General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 *
 *     Wirecloud is distributed in the hope that it will be useful, but WITHOUT
 *     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 *     License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with Wirecloud Platform.  If not, see
 *     <http://www.gnu.org/licenses/>.
 *
 */

/*global Wirecloud */

(function () {

    "use strict";

    /*************************************************************************
     * Constructor
     *************************************************************************/
    /**
     * OperatorInterface Class
     */
    var OperatorInterface = function OperatorInterface(wiringEditor, ioperator, manager, isMenubarRef, endPointPos) {
        var outputs, inputs, desc, label, key, anchorContext, i, isGhost;

        this.ioperator = ioperator;
        this.wiringEditor = wiringEditor;

        if ('ghost' in ioperator) {
            // Ghost Operator
            isGhost = true;
            this.ioperator.display_name = ioperator.name;
            this.ioperator.meta = {};
            this.ioperator.meta.uri = ioperator.name;
            ioperator.outputs = {};
            ioperator.inputs = {};
            for (i = 0; i < endPointPos.sources.length; i += 1) {
                ioperator.outputs[endPointPos.sources[i]] = {
                    'description': '',
                    'label': endPointPos.sources[i],
                    'name': endPointPos.sources[i],
                    'connectable': {
                        _friendCode: 'ghost'
                    }
                };
            }
            for (i = 0; i < endPointPos.targets.length; i += 1) {
                ioperator.inputs[endPointPos.targets[i]] = {
                    'description': '',
                    'label': endPointPos.targets[i],
                    'name': endPointPos.targets[i],
                    'connectable': {
                        _friendCode: 'ghost'
                    }
                };
            }
        } else {
            isGhost = false;
        }

        Wirecloud.ui.WiringEditor.GenericInterface.call(this, false, wiringEditor, this.ioperator.display_name, manager, 'ioperator', isGhost);
        if (!isMenubarRef) {
            inputs = ioperator.inputs;
            outputs = ioperator.outputs;
            //sources & targets anchors (sourceAnchor and targetAnchor)
            for (key in outputs) {
                desc = outputs[key].description;
                label = outputs[key].label;
                anchorContext = {'data': outputs[key], 'iObject': this};
                this.addSource(label, desc, outputs[key].name, anchorContext);
            }
            for (key in inputs) {
                desc = inputs[key].description;
                label = inputs[key].label;
                anchorContext = {'data': inputs[key], 'iObject': this};
                this.addTarget(label, desc, inputs[key].name, anchorContext);
            }
{'fraction_non_alphanumeric': 0.13728013728013727, 'fraction_numerical': 0.0037180037180037182, 'mean_word_length': 1.933724832214765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6990644', 'n_tokens_mistral': 1817, 'n_tokens_neox': 1709, 'n_words': 511}