descriptor.model.ts 4.36 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
2
3
4
import { UuidModel, CurrentPermissions, IUserPermissions } from 'model/common.model';
import { Partner } from 'model/partner.model';
import { Vocabulary, VocabularyTerm } from 'model/vocabulary.model';
import { IAuditedVersionedModelFilter, IStringFilter } from 'model/filter.model';
markchkhotua's avatar
markchkhotua committed
5

6
export enum DataType {
7
8
9
10
11
12
  TEXT = 'TEXT',
  BOOLEAN = 'BOOLEAN',
  DATE = 'DATE',
  CODED = 'CODED',
  NUMERIC = 'NUMERIC',
  SCALE = 'SCALE',
13
14
}

15
16
17
18
19
20
21
22
23
24
25
export enum DescriptorCategory {
  PASSPORT = 'PASSPORT',
  MANAGEMENT = 'MANAGEMENT',
  CHARACTERIZATION = 'CHARACTERIZATION',
  EVALUATION = 'EVALUATION',
  ENVIRONMENT = 'ENVIRONMENT',
  ABIOTICSTRESS = 'ABIOTICSTRESS',
  BIOTICSTRESS = 'BIOTICSTRESS',
  MOLECULAR = 'MOLECULAR',
}

26
export class Descriptor extends UuidModel implements IUserPermissions {
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  public static DATATYPES: { [key: string]: any; } = {
    TEXT: 'Free text',
    BOOLEAN: 'Yes/No',
    DATE: 'Date',
    CODED: 'Controlled vocabulary',
    NUMERIC: 'Numeric',
    SCALE: 'Scale',
  };

  public static CATEGORIES: { [key: string]: any; } = {
    PASSPORT: 'Passport descriptor',
    MANAGEMENT: 'Management descriptor',
    CHARACTERIZATION: 'Characterization descriptor',
    EVALUATION: 'Evaluation descriptor',
Matija Obreza's avatar
Matija Obreza committed
41
    ENVIRONMENT: 'Environment or site descriptor',
42
43
44
45
46
    ABIOTICSTRESS: 'Abiotic stress',
    BIOTICSTRESS: 'Biotic stress',
    MOLECULAR: 'Molecular marker',
  };

47
  public clazz: string = 'org.genesys.catalog.model.traits.Descriptor';
48
  public crop: string;
49
  public category: DescriptorCategory;
50
51
52
53
  public title: string;
  public description: string;
  public published: boolean;
  public versionTag: string;
54
  public dataType: DataType;
55
56
57
58
59
60
  public integerOnly: boolean;
  public minValue: number;
  public maxValue: number;
  public columnName: string;
  public uom: string;
  public bibliographicCitation: string;
61
  public owner: Partner;
62
  public vocabulary: Vocabulary;
Matija Obreza's avatar
Matija Obreza committed
63
  public terms: VocabularyTerm[];
Valeriy Panov's avatar
Valeriy Panov committed
64
65
  public key: boolean;
  public publisher: string;
66
  public _permissions: CurrentPermissions;
markchkhotua's avatar
markchkhotua committed
67

Matija Obreza's avatar
Matija Obreza committed
68
69
70
  public static SORT_OPTIONS = {
    crop: { label: 'Crop' },
    title: { label: 'Title' },
71
    // publisher: { label: 'Publisher' },
Matija Obreza's avatar
Matija Obreza committed
72
73
74
75
76
77
78
79
80
    versionTag: { label: 'Version' },
    dataType: { label: 'Data type' },
    key: { label: 'Key', dir: 'DESC' },
    uom: { label: 'Unit of measure' },
    columnName: { label: 'Column name' },
    owner: { label: 'Maintainer' },
    ...UuidModel.SORT_OPTIONS,
  };

81
82
83
84
85
  public constructor(obj?) {
    super(obj);
    if (obj && obj._permissions) {
      this._permissions = new CurrentPermissions(obj._permissions);
    }
86
87
88
    if (this.dataType) {
      this.dataType = DataType[obj.dataType as keyof typeof DataType];
    }
89
  }
markchkhotua's avatar
markchkhotua committed
90
91
}

Matija Obreza's avatar
Matija Obreza committed
92
93
94
95
export interface IDescriptorFilter extends IAuditedVersionedModelFilter {
  crop?: string[];
  title?: IStringFilter;
  published?: boolean;
96
  // publisher?: string[];
Matija Obreza's avatar
Matija Obreza committed
97
98
99
100
101
  bibliographicCitation?: IStringFilter;
  columnName?: IStringFilter;
  description?: IStringFilter;
  integerOnly?: boolean;
  uom?: IStringFilter;
102
  list?: IDescriptorListFilter;
Matija Obreza's avatar
Matija Obreza committed
103
104
}

105
106
107
108
export enum DescriptorListExtra {
  JSON_MAPPING = 'JSON_MAPPING',
}

109
export class DescriptorList extends UuidModel implements IUserPermissions {
110
  public clazz: string = 'org.genesys.catalog.model.traits.DescriptorList';
111
  public owner: Partner;
112
113
  public crop: string;
  public title: string;
Maxym Borodenko's avatar
Maxym Borodenko committed
114
  public url: string;
115
116
117
118
119
120
  public description: string;
  public published: boolean;
  public versionTag: string;
  public publisher: string;
  public bibliographicCitation: string;
  public descriptors: Descriptor[];
121
  public extras: Map<DescriptorListExtra, string>;
122
  public _permissions: CurrentPermissions;
markchkhotua's avatar
markchkhotua committed
123

Valeriy Panov's avatar
Valeriy Panov committed
124
125
126
127
128
129
130
131
132
133
  public static SORT_OPTIONS = {
    crop: { label: 'Crop' },
    title: { label: 'Title' },
    publisher: { label: 'Publisher' },
    versionTag: { label: 'Version' },
    bibliographicCitation: { label: 'Bibliographic citation' },
    owner: { label: 'Maintainer' },
    ...UuidModel.SORT_OPTIONS,
  };

134
135
136
137
138
139
140
141
142
  public constructor(obj?) {
    super(obj);
    if (obj && obj._permissions) {
      this._permissions = new CurrentPermissions(obj._permissions);
    }
    if (obj && obj.descriptors) {
      this.descriptors = obj.descriptors.map((d) => new Descriptor(d));
    }
  }
markchkhotua's avatar
markchkhotua committed
143
144
}

145
146
147
148
149
150
151
152
export interface IDescriptorListFilter extends IAuditedVersionedModelFilter {
  title?: IStringFilter;
  description?: IStringFilter;
  published?: boolean;
  publisher?: string[];
  crop?: string[];
  bibliographicCitation?: IStringFilter;
}