Skip to content

Commit

Permalink
[#62] Refactor Dagre constants to Vocabulary
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Nov 1, 2024
1 parent 96b700a commit bb79438
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/components/dagre/Dagre.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ import {
MODULE_VARIABLE_VALUE,
MODULE_VARIABLES,
SCRIPT_PATH,
MODULE_TYPE,
X_COORDINATE,
Y_COORDINATE,
EDGE,
SOURCE_NODE,
DESTINATION_NODE,
NODE,
COMPONENT,
INPUT_PARAMETER,
OUTPUT_PARAMETER,
GROUP,
LABEL,
} from "../../vocabularies/Vocabulary.js";
import SFormsModal from "../sform/SFormsModal";
import ModuleTypesSelection from "../ModuleTypesSelection";
Expand All @@ -30,24 +42,7 @@ 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 { useLocation } from "react-router-dom";

const rankDirOptions = [
// preset
Expand Down Expand Up @@ -82,10 +77,9 @@ const modalInputs = {
errorMessage: null,
};

class Dagre extends React.Component {
class DagrePage extends React.Component {
constructor(props) {
super(props);

const params = new URLSearchParams(props.location.search);
this.state = {
isLoaded: false,
Expand Down Expand Up @@ -128,6 +122,7 @@ class Dagre extends React.Component {
let result = new Map(validation.map((i) => [i[MODULE_URI], i]));
this.setState({ validationMap: result, validationOrigin: validation });
Rest.getScript(this.state.file, this.state.transformation).then((response) => {
console.log(response);
this._processGraph(response).then(() => {
this.renderCytoscapeElement();
});
Expand All @@ -153,7 +148,7 @@ class Dagre extends React.Component {
id: n["@id"],
label: label,
component: n[COMPONENT],
type: n[TYPE],
type: n[MODULE_TYPE],
input: n[INPUT_PARAMETER],
output: n[OUTPUT_PARAMETER],
variables: n[MODULE_VARIABLES],
Expand All @@ -164,7 +159,7 @@ class Dagre extends React.Component {
validation: this.state.validationMap.get(n["@id"]),
},
selectable: false,
position: { x: n[X], y: n[Y] },
position: { x: n[X_COORDINATE], y: n[Y_COORDINATE] },
});
}

Expand All @@ -175,16 +170,16 @@ class Dagre extends React.Component {
const newGroups = new Set(this.state.groups);

data[NODE].forEach((n) => {
if (n[TYPE] !== undefined) {
if (n[MODULE_TYPE] !== undefined) {
this._addNode(n, newNodes, newGroups);
}
});

data[EDGE].forEach((e) => {
if (e[SOURCE_NODE][TYPE] !== undefined) {
if (e[SOURCE_NODE][MODULE_TYPE] !== undefined) {
this._addNode(e[SOURCE_NODE], newNodes, newGroups);
}
if (e[DESTINATION_NODE][TYPE] !== undefined) {
if (e[DESTINATION_NODE][MODULE_TYPE] !== undefined) {
this._addNode(e[DESTINATION_NODE], newNodes, newGroups);
}
});
Expand Down Expand Up @@ -729,4 +724,9 @@ class Dagre extends React.Component {
}
}

const Dagre = (props) => {
const location = useLocation();
return <DagrePage {...props} location={location} />;
};

export default Dagre;
20 changes: 20 additions & 0 deletions src/vocabularies/Vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const S_PIPES_VIEW = "http://onto.fel.cvut.cz/ontologies/s-pipes-view";
export const SCRIPT_DTO = `${S_PIPES}/script-dto`;
export const QUESTION_DTO = `${S_PIPES}/question-dto`;
export const EXECUTION_FUNCTION_DTO = `${S_PIPES}/execution-function-dto`;
export const EXECUTION_MODULE_DTO = `${S_PIPES}/execution-module-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`;
Expand All @@ -15,6 +16,7 @@ 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 MODULE_TYPE = `${S_PIPES}/has-module-type`;
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`;
Expand All @@ -41,5 +43,23 @@ export const MODULE_EXECUTION_START_DATE = `${S_PIPES}/has-module-execution-star
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 OUTPUT_PARAMETER = `${S_PIPES}/has-output-parameter`;
export const ANSWERS = `${S_PIPES}/has_answer`;
export const FUNCTION_LOCAL_NAME = `${S_PIPES}/has-function-local-name`;
export const FUNCTION_URI = `${S_PIPES}/has-function-uri`;
export const OBJECT_VALUE = `${S_PIPES}/has_object_value`;

export const COMPONENT = `${S_PIPES_VIEW}/component`;
export const GROUP = `${S_PIPES_VIEW}/group`;
export const NODE = `${S_PIPES_VIEW}/consists-of-node`;
export const DESTINATION_NODE = `${S_PIPES_VIEW}/has-destination-node`;
export const SOURCE_NODE = `${S_PIPES_VIEW}/has-source-node`;
export const EDGE = `${S_PIPES_VIEW}/consists-of-edge`;
export const X_COORDINATE = `${S_PIPES_VIEW}/has-x-coordinate`;
export const Y_COORDINATE = `${S_PIPES_VIEW}/has-y-coordinate`;
export const MODULE_VARIABLE_NAME = `${S_PIPES_VIEW}/has-variable-name`;
export const MODULE_VARIABLE_VALUE = `${S_PIPES_VIEW}/has-variable-value`;

export const ICON = "http://topbraid.org/sparqlmotion#icon";
export const COMMENT = "http://www.w3.org/2000/01/rdf-schema#comment";
export const LABEL = "http://www.w3.org/2000/01/rdf-schema#label";

0 comments on commit bb79438

Please sign in to comment.