Skip to content

Commit

Permalink
Generalize applicablePredicates (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed May 11, 2021
1 parent 4216154 commit aff90e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/utilities/relation-utilities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forEach, some, keys, ListIterator } from 'lodash';
import { forEach, some, keys, ListIterator, isString } from 'lodash';

import Collection from '../core/collection';
import ldChannel from '../common-rdf/radio';
Expand Down Expand Up @@ -33,11 +33,13 @@ export function matchRelatee(direction: string, types: Node[]) {
}

/**
* Returns a Graph with all direct and inverse predicates applicable to model.
* Returns a Graph with all direct and inverse predicates applicable to `model`.
* If `model` is a bare string, it is assumed to name the range type.
* This function runs entirely sync.
*/
export function applicablePredicates(model: Node): Graph {
const allTypes = getRdfSuperClasses(model.get('@type') as string[]);
export function applicablePredicates(model: Node | string): Graph {
const seed = isString(model) ? [model] : model.get('@type') as string[];
const allTypes = getRdfSuperClasses(seed);
const predicates = new Graph();
const ontology = ldChannel.request('ontology:graph') as Graph;
// predicates that can have model in subject position
Expand Down

0 comments on commit aff90e0

Please sign in to comment.