39
|
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
|
40
|
31 export function getRelationType(relType: string, isOutgoing: boolean): RelationType {
|
|
32 let name = relType;
|
39
|
33 if (isOutgoing === false) {
|
|
34 // add prefix to name
|
|
35 name = invNamePrefix + name;
|
|
36 }
|
|
37 let rt = RELATION_TYPES[name];
|
|
38 if (rt == null) {
|
40
|
39 rt = new RelationType(relType, isOutgoing);
|
|
40 }
|
|
41 return rt;
|
|
42 }
|
|
43
|
|
44 export function getRelationByName(name: string): RelationType {
|
|
45 let rt = RELATION_TYPES[name];
|
|
46 if (rt == null) {
|
39
|
47 if (name.indexOf(invNamePrefix) == 0) {
|
|
48 // inverse relation
|
|
49 name = name.substr(invNamePrefix.length);
|
|
50 rt = new RelationType(name, false);
|
|
51 } else {
|
|
52 rt = new RelationType(name, true);
|
|
53 }
|
|
54 }
|
|
55 return rt;
|
|
56 }
|
|
57
|
|
58 function addRelationType(name: string, outLabel: string, inLabel: string) {
|
|
59 // add outgoing relation
|
|
60 RELATION_TYPES[name] = new RelationType(name, true, outLabel);
|
|
61 // add inverse relation
|
|
62 RELATION_TYPES[invNamePrefix + name] = new RelationType(name, false, inLabel);
|
|
63 } |