Skip to content

Commit

Permalink
Fix iri property name
Browse files Browse the repository at this point in the history
  • Loading branch information
mewim committed Feb 8, 2024
1 parent 1f178d5 commit fc97262
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/server/utils/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
13 changes: 13 additions & 0 deletions src/server/utils/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 2 additions & 3 deletions src/store/SettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
PLACEHOLDER_REL_TABLE,
GPT_MODELS,
IRI_PROPERTY_NAME,
IRI_VIRTUAL_PROPERTY_NAME,
} from "../utils/Constants";

const COLOR_PALETTE = [
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/utils/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
11 changes: 9 additions & 2 deletions src/utils/ValueFormatter.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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("/");
Expand Down

0 comments on commit fc97262

Please sign in to comment.