Created
June 29, 2014 15:35
-
-
Save sgithens/9bb2e970a84d66e969cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gpii.invokeGradedFunction = function (name, spec) { | |
| var defaults = fluid.defaults(name); | |
| if (!defaults.argumentMap || !fluid.hasGrade(defaults, "fluid.function")) { | |
| fluid.fail("Cannot look up name " + name + " to a function with registered argumentMap - got defaults ", defaults); | |
| } | |
| var args = []; | |
| fluid.each(defaults.argumentMap, function (value, key) { | |
| args[value] = spec[key]; | |
| }); | |
| return fluid.invokeGlobalFunction(name, args); | |
| }; | |
| gpii.handleDeviceGet = function (requestProxy, installedSolutionsDataSource, solutionsRegistryDataSource) { | |
| if (installedSolutionsDataSource.options.url) { | |
| installedSolutionsDataSource.get(null, function onSuccess(solutions) { | |
| fireDeviceInformation(requestProxy, solutions); | |
| }); | |
| } else { | |
| var installedSolutions = []; | |
| solutionsRegistryDataSource.get(null, function onSuccess(entries) { | |
| entries.forEach( function (entry) { | |
| if (!installedSolutions.some(function(s) { return s.id === entry.id; })) { | |
| fluid.each(entry.contexts.deviceReporters, function (deviceReporter) { | |
| if (!installedSolutions.some(function(s) { return s.id === entry.id; })) { | |
| if (gpii.invokeGradedFunction(deviceReporter.type, deviceReporter)) { | |
| installedSolutions.push({ "id": entry.id }); | |
| } | |
| } | |
| }); | |
| } | |
| }); | |
| fireDeviceInformation(requestProxy, installedSolutions); | |
| }); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment