How to use the @hpcc-js/common.Utility.exists function in @hpcc-js/common

To help you get started, we’ve selected a few @hpcc-js/common 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 hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
processResponse(response, request, updates) {
        const lowerResponse = {};
        for (const responseKey in response) {
            lowerResponse[responseKey.toLowerCase()] = response[responseKey];
        }
        const promises = [];
        for (const key in this._outputs) {
            const from = this._outputs[key].id;
            if (Utility.exists(from, response)) {
                if (!Utility.exists(from + _CHANGED, response) || (Utility.exists(from + _CHANGED, response) && response[from + _CHANGED].length && response[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(response[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else if (Utility.exists(from, lowerResponse)) {
                console.log("DDL 'Datasource.From' case is Incorrect");
                if (!Utility.exists(from + _CHANGED, lowerResponse) || (Utility.exists(from + _CHANGED, lowerResponse) && response[from + _CHANGED].length && lowerResponse[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(lowerResponse[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else {
                const responseItems = [];
                for (const responseKey2 in response) {
                    responseItems.push(responseKey2);
                }
                console.log("Unable to locate '" + from + "' in response {" + responseItems.join(", ") + "}");
            }
        }
        return Promise.all(promises);
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
processResponse(response, request, updates) {
        const lowerResponse = {};
        for (const responseKey in response) {
            lowerResponse[responseKey.toLowerCase()] = response[responseKey];
        }
        const promises = [];
        for (const key in this._outputs) {
            const from = this._outputs[key].id;
            if (Utility.exists(from, response)) {
                if (!Utility.exists(from + _CHANGED, response) || (Utility.exists(from + _CHANGED, response) && response[from + _CHANGED].length && response[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(response[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else if (Utility.exists(from, lowerResponse)) {
                console.log("DDL 'Datasource.From' case is Incorrect");
                if (!Utility.exists(from + _CHANGED, lowerResponse) || (Utility.exists(from + _CHANGED, lowerResponse) && response[from + _CHANGED].length && lowerResponse[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(lowerResponse[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else {
                const responseItems = [];
                for (const responseKey2 in response) {
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
for (const responseKey in response) {
            lowerResponse[responseKey.toLowerCase()] = response[responseKey];
        }
        const promises = [];
        for (const key in this._outputs) {
            const from = this._outputs[key].id;
            if (Utility.exists(from, response)) {
                if (!Utility.exists(from + _CHANGED, response) || (Utility.exists(from + _CHANGED, response) && response[from + _CHANGED].length && response[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(response[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else if (Utility.exists(from, lowerResponse)) {
                console.log("DDL 'Datasource.From' case is Incorrect");
                if (!Utility.exists(from + _CHANGED, lowerResponse) || (Utility.exists(from + _CHANGED, lowerResponse) && response[from + _CHANGED].length && lowerResponse[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(lowerResponse[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else {
                const responseItems = [];
                for (const responseKey2 in response) {
                    responseItems.push(responseKey2);
                }
                console.log("Unable to locate '" + from + "' in response {" + responseItems.join(", ") + "}");
            }
        }
        return Promise.all(promises);
    }
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
processResponse(response, request, updates) {
        const lowerResponse = {};
        for (const responseKey in response) {
            lowerResponse[responseKey.toLowerCase()] = response[responseKey];
        }
        const promises = [];
        for (const key in this._outputs) {
            const from = this._outputs[key].id;
            if (Utility.exists(from, response)) {
                if (!Utility.exists(from + _CHANGED, response) || (Utility.exists(from + _CHANGED, response) && response[from + _CHANGED].length && response[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(response[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else if (Utility.exists(from, lowerResponse)) {
                console.log("DDL 'Datasource.From' case is Incorrect");
                if (!Utility.exists(from + _CHANGED, lowerResponse) || (Utility.exists(from + _CHANGED, lowerResponse) && response[from + _CHANGED].length && lowerResponse[from + _CHANGED][0][from + _CHANGED])) {
                    promises.push(this._outputs[key].setData(lowerResponse[from], updates));
                } else {
                    //  TODO - I Suspect there is a HIPIE/Roxie issue here (empty request)
                    promises.push(this._outputs[key].vizNotify(updates));
                }
            } else {
                const responseItems = [];
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
this.getVisualizationArray().forEach(function (visualization) {
        //  Clear all charts back to their default values ---
        visualization.clear();
        visualization.update();
        if (state && state[visualization.id]) {
            if (Utility.exists("source.mappings.mappings", visualization)) {
                for (const key in visualization.source.mappings.mappings) {
                    if (state[visualization.id][visualization.source.mappings.mappings[key]]) {
                        visualization._widgetState.row[key] = state[visualization.id][visualization.source.mappings.mappings[key]];
                        visualization._widgetState.selected = true;
                    }
                }
            }
        }
    });
    this.getVisualizationArray().forEach(function (visualization) {
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
this.loadWidget("../form/Slider", function (widget) {
                    try {
                        widget
                            .id(visualization.id)
                            ;
                        if (visualization.range) {
                            let selectionLabel = "";
                            if (Utility.exists("events.click.updates", visualization) && visualization.events.click.updates.length) {
                                for (const key in visualization.events.click.updates[0].mappings) {
                                    selectionLabel = key;
                                    break;
                                }
                            }
                            widget
                                .low_default(+visualization.range[0])
                                .high_default(+visualization.range[1])
                                .step_default(+visualization.range[2])
                                .selectionLabel_default(selectionLabel)
                                .selectionLabel(selectionLabel)
                                ;
                        }
                    } catch (e) {
                        console.log("Unexpected widget type:  " + widget.classID());
                    }
github hpcc-systems / Visualization / packages / other / src / ESP.ts View on Github external
}).then(function (response) {
        let retVal = [];
        if (Utility.exists("WUInfoResponse.Workunit.Results.ECLResult", response)) {
            retVal = response.WUInfoResponse.Workunit.Results.ECLResult.map(function (result) {
                return new WUResult(context.getUrl({ pathname: "WsWorkunits/" }), context._wuid, result.Name);
            });
        }
        return retVal;
    });
};
github hpcc-systems / Visualization / packages / marshaller / src / ddl1 / HipieDDL.ts View on Github external
transport.fetchResults().then(function (response) {
        if (Utility.exists(hipieResultName, response)) {
            return transport.fetchResult(hipieResultName).then(function (ddlResponse) {
                const json = ddlResponse[0][hipieResultName];
                context.parse(json, function () {
                    callback(response);
                });
            }).catch(function (e) {
                context.commsEvent(context, "error", hipieResultName, e);
            });
        }
    }).catch(function (e) {
        context.commsEvent(context, "error", "fetchResults", e);