comparison src/layout/ViewConfig.ts @ 122:2e8fa3fec0c8

support joining subjects into wider rows
author drewp@bigasterisk.com
date Sun, 20 Mar 2022 14:12:03 -0700
parents 3cdbbd913f1d
children 5a1a79f54779
comparison
equal deleted inserted replaced
121:3584f24becf4 122:2e8fa3fec0c8
10 return e; 10 return e;
11 } 11 }
12 throw new Error("no elems"); 12 throw new Error("no elems");
13 } 13 }
14 14
15 export interface TableDesc { 15 export interface Link {
16 // If you display a subject u1 with a `pred` edge to u2, then treat u2 as an alias of u1.
17 pred: NamedNode;
18 }
19
20 interface TableDesc {
16 uri: NamedNode; 21 uri: NamedNode;
17 primary: NamedNode; 22 primary: NamedNode;
18 joins: NamedNode[]; 23 joins: NamedNode[];
24 links: Link[];
19 } 25 }
20 26
21 export class ViewConfig { 27 export class ViewConfig {
22 graph: Store; 28 graph: Store;
23 viewRoot!: NamedNode; 29 viewRoot!: NamedNode;
52 const joins: NamedNode[] = []; 58 const joins: NamedNode[] = [];
53 for (let joinType of this.graph.getObjects(table, EX("joinType"), null)) { 59 for (let joinType of this.graph.getObjects(table, EX("joinType"), null)) {
54 joins.push(joinType as NamedNode); 60 joins.push(joinType as NamedNode);
55 } 61 }
56 joins.sort(); 62 joins.sort();
63
64 const links: Link[] = [];
65 for (let linkDesc of this.graph.getObjects(table, EX("link"), null)) {
66 links.push({
67 pred: uriValue(this.graph, linkDesc, EX("predicate")),
68 });
69 }
70
57 this.tables.push({ 71 this.tables.push({
58 uri: table as NamedNode, 72 uri: table as NamedNode,
59 primary: tableType, 73 primary: tableType,
60 joins: joins, 74 joins: joins,
75 links: links,
61 }); 76 });
62 } 77 }
63 this.tables.sort(); 78 this.tables.sort();
64 } 79 }
65 80