How to use the infusion.copy function in infusion

To help you get started, we’ve selected a few infusion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GPII / universal / gpii / node_modules / ontologyHandler / src / ontologyHandler.js View on Github external
gpii.ontologyHandler.mergePrefsSets = function (master, secondary) {
        master = fluid.copy(master);
        secondary = fluid.copy(secondary);

        master.name = master.name || secondary.name;
        fluid.each(secondary.contexts, function (context, contextId) {
            var mcontext = master.contexts[contextId];
            // if not in master, just copy over from secondary:
            if (!mcontext) {
                master.contexts[contextId] = context;
            } else {
                // preferences and metadata should be the only things varying
                fluid.extend(true, mcontext.preferences, context.preferences);
                mcontext.metadata = fluid.makeArray(mcontext.metadata).concat(fluid.makeArray(context.metadata));
            }
        });

        // merge outer metadata block
        master.metadata = fluid.makeArray(master.metadata).concat(fluid.makeArray(secondary.metadata));
github GPII / universal / gpii / node_modules / ontologyHandler / src / ontologyHandler.js View on Github external
gpii.ontologyHandler.addPrefsToRawPrefs = function (that, prefs, prefsView, rawPrefs) {
        var togo = fluid.copy(rawPrefs);

        // on an update, the consumer is responsible for sending _ALL_ relevant preferences in an
        // ontology, so we can safely replace the existing preferences in that ontology
        togo[prefsView] = prefs;

        // for each of the remaining ontologies in the raw preferences, check if there are any
        // preferences that are duplicate and remove them if that is the case:
        fluid.each(togo, function (existingPrefs, existingView) {
            if (existingView === prefsView) {
                return;
            }
            // TODO - GPII-848: The preference merging needs to be improved once the user has the
            // ability to specifically 'unset' settings in the PSP/PMT - i.e. decide that they do not
            // want eg. font-size defined anymore.

            // transform settings from the new preference set (prefsView) into the ontology
github GPII / universal / gpii / node_modules / eventLog / src / eventLog.js View on Github external
gpii.eventLog.createLogObject = function (moduleName, event, data, level) {
    var eventObject = {
        module: moduleName || "GPII",
        event: event,
        level: level
    };

    var hasValue = (data !== null && data !== undefined);
    if (hasValue && fluid.isPlainObject(data)) {
        hasValue = !$.isEmptyObject(data);
    }

    if (hasValue) {
        eventObject.data = fluid.copy(data);
        // Replace any components in the data object with their id.
        fluid.each(eventObject.data, function (value, key) {
            if (fluid.isComponent(value)) {
                eventObject.data[key] = value.id;
            }
        });
    }
    return eventObject;
};
github GPII / universal / gpii / node_modules / testing / src / RunTestDefs.js View on Github external
gpii.test.recordToTestDefs = function (record) {
    var testDefs = fluid.copy(fluid.getGlobalValue(record.testDefs));
    fluid.each(testDefs, function (testDef) {
        testDef.config = {
            configName: testDef.configName || record.configName,
            configPath: testDef.configPath || record.configPath
        };
    });
    return testDefs;
};
github GPII / universal / tests / UntrustedPSPIntegrationTests.js View on Github external
gpii.tests.untrusted.pspIntegration.testDefs = fluid.transform(gpii.tests.pspIntegration.testDefs, function (testDefIn, i) {
    var testDef = gpii.tests.untrusted.pspIntegration.addConfig(testDefIn);

    testDef.expect = testDef.expect + 2;
    gpii.test.unshift(testDef.sequence, gpii.test.untrusted.pspIntegration.startSequence);

    var sequenceAtEnd = fluid.copy(gpii.test.untrusted.pspIntegration.endSequence);
    fluid.set(sequenceAtEnd[1], ["args"], ["{that}", "{arguments}.0", i]);
    gpii.test.push(testDef.sequence, sequenceAtEnd);

    return testDef;
});
github GPII / universal / gpii / node_modules / testing / src / UntrustedFlowManager.js View on Github external
gpii.test.untrustedFlowManager.combinedConfig.build = function (untrustedFlowManagerConfigName,
                                                                untrustedFlowManagerConfigPath,
                                                                cloudBasedFlowManagerConfigName,
                                                                cloudBasedFlowManagerConfigPath) {

    var untrustedFlowManagerConfig = fluid.copy(fluid.defaults(kettle.config.createDefaults({
        configName: untrustedFlowManagerConfigName,
        configPath: untrustedFlowManagerConfigPath
    })));

    var cloudBasedFlowManagerConfig = fluid.copy(fluid.defaults(kettle.config.createDefaults({
        configName: cloudBasedFlowManagerConfigName,
        configPath: cloudBasedFlowManagerConfigPath
    })));

    delete untrustedFlowManagerConfig.gradeNames;
    delete cloudBasedFlowManagerConfig.gradeNames;

    var config = fluid.copy(gpii.test.untrustedFlowManager.combinedConfig.template);

    fluid.set(config, "options.components.server.options.components.localConfig.options",
              untrustedFlowManagerConfig);
github GPII / universal / gpii / node_modules / testing / src / UntrustedFlowManager.js View on Github external
gpii.test.untrustedFlowManager.combinedConfig.build = function (untrustedFlowManagerConfigName,
                                                                untrustedFlowManagerConfigPath,
                                                                cloudBasedFlowManagerConfigName,
                                                                cloudBasedFlowManagerConfigPath) {

    var untrustedFlowManagerConfig = fluid.copy(fluid.defaults(kettle.config.createDefaults({
        configName: untrustedFlowManagerConfigName,
        configPath: untrustedFlowManagerConfigPath
    })));

    var cloudBasedFlowManagerConfig = fluid.copy(fluid.defaults(kettle.config.createDefaults({
        configName: cloudBasedFlowManagerConfigName,
        configPath: cloudBasedFlowManagerConfigPath
    })));

    delete untrustedFlowManagerConfig.gradeNames;
    delete cloudBasedFlowManagerConfig.gradeNames;

    var config = fluid.copy(gpii.test.untrustedFlowManager.combinedConfig.template);

    fluid.set(config, "options.components.server.options.components.localConfig.options",
              untrustedFlowManagerConfig);
    fluid.set(config, "options.components.server.options.components.cloudBasedConfig.options",
              cloudBasedFlowManagerConfig);

    return config;
};
github GPII / universal / tests / UntrustedPSPIntegrationTests.js View on Github external
gpii.tests.untrusted.pspIntegration.testDefs = fluid.transform(gpii.tests.pspIntegration.testDefs, function (testDefIn, i) {
    var testDef = gpii.tests.untrusted.pspIntegration.addConfig(testDefIn);

    testDef.expect = testDef.expect + 2;
    gpii.test.unshift(testDef.sequence, gpii.test.untrusted.pspIntegration.startSequence);

    var sequenceAtEnd = fluid.copy(gpii.test.untrusted.pspIntegration.endSequence);
    fluid.set(sequenceAtEnd[1], ["args"], ["{that}", "{arguments}.0", i]);
    gpii.test.push(testDef.sequence, sequenceAtEnd);

    return testDef;
});
github GPII / universal / gpii / node_modules / configurationManager / src / ConfigurationManager.js View on Github external
fluid.each(that.settingsStore, function (solution) {
                var snapshottedSolution = fluid.copy(solution);
                //call all settingsHandlers
                gpii.configurationManager.invokeSettingsHandlers(solution.id, solution.settingsHandlers, snapshottedSolution.settingsHandlers);
                //TODO react to stuff failing.
                gpii.configurationManager.invokeLaunchHandlers(solution.launchHandlers, "stop");
                //clear the settingsStore as it is no longer relevant
                //TODO handle the settingsStore in file instead.
                that.settingsStore = [];
            });
            callback(true);
github GPII / universal / gpii / node_modules / preferencesFramework / src / ontologyPutHandler.js View on Github external
gpii.ontology.put.onGetRawPreferences = function (rawPrefs, request, ontologySource, ontologyServer, event) {
        var token = request.req.params.token;
        var togo = fluid.copy(rawPrefs);
        var put = {
            format: (request.req.query && request.req.query.view) ? request.req.query.view : "flat",
            preferences: request.req.body
        };

        //each consumer is responsible for sending _ALL_ relevant preferences in an ontology, so
        //we can safely replace
        togo[put.format] = put.preferences;

        //build a set of ontology transformations that we would like to have available
        var transformSpecs = [];
        fluid.each(rawPrefs, function (preferences, view) {
            if (view === put.format)
                return;

            transformSpecs.push({from: put.format, to: view});