Project

General

Profile

1
import {Filter, Value} from "./searchHelperClasses.class";
2
import {SearchFields} from "../../utils/properties/searchFields";
3

    
4
export class DatasourcesHelperClass {
5

    
6
  public static getrefineFields(type: "all" | "registries" | "journals" | "compatible" | "deposit") {
7
    let searchFields:SearchFields = new SearchFields();
8
    if (type == "registries") {
9
      return searchFields.ENTITY_REGISTRIES_FIELDS;
10
    } else if (type == "journals") {
11
      return searchFields.JOURNAL_FIELDS;
12

    
13
    } else if (type == "compatible") {
14
      return searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
15
    } else if (type == "deposit") {
16
      return searchFields.DEPOSIT_DATASOURCE_REFINE_FIELDS;
17
    } else {
18
      return searchFields.DATASOURCE_REFINE_FIELDS;
19
    }
20
  }
21

    
22
  public static getTitle(type: "all" | "registries" | "journals" | "compatible" | "deposit") {
23
    if (type == "registries") {
24
      return "Entity Registries"
25
    } else if (type == "journals") {
26
      return "Journals"
27
    } else if (type == "compatible") {
28
      return "Compatible Content Providers";
29
    } else {
30
      return "Content Providers"
31
    }
32
  }
33
  public static getQueryPrefix(type: "all" | "registries" | "journals" | "compatible" | "deposit"): string {
34
    if (type == "registries") {
35
      return ' datasourcetypeuiid = other ';
36
    } else if (type == "journals") {
37
      // return ' not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) ';
38
      return 'oaftype exact datasource  not datasourcecompatibilityid = notCompatible and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) ';
39

    
40
    } else if (type == "compatible") {
41
      return ' oaftype exact datasource  and datasourcecompatibilityid <> notCompatible  and datasourcetypeuiid <> other and datasourcetypeuiid <> "pubsrepository::journal" and datasourcetypeuiid <> "aggregator::pubsrepository::journals" ';
42
    }else if (type == "deposit") {
43
      return ' oaftype exact datasource  ';
44
    } else {
45
      return "";
46
    }
47
  }
48

    
49
  public static createFilters(type: "all" | "registries" | "journals" | "compatible" | "deposit"): Filter[] {
50
    if (type == "registries") {
51
      return this.createRegistriesFilters();
52
    } else if (type == "journals") {
53
      return this.createJournalFilters();
54
    } else if (type == "compatible") {
55
      return this.createCompatibleFilters();
56
    } else {
57
      return [];
58
    }
59
  }
60

    
61
  private static createCompatibleFilters(): Filter[] {
62
    var filter_names = ["Type", "Compatibility Level"];
63
    var filter_ids = ["datasourcetypeuiid", "datasourcecompatibilityname"];
64
    var searchFields = new SearchFields();
65
    var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS;
66
    var value_names = [
67

    
68
      [
69
        "Institutional Repository", "Thematic Repository", "Publication Repository",
70
        "Institutional Repository Aggregator",
71
        "Thematic Repository Aggregator", "Publication Repository Aggregator",
72
        "Data Repository", "Data Repository Aggregator", "CRIS System", "Publication Catalogue",
73
        "Software Repository", "Software Repository Aggregator"],
74
      ["OpenAIRE Basic (DRIVER OA)", "OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE 4.0 (inst.&thematic. repo.)", "OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1",
75
        "collected from a compatible aggregator", "proprietary", "under validation"]];
76
//{"englishName":"OpenAIRE 4.0 (inst.&thematic. repo.)","nativeName":"OpenAIRE 4.0 (inst.&thematic. repo.)","encoding":"OPENAIRE","code":"openaire4.0","synonyms":null}
77
    var value_original_ids = [
78
      ["pubsrepository::institutional", "pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional", "aggregator::pubsrepository::thematic", "aggregator::pubsrepository::unknown",
79
        "datarepository::unknown", "aggregator::datarepository", "crissystem", "pubscatalogue::unknown", "softwarerepository", "aggregator::softwarerepository"],
80
      //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
81
      ["OpenAIRE Basic (DRIVER OA)", "OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE 4.0 (inst.&thematic. repo.)", "OpenAIRE Data (funded, referenced datasets)", "OpenAIRE CRIS v1.1",
82
        "collected from a compatible aggregator", "proprietary", "under validation"]];
83
    var filters: Filter[] = [];
84
    for (var i = 0; i < filter_names.length; i++) {
85
      var values: Value[] = [];
86
      for (var j = 0; j < value_names[i].length; j++) {
87
        var value: Value = {name: value_names[i][j], id: value_original_ids[i][j], number: 0, selected: false}
88
        values.push(value);
89
      }
90
      var filter: Filter = {
91
        title: filter_names[i],
92
        filterId: filter_ids[i],
93
        originalFilterId: filter_original_ids[i],
94
        values: values,
95
        countSelectedValues: 0,
96
        "filterOperator": 'or',
97
        valueIsExact: true,
98
        filterType: "checkbox"
99
      };
100
      filters.push(filter);
101
    }
102
    return filters;
103
  }
104

    
105
  private static createRegistriesFilters(): Filter[] {
106
    var filter_names = ["Type", "Compatibility Level"];
107
    var filter_ids = ["datasourcetypename", "datasourcecompatibilityname"];
108
    var searchFields = new SearchFields();
109
    var filter_original_ids = searchFields.ENTITY_REGISTRIES_FIELDS;
110
    var value_names = [
111
      ["Funder", "Registry of repositories", "Scholarly Comm. Infrastructure", "Registry", "Information Space", "Web Source"],
112

    
113
      ["OpenAIRE Basic (DRIVER OA)", "OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)",
114
        "collected from a compatible aggregator", "proprietary", "under validation"]];
115

    
116
    var value_original_ids = [
117
      ["Funder database", "Registry of repositories", "Scholarly Comm. Infrastructure", "Registry", "Information Space", "Web Source"],
118
      //["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"],
119
      //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
120
      ["OpenAIRE Basic (DRIVER OA)", "OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)", "OpenAIRE Data (funded, referenced datasets)",
121
        "collected from a compatible aggregator", "proprietary", "under validation"]];
122

    
123
    var filters: Filter[] = [];
124
    for (var i = 0; i < filter_names.length; i++) {
125
      var values: Value[] = [];
126
      for (var j = 0; j < value_names[i].length; j++) {
127
        var value: Value = {name: value_names[i][j], id: value_original_ids[i][j], number: 0, selected: false}
128
        values.push(value);
129
      }
130
      var filter: Filter = {
131
        title: filter_names[i],
132
        filterId: filter_ids[i],
133
        originalFilterId: filter_original_ids[i],
134
        values: values,
135
        countSelectedValues: 0,
136
        "filterOperator": 'or',
137
        valueIsExact: true,
138
        filterType: "checkbox"
139
      };
140
      filters.push(filter);
141
    }
142
    return filters;
143
  }
144

    
145

    
146
  private static createJournalFilters():Filter[] {
147
    var filter_names=["Type","Compatibility Level"];
148
    var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"];
149
    var searchFields = new SearchFields();
150
    var filter_original_ids = searchFields.JOURNAL_FIELDS;
151
    var value_names=[
152
      /*[
153
      "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository",
154
     "Institutional Repositories Aggregators",
155
     "Thematic Repositories Aggregators", "Other Repositories Aggregators",
156
      "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"],
157
      */
158
      ["Journal", "Journal Aggregator\/Publisher"],
159
      ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)",
160
        "collected from a compatible aggregator", "proprietary", "under validation"]];
161

    
162
    var value_original_ids=[
163
      ["pubsrepository::journal", "aggregator::pubsrepository::journals"],
164
      //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
165
      ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)", "OpenAIRE 4.0 (inst.&thematic. repo.)","OpenAIRE Data (funded, referenced datasets)",
166
        "collected from a compatible aggregator", "proprietary", "under validation"]];
167
    var filters: Filter[] =[];
168
    for(var i =0 ; i < filter_names.length;i++){
169
      var values:Value[] = [];
170
      for(var j =0 ; j < value_names[i].length;j++){
171
        var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:0, selected:false}
172
        values.push(value);
173
      }
174
      var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId:  filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or', valueIsExact: true, filterType: "checkbox" };
175
      filters.push(filter);
176
    }
177
    return filters;
178
  }
179

    
180

    
181
}
(14-14/55)