Mercurial > hg > ng2-query-ismi
comparison app/ismi-relation-types.ts @ 39:7578b21cdf2e
make relation types configurable.
relations can have custom labels for incoming or outgoing direction.
author | casties |
---|---|
date | Sun, 14 Feb 2016 19:40:07 +0100 |
parents | |
children | 896ae7eefb33 |
comparison
equal
deleted
inserted
replaced
38:313a5360c2d3 | 39:7578b21cdf2e |
---|---|
1 import {RelationType, invNamePrefix} from './relation-type'; | |
2 | |
3 export var RELATION_TYPES: {[name:string]: RelationType} = {}; | |
4 | |
5 addRelationType('is_part_of', 'is included in', 'includes'); | |
6 addRelationType('is_exemplar_of', 'title of witness', 'witnesses to title'); | |
7 addRelationType('was_created_by', 'created by', 'works of'); | |
8 addRelationType('has_subject', 'subject of title', 'titles with subject'); | |
9 addRelationType('has_role', 'role of person', 'persons with role'); | |
10 addRelationType('is_alias_name_of', 'person name for alias', 'alias of person'); | |
11 addRelationType('is_alias_title_of', 'title name for alias', 'alias of title'); | |
12 addRelationType('is_commentary_on', 'is commentary on', 'list of commentaries'); | |
13 addRelationType('has_title_written_as', 'title in witness', 'witness with title as'); | |
14 addRelationType('has_author_written_as', 'author in witness', 'witness with author as'); | |
15 addRelationType('lived_in', 'place person lived in', 'persons who lived in'); | |
16 addRelationType('was_copied_by', 'witness copied by', 'witnesses that were copied by'); | |
17 addRelationType('was_born_in', 'place person was born in', 'persons who were born in'); | |
18 addRelationType('owned_by', 'codex owned by', 'persons who owned codex'); | |
19 addRelationType('was_student_of', 'studied with', 'persons studying with'); | |
20 addRelationType('died_in', 'place person died in', 'persons who died in'); | |
21 addRelationType('was_created_in', 'place title was created', 'titles that were created in'); | |
22 addRelationType('was_copied_in', 'place witness was copied', 'witnesses that were copied in'); | |
23 addRelationType('misattributed_to', 'title misattributed to', 'misattributions to person'); | |
24 addRelationType('was_dedicated_to', 'text dedicated to', 'texts that were dedicated to'); | |
25 addRelationType('is_version_of', 'standard text of different version', 'different version of standard text'); | |
26 addRelationType('is_translation_of', 'original text of a translation', 'translation of a text'); | |
27 addRelationType('has_floruit_date', 'floruit date of person', 'persons with floruit date'); | |
28 addRelationType('was_studied_by', 'persons studying this text', 'text studied by'); | |
29 //addRelationType('', '', ''); | |
30 | |
31 export function getRelationType(name: string, isOutgoing?: boolean): RelationType { | |
32 if (isOutgoing === false) { | |
33 // add prefix to name | |
34 name = invNamePrefix + name; | |
35 } | |
36 let rt = RELATION_TYPES[name]; | |
37 if (rt == null) { | |
38 if (name.indexOf(invNamePrefix) == 0) { | |
39 // inverse relation | |
40 name = name.substr(invNamePrefix.length); | |
41 rt = new RelationType(name, false); | |
42 } else { | |
43 rt = new RelationType(name, true); | |
44 } | |
45 } | |
46 return rt; | |
47 } | |
48 | |
49 function addRelationType(name: string, outLabel: string, inLabel: string) { | |
50 // add outgoing relation | |
51 RELATION_TYPES[name] = new RelationType(name, true, outLabel); | |
52 // add inverse relation | |
53 RELATION_TYPES[invNamePrefix + name] = new RelationType(name, false, inLabel); | |
54 } |