diff --git a/src/server/utils/Constants.js b/src/server/utils/Constants.js index bfbe148..c2f53ff 100644 --- a/src/server/utils/Constants.js +++ b/src/server/utils/Constants.js @@ -4,6 +4,11 @@ const MODES = { READ_ONLY: "READ_ONLY", }; +const IRI_PROPERTY_NAME = "iri"; +const IRI_VIRTUAL_PROPERTY_NAME = "iri (Virtual)"; + module.exports = { MODES, + IRI_PROPERTY_NAME, + IRI_VIRTUAL_PROPERTY_NAME, }; diff --git a/src/server/utils/Database.js b/src/server/utils/Database.js index 9e042df..ec8b267 100644 --- a/src/server/utils/Database.js +++ b/src/server/utils/Database.js @@ -12,6 +12,8 @@ const RDF_REL_TABLE_SUFFIXES = ["_lt", "_rt"]; const CONSTANTS = require("./Constants"); const MODES = CONSTANTS.MODES; const READ_WRITE_MODE = MODES.READ_WRITE; +const IRI_PROPERTY_NAME = CONSTANTS.IRI_PROPERTY_NAME; +const IRI_VIRTUAL_PROPERTY_NAME = CONSTANTS.IRI_VIRTUAL_PROPERTY_NAME; let kuzu; if (process.env.NODE_ENV !== "production") { @@ -191,6 +193,17 @@ class Database { return name; }); }); + relTables.forEach((relTable) => { + if (rdfRelTables.has(relTable.name)) { + const indexOfVirtualProperty = relTable.properties.findIndex( + (property) => property.name === IRI_VIRTUAL_PROPERTY_NAME + ); + if (indexOfVirtualProperty > -1) { + relTable.properties[indexOfVirtualProperty].name = + IRI_PROPERTY_NAME; + } + } + }); nodeTables.sort((a, b) => a.name.localeCompare(b.name)); relTables.sort((a, b) => a.name.localeCompare(b.name)); relGroups.sort((a, b) => a.name.localeCompare(b.name)); diff --git a/src/store/SettingsStore.js b/src/store/SettingsStore.js index 1802940..ee22f56 100644 --- a/src/store/SettingsStore.js +++ b/src/store/SettingsStore.js @@ -6,7 +6,6 @@ import { PLACEHOLDER_REL_TABLE, GPT_MODELS, IRI_PROPERTY_NAME, - IRI_VIRTUAL_PROPERTY_NAME, } from "../utils/Constants"; const COLOR_PALETTE = [ @@ -187,10 +186,10 @@ export const useSettingsStore = defineStore("settings", { const relSettings = this.initDefaultRel(rel); if (rel.rdf) { const isIriPropertyExist = rel.properties.some( - (property) => property.name === IRI_VIRTUAL_PROPERTY_NAME + (property) => property.name === IRI_PROPERTY_NAME ); if (isIriPropertyExist) { - relSettings.label = IRI_VIRTUAL_PROPERTY_NAME; + relSettings.label = IRI_PROPERTY_NAME; } } this.graphViz.rels[rel.name] = relSettings; diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 993c508..437bcaa 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -76,4 +76,3 @@ export const PLACEHOLDER_NODE_TABLE = "__placeholder_node_table__"; export const PLACEHOLDER_REL_TABLE = "__placeholder_rel_table__"; export const IRI_PROPERTY_NAME = "iri"; -export const IRI_VIRTUAL_PROPERTY_NAME = "iri (Virtual)"; \ No newline at end of file diff --git a/src/utils/ValueFormatter.js b/src/utils/ValueFormatter.js index cd6a23c..d4b2f66 100644 --- a/src/utils/ValueFormatter.js +++ b/src/utils/ValueFormatter.js @@ -1,5 +1,8 @@ import Moment from "moment"; -import { DATA_TYPES, IRI_PROPERTY_NAME } from "./Constants"; +import { + DATA_TYPES, + IRI_PROPERTY_NAME, +} from "./Constants"; class ValueFormatter { constructor() { @@ -52,7 +55,11 @@ class ValueFormatter { } beautifyValue(value, type, propName = "") { - if (type === DATA_TYPES.STRING && propName === IRI_PROPERTY_NAME) { + if ( + type === DATA_TYPES.STRING && + (propName === IRI_PROPERTY_NAME) + ) { + console.log("IRI", value); if (value.startsWith("http")) { // Extract the last part of the IRI as the label const parts = value.split("/");