diff --git a/src/components/Executions.jsx b/src/components/Executions.jsx index ec82cd1..880ee48 100644 --- a/src/components/Executions.jsx +++ b/src/components/Executions.jsx @@ -6,10 +6,10 @@ import { DISPLAY_NAME, EXECUTION_DURATION, FINISH_DATE_UNIX, - Rest, START_DATE_UNIX, TRANSFORMATION, -} from "./rest/Rest"; +} from "../constants/Vocabulary.js"; +import Rest from "./rest/Rest.jsx"; import { Col, Container, Row, Table } from "react-bootstrap"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faMugHot, faTrash, faRunning, faPlayCircle, faEdit, faQuestion } from "@fortawesome/free-solid-svg-icons"; diff --git a/src/components/ModuleTypesSelection.jsx b/src/components/ModuleTypesSelection.jsx index bfa0286..a8e7475 100644 --- a/src/components/ModuleTypesSelection.jsx +++ b/src/components/ModuleTypesSelection.jsx @@ -1,6 +1,6 @@ import React from "react"; import { Dropdown } from "semantic-ui-react"; -import { Rest } from "./rest/Rest"; +import Rest from "./rest/Rest"; import { ICONS_MAP } from "./dagre/DagreIcons"; class ModuleTypesSelection extends React.Component { diff --git a/src/components/ScriptFunctionSelection.jsx b/src/components/ScriptFunctionSelection.jsx index bcdc176..b786b33 100644 --- a/src/components/ScriptFunctionSelection.jsx +++ b/src/components/ScriptFunctionSelection.jsx @@ -1,6 +1,7 @@ import React from "react"; import { Dropdown } from "semantic-ui-react"; -import { FUNCTION, FUNCTION_NAME, Rest } from "./rest/Rest"; +import { FUNCTION_URI, FUNCTION_NAME } from "../constants/Vocabulary.js"; +import Rest from "./rest/Rest.jsx"; import { ICONS_MAP } from "./dagre/DagreIcons"; class ScriptFunctionSelection extends React.Component { @@ -15,9 +16,9 @@ class ScriptFunctionSelection extends React.Component { Rest.getModulesFunctions(this.props.scriptPath).then((res) => { const options = res.map((r) => { return { - key: r[FUNCTION], + key: r[FUNCTION_URI], text: r[FUNCTION_NAME], - value: r[FUNCTION], + value: r[FUNCTION_URI], image: { avatar: true, src: "/icons/fire-extinguisher.png" }, }; }); diff --git a/src/components/dagre/Dagre.jsx b/src/components/dagre/Dagre.jsx index 92b3872..d2a8428 100644 --- a/src/components/dagre/Dagre.jsx +++ b/src/components/dagre/Dagre.jsx @@ -6,14 +6,7 @@ import cxtmenu from "cytoscape-cxtmenu"; import popper from "cytoscape-popper"; import navigator from "cytoscape-navigator"; import expandCollapse from "cytoscape-expand-collapse"; -import { - MODULE_URI, - MODULE_VARIABLE_NAME, - MODULE_VARIABLE_VALUE, - MODULE_VARIABLES, - Rest, - SCRIPT_PATH, -} from "../rest/Rest"; +import Rest from "../rest/Rest.jsx"; import NavbarMenu from "../NavbarMenu"; import SFormsModal from "../sform/SFormsModal"; import ModuleTypesSelection from "../ModuleTypesSelection"; @@ -31,24 +24,31 @@ import SFormsFunctionModal from "../sform/SFormsFunctionModal"; import "@kbss-cvut/s-forms/css"; import Loading from "../Loading"; import ErrorModal from "../modal/ErrorModal"; -const TYPE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-module-type"; -const LABEL = "http://www.w3.org/2000/01/rdf-schema#label"; -const X = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-x-coordinate"; -const Y = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-y-coordinate"; -const EDGE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/consists-of-edge"; -const SOURCE_NODE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-source-node"; -const DESTINATION_NODE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-destination-node"; -const NODE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/consists-of-node"; -const ICON = "http://topbraid.org/sparqlmotion#icon"; -const COMMENT = "http://www.w3.org/2000/01/rdf-schema#comment"; -const ANSWERS = "http://onto.fel.cvut.cz/ontologies/documentation/has_answer"; -const OBJECT_VALUE = "http://onto.fel.cvut.cz/ontologies/documentation/has_object_value"; -const COMPONENT = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/component"; -const FUNCTION_LOCAL_NAME = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-function-local-name"; -const FUNCTION_URI = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-function-uri"; -const INPUT_PARAMETER = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-input-parameter"; -const OUTPUT_PARAMETER = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-output-parameter"; -const GROUP = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/group"; +import { + TYPE, + LABEL, + X, + Y, + EDGE, + SOURCE_NODE, + DESTINATION_NODE, + NODE, + ICON, + COMMENT, + ANSWERS, + OBJECT_VALUE, + COMPONENT, + FUNCTION_LOCAL_NAME, + FUNCTION_URI, + INPUT_PARAMETER, + OUTPUT_PARAMETER, + GROUP, + MODULE_URI, + MODULE_VARIABLE_NAME, + MODULE_VARIABLE_VALUE, + MODULE_VARIABLES, + SCRIPT_PATH, +} from "../../constants/Vocabulary.js"; const rankDirOptions = [ // preset diff --git a/src/components/modal/ErrorModal.jsx b/src/components/modal/ErrorModal.jsx index c7cce97..15409e3 100644 --- a/src/components/modal/ErrorModal.jsx +++ b/src/components/modal/ErrorModal.jsx @@ -1,7 +1,6 @@ import React from "react"; import { Button, Form, Modal } from "react-bootstrap"; -import { Rest } from "../rest/Rest"; class ErrorModal extends React.Component { constructor(props) { diff --git a/src/components/modal/MoveModuleModal.jsx b/src/components/modal/MoveModuleModal.jsx index 552d1f4..42e9b6a 100644 --- a/src/components/modal/MoveModuleModal.jsx +++ b/src/components/modal/MoveModuleModal.jsx @@ -9,12 +9,12 @@ import { FINISH_DATE_UNIX, MODULE_URI, ONTOLOGY_URI, - Rest, RULE_COMMENT, SCRIPT_PATH, START_DATE_UNIX, TRANSFORMATION, -} from "../rest/Rest"; +} from "../../constants/Vocabulary.js"; +import Rest from "../rest/Rest.jsx"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faEdit, faMugHot, faPlayCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; import { Link } from "react-router-dom"; diff --git a/src/components/modal/ScriptActionsModuleModal.jsx b/src/components/modal/ScriptActionsModuleModal.jsx index bcee202..2b6ed58 100644 --- a/src/components/modal/ScriptActionsModuleModal.jsx +++ b/src/components/modal/ScriptActionsModuleModal.jsx @@ -9,12 +9,11 @@ import { FINISH_DATE_UNIX, MODULE_URI, ONTOLOGY_URI, - Rest, RULE_COMMENT, SCRIPT_PATH, START_DATE_UNIX, TRANSFORMATION, -} from "../rest/Rest"; +} from "../../constants/Vocabulary.js"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faEdit, faMugHot, faPlayCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; import { Link } from "react-router-dom"; diff --git a/src/components/modal/ScriptExecutionModal.jsx b/src/components/modal/ScriptExecutionModal.jsx index efd98df..c884852 100644 --- a/src/components/modal/ScriptExecutionModal.jsx +++ b/src/components/modal/ScriptExecutionModal.jsx @@ -6,14 +6,13 @@ import { MODULE_EXECUTION_START_DATE, MODULE_EXECUTION_DURATION, MODULE_URI, - Rest, MODULE_INPUT_PATH, MODULE_OUTPUT_PATH, EXECUTION_VARIABLE, MODULE_VARIABLES, MODULE_VARIABLE_NAME, MODULE_VARIABLE_VALUE, -} from "../rest/Rest"; +} from "../../constants/Vocabulary.js"; import { faDownload, faMugHot } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; diff --git a/src/components/modal/ScriptOntologyModal.jsx b/src/components/modal/ScriptOntologyModal.jsx index 0cf2c38..d7418bf 100644 --- a/src/components/modal/ScriptOntologyModal.jsx +++ b/src/components/modal/ScriptOntologyModal.jsx @@ -9,12 +9,11 @@ import { FINISH_DATE_UNIX, MODULE_URI, ONTOLOGY_URI, - Rest, RULE_COMMENT, SCRIPT_PATH, START_DATE_UNIX, TRANSFORMATION, -} from "../rest/Rest"; +} from "../../constants/Vocabulary.js"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faEdit, faMugHot, faPlayCircle, faPlusCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; import { Link } from "react-router-dom"; diff --git a/src/components/modal/ValidationReportModal.jsx b/src/components/modal/ValidationReportModal.jsx index 1f5ba9e..c9a4ef6 100644 --- a/src/components/modal/ValidationReportModal.jsx +++ b/src/components/modal/ValidationReportModal.jsx @@ -8,11 +8,11 @@ import { EXECUTION_DURATION, FINISH_DATE_UNIX, MODULE_URI, - Rest, RULE_COMMENT, START_DATE_UNIX, TRANSFORMATION, -} from "../rest/Rest"; +} from "../../constants/Vocabulary.js"; +import Rest from "../rest/Rest.jsx"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faEdit, faMugHot, faPlayCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; import { Link } from "react-router-dom"; diff --git a/src/components/rest/Rest.jsx b/src/components/rest/Rest.jsx index 857dde8..e39f74c 100644 --- a/src/components/rest/Rest.jsx +++ b/src/components/rest/Rest.jsx @@ -1,47 +1,5 @@ import React from "react"; - -//TODO - refactor to separate -export const SCRIPT_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/script-dto"; -export const QUESTION_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/question-dto"; -export const ROOT_QUESTION = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-root-question"; -export const SCRIPT_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-script-path"; -export const MODULE_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/module-dto"; -export const DEPENDENCY_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/dependency-dto"; -export const MOVE_MODULE_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/move-module-dto"; -export const ABSOLUTE_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-absolute-path"; -export const MODULE_URI = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-uri"; -export const RULE_COMMENT = "http://onto.fel.cvut.cz/ontologies/s-pipes/rule-comment"; -export const ERROR_MESSAGE = "http://onto.fel.cvut.cz/ontologies/s-pipes/error-message"; -export const MODULE_LOG = "http://onto.fel.cvut.cz/ontologies/s-pipes/module-log-dto"; -export const MODULE_TYPE_URI = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-type-uri"; -export const TARGET_MODULE_URI = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-target-module-uri"; -export const TRANSFORMATION_ID = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-transformation-id"; -export const DISPLAY_NAME = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-display-name"; -export const START_DATE_UNIX = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-pipeline-execution-start-date-unix"; -export const FINISH_DATE_UNIX = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-pipeline-execution-finish-date-unix"; -export const EXECUTION_DURATION = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-pipeline-execution-duration"; -export const TRANSFORMATION = "http://onto.fel.cvut.cz/ontologies/dataset-descriptor/transformation"; -export const FUNCTION = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-function-uri"; -export const FUNCTION_NAME = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-function-local-name"; -export const ONTOLOGY_URI = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-ontology-uri"; -export const SCRIPT_NAME = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-name"; -export const SCRIPT_CREATE_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/script-create-dto"; -export const SCRIPT_ONTOLOGY_CREATE_DTO = "http://onto.fel.cvut.cz/ontologies/s-pipes/script-ontology-create-dto"; -export const MODULE_FROM_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-from-path"; -export const MODULE_TO_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-to-path"; -export const RENAME_MODULE = "http://onto.fel.cvut.cz/ontologies/s-pipes/rename-module"; -export const EXECUTION_INFO = "http://onto.fel.cvut.cz/ontologies/s-pipes/module-execution-info"; -export const EXECUTION_VARIABLE = "http://onto.fel.cvut.cz/ontologies/s-pipes/execution-variable-dto"; -export const MODULE_VARIABLES = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-variables"; -export const MODULE_EXECUTION_DURATION = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-execution-duration"; -export const MODULE_EXECUTION_START_DATE = - "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-execution-start-date-unix"; -export const MODULE_EXECUTION_FINISH_DATE = - "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-execution-finish-date-unix"; -export const MODULE_INPUT_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-input-path"; -export const MODULE_OUTPUT_PATH = "http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-output-path"; -export const MODULE_VARIABLE_NAME = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-variable-name"; -export const MODULE_VARIABLE_VALUE = "http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-variable-value"; +import * as Vocabulary from "../../constants/Vocabulary.js"; const postRequestOptions = { method: "POST", @@ -51,8 +9,7 @@ const postRequestOptions = { }, }; -//TODO consider React api -export const Rest = { +const Rest = { getScripts: function () { return fetch("/rest/scripts") .then((res) => res.json()) @@ -67,9 +24,9 @@ export const Rest = { getScript: function (script, transformation) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [SCRIPT_PATH]: script, - [TRANSFORMATION_ID]: transformation, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.SCRIPT_PATH]: script, + [Vocabulary.TRANSFORMATION_ID]: transformation, }); return fetch("/rest/views/new", postRequestOptions) .then((res) => res.json()) @@ -80,8 +37,8 @@ export const Rest = { deleteScript: function (script) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: script, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: script, }); return fetch("/rest/scripts/delete", postRequestOptions).then((result) => { return result; @@ -90,8 +47,8 @@ export const Rest = { getScriptOntologies: function (script) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: script, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: script, }); return fetch("/rest/scripts/ontologies", postRequestOptions) .then((res) => res.json()) @@ -102,9 +59,9 @@ export const Rest = { removeScriptOwnOntology: function (script, ontologyURI) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_ONTOLOGY_CREATE_DTO, - [SCRIPT_PATH]: script, - [ONTOLOGY_URI]: ontologyURI, + "@type": Vocabulary.SCRIPT_ONTOLOGY_CREATE_DTO, + [Vocabulary.SCRIPT_PATH]: script, + [Vocabulary.ONTOLOGY_URI]: ontologyURI, }); return fetch("/rest/scripts/ontology/remove", postRequestOptions).then((result) => { return result; @@ -113,9 +70,9 @@ export const Rest = { addScriptOwnOntology: function (script, ontologyURI) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_ONTOLOGY_CREATE_DTO, - [SCRIPT_PATH]: script, - [ONTOLOGY_URI]: ontologyURI, + "@type": Vocabulary.SCRIPT_ONTOLOGY_CREATE_DTO, + [Vocabulary.SCRIPT_PATH]: script, + [Vocabulary.ONTOLOGY_URI]: ontologyURI, }); return fetch("/rest/scripts/ontology/add", postRequestOptions).then((result) => { return result; @@ -124,8 +81,8 @@ export const Rest = { getScriptOwnOntology: function (script) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: script, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: script, }); return fetch("/rest/scripts/own-ontology", postRequestOptions) .then((res) => res.json()) @@ -136,10 +93,10 @@ export const Rest = { getScriptForm: function (moduleTypeUri, moduleUri, scriptPath) { postRequestOptions["body"] = JSON.stringify({ - "@type": QUESTION_DTO, - [MODULE_TYPE_URI]: moduleTypeUri, - [MODULE_URI]: moduleUri, - [SCRIPT_PATH]: scriptPath, + "@type": Vocabulary.QUESTION_DTO, + [Vocabulary.MODULE_TYPE_URI]: moduleTypeUri, + [Vocabulary.MODULE_URI]: moduleUri, + [Vocabulary.SCRIPT_PATH]: scriptPath, }); return fetch("/rest/scripts/forms", postRequestOptions) .then((res) => res.json()) @@ -150,9 +107,9 @@ export const Rest = { getFunctionForm: function (scriptPath, functionUri) { postRequestOptions["body"] = JSON.stringify({ - "@type": "http://onto.fel.cvut.cz/ontologies/s-pipes/execution-function-dto", - [SCRIPT_PATH]: scriptPath, - [FUNCTION]: functionUri, + "@type": Vocabulary.EXECUTION_FUNCTION_DTO, + [Vocabulary.SCRIPT_PATH]: scriptPath, + [Vocabulary.FUNCTION_URI]: functionUri, }); return fetch("/rest/function/form", postRequestOptions) .then((res) => res.json()) @@ -163,10 +120,10 @@ export const Rest = { createScript: function (ontologyURI, scriptName, scriptPath) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_CREATE_DTO, - [ONTOLOGY_URI]: ontologyURI, - [SCRIPT_NAME]: scriptName, - [SCRIPT_PATH]: scriptPath, + "@type": Vocabulary.SCRIPT_CREATE_DTO, + [Vocabulary.ONTOLOGY_URI]: ontologyURI, + [Vocabulary.SCRIPT_NAME]: scriptName, + [Vocabulary.SCRIPT_PATH]: scriptPath, }); return fetch("/rest/scripts/create", postRequestOptions).then((result) => { return result; @@ -175,8 +132,8 @@ export const Rest = { getLogForm: function (logPath) { postRequestOptions["body"] = JSON.stringify({ - "@type": MODULE_LOG, - [ABSOLUTE_PATH]: logPath, + "@type": Vocabulary.MODULE_LOG, + [Vocabulary.ABSOLUTE_PATH]: logPath, }); return fetch("/rest/scripts/load-log", postRequestOptions) .then((res) => res.json()) @@ -187,10 +144,10 @@ export const Rest = { updateScriptForm: function (moduleTypeUri, rootQuestion, scriptPath) { postRequestOptions["body"] = JSON.stringify({ - "@type": QUESTION_DTO, - [MODULE_TYPE_URI]: moduleTypeUri, - [ROOT_QUESTION]: rootQuestion, - [SCRIPT_PATH]: scriptPath, + "@type": Vocabulary.QUESTION_DTO, + [Vocabulary.MODULE_TYPE_URI]: moduleTypeUri, + [Vocabulary.ROOT_QUESTION]: rootQuestion, + [Vocabulary.SCRIPT_PATH]: scriptPath, }); console.log("update script json: " + postRequestOptions); return fetch("/rest/scripts/forms/answers", postRequestOptions); @@ -198,30 +155,30 @@ export const Rest = { deleteScriptNode: function (filepath, nodeId) { postRequestOptions["body"] = JSON.stringify({ - "@type": MODULE_DTO, - [ABSOLUTE_PATH]: filepath, - [MODULE_URI]: nodeId, + "@type": Vocabulary.MODULE_DTO, + [Vocabulary.ABSOLUTE_PATH]: filepath, + [Vocabulary.MODULE_URI]: nodeId, }); return fetch("/rest/scripts/modules/delete", postRequestOptions); }, deleteScriptEdge: function (filepath, fromNodeId, toNodeId) { postRequestOptions["body"] = JSON.stringify({ - "@type": DEPENDENCY_DTO, - [ABSOLUTE_PATH]: filepath, - [MODULE_URI]: fromNodeId, - [TARGET_MODULE_URI]: toNodeId, + "@type": Vocabulary.DEPENDENCY_DTO, + [Vocabulary.ABSOLUTE_PATH]: filepath, + [Vocabulary.MODULE_URI]: fromNodeId, + [Vocabulary.TARGET_MODULE_URI]: toNodeId, }); return fetch("/rest/scripts/modules/dependencies/delete", postRequestOptions); }, moveModule: function (fromScript, toScript, moduleUri, rename) { postRequestOptions["body"] = JSON.stringify({ - "@type": MOVE_MODULE_DTO, - [MODULE_FROM_PATH]: fromScript, - [MODULE_TO_PATH]: toScript, - [MODULE_URI]: moduleUri, - [RENAME_MODULE]: rename, + "@type": Vocabulary.MOVE_MODULE_DTO, + [Vocabulary.MODULE_FROM_PATH]: fromScript, + [Vocabulary.MODULE_TO_PATH]: toScript, + [Vocabulary.MODULE_URI]: moduleUri, + [Vocabulary.RENAME_MODULE]: rename, }); return fetch("/rest/scripts/modules/move", postRequestOptions).then((result) => { return result; @@ -230,8 +187,8 @@ export const Rest = { getModulesTypes: function (filepath) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: filepath, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: filepath, }); return fetch("/rest/scripts/moduleTypes", postRequestOptions) .then((res) => res.json()) @@ -242,8 +199,8 @@ export const Rest = { getModulesFunctions: function (filepath) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: filepath, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: filepath, }); return fetch("/rest/function/script", postRequestOptions) .then((res) => res.json()) @@ -254,20 +211,20 @@ export const Rest = { executeFunction: function (functionUri, params) { postRequestOptions["body"] = JSON.stringify({ - "@type": "http://onto.fel.cvut.cz/ontologies/s-pipes/execution-function-dto", - ["http://onto.fel.cvut.cz/ontologies/s-pipes/has-function-uri"]: functionUri, - ["http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-parameter"]: params, + "@type": Vocabulary.EXECUTION_FUNCTION_DTO, + [Vocabulary.FUNCTION_URI]: functionUri, + [Vocabulary.PARAMETER]: params, }); return fetch("/rest/function/execute", postRequestOptions); }, executeModule: function (scriptPath, moduleURI, moduleInput, params) { postRequestOptions["body"] = JSON.stringify({ - "@type": "http://onto.fel.cvut.cz/ontologies/s-pipes/execution-module-dto", - ["http://onto.fel.cvut.cz/ontologies/s-pipes/has-script-path"]: scriptPath, - ["http://onto.fel.cvut.cz/ontologies/s-pipes/has-module-uri"]: moduleURI, - ["http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-input-parameter"]: moduleInput, - ["http://onto.fel.cvut.cz/ontologies/s-pipes-view/has-parameter"]: params, + "@type": Vocabulary.EXECUTION_MODULE_DTO, + [Vocabulary.SCRIPT_PATH]: scriptPath, + [Vocabulary.MODULE_URI]: moduleURI, + [Vocabulary.INPUT_PARAMETER]: moduleInput, + [Vocabulary.PARAMETER]: params, }); return fetch("/rest/function/module/execute", postRequestOptions) .then((res) => res.text()) @@ -278,18 +235,18 @@ export const Rest = { addModuleDependency: function (scriptPath, moduleUri, targetModuleUri) { postRequestOptions["body"] = JSON.stringify({ - "@type": DEPENDENCY_DTO, - [ABSOLUTE_PATH]: scriptPath, - [MODULE_URI]: moduleUri, - [TARGET_MODULE_URI]: targetModuleUri, + "@type": Vocabulary.DEPENDENCY_DTO, + [Vocabulary.ABSOLUTE_PATH]: scriptPath, + [Vocabulary.MODULE_URI]: moduleUri, + [Vocabulary.TARGET_MODULE_URI]: targetModuleUri, }); return fetch("/rest/scripts/modules/dependency", postRequestOptions); }, validateScript: function (filepath) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [ABSOLUTE_PATH]: filepath, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.ABSOLUTE_PATH]: filepath, }); return fetch("/rest/scripts/validate", postRequestOptions) .then((res) => res.json()) @@ -300,8 +257,8 @@ export const Rest = { getScriptModuleExecution: function (transformationId) { postRequestOptions["body"] = JSON.stringify({ - "@type": SCRIPT_DTO, - [TRANSFORMATION_ID]: transformationId, + "@type": Vocabulary.SCRIPT_DTO, + [Vocabulary.TRANSFORMATION_ID]: transformationId, }); return fetch("/rest/execution/history-modules", postRequestOptions) .then((res) => res.json()) @@ -310,3 +267,5 @@ export const Rest = { }); }, }; + +export default Rest; diff --git a/src/components/sform/SFormsFunctionModal.jsx b/src/components/sform/SFormsFunctionModal.jsx index a891e9d..cae3849 100644 --- a/src/components/sform/SFormsFunctionModal.jsx +++ b/src/components/sform/SFormsFunctionModal.jsx @@ -2,7 +2,7 @@ import React from "react"; import SForms from "@kbss-cvut/s-forms"; import { Button, Modal } from "react-bootstrap"; -import { Rest } from "../rest/Rest"; +import Rest from "../rest/Rest"; import "@triply/yasgui/build/yasgui.min.css"; import ErrorModal from "../modal/ErrorModal"; import ScriptActionsModuleModal from "../modal/ScriptActionsModuleModal"; diff --git a/src/components/sform/SFormsModal.jsx b/src/components/sform/SFormsModal.jsx index 7f1a32b..7857630 100644 --- a/src/components/sform/SFormsModal.jsx +++ b/src/components/sform/SFormsModal.jsx @@ -1,7 +1,7 @@ import React from "react"; import SForms from "@kbss-cvut/s-forms"; import { Button, Modal } from "react-bootstrap"; -import { Rest } from "../rest/Rest"; +import Rest from "../rest/Rest"; import Loading from "../Loading"; import "@triply/yasgui/build/yasgui.min.css"; import ErrorModal from "../modal/ErrorModal"; diff --git a/src/components/sform/ScriptInputOutputModal.jsx b/src/components/sform/ScriptInputOutputModal.jsx index ab05e25..07c6b2f 100644 --- a/src/components/sform/ScriptInputOutputModal.jsx +++ b/src/components/sform/ScriptInputOutputModal.jsx @@ -1,7 +1,7 @@ import React from "react"; import { Alert, Button, Form, Modal } from "react-bootstrap"; -import { Rest } from "../rest/Rest"; +import Rest from "../rest/Rest"; import Yasgui from "@triply/yasgui"; import "@triply/yasgui/build/yasgui.min.css"; import JSONPretty from "react-json-pretty"; diff --git a/src/components/treebeard/ScriptsTree.jsx b/src/components/treebeard/ScriptsTree.jsx index f0b0910..6e05cda 100644 --- a/src/components/treebeard/ScriptsTree.jsx +++ b/src/components/treebeard/ScriptsTree.jsx @@ -4,7 +4,7 @@ import { includes } from "lodash"; import styles from "./styles"; import Header from "./Header"; import { Treebeard, decorators } from "react-treebeard"; -import { Rest } from "../rest/Rest"; +import Rest from "../rest/Rest"; import { withRouter } from "react-router-dom"; import ScriptActionsModuleModal from "../modal/ScriptActionsModuleModal"; import Loading from "../Loading"; diff --git a/src/constants/Vocabulary.js b/src/constants/Vocabulary.js new file mode 100644 index 0000000..9f9c5ee --- /dev/null +++ b/src/constants/Vocabulary.js @@ -0,0 +1,64 @@ +export const S_PIPES = "http://onto.fel.cvut.cz/ontologies/s-pipes"; +export const S_PIPES_VIEW = "http://onto.fel.cvut.cz/ontologies/s-pipes-view"; + +export const EXECUTION_MODULE_DTO = `${S_PIPES}/execution-module-dto`; +export const EXECUTION_FUNCTION_DTO = `${S_PIPES}/execution-function-dto`; +export const SCRIPT_DTO = `${S_PIPES}/script-dto`; +export const QUESTION_DTO = `${S_PIPES}/question-dto`; +export const ROOT_QUESTION = `${S_PIPES}/has-root-question`; +export const SCRIPT_PATH = `${S_PIPES}/has-script-path`; +export const MODULE_DTO = `${S_PIPES}/module-dto`; +export const DEPENDENCY_DTO = `${S_PIPES}/dependency-dto`; +export const MOVE_MODULE_DTO = `${S_PIPES}/move-module-dto`; +export const ABSOLUTE_PATH = `${S_PIPES}/has-absolute-path`; +export const MODULE_URI = `${S_PIPES}/has-module-uri`; +export const RULE_COMMENT = `${S_PIPES}/rule-comment`; +export const ERROR_MESSAGE = `${S_PIPES}/error-message`; +export const MODULE_LOG = `${S_PIPES}/module-log-dto`; +export const MODULE_TYPE_URI = `${S_PIPES}/has-module-type-uri`; +export const TARGET_MODULE_URI = `${S_PIPES}/has-target-module-uri`; +export const TRANSFORMATION_ID = `${S_PIPES}/has-transformation-id`; +export const DISPLAY_NAME = `${S_PIPES}/has-display-name`; +export const START_DATE_UNIX = `${S_PIPES}/has-pipeline-execution-start-date-unix`; +export const FINISH_DATE_UNIX = `${S_PIPES}/has-pipeline-execution-finish-date-unix`; +export const EXECUTION_DURATION = `${S_PIPES}/has-pipeline-execution-duration`; +export const TRANSFORMATION = "http://onto.fel.cvut.cz/ontologies/dataset-descriptor/transformation"; // left unchanged +export const FUNCTION_URI = `${S_PIPES}/has-function-uri`; +export const FUNCTION_NAME = `${S_PIPES}/has-function-local-name`; +export const ONTOLOGY_URI = `${S_PIPES}/has-ontology-uri`; +export const SCRIPT_NAME = `${S_PIPES}/has-name`; +export const SCRIPT_CREATE_DTO = `${S_PIPES}/script-create-dto`; +export const SCRIPT_ONTOLOGY_CREATE_DTO = `${S_PIPES}/script-ontology-create-dto`; +export const MODULE_FROM_PATH = `${S_PIPES}/has-module-from-path`; +export const MODULE_TO_PATH = `${S_PIPES}/has-module-to-path`; +export const RENAME_MODULE = `${S_PIPES}/rename-module`; +export const EXECUTION_INFO = `${S_PIPES}/module-execution-info`; +export const EXECUTION_VARIABLE = `${S_PIPES}/execution-variable-dto`; +export const MODULE_VARIABLES = `${S_PIPES}/has-module-variables`; +export const MODULE_EXECUTION_DURATION = `${S_PIPES}/has-module-execution-duration`; +export const MODULE_EXECUTION_START_DATE = `${S_PIPES}/has-module-execution-start-date-unix`; +export const MODULE_EXECUTION_FINISH_DATE = `${S_PIPES}/has-module-execution-finish-date-unix`; +export const MODULE_INPUT_PATH = `${S_PIPES}/has-module-input-path`; +export const MODULE_OUTPUT_PATH = `${S_PIPES}/has-module-output-path`; +export const PARAMETER = `${S_PIPES}/has-parameter`; +export const FUNCTION_LOCAL_NAME = `${S_PIPES}/has-function-local-name`; + +export const X = `${S_PIPES_VIEW}/has-x-coordinate`; +export const Y = `${S_PIPES_VIEW}/has-y-coordinate`; +export const EDGE = `${S_PIPES_VIEW}/consists-of-edge`; +export const SOURCE_NODE = `${S_PIPES_VIEW}/has-source-node`; +export const DESTINATION_NODE = `${S_PIPES_VIEW}/has-destination-node`; +export const NODE = `${S_PIPES_VIEW}/consists-of-node`; +export const COMPONENT = `${S_PIPES_VIEW}/component`; +export const OUTPUT_PARAMETER = `${S_PIPES_VIEW}/has-output-parameter`; +export const INPUT_PARAMETER = `${S_PIPES_VIEW}/has-input-parameter`; +export const GROUP = `${S_PIPES_VIEW}/group`; +export const MODULE_VARIABLE_NAME = `${S_PIPES_VIEW}/has-variable-name`; +export const MODULE_VARIABLE_VALUE = `${S_PIPES_VIEW}/has-variable-value`; +export const TYPE = `${S_PIPES_VIEW}/has-module-type`; + +export const LABEL = "http://www.w3.org/2000/01/rdf-schema#label"; +export const ICON = "http://topbraid.org/sparqlmotion#icon"; +export const COMMENT = "http://www.w3.org/2000/01/rdf-schema#comment"; +export const ANSWERS = "http://onto.fel.cvut.cz/ontologies/documentation/has_answer"; +export const OBJECT_VALUE = "http://onto.fel.cvut.cz/ontologies/documentation/has_object_value";