{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from model.WoT_TD_model import TD\n", "from service.WoT_TD_Service import TD_Service" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "thing = TD(\"uuid:cogito:test\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "service = TD_Service(thing)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "service.load_template()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "prefixes = [\n", " {\n", " \"name\":\"beo\",\n", " \"href\":\"https://pi.pauwel.be/voc/buildingelement#\"\n", " } # hardcode prefixes (read from file)\n", "]\n", "\n", "types = [\n", " \"bot:Building\",\n", " \"brick:Building\"\n", "]\n", "\n", "description = \"A building element.\"\n", "\n", "properties = [\n", " {\n", " \"name\": \"IFC\", # type of file\n", " \"href\": \"https://example_uri.com/files/cogito1234.ifc\", # uri of the file\n", " \"type\": \"application/ifc\" # type_name of the file\n", " },\n", " {\n", " \"name\": \"KnowledgeGraph\", # graph\n", " \"href\": \"https://openmetrics.eu/openmetrics#Building_120\", # uri of the graph\n", " \"type\": \"text/turtle\" # type_name of the graph\n", " },\n", " {\n", " \"name\": \"BuildingElement\", # property with the info of subject provided by the query\n", " },\n", " {\n", " \"name\": \"test1\",\n", " \"href\": \"https://example_test_url.com/test1\"\n", " },\n", " {\n", " \"name\": \"test2\",\n", " \"type\": \"text/plain\"\n", " }\n", "]\n", "\n", "actions = {}\n", "events = {}\n", "links = {}\n", "\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "service.set_variables_to_render(prefixes, types, description, properties, actions, events, links)\n", "service.info_to_render()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'uuid:cogito:test',\n", " 'prefixes': [{'name': 'beo',\n", " 'href': 'https://pi.pauwel.be/voc/buildingelement#'}],\n", " 'types': ['bot:Building', 'brick:Building'],\n", " 'description': 'A building element.',\n", " 'properties': [{'name': 'IFC',\n", " 'href': 'https://example_uri.com/files/cogito1234.ifc',\n", " 'type': 'application/ifc'},\n", " {'name': 'KnowledgeGraph',\n", " 'href': 'https://openmetrics.eu/openmetrics#Building_120',\n", " 'type': 'text/turtle'},\n", " {'name': 'BuildingElement'},\n", " {'name': 'test1', 'href': 'https://example_test_url.com/test1'},\n", " {'name': 'test2', 'type': 'text/plain'}],\n", " 'actions': {},\n", " 'events': {},\n", " 'links': {}}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "thing.get_info_to_render()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"@context\": [\n", " \"https://www.w3.org/2019/wot/td/v1\",\n", " {\n", " \"beo\": \"https://pi.pauwel.be/voc/buildingelement#)\"\n", " }\n", " ],\n", " \"id\": \"uuid:cogito:test\",\n", " \"@type\": [\n", " \"bot:Building\",\n", " \"brick:Building\"\n", " ],\n", " \"description\": \"Abuildingelement.\",\n", " \"properties\": {\n", " \"IFC\": {\n", " \"forms\": [\n", " {\n", " \"href\": \"https://example_uri.com/files/cogito1234.ifc\",\n", " \"type\": \"application/ifc\"\n", " }\n", " ]\n", " },\n", " \"KnowledgeGraph\": {\n", " \"forms\": [\n", " {\n", " \"href\": \"https://openmetrics.eu/openmetrics#Building_120\",\n", " \"type\": \"text/turtle\"\n", " }\n", " ]\n", " },\n", " \"BuildingElement\": {\n", " \"forms\": [\n", " {}\n", " ]\n", " },\n", " \"test1\": {\n", " \"forms\": [\n", " {\n", " \"href\": \"https://example_test_url.com/test1\"\n", " }\n", " ]\n", " },\n", " \"test2\": {\n", " \"forms\": [\n", " {\n", " \"type\": \"text/plain\"\n", " }\n", " ]\n", " }\n", " },\n", " \"security\": [\n", " \"no_sec\"\n", " ],\n", " \"securityDefinitions\": {\n", " \"no_sec\": {\n", " \"scheme\": \"none\"\n", " }\n", " },\n", " \"title\": \"uuid:cogito:test\"\n", "}\n" ] } ], "source": [ "service.generate_td()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.2 64-bit ('3.10.2')", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.2 (main, Jul 12 2022, 13:04:44) [Clang 13.1.6 (clang-1316.0.21.2.5)]" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "a9c44c8ff930b067c6bc3f134a348d3cb9f19f01dfb46c39e0c18c228169b636" } } }, "nbformat": 4, "nbformat_minor": 2 }