{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from controller.Helio_Mapping_Controller import Helio_Mapping_Controller" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "\n", "rdf = \"\"\"@prefix project: .\n", "@prefix platform: .\n", "@prefix facility: .\n", "@prefix dcterms: .\n", "@prefix element: .\n", "\n", "element:12345678-1234-1234-1234-123456789012\n", " a facility:Element .\n", "\n", "project:079637bb-87d5-4fef-9704-d556364d90ba\n", " a facility:Project ;\n", " platform:hasFile .\"\"\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "controller = Helio_Mapping_Controller(\"1234\", \"567890\", rdf, \"http://localhost:4567\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "controller.generate_single_mapping(\"mapping.template.edge\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Update Helio Mapping\n" ] } ], "source": [ "controller.post_mapping(\"single_mapping\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Retrieving Helio Mapping Data\n", "Helio Mapping Data Retrieved\n" ] } ], "source": [ "controller.get_mapping_data(\"single_mapping\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Triples Stored Properly\n" ] } ], "source": [ "print(controller.data.replace(\"\\n\\n\\n\", \"\").replace(\"\\n\\n\", \"\"))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from service.Graph_Service import Graph_Service" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "graph_service = Graph_Service(rdf)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "graph_service.serialize_graph()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "results = graph_service.get_files()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['8496ba81a9f6cacc5b4a554ff95733c79963cb0cc47f9bda87441835f8f46772',\n", " 'https://raw.githubusercontent.com/oeg-upm/cogito_data_repository/main/ifc/file.ifc']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "result_elements = graph_service.query_graph(graph_service.query_elements)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "len(result_elements)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for row in result_elements:\n", " print(row.element)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(graph_service.graph.serialize(format=\"turtle\"))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "graph_service.update_graph(graph_service.query_remove_files)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(graph_service.graph.serialize(format=\"turtle\"))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "a9c44c8ff930b067c6bc3f134a348d3cb9f19f01dfb46c39e0c18c228169b636" } } }, "nbformat": 4, "nbformat_minor": 2 }