openaire-library/utils/properties/searchFields.ts

754 lines
23 KiB
TypeScript

export class SearchFields {
//main Entities
//RESULTS
//Used for datasets and publications and software and orp
//In case Datasets or Software should display different fields, use seperate tables for fields
// "resultacceptanceyear",
public RESULT_RANGE_FIELDS = [
["resultacceptanceyear", "resultacceptanceyear"]
];
// Remove Collected From Filter "collectedfrom","collectedfrom"
public RESULT_REFINE_FIELDS = [
"resultbestaccessright", "relfunder",
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id",
"relproject",
"instancetypename", "resultlanguagename", "community", "resulthostingdatasource", "country"];
public RESULT_ADVANCED_FIELDS: string[] = ["q", "resulttitle", "resultauthor", "authorid", "resultdescription", "resultsubject", "resultpublisher",
"resultbestaccessright", "community", "collectedfromdatasourceid", "resulthostingdatasourceid", "resultdateofacceptance",
"relfunder",
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id",
"resultlanguagename", "relorganizationid", "pid", "relprojectid", "instancetypename"];
public RESULT_FIELDS: { [key: string]: FieldDetails } = {
["q"]: {name: "All fields", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
["resulttitle"]: {
name: "Title",
type: "keyword",
param: "title",
operator: "tt",
equalityOperator: "=",
filterType: null
},
["resultauthor"]: {
name: "Author",
type: "keyword",
param: "author",
operator: "at",
equalityOperator: "=",
filterType: null
},
["authorid"]: {
name: "Author ORCID",
type: "keyword",
param: "orcid",
operator: "oc",
equalityOperator: " exact ",
filterType: null
},
["resultsubject"]: {
name: "Subject",
type: "keyword",
param: "subject",
operator: "sb",
equalityOperator: "=",
filterType: null
},
["resultdescription"]: {
name: "Abstract",
type: "keyword",
param: "description",
operator: "ds",
equalityOperator: "=",
filterType: null
},
["resultpublisher"]: {
name: "Publisher",
type: "keyword",
param: "publisher",
operator: "pb",
equalityOperator: "=",
filterType: null
},
["pid"]: {name: "PID", type: "keyword", param: "pid", operator: "pd", equalityOperator: " = ", filterType: null},
["resulthostingdatasourceid"]: {
name: "Hosting Content Provider",
type: "entity",
param: "hostedBy",
operator: "hs",
equalityOperator: " exact ",
filterType: null
},
["resulthostingdatasource"]: {
name: "Content Provider",
type: "refine",
param: "hostedBy",
operator: "hs",
equalityOperator: " exact ",
filterType: "checkbox"
},
["instancetypename"]: {
name: "Type",
type: "vocabulary",
param: "type",
operator: "tp",
equalityOperator: " exact ",
filterType: "checkbox"
},
["resultlanguagename"]: {
name: "Language",
type: "vocabulary",
param: "lang",
operator: "ln",
equalityOperator: " exact ",
filterType: "checkbox"
},
["community"]: {
name: "Community",
type: "refine",
param: "community",
operator: "cm",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relproject"]: {
name: "Project",
type: "refine",
param: "project",
operator: "po",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relprojectid"]: {
name: "Project",
type: "entity",
param: "project",
operator: "po",
equalityOperator: " exact ",
filterType: null
},
["relfunder"]: {
name: "Funder",
type: "refine",
param: "funder",
operator: "fn",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relfundinglevel0_id"]: {
name: "Funding Stream",
type: "refine",
param: "funderlv0",
operator: "fn0",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relfundinglevel1_id"]: {
name: "Funding Substream level 1",
type: "refine",
param: "funderlv1",
operator: "fn1",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relfundinglevel2_id"]: {
name: "Funding Substream level 2",
type: "refine",
param: "funderlv2",
operator: "fn0",
equalityOperator: " exact ",
filterType: "checkbox"
},
["resultacceptanceyear"]: {
name: "Publication Date",
type: "keyword",
param: "year",
operator: "ya",
equalityOperator: " = ",
filterType: null
},
["resultdateofacceptance"]: {
name: "Publication Date",
type: "date",
param: "date",
operator: "dt",
equalityOperator: " within ",
filterType: null
},
["resultacceptanceyear-range-resultacceptanceyear"]: {
name: "Year range",
type: "keyword",
param: "year",
operator: "ya",
equalityOperator: " within ",
filterType: "range"
},
["resultbestaccessright"]: {
name: "Access Mode",
type: "vocabulary",
param: "access",
operator: "ac",
equalityOperator: " exact ",
filterType: "radio"
},
["collectedfrom"]: {
name: "Collected From",
type: "refine",
param: "datasource",
operator: "cl",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relorganizationid"]: {
name: "Organization",
type: "entity",
param: "organization",
operator: "og",
equalityOperator: " exact ",
filterType: null
},
["collectedfromdatasourceid"]: {
name: "Collected from Content Provider",
type: "entity",
param: "collectedFrom",
operator: "cl",
equalityOperator: " exact ",
filterType: null
},
["resulttypeid"]: {
name: "Result type",
type: "refine",
param: "types",
operator: "tp",
equalityOperator: " exact ",
filterType: "radio"
},
["country"]: {
name: "Country",
type: "refine",
param: "country",
operator: "cu",
equalityOperator: " exact ",
filterType: "checkbox"
}
};
//PROJECT
public PROJECT_RANGE_FIELDS = [
["projectendyear", "projectstartyear"]
];
public PROJECT_REFINE_FIELDS: string[] = ["funder", "fundinglevel0_id", "fundinglevel1_id",
"fundinglevel2_id", "projectstartyear", "projectendyear", "projectecsc39"];
public PROJECT_ADVANCED_FIELDS: string[] = ["q", "projectacronym", "projecttitle", "projectkeywords",
"funder", "fundinglevel0_id", "fundinglevel1_id", "fundinglevel2_id",
"projectstartdate", "projectenddate", "projectecsc39",
"projectcode_nt", "relorganizationid", "collectedfromdatasourceid"];
public PROJECT_FIELDS: { [key: string]: FieldDetails } = {
["q"]: {name: "All fields", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
["projectacronym"]: {
name: "Acronym",
type: "keyword",
param: "acronym",
operator: "ar",
equalityOperator: "=",
filterType: null
},
["projecttitle"]: {
name: "Title",
type: "keyword",
param: "title",
operator: "tt",
equalityOperator: "=",
filterType: null
},
["projectkeywords"]: {
name: "Keywords",
type: "keyword",
param: "keywords",
operator: "ky",
equalityOperator: "=",
filterType: null
},
["funder"]: {
name: "Funder",
type: "refine",
param: "funder",
operator: "fn",
equalityOperator: " exact ",
filterType: "checkbox"
},
["fundinglevel0_id"]: {
name: "Funding Stream",
type: "refine",
param: "funderlv0",
operator: "fn0",
equalityOperator: " exact ",
filterType: "checkbox"
},
["fundinglevel1_id"]: {
name: "Funding Substream level 1",
type: "refine",
param: "funderlv1",
operator: "fn1",
equalityOperator: " exact ",
filterType: "checkbox"
},
["fundinglevel2_id"]: {
name: "Funding Substream level 2",
type: "refine",
param: "funderlv2",
operator: "fn2",
equalityOperator: " exact ",
filterType: "checkbox"
},
["projectstartyear"]: {
name: "Start Year",
type: "year",
param: "startyear",
operator: "sy",
equalityOperator: " <= ",
filterType: "checkbox"
},
["projectendyear"]: {
name: "End Year",
type: "year",
param: "endyear",
operator: "ey",
equalityOperator: " >= ",
filterType: "checkbox"
},
["projectendyear-range-projectstartyear"]: {
name: "Active within",
type: "year",
param: "year",
operator: "ya",
equalityOperator: " = ",
filterType: "range"
},
["projectstartdate"]: {
name: "Start Date",
type: "date",
param: "startdate",
operator: "sd",
equalityOperator: " within ",
filterType: null
},
["projectenddate"]: {
name: "End Date",
type: "date",
param: "enddate",
operator: "ed",
equalityOperator: " within ",
filterType: null
},
["projectecsc39"]: {
name: "Special Clause 39",
type: "boolean",
param: "sc39",
operator: "sc",
equalityOperator: " exact ",
filterType: "radio"
},
["projectcode_nt"]: {
name: "Project Code",
type: "keyword",
param: "code",
operator: "cd",
equalityOperator: " exact ",
filterType: null
},
["relorganizationid"]: {
name: "Organization",
type: "entity",
param: "organization",
operator: "og",
equalityOperator: " exact ",
filterType: null
},
["collectedfromdatasourceid"]: {
name: "Collected from Content Provider",
type: "entity",
param: "collectedFrom",
operator: "cl",
equalityOperator: " exact ",
filterType: null
}
};
//DATAPROVIDERS
// add Collected From Filter "collectedfromname"
public DATASOURCE_REFINE_FIELDS: string[] = ["datasourcetypeuiname", "datasourceodlanguages", "datasourceodcontenttypes",
"datasourcecompatibilityname", "country", "collectedfromname"];
public DATASOURCE_ADVANCED_FIELDS: string[] = ["q", "datasourceofficialname",
"datasourceenglishname", "datasourceodsubjects", "datasourcetypename", "datasourceodlanguages",
"datasourceodcontenttypes", "datasourcecompatibilityname", "relorganizationid", "collectedfromdatasourceid"];
public DATASOURCE_FIELDS: { [key: string]: FieldDetails } = {
["q"]: {name: "All fields", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
["datasourceofficialname"]: {
name: "English name",
type: "keyword",
param: "officialname",
operator: "of",
equalityOperator: "=",
filterType: null
},
["datasourceenglishname"]: {
name: "Title",
type: "keyword",
param: "engname",
operator: "eg",
equalityOperator: "=",
filterType: null
},
["datasourceodsubjects"]: {
name: "Subject",
type: "keyword",
param: "subjects",
operator: "sb",
equalityOperator: "=",
filterType: null
},
["datasourcetypeuiid"]: {
name: "Type",
type: "refine",
param: "type",
operator: "tp",
equalityOperator: " exact ",
filterType: null
},
["datasourcetypeuiname"]: {
name: "Type",
type: "refine",
param: "type",
operator: "tp",
equalityOperator: " exact ",
filterType: "radio"
},
["datasourcetypename"]: {
name: "Type",
type: "vocabulary",
param: "type",
operator: "tp",
equalityOperator: " exact ",
filterType: "radio"
},
["datasourceodlanguages"]: {
name: "Language",
type: "vocabulary",
param: "lang",
operator: "ln",
equalityOperator: " exact ",
filterType: "checkbox"
},
["datasourceodcontenttypes"]: {
name: "Content",
type: "refine",
param: "content",
operator: "cn",
equalityOperator: " exact ",
filterType: "checkbox"
},
["datasourcecompatibilityid"]: {
name: "Compatibility Level",
type: "refine",
param: "compatibility",
operator: "cm",
equalityOperator: " exact ",
filterType: null
},
["datasourcecompatibilityname"]: {
name: "Compatibility Level",
type: "vocabulary",
param: "compatibility",
operator: "cm",
equalityOperator: " exact ",
filterType: "checkbox"
},
["relorganizationid"]: {
name: "Organization",
type: "entity",
param: "organization",
operator: "og",
equalityOperator: " exact ",
filterType: null
},
["collectedfromname"]: {
name: "Collected from",
type: "entity",
param: "collectedFrom",
operator: "cl",
equalityOperator: " exact ",
filterType: "checkbox"
},
["collectedfromdatasourceid"]: {
name: "Collected from Content Provider",
type: "entity",
param: "collectedFrom",
operator: "cl",
equalityOperator: " exact ",
filterType: null
},
["country"]: {
name: "Country",
type: "vocabulary",
param: "country",
operator: "cu",
equalityOperator: "=",
filterType: "checkbox"
}
};
public DEPOSIT_DATASOURCE_KEYWORD_FIELDS: { "name": string, "equalityOperator": string } [] = [
{"name": "relorganizationname", "equalityOperator": "="},
{"name": "relorganizationshortname", "equalityOperator": "="},
{"name": "datasourceofficialname", "equalityOperator": "="},
{"name": "datasourceenglishname", "equalityOperator": "="},
{"name": "datasourcetypeuiname", "equalityOperator": " exact "},
{"name": "country", "equalityOperator": " exact "},
{"name": "datasourcesubject", "equalityOperator": " all "}
];
public DEPOSIT_DATASOURCE_REFINE_FIELDS: string[] = ["datasourcetypename", "country", "datasourceodsubjects", "datasourceodcontenttypes", "datasourcecompatibilityname"];
public DEPOSIT_DATASOURCE_FIELDS: { [key: string]: FieldDetails } = {
["datasourcetypeuiname"]: {
name: "Repository type",
type: "refine",
param: "type",
operator: "tp",
equalityOperator: " exact ",
filterType: "radio"
},
["country"]: {
name: "Countries",
type: "vocabulary",
param: "country",
operator: "cu",
equalityOperator: "=",
filterType: "checkbox"
},
["datasourceodsubjects"]: {
name: "Subjects",
type: "keyword",
param: "subjects",
operator: "sb",
equalityOperator: "=",
filterType: "checkbox"
},
["datasourceodcontenttypes"]: {
name: "Content type",
type: "refine",
param: "content",
operator: "cn",
equalityOperator: " exact ",
filterType: "checkbox"
},
["datasourcecompatibilityname"]: {
name: "Compatibility Level",
type: "vocabulary",
param: "compatibility",
operator: "cm",
equalityOperator: " exact ",
filterType: "checkbox"
},
};
public COMPATIBLE_DATAPROVIDER_FIELDS: string[] = ["datasourcetypename", "datasourcecompatibilityname"];
public ENTITY_REGISTRIES_FIELDS: string[] = ["datasourcetypename", "datasourcecompatibilityname"];
public JOURNAL_FIELDS: string[] = ["datasourcetypename", "datasourcecompatibilityname"];
//ORGANIZATION
public ORGANIZATION_REFINE_FIELDS: string[] = ["country"]
public ORGANIZATION_ADVANCED_FIELDS: string[] = ["q", "organizationlegalname", "organizationlegalshortname", "country"];
public ORGANIZATION_FIELDS: { [key: string]: FieldDetails } = {
["q"]: {name: "All fields", type: "keyword", param: "q", operator: "op", equalityOperator: "=", filterType: null},
["organizationlegalname"]: {
name: "Legal Name",
type: "keyword",
param: "name",
operator: "nm",
equalityOperator: "=",
filterType: null
},
["organizationlegalshortname"]: {
name: "Legal Short Name",
type: "keyword",
param: "shortname",
operator: "so",
equalityOperator: "=",
filterType: null
},
["country"]: {
name: "Country",
type: "vocabulary",
param: "country",
operator: "cu",
equalityOperator: "=",
filterType: "checkbox"
},
};
// public ORGANIZATION_INDEX:string[] = ["organizationcountryname"]//,"organizationeclegalbody"];
// public ADVANCED_SEARCH_ORGANIZATION_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
// public ORGANIZATION_INDEX_PARAM_MAP:{ [key:string]:string } = {["organizationlegalname"]:"contenttype", ["organizationlegalshortname"]:"type",
// ["organizationcountryname"]:"country"};//,["organizationeclegalbody"]:"type"};
// public ORGANIZATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string , operator: "op", equalityOperator:string}} ={
// ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, operator: "op", equalityOperator: "="},
// ["contenttype"]:{name:"Legal Name",operator:"cn", type:"keyword" , indexField:"organizationlegalname", operator: "op", equalityOperator: "="},
// ["compatibility"]:{name:"Legal Short Name",operator:"cm", type:"keyword", indexField:"organizationlegalshortname", operator: "op", equalityOperator: "="},
// ["country"]:{name:"Country",operator:"cu", type:"vocabulary", indexField:"organizationcountryname", operator: "op", equalityOperator: " exact "},
// ["type"]:{name:"Type",operator:"tp", type:"refine", indexField:"organizationeclegalbody", operator: "op", equalityOperator: " exact "},
//
// };
//add project field depending on funder
public HIDDEN_FIELDS: string[] = ["fundinglevel0_id", "fundinglevel1_id", "fundinglevel2_id",
"relfundinglevel0_id", "relfundinglevel1_id", "relfundinglevel2_id", "relproject"];
public DEPENDENT_FIELDS: { [key: string]: string } = {
["relproject"]: "relfunder",
["fundinglevel0_id"]: "funder",
["fundinglevel1_id"]: "fundinglevel0_id",
["fundinglevel2_id"]: "fundinglevel1_id",
["relfundinglevel0_id"]: "relfunder",
["relfundinglevel1_id"]: "relfundinglevel0_id",
["relfundinglevel2_id"]: "relfundinglevel1_id"
};
public ADVANCED_SEARCH_OPERATORS: { name: string, id: string }[] = [{name: "AND", id: "and"}, {
name: "OR",
id: "or"
}, {name: "NOT", id: "not"}];
public COMMUNITIES_SEARCH_FIELDS: string[] = ["type", "access", "role"];
public STAKEHOLDER_SEARCH_FIELDS: string[] = ["type", "access", "role"];
constructor() {
}
getFieldName(fieldId: string, fieldType: string): string {
if (fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result") {
return this.RESULT_FIELDS[fieldId].name;
} else if (fieldType == "project") {
return this.PROJECT_FIELDS[fieldId].name;
} else if (fieldType == "organization") {
return this.ORGANIZATION_FIELDS[fieldId].name;
} else if (fieldType == "datasource" || fieldType == "dataprovider") {
return this.DATASOURCE_FIELDS[fieldId].name;
} else {
return "UNDEFINED";
}
}
getFieldFilterType(fieldId: string, fieldType: string, usedBy: string = "search"): string {
if (fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result") {
return this.RESULT_FIELDS[fieldId].filterType;
} else if (fieldType == "project") {
return this.PROJECT_FIELDS[fieldId].filterType;
} else if (fieldType == "organization") {
return this.ORGANIZATION_FIELDS[fieldId].filterType;
} else if (fieldType == "datasource" || fieldType == "dataprovider") {
if (usedBy == "search") {
return this.DATASOURCE_FIELDS[fieldId].filterType;
} else if (usedBy == "deposit") {
return this.DEPOSIT_DATASOURCE_FIELDS[fieldId].filterType;
}
} else {
return "checkbox";
}
}
getFieldParam(fieldId: string, fieldType: string): string {
if (fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result") {
return this.RESULT_FIELDS[fieldId].param;
} else if (fieldType == "project") {
return this.PROJECT_FIELDS[fieldId].param;
} else if (fieldType == "organization") {
return this.ORGANIZATION_FIELDS[fieldId].param;
} else if (fieldType == "datasource" || fieldType == "dataprovider") {
return this.DATASOURCE_FIELDS[fieldId].param;
} else {
return "UNDEFINED";
}
}
public static getParameterOrder(fieldId: string, params): number {
let fields = [];
let searchFields = new SearchFields();
if (searchFields.RESULT_REFINE_FIELDS.indexOf(fieldId) !=-1) {
fields = searchFields.RESULT_REFINE_FIELDS;
} else if (searchFields.PROJECT_REFINE_FIELDS.indexOf(fieldId) !=-1) {
fields = searchFields.PROJECT_REFINE_FIELDS
} else if (searchFields.ORGANIZATION_REFINE_FIELDS.indexOf(fieldId) !=-1) {
fields = searchFields.ORGANIZATION_REFINE_FIELDS;
} else if (searchFields.DATASOURCE_REFINE_FIELDS.indexOf(fieldId) !=-1) {
fields = searchFields.DATASOURCE_REFINE_FIELDS;
}
let index = fields.indexOf(fieldId);
let paramIndex = 0;
if(index != -1){
for(let keyValue of params){
if(fields.indexOf(keyValue[0])>index){
break;
}
paramIndex++
}
}
return paramIndex;
}
/*
AND
Funder: relfunder, relfundinglevel0_id, relfundinglevel1_id, relfundinglevel2_id
Project: relproject
Community: community
OR
Type: instancetypename, datasourcetypeuiname
Language: resultlanguagename, datasourceodlanguages
Compatibility Level: datasourcecompatibilityname
Country: country
Content: datasourceodcontenttypes
Content Provider: resulthostingdatasource
Collected From: collectedfrom
BULLETS
Access Mode: resultbestaccessright
Special Clause 39: projectecsc39
Versioning:
RANGE
Publication date: resultacceptanceyear
Project life: projectstartyear, projectendyear
? WHAT ABOUT ?:
Subjects:
Supported Identifiers:
*/
getFieldOperator(fieldId: string): string {
if (fieldId == "relfunder" || fieldId == "relfundinglevel0_id" || fieldId == "relfundinglevel1_id" || fieldId == "relfundinglevel2_id"
|| fieldId == "relproject" || fieldId == "community" || fieldId == "projectendyear-range-projectstartyear") {
return "and";
} else if (fieldId == "instancetypename" || fieldId == "datasourcetypeuiname"
|| fieldId == "resultlanguagename" || fieldId == "datasourceodlanguages"
|| fieldId == "datasourcecompatibilityname" || fieldId == "country" || fieldId == "datasourceodcontenttypes"
|| fieldId == "resulthostingdatasource" || fieldId == "collectedfrom") {
return "or";
}
return "or";
}
}
export class FieldDetails {
name: string;
type: string;
param: string;
equalityOperator: string;
operator: string;
filterType: string = "checkbox";
}