2020-02-25 16:40:56 +01:00
import { Filter , Value } from "./searchHelperClasses.class" ;
import { SearchFields } from "../../utils/properties/searchFields" ;
export class DatasourcesHelperClass {
2020-03-12 18:03:35 +01:00
public static getrefineFields ( type : "all" | "registries" | "journals" | "compatible" | "deposit" ) {
2020-02-25 16:40:56 +01:00
let searchFields :SearchFields = new SearchFields ( ) ;
if ( type == "registries" ) {
return searchFields . ENTITY_REGISTRIES_FIELDS ;
} else if ( type == "journals" ) {
return searchFields . JOURNAL_FIELDS ;
} else if ( type == "compatible" ) {
return searchFields . COMPATIBLE_DATAPROVIDER_FIELDS ;
2020-03-12 18:03:35 +01:00
} else if ( type == "deposit" ) {
return searchFields . DEPOSIT_DATASOURCE_REFINE_FIELDS ;
2020-02-25 16:40:56 +01:00
} else {
return searchFields . DATASOURCE_REFINE_FIELDS ;
}
}
2020-03-12 18:03:35 +01:00
public static getTitle ( type : "all" | "registries" | "journals" | "compatible" | "deposit" ) {
2020-02-25 16:40:56 +01:00
if ( type == "registries" ) {
return "Entity Registries"
} else if ( type == "journals" ) {
return "Journals"
} else if ( type == "compatible" ) {
return "Compatible Content Providers" ;
} else {
return "Content Providers"
}
}
2020-03-12 18:03:35 +01:00
public static getQueryPrefix ( type : "all" | "registries" | "journals" | "compatible" | "deposit" ) : string {
2020-02-25 16:40:56 +01:00
if ( type == "registries" ) {
return ' datasourcetypeuiid = other ' ;
} else if ( type == "journals" ) {
// return ' not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) ';
return 'oaftype exact datasource not datasourcecompatibilityid = notCompatible and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ) ' ;
} else if ( type == "compatible" ) {
return ' oaftype exact datasource and datasourcecompatibilityid <> notCompatible and datasourcetypeuiid <> other and datasourcetypeuiid <> "pubsrepository::journal" and datasourcetypeuiid <> "aggregator::pubsrepository::journals" ' ;
2020-03-12 18:03:35 +01:00
} else if ( type == "deposit" ) {
return ' oaftype exact datasource ' ;
2020-02-25 16:40:56 +01:00
} else {
return "" ;
}
}
2020-03-12 18:03:35 +01:00
public static createFilters ( type : "all" | "registries" | "journals" | "compatible" | "deposit" ) : Filter [ ] {
2020-02-25 16:40:56 +01:00
if ( type == "registries" ) {
return this . createRegistriesFilters ( ) ;
} else if ( type == "journals" ) {
return this . createJournalFilters ( ) ;
} else if ( type == "compatible" ) {
return this . createCompatibleFilters ( ) ;
} else {
return [ ] ;
}
}
private static createCompatibleFilters ( ) : Filter [ ] {
var filter_names = [ "Type" , "Compatibility Level" ] ;
var filter_ids = [ "datasourcetypeuiid" , "datasourcecompatibilityname" ] ;
var searchFields = new SearchFields ( ) ;
var filter_original_ids = searchFields . COMPATIBLE_DATAPROVIDER_FIELDS ;
var value_names = [
[
"Institutional Repository" , "Thematic Repository" , "Publication Repository" ,
"Institutional Repository Aggregator" ,
"Thematic Repository Aggregator" , "Publication Repository Aggregator" ,
"Data Repository" , "Data Repository Aggregator" , "CRIS System" , "Publication Catalogue" ,
"Software Repository" , "Software Repository Aggregator" ] ,
2020-02-26 12:24:50 +01:00
[ "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" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
2020-02-26 12:24:50 +01:00
//{"englishName":"OpenAIRE 4.0 (inst.&thematic. repo.)","nativeName":"OpenAIRE 4.0 (inst.&thematic. repo.)","encoding":"OPENAIRE","code":"openaire4.0","synonyms":null}
2020-02-25 16:40:56 +01:00
var value_original_ids = [
[ "pubsrepository::institutional" , "pubsrepository::thematic" , "pubsrepository::unknown" , "aggregator::pubsrepository::institutional" , "aggregator::pubsrepository::thematic" , "aggregator::pubsrepository::unknown" ,
"datarepository::unknown" , "aggregator::datarepository" , "crissystem" , "pubscatalogue::unknown" , "softwarerepository" , "aggregator::softwarerepository" ] ,
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
2020-02-26 12:24:50 +01:00
[ "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" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
var filters : Filter [ ] = [ ] ;
for ( var i = 0 ; i < filter_names . length ; i ++ ) {
var values : Value [ ] = [ ] ;
for ( var j = 0 ; j < value_names [ i ] . length ; j ++ ) {
var value : Value = { name : value_names [ i ] [ j ] , id : value_original_ids [ i ] [ j ] , number : 0 , selected : false }
values . push ( value ) ;
}
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"
} ;
filters . push ( filter ) ;
}
return filters ;
}
private static createRegistriesFilters ( ) : Filter [ ] {
var filter_names = [ "Type" , "Compatibility Level" ] ;
var filter_ids = [ "datasourcetypename" , "datasourcecompatibilityname" ] ;
var searchFields = new SearchFields ( ) ;
var filter_original_ids = searchFields . ENTITY_REGISTRIES_FIELDS ;
var value_names = [
[ "Funder" , "Registry of repositories" , "Scholarly Comm. Infrastructure" , "Registry" , "Information Space" , "Web Source" ] ,
2020-02-26 12:24:50 +01:00
[ "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)" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
var value_original_ids = [
[ "Funder database" , "Registry of repositories" , "Scholarly Comm. Infrastructure" , "Registry" , "Information Space" , "Web Source" ] ,
//["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"],
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
2020-02-26 12:24:50 +01:00
[ "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)" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
var filters : Filter [ ] = [ ] ;
for ( var i = 0 ; i < filter_names . length ; i ++ ) {
var values : Value [ ] = [ ] ;
for ( var j = 0 ; j < value_names [ i ] . length ; j ++ ) {
var value : Value = { name : value_names [ i ] [ j ] , id : value_original_ids [ i ] [ j ] , number : 0 , selected : false }
values . push ( value ) ;
}
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"
} ;
filters . push ( filter ) ;
}
return filters ;
}
private static createJournalFilters ( ) : Filter [ ] {
var filter_names = [ "Type" , "Compatibility Level" ] ;
var filter_ids = [ "datasourcetypeuiid" , "datasourcecompatibilityname" ] ;
var searchFields = new SearchFields ( ) ;
var filter_original_ids = searchFields . JOURNAL_FIELDS ;
var value_names = [
/ * [
"Institutional Publication Repository" , "Thematic Publication Repository" , "Other Publication Repository" ,
"Institutional Repositories Aggregators" ,
"Thematic Repositories Aggregators" , "Other Repositories Aggregators" ,
"Data Repositories" , "Data Repositories Aggregators" , "Journals" , "Journals Aggregators" , "CRIS Systems" , "Publication Catalogues" ] ,
* /
[ "Journal" , "Journal Aggregator\/Publisher" ] ,
2020-02-26 12:24:50 +01:00
[ "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)" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
var value_original_ids = [
[ "pubsrepository::journal" , "aggregator::pubsrepository::journals" ] ,
//["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]
2020-02-26 12:24:50 +01:00
[ "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)" ,
2020-02-25 16:40:56 +01:00
"collected from a compatible aggregator" , "proprietary" , "under validation" ] ] ;
var filters : Filter [ ] = [ ] ;
for ( var i = 0 ; i < filter_names . length ; i ++ ) {
var values :Value [ ] = [ ] ;
for ( var j = 0 ; j < value_names [ i ] . length ; j ++ ) {
var value :Value = { name : value_names [ i ] [ j ] , id : value_original_ids [ i ] [ j ] , number : 0 , selected :false }
values . push ( value ) ;
}
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" } ;
filters . push ( filter ) ;
}
return filters ;
}
}