Skip to content
Snippets Groups Projects
Commit a145ca3d authored by Jonas Schlabertz's avatar Jonas Schlabertz
Browse files

Adds JSON-LD annotations to component, adds component targeting to API output.

parent c53c47d9
Branches
No related tags found
No related merge requests found
Pipeline #153437 passed
No preview for this file type
......@@ -95,6 +95,7 @@ export default class Component {
.leftJoinAndSelect("isComponentOf.child", "isComponentOfChild")
.leftJoinAndSelect("isComponentOf.parent", "isComponentOfParent")
.leftJoinAndSelect("information.type", "type")
.leftJoinAndSelect("component.isTargetOfInformation", "isTargetOfInformation")
.where("component.id != :rootIdFilter AND component.dateCreated <= :dateCreated::timestamptz AND parent.parent = :parentIsRootFilter", {
rootIdFilter: Component.rootId,
dateCreated: date,
......@@ -113,6 +114,7 @@ export default class Component {
.leftJoinAndSelect("isComponentOf.parent", "isComponentOfParent", "isComponentOf.parent != :rootId", { rootId: Component.rootId })
.leftJoinAndSelect("isComponentOf.child", "isComponentOfChild")
.leftJoinAndSelect("component.information", "information")
.leftJoinAndSelect("component.isTargetOfInformation", "isTargetOfInformation")
.leftJoinAndSelect("information.type", "type");
if(filter != null && filter.length > 0) {
......@@ -152,6 +154,7 @@ export default class Component {
.leftJoinAndSelect("isComponentOf.parent", "isComponentOfParent", "isComponentOf.parent != :rootId", { rootId: Component.rootId })
.leftJoinAndSelect("isComponentOf.child", "isComponentOfChild")
.leftJoinAndSelect("component.information", "information")
.leftJoinAndSelect("component.isTargetOfInformation", "isTargetOfInformation")
.leftJoinAndSelect("information.type", "type")
.where("component.id = :id AND component.dateCreated <= :date::timestamptz", { id, date })
.getOne();
......@@ -194,7 +197,7 @@ export default class Component {
};
if (this.isComponentOf) {
const relationJSONLD: Record<string, unknown>[] = this.isComponentOf.map((relation) => { return relation.toJSONLD(); });
const relationJSONLD: Record<string, unknown>[] = this.isComponentOf.map((relation) => { return { "@id": `${config.baseURL}/relation/${relation.id.toString()}` }; });
if (relationJSONLD.length == 1) {
document.isComponentOf = relationJSONLD[0];
} else {
......@@ -203,11 +206,15 @@ export default class Component {
}
if (this.subComponents) {
document.subComponents = this.subComponents.map((relation) => { return relation.toJSONLD(); });
document.subComponents = this.subComponents.map((relation) => { return { "@id": `${config.baseURL}/relation/${relation.id.toString()}` }; });
}
if (this.information) {
document.information = this.information.map((information) => { return information.toJSONLD(); });
document.information = this.information.map((information) => { return { "@id": `${config.baseURL}/information/${information.id.toString()}` }; });
}
if (this.isTargetOfInformation) {
document.isTargetOfInformation = this.isTargetOfInformation.map((information) => { return { "@id": `${config.baseURL}/information/${information.id.toString()}` }; });
}
return document;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment