<commit_before>export default ["CONFIG", "HTTP", "WAMP", "$q", "commonUtils", function(CONFIG, HTTP, WAMP, $q, commonUtils) {

/*

"{
    "@id": "_:b3",
    "@type": "semiot:CommandResult",
    "semiot:commandResultTime": {
        "@type": "xsd:dateTime",
        "@value": "2016-06-17T07:49:52.953Z"
    },
    "semiot:isResultOf": {
        "@type": "semiot:StartCommand",
        "http://purl.org/dc/terms/identifier": "light-startcommand",
        "semiot:forProcess": {
            "@id": "https://demo.semiot.ru/systems/1231231231231230/processes/light"
        },
        "dul:associatedWith": {
            "@id": "https://demo.semiot.ru/systems/1231231231231230"
        },
        "dul:hasParameter": [
            {
                "@type": "semiot:MappingParameter",
                "semiot:forParameter": {
                    "@id": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-…rces/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Lumen"
                },
                "dul:hasParameterDataValue": 8
            },
            {
                "@type": "semiot:MappingParameter",
                "semiot:forParameter": {
                    "@id": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-…rces/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Color"
                },
                "dul:hasParameterDataValue": 4000
            }
        ]
    },
    "dul:associatedWith": {
        "@id": "https://demo.semiot.ru/systems/1231231231231230"
    },
    "@context": {
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "dul": "http://www.loa-cnr.it/ontologies/DUL.owl#",
        "semiot": "http://w3id.org/semiot/ontologies/semiot#"
    }
}"

*/

    function parseParameter(obj) {
        obj['dul:hasParameterDataValue'] = "";
        if (obj["sh:property"] && obj["sh:property"]["sh:defaultValue"]) {
            obj['dul:hasParameterDataValue'] = obj["sh:property"] && obj["sh:property"]["sh:defaultValue"];
        }
        return obj;
    }

    function parseOperations(uri, context, o) {
        return commonUtils.ensureArray(o["hydra:expects"]).map((e) => {
            const result = {
                method: o["hydra:method"],
                id: e["dcterms:identifier"],
                label: e["rdfs:label"]["@value"],
                body: $.extend(e, {
                    '@context': context
                }),
                uri
            };
            if (e['dul:hasParameter']) {
                result.body = $.extend(result.body, {
                    'dul:hasParameter': e['dul:hasParameter'].map(parseParameter)
                });
            }
            return result;
        });
    }

    function parseWAMPTopicFromCommandResults(res) {
        const operations = commonUtils.ensureArray(res["hydra-filter:viewOf"]["hydra:operation"]);
        const subscriptionOperation = operations.find((o) => {
            return o['@type'] === "hydra-pubsub:SubscribeOperation";
        });
        return {
            endpoint: subscriptionOperation['hydra-pubsub:endpoint'],
            topic: subscriptionOperation['hydra-pubsub:topic']
        };
    }

    function extractCommandResultFromWAMPMessage(data) {
        return {
            value: data["semiot:isResultOf"]["dcterms:identifier"],
            timestamp: data["semiot:commandResultTime"]["@value"]
        };
    }

    return {
        loadProcessInformation(uri) {
            console.info(`loading process info from ${uri}`);<commit_msg>fixed process view in case of one available command result<commit_after>export default ["CONFIG", "HTTP", "WAMP", "$q", "commonUtils", function(CONFIG, HTTP, WAMP, $q, commonUtils) {

/*

"{
    "@id": "_:b3",
    "@type": "semiot:CommandResult",
    "semiot:commandResultTime": {
        "@type": "xsd:dateTime",
        "@value": "2016-06-17T07:49:52.953Z"
    },
    "semiot:isResultOf": {
        "@type": "semiot:StartCommand",
        "http://purl.org/dc/terms/identifier": "light-startcommand",
        "semiot:forProcess": {
            "@id": "https://demo.semiot.ru/systems/1231231231231230/processes/light"
        },
        "dul:associatedWith": {
            "@id": "https://demo.semiot.ru/systems/1231231231231230"
        },
        "dul:hasParameter": [
            {
                "@type": "semiot:MappingParameter",
                "semiot:forParameter": {
                    "@id": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-…rces/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Lumen"
                },
                "dul:hasParameterDataValue": 8
            },
            {
                "@type": "semiot:MappingParameter",
                "semiot:forParameter": {
                    "@id": "https://raw.githubusercontent.com/semiotproject/semiot-drivers/master/mock-…rces/ru/semiot/drivers/mocks/plainlamp/prototype.ttl#PlainLamp-Shine-Color"
                },
                "dul:hasParameterDataValue": 4000
            }
        ]
    },
    "dul:associatedWith": {
        "@id": "https://demo.semiot.ru/systems/1231231231231230"
    },
    "@context": {
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "dul": "http://www.loa-cnr.it/ontologies/DUL.owl#",
        "semiot": "http://w3id.org/semiot/ontologies/semiot#"
    }
}"

*/

    function parseParameter(obj) {
        obj['dul:hasParameterDataValue'] = "";
        if (obj["sh:property"] && obj["sh:property"]["sh:defaultValue"]) {
            obj['dul:hasParameterDataValue'] = obj["sh:property"] && obj["sh:property"]["sh:defaultValue"];
        }
        return obj;
    }

    function parseOperations(uri, context, o) {
        return commonUtils.ensureArray(o["hydra:expects"]).map((e) => {
            const result = {
                method: o["hydra:method"],
                id: e["dcterms:identifier"],
                label: e["rdfs:label"]["@value"],
                body: $.extend(e, {
                    '@context': context
                }),
                uri
            };
            if (e['dul:hasParameter']) {
                result.body = $.extend(result.body, {
                    'dul:hasParameter': commonUtils.ensureArray(e['dul:hasParameter']).map(parseParameter)
                });
            }
            return result;
        });
    }

    function parseWAMPTopicFromCommandResults(res) {
        const operations = commonUtils.ensureArray(res["hydra-filter:viewOf"]["hydra:operation"]);
        const subscriptionOperation = operations.find((o) => {
            return o['@type'] === "hydra-pubsub:SubscribeOperation";
        });
        return {
            endpoint: subscriptionOperation['hydra-pubsub:endpoint'],
            topic: subscriptionOperation['hydra-pubsub:topic']
        };
    }

    function extractCommandResultFromWAMPMessage(data) {
        return {
            value: data["semiot:isResultOf"]["dcterms:identifier"],
            timestamp: data["semiot:commandResultTime"]["@value"]
        };
    }

    return {
        loadProcessInformation(uri) {
            console.info(`loading process info from ${uri}`);
{'fraction_non_alphanumeric': 0.1652542372881356, 'fraction_numerical': 0.022963367960634227, 'mean_word_length': 2.1043699618158676, 'pattern_counts': {'":': 56, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 6, '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': '5323184', 'n_tokens_mistral': 2435, 'n_tokens_neox': 2248, 'n_words': 262}