openaire-library/landingPages/landing-utils/parsingFunctions.class.ts

856 lines
32 KiB
TypeScript
Raw Normal View History

import {HostedByCollectedFrom, Journal, Project, RelationResult} from "../../utils/result-preview/result-preview";
import {Context, Reference} from "../../utils/entities/resultLandingInfo";
import {Injectable} from '@angular/core';
import {properties} from "../../../../environments/environment";
import {StringUtils} from "../../utils/string-utils.class";
@Injectable({
providedIn: 'root'
})
export class ParsingFunctions {
public notebookInSubjects: boolean = false;
private notebookKeyword: string = "eosc jupyter notebook";
private notebook_label: string = "EOSC";
private notebook_value: string = "EOSC Jupyter Notebook";
[Library & common-assets | new-theme]: Updates for redesign. 1. availableOn.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external icon to links and updated accessright icons. 2. citation.class.ts: Added fileFormatOptions: Option[] to use it in input options. 3. citeThis.component.ts: Updated select inputs using "input" from InputComponent | Updated copy to clipboard button to link. 4. citeThis.module.ts: Import InputModule. 5. fos.component.ts: Updated class of title to "uk-text-light-grey". 6. fundedBy.component.ts: Updated class of title to "uk-text-light-grey" and updated links with uk-text-emphasis class. 7. landing-header.component.ts: Increase authorsLimit to 7 | Changed class of "under curation" to uk-text-primary (used to be custom class). 8. metrics.component.ts: Updated in clickOutside event. parsingFunctions.class.ts: Updated open, closed and unknown with icon names instead of paths to svgs (download accessright icons). 9. relatedTo.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external for links. 10. resultLandingUtils.module.ts: Inport AlertModalModule (to open modal). 11. sdg.component.ts: Updated class of titlte to "uk-text-light-grey". 12. showIdentifiers.component.ts: Added view more functionality. 13. showPublisher.component.ts: Updated custon-external class. 14. resultLanding.module.ts: registerIcon link. 15. resultLanding.component.html: Updated css for result landing and commented annotations (b2note). 16. orcid-work.component.ts: Updated orcid action button for landing page. 17. orcid.module.ts: registerIcons orcid_add and orcid_bin. 18. customOptions.class.ts: [Bug fix] [By Kostis] registryOptions() was not returning properly httpHeaders. 19. showAuthors.component.ts: Updated css 20. icons.ts: Export svgs orcid_add, orcid_bin, link. 21. alert.ts: Removed margin from title. 22. result-preview.component.html: Title of results set to <h2> and uk-h6 and when links to uk-link-heading | accessRightIcon for hostedBy_collectedFrom. 23. result-preview.module.ts: Imported IconsModule. 24. landing-utils.css: Updates in landing css & css of landing-action-button & added backdrop filter missing rules. 25. utils.css: Updated class orcid-clipboard-wrapper and renamed to clipboad-wrapper | Update class .custom-external to set in content with code instead of name and updated not to underline it on hover 26. library.css: Added class .default-dropdown with max-width: 500px;
2022-04-16 09:47:30 +02:00
// public open = 'assets/common-assets/unlock.svg';
// public closed = 'assets/common-assets/lock.svg';
// public unknown = 'assets/common-assets/question.svg';
public open = 'lock_open';
public closed = 'lock';
public unknown = 'question_mark';
private instanceWithDoiExists: boolean = false;
constructor() {
}
public ngOnDestroy() {
}
public parseFundingByProjects(fundedByProjects: Project[], relation: any,
provenanceActionVocabulary: any): Project[] {
if (fundedByProjects == undefined) {
fundedByProjects = [];
}
let fundedByProject: Project = {
"id": "", "acronym": "", "title": "",
"funderShortname": "", "funderName": "",
"funding": "", "code": "", "provenanceAction": "", "validated": false
};
if (relation.title != 'unidentified') {
fundedByProject['id'] = relation['to'].content;
fundedByProject['acronym'] = relation.acronym;
fundedByProject['title'] = relation.title;
fundedByProject['code'] = relation.code;
if(relation.validated && relation.validated.date) {
fundedByProject['validated'] = true;
}
if (provenanceActionVocabulary != null && relation.provenanceaction in provenanceActionVocabulary) {
fundedByProject['provenanceAction'] = provenanceActionVocabulary[relation.provenanceaction];
}
} else {
fundedByProject['id'] = "";
fundedByProject['acronym'] = "";
fundedByProject['title'] = "";
fundedByProject['code'] = "";
fundedByProject['provenanceAction'] = "";
}
if (relation.hasOwnProperty("funding")) {
let funding: { "funderName": string, "funderShortname": string, "stream": string };
funding = this.parseFundingTrees(relation.funding);
if (funding.funderName) {
fundedByProject['funderName'] = funding.funderName;
}
if (funding.funderShortname) {
fundedByProject['funderShortname'] = funding.funderShortname;
}
if (funding.stream) {
fundedByProject['funding'] = funding.stream;
}
}
fundedByProjects.push(fundedByProject);
return fundedByProjects;
}
// publication & research data : for fundedByProjects | project landing : for funding
public parseFundingTrees(fundingTree: any): { "funderName": string, "funderShortname": string, "stream": string } {
let funding: { "funderName": string, "funderShortname": string, "stream": string } = {
"funderName": "",
"funderShortname": "",
"stream": ""
};
let length = Array.isArray(fundingTree) ? fundingTree.length : 1;
for (let i = 0; i < length; i++) {
let fundingData = Array.isArray(fundingTree) ? fundingTree[i] : fundingTree;
if (fundingData.hasOwnProperty("funder")) {
funding.funderShortname = fundingData['funder'].shortname;
funding.funderName = fundingData['funder'].name;
}
funding.stream = this.addFundingLevel0(fundingData, funding.stream);
funding.stream = this.addFundingLevel1(fundingData, funding.stream);
funding.stream = this.addFundingLevel2(fundingData, funding.stream);
}
return funding;
}
addFundingLevel0(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_0")) {
let level0 = parent['funding_level_0'];
fundingStream += (fundingStream) ? " ; " : "";
fundingStream += level0.name;
}
return fundingStream;
}
addFundingLevel1(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_1")) {
let level1 = parent['funding_level_1'];
// For projects' parsing
if (level1.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel0(level1.parent, fundingStream);
}
fundingStream += (fundingStream) ? " | " : "";
fundingStream += level1.name;
}
return fundingStream;
}
addFundingLevel2(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_2")) {
let level2 = parent['funding_level_2'];
// For projects' parsing
if (level2.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel1(level2.parent, fundingStream);
}
fundingStream += (fundingStream) ? " | " : "";
fundingStream += level2.name;
}
return fundingStream;
}
// publication & dataset landing : for collectedFrom
parseCollectedFrom(collectedFrom: { "name": string, "id": string }[],
_collectedFrom: any) {
let length: number = collectedFrom.length;
collectedFrom[length] = {"name": "", "id": ""};
collectedFrom[length]['name'] = _collectedFrom.name;
collectedFrom[length]['id'] = _collectedFrom.id;
}
// publication & dataset landing : for downloadFrom
addPublisherToHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
publisher: string, journal: Journal,
identifiers: Map<string, string[]>/*, title: { "name": string, "url": string, "accessMode": string}*/) {
if (!this.instanceWithDoiExists && publisher && identifiers != null && identifiers.has('doi')) {
if (hostedBy_collectedFrom == null) {
hostedBy_collectedFrom = [];
}
let available: HostedByCollectedFrom = {
downloadNames: [],
downloadUrl: "",
collectedNamesAndIds: null,
accessRight: "",
types: [],
years: [],
accessRightIcon: ""
};
if (journal && journal.journal) {
available.downloadNames.push(publisher + "/ " + journal['journal']);
} else {
available.downloadNames.push(publisher);
}
available.downloadUrl = properties.doiURL + identifiers.get("doi")[0];;
available.accessRightIcon = this.unknown;
/*
if(title != undefined && title['url'] == "") {
title['url'] = url;
}
*/
hostedBy_collectedFrom.push(available);
}
return hostedBy_collectedFrom;
}
// publication & dataset landing : for downloadFrom
parseDownloadFrom(downloadFrom: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, url: string) {
let key: string = instance['hostedby'].name;
if (key) {
this.addUrlAndAccessMode(downloadFrom, instance, key, url);
}
}
// publication & dataset landing : for publishedIn
parsePublishedIn(publishedIn: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, result: any, url: string, counter: number): number {
if (result != null && result.hasOwnProperty("source")) {
let key: string;
if (Array.isArray(result.source)) {
if (counter == result.source.length) {
counter--;
}
key = result['source'][counter];
} else {
key = result['source'];
}
if (key) {
this.addUrlAndAccessMode(publishedIn, instance, key, url);
counter++;
}
}
return counter;
}
// publication & dataset landing : for downloadFrom and publishedIn
addUrlAndAccessMode(mapStructure: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, key: string, url: string) {
if (!mapStructure.has(key)) {
mapStructure.set(key, {"url": null, "accessMode": null, "bestAccessMode": null});
}
if (mapStructure.get(key)['url'] == null) {
mapStructure.get(key)['url'] = new Array<string>();
}
if (url) {
mapStructure.get(key)['url'].push(url);
}
if (mapStructure.get(key)['accessMode'] == null) {
mapStructure.get(key)['accessMode'] = new Array<string>();
}
if (instance.hasOwnProperty("accessright")) {
if (url) {
mapStructure.get(key)['accessMode'].push(instance['accessright'].classname);
}
if (this.changeBestAccessMode(mapStructure.get(key)['bestAccessMode'], instance['accessright'])) {
mapStructure.get(key)['bestAccessMode'] = instance['accessright'].classname;
}
} else if (url) {
mapStructure.get(key)['accessMode'].push("");
}
}
parseHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
instance: any, url: string, globalAccessRight: string) {
if(!url) {
return;
}
let available: HostedByCollectedFrom = {
"downloadNames": [],
"downloadUrl": null,
"collectedNamesAndIds": new Map(),
"accessRight": null,
"accessRightIcon": "",
"types": [],
"years": []
};
if (instance.hasOwnProperty("hostedby")) {
let downloadNames: Set<string> = new Set();
let length = Array.isArray(instance['hostedby']) ? instance['hostedby'].length : 1;
for (let i = 0; i < length; i++) {
let hostedBy = Array.isArray(instance['hostedby']) ? instance['hostedby'][i] : instance['hostedby'];
if (hostedBy.name && hostedBy.name != "other resources" && hostedBy.name != "Unknown Repository") {
downloadNames.add(hostedBy.name);
}
}
available.downloadNames = Array.from(downloadNames);
if (available.downloadNames.length == 0) {
available.downloadNames.push(url.substring(0, 30) + '...'); // substring(from, to);
}
}
if (instance.hasOwnProperty("collectedfrom")) {
let length = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'].length : 1;
for (let i = 0; i < length; i++) {
let collectedFrom = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'][i] : instance['collectedfrom'];
if(collectedFrom.name && collectedFrom.id) {
available.collectedNamesAndIds.set(collectedFrom.name, collectedFrom.id);
}
}
}
if (instance.hasOwnProperty("instancetype")) {
let types: Set<string> = new Set();
let length = Array.isArray(instance['instancetype']) ? instance['instancetype'].length : 1;
for (let i = 0; i < length; i++) {
let instanceType = Array.isArray(instance['instancetype']) ? instance['instancetype'][i] : instance['instancetype'];
if(instanceType.classname && instanceType.classname.toLowerCase() !== "unknown") {
types.add(instanceType.classname);
}
}
available.types = Array.from(types);
}
if (instance.hasOwnProperty("dateofacceptance")) {
let years: Set<string> = new Set();
let length = Array.isArray(instance['dateofacceptance']) ? instance['dateofacceptance'].length : 1;
for (let i = 0; i < length; i++) {
let dateOfAcceptance = Array.isArray(instance['dateofacceptance']) ? instance['dateofacceptance'][i] : instance['dateofacceptance'];
let date: string = (dateOfAcceptance) + ""; // transform to string in case it is an integer
years.add((date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date);
}
available.years = Array.from(years);
}
available['downloadUrl'] = url;
if(url.includes("doi.org/")) {
this.instanceWithDoiExists = true;
}
if (instance.hasOwnProperty("accessright")) {
let length = Array.isArray(instance['accessright']) ? instance['accessright'].length : 1;
for (let i = 0; i < length; i++) {
let accessRight = Array.isArray(instance['accessright']) ? instance['accessright'][i] : instance['accessright'];
if (this.changeBestAccessMode(available.accessRight, accessRight)) {
available.accessRight = accessRight.classname;
if (this.changeBestAccessMode(globalAccessRight, accessRight)) {
globalAccessRight = accessRight.classname;
}
}
}
}
if (available.accessRight) {
if (available.accessRight.toLowerCase().indexOf('open') !== -1) {
available.accessRightIcon = this.open;
} else if (available.accessRight.toLowerCase().indexOf('not available') !== -1) {
available.accessRightIcon = this.unknown;
} else {
available.accessRightIcon = this.closed;
}
} else {
available.accessRightIcon = this.unknown;
}
hostedBy_collectedFrom.push(available);
}
// publication & dataset landing : for downloadFrom and publishedIn
changeBestAccessMode(currentAccessMode: string, accessMode: any): boolean {
if (!accessMode) {
return false;
}
accessMode = accessMode.classid;
switch (currentAccessMode) {
case null:
if (accessMode != "UNKNOWN") {
return true;
}
return false;
case "CLOSED":
if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE" ||
accessMode == "EMBARGO" ||
accessMode == "RESTRICTED") {
return true;
}
return false;
case "RESTRICTED":
if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE" ||
accessMode == "EMBARGO") {
return true;
}
return false;
case "EMBARGO":
if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE") {
return true;
}
return false;
case "OPEN SOURCE":
if (accessMode == "OPEN") {
return true;
}
return false;
}
return false;
}
// publication & dataset & software & orp landing : for relatedResearchResults
parseRelatedResearchResults(relatedResearchResults: RelationResult[], relation: any, provenanceAction: string):
RelationResult[] {
if (relatedResearchResults == undefined) {
relatedResearchResults = []
}
relatedResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust", provenanceAction));
return relatedResearchResults;
}
// publication & dataset & software & orp landing : for supplementaryResearchResults
parseSupplementaryResearchResults(supplementaryResearchResults: RelationResult[], relation: any): RelationResult[] {
if (supplementaryResearchResults == undefined) {
supplementaryResearchResults = [];
}
supplementaryResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust"));
return supplementaryResearchResults;
}
// publication & dataset & software & orp landing : for supplementedByResearchResults
parseSupplementedByResearchResults(supplementedByResearchResults: RelationResult[], relation: any): RelationResult[] {
if (supplementedByResearchResults == undefined) {
supplementedByResearchResults = [];
}
supplementedByResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust"));
return supplementedByResearchResults;
}
// publication & dataset & software & orp landing : for similarResearchResults
parseSimilarResearchResults(similarResearchResults: RelationResult[], relation: any): RelationResult[] {
if (similarResearchResults == undefined) {
similarResearchResults = [];
}
similarResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "similarity"));
return similarResearchResults;
}
parseResults(researchResults: RelationResult[], relation, provenanceAction: string): RelationResult[] {
if (researchResults == undefined) {
researchResults = [];
}
let researchResult: RelationResult = {
name: "",
id: "",
date: "",
percentage: null,
percentageName: null,
class: "",
provenanceAction: provenanceAction,
relationName: ""
};
researchResult.relationName = relation.to.class;
if(relation['resulttype']) {
if (relation['resulttype'].classname == "publication") {
researchResult['class'] = "publication";
} else if (relation['resulttype'].classname == "dataset") {
researchResult['class'] = "dataset";
} else if (relation['resulttype'].classname == "software") {
researchResult['class'] = "software";
} else if (relation['resulttype'].classname == "other") {
researchResult['class'] = "other";
}
}
researchResult['id'] = relation['to'].content;
let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : (relation['title']?relation['title'].content:null);
researchResult['name'] = titleName;
if(!researchResult['name']) {
researchResult['name'] = "[no title available]";
}
if (relation.hasOwnProperty("dateofacceptance")) {
var date: string = ((Array.isArray(relation.dateofacceptance)) ? (relation.dateofacceptance[0]) : (relation.dateofacceptance)) + ""; // transform to string in case it is an integer
researchResult['date'] = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
}
//researchResult['date'] = relation.dateofacceptance.substring(0,4);;
let percentageName: string;
if(relation.trust) {
percentageName = "trust";
} else if(relation.similarity) {
percentageName = "similarity";
}
if(percentageName) {
researchResult['percentage'] = Math.round(relation[percentageName] * 100);
researchResult['percentageName'] = percentageName;
}
researchResults.push(researchResult);
return researchResults;
}
parseResearchResults(researchResults: RelationResult[], relation: any, percentageName: string = "trust"): RelationResult[] {
if (researchResults == undefined) {
researchResults = [];
}
researchResults.push(this.parseRelatedOrSimilarResearchResult(relation, percentageName));
return researchResults;
}
// publication & dataset & software & orp landing : for relatedResearchResults and similarResearchResults
parseRelatedOrSimilarResearchResult(relation: any, percentageName: string, provenanceAction: string = null): RelationResult {
let researchResult: RelationResult = {
name: "",
id: "",
date: "",
percentage: null,
class: "",
provenanceAction: provenanceAction
};
if(relation['resulttype']) {
if (relation['resulttype'].classname == "publication") {
researchResult['class'] = "publication";
} else if (relation['resulttype'].classname == "dataset") {
researchResult['class'] = "dataset";
} else if (relation['resulttype'].classname == "software") {
researchResult['class'] = "software";
} else if (relation['resulttype'].classname == "other") {
researchResult['class'] = "other";
}
}
researchResult['id'] = relation['to'].content;
let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : (relation['title']?relation['title'].content:null);
researchResult['name'] = titleName;
if(!researchResult['name']) {
researchResult['name'] = "[no title available]";
}
if (relation.hasOwnProperty("dateofacceptance")) {
var date: string = ((Array.isArray(relation.dateofacceptance)) ? (relation.dateofacceptance[0]) : (relation.dateofacceptance)) + ""; // transform to string in case it is an integer
researchResult['date'] = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
}
//researchResult['date'] = relation.dateofacceptance.substring(0,4);;
researchResult['percentage'] = Math.round(relation[percentageName] * 100);
return researchResult;
}
sortByPercentage(results: RelationResult[]): RelationResult[] {
if (results) {
return results.sort(function (a, b) {
return b["percentage"] - a["percentage"]
});
}
return results;
}
// publication & dataset landing : for identifiers
parseIdentifiers(pid: any): Map<string, string[]> {
let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("classid") && pid['classid'] != "") {
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid") {
if (!identifiers.has(pid.classid)) {
identifiers.set(pid.classid, new Array<string>());
}
identifiers.get(pid.classid).push(pid.content+"");
}
} else {
for (let i = 0; i < pid.length; i++) {
if (pid[i].classid == "doi" || pid[i].classid == "pmc" || pid[i].classid == "handle" || pid[i].classid == "pmid") {
if (!identifiers.has(pid[i].classid)) {
identifiers.set(pid[i].classid, new Array<string>());
}
identifiers.get(pid[i].classid).push(pid[i].content+"");
}
}
}
return identifiers;
}
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseAllSubjects(_subjects: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] {
let subjects: string[];
let otherSubjects: Map<string, string[]>;
let classifiedSubjects: Map<string, string[]>;
let fos: string[];
let sdg: string[];
let subject;
let length = Array.isArray(_subjects) ? _subjects.length : 1;
for (let i = 0; i < length; i++) {
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
if (subject.classid != "") {
if (subject.inferred && subject.inferred == true) {
if(subject.classid === "SDG") {
if (sdg == undefined) {
sdg = new Array<string>();
}
sdg.push(subject.content+"");
} else if(subject.classid === "FOS") {
if (fos == undefined) {
fos = new Array<string>();
}
fos.push(subject.content+"");
} else {
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(subject.classname, new Array<string>());
}
classifiedSubjects.get(subject.classname).push(subject.content+"");
}
} else {
if (subject.classid == "keyword") {
let content: string = subject.content+"";
// console.log("keyword subject: "+content);
if(content && content.toLowerCase().includes(this.notebookKeyword)) {
// console.log("included in keyword subject: "+content);
// console.log("included");
this.notebookInSubjects = true;
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(this.notebook_label, new Array<string>());
}
classifiedSubjects.get(this.notebook_label).push(this.notebook_value);
} else {
if (subjects == undefined) {
subjects = new Array<string>();
}
subjects.push(content);
}
} else {
let content: string = subject.content+"";
let classname: string = subject.classname + "";
// console.log("other subject: "+classname + ": " +content);
if( (content && content.toLowerCase().includes(this.notebookKeyword) ||
(classname && classname.toLowerCase().includes(this.notebookKeyword)))) {
// console.log("included in other subject: "+classname + ": "+content);
// console.log("included");
this.notebookInSubjects = true;
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has(subject.classname)) {
classifiedSubjects.set(this.notebook_label, new Array<string>());
}
classifiedSubjects.get(this.notebook_label).push(this.notebook_value);
} else {
[Explore & Library & Common Assets | new-theme]: Updates related to result landing redesign. 1. fos.component.css: Removed rule "mark.highlighted" and ".custom-bottom-border" updated with variables. 2. feedback.component.html: Updated width of email input for small screens. 3. parsingFunctions.class.ts: In "parseAllSubjects()" method, comment otherSubjects and push them in subjects. 4. showIdentifiers.component.ts: Updated classes in <modal-alert>. 5. showSubjects.component.ts: "Subjects by Vocabulary" and "Subjects" separated & view more functionality added in "Subjects". 6. resultLanding.component: a. Added button and modal for <addThis> (share in social media). b. View more functionality for related organizations. c. Graph and feedback section sticky. d. Added checks for summary tab and right sidebar. e. In small screens made right sidebar offcanvas. 7. resultLanding.module.ts: Updated iconsService.registerIcons to register link, graph, quotes. 8. orcid-work.component.ts: Added visually-hidden in icon buttons for landing | Updated classes in <modal-alert> and use buttons of alert instead of custom. 9. no-load-paging.component.ts: Use new component <results-and-pages> for results and pages number and set uk-flex-right in <paging-no-load> (default is center). 10. cookie-law.css: In ".cookie-law-wrapper" increased z-index from 100 to 1000. 11. showAuthors.component.ts: Removed shadow from search button | Updated classes in <modal-alert>. 12. icons.ts: Added "quotes" svg. 13. alert.ts: Updated modal to have header - body - footer (theme was updated too) | classTitle input set default to "uk-background-primary-opacity" | @Input() overflowBody: boolean = true; added to add overflow in body. 14. paging.module.ts: Added ResultsAndPagesNumComponent in declarations and exports. 15. pagingFormatter.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them. 16. pagingFormatterNoLoad.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them | Set customClasses default to "uk-flex-center". 17. tabs.component.ts: Updated margins/ paddings | Added @Input() offsetForSticky:number=0; to compare with the top distance for isSticky. 18. resultsAndPagesNum.component.ts: [NEW] Component to show number of results, number of pages and current page (used in paging). 19. landing-utils.css: a. Moved variables in .landing instead of :root. b. Added variable --landing-light-color-rgb: var(--light-color-rgb); c. Added glass filter in #graph_and_feedback. d. Set z-index of #main-tabs-div and #graph_and_feedback to 979 (default 980 caused problems with metrics box). e. Added padding-bottom: 80px and margin-top: 80px in .landing-sections. f. Added top rule for #right-sidebar-switcher. g. Added custom width rules for .landing-left-sidebar-width. 20. css-rules.txt: Added cookie-law-wrapper: 1000 info for z-index 21. explore-custom.css: Added variable --background-primary-rgb: var(--explore-color-rgb);
2022-04-20 16:40:18 +02:00
// if (otherSubjects == undefined) {
// otherSubjects = new Map<string, string[]>();
// }
//
// if (!otherSubjects.has(subject.classname)) {
// otherSubjects.set(subject.classname, new Array<string>());
// }
// otherSubjects.get(classname).push(content);
[Explore & Library & Common Assets | new-theme]: Updates related to result landing redesign. 1. fos.component.css: Removed rule "mark.highlighted" and ".custom-bottom-border" updated with variables. 2. feedback.component.html: Updated width of email input for small screens. 3. parsingFunctions.class.ts: In "parseAllSubjects()" method, comment otherSubjects and push them in subjects. 4. showIdentifiers.component.ts: Updated classes in <modal-alert>. 5. showSubjects.component.ts: "Subjects by Vocabulary" and "Subjects" separated & view more functionality added in "Subjects". 6. resultLanding.component: a. Added button and modal for <addThis> (share in social media). b. View more functionality for related organizations. c. Graph and feedback section sticky. d. Added checks for summary tab and right sidebar. e. In small screens made right sidebar offcanvas. 7. resultLanding.module.ts: Updated iconsService.registerIcons to register link, graph, quotes. 8. orcid-work.component.ts: Added visually-hidden in icon buttons for landing | Updated classes in <modal-alert> and use buttons of alert instead of custom. 9. no-load-paging.component.ts: Use new component <results-and-pages> for results and pages number and set uk-flex-right in <paging-no-load> (default is center). 10. cookie-law.css: In ".cookie-law-wrapper" increased z-index from 100 to 1000. 11. showAuthors.component.ts: Removed shadow from search button | Updated classes in <modal-alert>. 12. icons.ts: Added "quotes" svg. 13. alert.ts: Updated modal to have header - body - footer (theme was updated too) | classTitle input set default to "uk-background-primary-opacity" | @Input() overflowBody: boolean = true; added to add overflow in body. 14. paging.module.ts: Added ResultsAndPagesNumComponent in declarations and exports. 15. pagingFormatter.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them. 16. pagingFormatterNoLoad.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them | Set customClasses default to "uk-flex-center". 17. tabs.component.ts: Updated margins/ paddings | Added @Input() offsetForSticky:number=0; to compare with the top distance for isSticky. 18. resultsAndPagesNum.component.ts: [NEW] Component to show number of results, number of pages and current page (used in paging). 19. landing-utils.css: a. Moved variables in .landing instead of :root. b. Added variable --landing-light-color-rgb: var(--light-color-rgb); c. Added glass filter in #graph_and_feedback. d. Set z-index of #main-tabs-div and #graph_and_feedback to 979 (default 980 caused problems with metrics box). e. Added padding-bottom: 80px and margin-top: 80px in .landing-sections. f. Added top rule for #right-sidebar-switcher. g. Added custom width rules for .landing-left-sidebar-width. 20. css-rules.txt: Added cookie-law-wrapper: 1000 info for z-index 21. explore-custom.css: Added variable --background-primary-rgb: var(--explore-color-rgb);
2022-04-20 16:40:18 +02:00
if (subjects == undefined) {
subjects = new Array<string>();
}
[Explore & Library & Common Assets | new-theme]: Updates related to result landing redesign. 1. fos.component.css: Removed rule "mark.highlighted" and ".custom-bottom-border" updated with variables. 2. feedback.component.html: Updated width of email input for small screens. 3. parsingFunctions.class.ts: In "parseAllSubjects()" method, comment otherSubjects and push them in subjects. 4. showIdentifiers.component.ts: Updated classes in <modal-alert>. 5. showSubjects.component.ts: "Subjects by Vocabulary" and "Subjects" separated & view more functionality added in "Subjects". 6. resultLanding.component: a. Added button and modal for <addThis> (share in social media). b. View more functionality for related organizations. c. Graph and feedback section sticky. d. Added checks for summary tab and right sidebar. e. In small screens made right sidebar offcanvas. 7. resultLanding.module.ts: Updated iconsService.registerIcons to register link, graph, quotes. 8. orcid-work.component.ts: Added visually-hidden in icon buttons for landing | Updated classes in <modal-alert> and use buttons of alert instead of custom. 9. no-load-paging.component.ts: Use new component <results-and-pages> for results and pages number and set uk-flex-right in <paging-no-load> (default is center). 10. cookie-law.css: In ".cookie-law-wrapper" increased z-index from 100 to 1000. 11. showAuthors.component.ts: Removed shadow from search button | Updated classes in <modal-alert>. 12. icons.ts: Added "quotes" svg. 13. alert.ts: Updated modal to have header - body - footer (theme was updated too) | classTitle input set default to "uk-background-primary-opacity" | @Input() overflowBody: boolean = true; added to add overflow in body. 14. paging.module.ts: Added ResultsAndPagesNumComponent in declarations and exports. 15. pagingFormatter.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them. 16. pagingFormatterNoLoad.component.ts: Add "uk-invisible" to previous and next buttons instead of hiding them | Set customClasses default to "uk-flex-center". 17. tabs.component.ts: Updated margins/ paddings | Added @Input() offsetForSticky:number=0; to compare with the top distance for isSticky. 18. resultsAndPagesNum.component.ts: [NEW] Component to show number of results, number of pages and current page (used in paging). 19. landing-utils.css: a. Moved variables in .landing instead of :root. b. Added variable --landing-light-color-rgb: var(--light-color-rgb); c. Added glass filter in #graph_and_feedback. d. Set z-index of #main-tabs-div and #graph_and_feedback to 979 (default 980 caused problems with metrics box). e. Added padding-bottom: 80px and margin-top: 80px in .landing-sections. f. Added top rule for #right-sidebar-switcher. g. Added custom width rules for .landing-left-sidebar-width. 20. css-rules.txt: Added cookie-law-wrapper: 1000 info for z-index 21. explore-custom.css: Added variable --background-primary-rgb: var(--explore-color-rgb);
2022-04-20 16:40:18 +02:00
subjects.push(content);
}
}
}
}
}
return [subjects, otherSubjects, classifiedSubjects, fos, sdg];
}
parseContexts(_contexts: any): Context[] {
let contexts = new Array<Context>();
let position = 0;
let labels = "";
let context;
let length = Array.isArray(_contexts) ? _contexts.length : 1;
for (let i = 0; i < length; i++) {
let numOfCategories: number = 0; // count categories with label
context = Array.isArray(_contexts) ? _contexts[i] : _contexts;
if (context.label && context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) {
if (context.hasOwnProperty("category")) {
let category;
let length2 = Array.isArray(context['category']) ? context['category'].length : 1;
for (let z = 0; z < length2; z++) {
let numOfConcepts: number = 0; // count category concepts with label
category = Array.isArray(context['category']) ? context['category'][z] : context['category'];
if (category.label && category.hasOwnProperty("concept")) {
let categoryConcept;
let length1 = Array.isArray(category['concept']) ? category['concept'].length : 1;
for (let j = 0; j < length1; j++) {
categoryConcept = Array.isArray(category['concept']) ? category['concept'][j] : category['concept'];
// initalize if there is concept label or this is the last concept of the category and there were no concepts
// otherwise we could have multiple entries for the same category but without concepts
if(categoryConcept.label || (numOfConcepts == 0 && j == (length1 - 1))) {
contexts[position] = {
"labelContext": "", "idContext": "",
"labelCategory": "", "idCategory": "",
"labelConcept": "", "idConcept": ""
};
contexts[position]['labelContext'] = context.label;
contexts[position]['idContext'] = context.id;
contexts[position]['labelCategory'] = category.label;
contexts[position]['idCategory'] = category.id;
contexts[position]['labelConcept'] = categoryConcept.label ? categoryConcept.label : null;
contexts[position]['idConcept'] = categoryConcept.label ? categoryConcept.id : null;
position++;
numOfConcepts++;
}
}
} else if(category.label || (numOfCategories == 0 && z == (length2 - 1))) {
contexts[position] = {"labelContext": "", "idContext": "",
"labelCategory": "", "idCategory": "",
"labelConcept": "", "idConcept": ""};
contexts[position]['labelContext'] = context.label;
contexts[position]['idContext'] = context.id;
contexts[position]['labelCategory'] = category.label ? category.label : null;
contexts[position]['idCategory'] = category.label ? category.id : null;
contexts[position]['labelConcept'] = null;
contexts[position]['idConcept'] = null;
position++;
numOfCategories++;
}
}
} else {
contexts[position] = {"labelContext": "", "idContext": "",
"labelCategory": "", "idCategory": "",
"labelConcept": "", "idConcept": ""};
contexts[position]['labelContext'] = context.label;
contexts[position]['idContext'] = context.id;
contexts[position]['labelCategory'] = null;
contexts[position]['idCategory'] = null;
contexts[position]['labelConcept'] = null;
contexts[position]['idConcept'] = null;
contexts[position]['new'] = false;
position++;
}
}
}
return contexts;
}
public static getEnermapsConceptId(contexts: any): string{
let enermapsconcepts = contexts.filter(c=> {return c.idCategory == "enermaps::selection" && c.idConcept});
return enermapsconcepts && enermapsconcepts.length > 0?enermapsconcepts[0].idConcept.split("enermaps::selection::")[1]:null;
// return "hotmaps_heat_tot_curr_density"
}
parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) {
if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
if (!uniqueTypes.has(instance['instancetype'].classname)) {
types.push(instance['instancetype'].classname);
uniqueTypes.add(instance['instancetype'].classname);
}
}
}
parseLanguages(_languages: any) {
var languages = new Array<string>();
if (!Array.isArray(_languages)) {
if (_languages.classname != "Undetermined" && _languages.classname) {
languages.push(_languages.classname);
}
} else {
for (let i = 0; i < _languages.length; i++) {
if (_languages[i].classname != "Undetermined" && _languages[i].classname) {
languages.push(_languages[i].classname);
}
}
}
return languages;
}
parseCountries(_countries: any) {
var countries = new Array<string>();
if (!Array.isArray(_countries)) {
if (_countries.classname != "Undetermined" && _countries.classname) {
countries.push(_countries.classname);
}
} else {
for (let i = 0; i < countries.length; i++) {
if (_countries[i].classname != "Undetermined" && _countries[i].classname) {
countries.push(_countries[i].classname);
}
}
}
return countries;
}
parseProgrammingLanguages(_pLanguages) {
var pLanguages = new Array<string>();
if (!Array.isArray(_pLanguages)) {
if (_pLanguages.classname != "Undetermined" && _pLanguages.classname) {
pLanguages.push(_pLanguages.classname);
}
} else {
for (let i = 0; i < _pLanguages.length; i++) {
if (_pLanguages[i].classname != "Undetermined" && _pLanguages[i].classname) {
pLanguages.push(_pLanguages[i].classname);
}
}
}
return pLanguages;
}
parseReferences(citations: any): Reference[] {
let references: Reference[] = [];
citations = Array.isArray(citations) ? citations : [citations];
citations.forEach(citation => {
let reference: Reference = {name: null, ids: []};
if(citation.rawText) {
reference.name = citation.rawText;
}
if(citation.id) {
let ids: any[] = Array.isArray(citation.id) ? citation.id : [citation.id];
ids.forEach(id => {
reference.ids.push({
type: id.type,
value: id.value,
trust: id.confidenceLevel
});
});
}
references[citation.position - 1] = reference;
});
return references;
}
static parseRelCanonicalId(record, type){
try{
if(record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"] && record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){
for(let child of record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){
return child["objidentifier"];
}
}
}catch(e){
// console.error(e);
}
return record["result"]["header"]["dri:objIdentifier"];
}
parseDescription(description):string[] {
let abstracts = [];
if(!Array.isArray(description)) {
abstracts = [description ? String(description) : ""];
} else {
abstracts = description.map( x => String(x));
}
try{
abstracts = abstracts.map( x => StringUtils.HTMLToString(x));
} catch (e) {}
abstracts =abstracts.sort((a,b) => b.length - a.length);
return abstracts;
}
}