[new-search-json | WIP ] continue parsing research results, start parsing result landing
This commit is contained in:
parent
187444bb09
commit
f675fba83b
|
@ -28,7 +28,10 @@ export class ParsingFunctions {
|
|||
public open = 'open_access';
|
||||
public closed = 'closed_access';
|
||||
public unknown = 'unknown_access';
|
||||
|
||||
// public identifierTypes = ["doi", "pmc" , "handle", "pmid", "re3data", "swhid", "ROR", "ISNI", "Wikidata", "FundRef"];
|
||||
//TODO what are the names of Identifiers types e.g doi = Digital Object Identifier
|
||||
public identifierTypes = ["Digital Object Identifier", "pmc", "Handle", "PubMed ID", "re3data", "swhid",
|
||||
"ROR", "International Standard Name Identifier", "Wikidata", "FundRef"];
|
||||
private instanceWithDoiExists: boolean = false;
|
||||
|
||||
constructor() {
|
||||
|
@ -595,9 +598,7 @@ export class ParsingFunctions {
|
|||
let identifiers = new Map<string, string[]>();
|
||||
|
||||
if (pid.hasOwnProperty("type") && pid['type'] != "") {
|
||||
if (pid.type == "doi" || pid.type == "pmc" || pid.type == "handle" || pid.type == "pmid" || pid.type == "re3data"
|
||||
|| pid.type == "swhid"
|
||||
|| pid.type == "ROR" || pid.type == "ISNI" || pid.type == "Wikidata" || pid.type == "FundRef") {
|
||||
if (this.identifierTypes.indexOf(pid.type) !=-1) {
|
||||
if (!identifiers.has(pid.type)) {
|
||||
identifiers.set(pid.type, new Array<string>());
|
||||
}
|
||||
|
@ -605,9 +606,7 @@ export class ParsingFunctions {
|
|||
}
|
||||
} else {
|
||||
for (let i = 0; i < pid.length; i++) {
|
||||
if (pid[i].type == "doi" || pid[i].type == "pmc" || pid[i].type == "handle" || pid[i].type == "pmid" || pid[i].type == "re3data"
|
||||
|| pid[i].type == "swhid"
|
||||
|| pid[i].type == "ROR" || pid[i].type == "ISNI" || pid[i].type == "Wikidata" || pid[i].type == "FundRef") {
|
||||
if (this.identifierTypes.indexOf(pid[i].type) !=-1) {
|
||||
if (!identifiers.has(pid[i].type)) {
|
||||
identifiers.set(pid[i].type, new Array<string>());
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
} from '@angular/core';
|
||||
import {EnvProperties} from "../../utils/properties/env-properties";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {ParsingFunctions} from "./parsingFunctions.class";
|
||||
|
||||
@Component({
|
||||
selector: 'showIdentifiers',
|
||||
|
@ -26,8 +27,7 @@ import {properties} from "../../../../environments/environment";
|
|||
<span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span>
|
||||
<span [class.uk-margin-small-left]="modal">
|
||||
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
|
||||
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle' || key == 're3data' || key == 'swhid'
|
||||
|| key == 'ROR' || key == 'ISNI' || key == 'Wikidata' || key == 'FundRef'"
|
||||
<a *ngIf="parsingFunctions.identifierTypes.indexOf(key) != -1"
|
||||
[href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external">
|
||||
{{item}}
|
||||
</a>
|
||||
|
@ -69,7 +69,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
|
|||
properties: EnvProperties = properties;
|
||||
@ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>;
|
||||
@ViewChild('identifiersModal') identifiersModal;
|
||||
|
||||
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
|
||||
constructor(private cdr: ChangeDetectorRef) {
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
|
|||
if(value.includes("http://") || value.includes("https://")) {
|
||||
return "";
|
||||
}
|
||||
if(key == "doi") {
|
||||
if(key == "doi" || key == "Digital Object Identifier") {
|
||||
return properties.doiURL;
|
||||
} else if(key == "pmc") {
|
||||
return properties.pmcURL;
|
||||
|
|
|
@ -74,13 +74,14 @@ export class ResultLandingService {
|
|||
error: "Http failure response for " + finalUrl + ": 404 Not Found"
|
||||
});
|
||||
}
|
||||
//TODO make sure to pass the correct part
|
||||
return res['results'][0];
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}))
|
||||
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res]))
|
||||
.pipe(map(res => [
|
||||
// .pipe(map(res => [res['meta']['status'], res['result']['metadata']['oaf:entity'], res]))
|
||||
/*.pipe(map(res => [
|
||||
res[1]['oaf:result'], // 0
|
||||
res[1]['oaf:result']['title'], // 1
|
||||
res[1]['oaf:result']['rels']['rel'], // 2
|
||||
|
@ -99,7 +100,7 @@ export class ResultLandingService {
|
|||
? res[1]['extraInfo']['references']['reference'] : null, // 13
|
||||
res[0], // 14
|
||||
res[2], // 15
|
||||
]))
|
||||
]))*/
|
||||
.pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
|
||||
}
|
||||
|
||||
|
@ -128,35 +129,38 @@ export class ResultLandingService {
|
|||
|
||||
parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any {
|
||||
this.resultLandingInfo = new ResultLandingInfo();
|
||||
try {
|
||||
|
||||
|
||||
// res
|
||||
this.resultLandingInfo.record = data[15];
|
||||
this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"];
|
||||
this.resultLandingInfo.record = data;
|
||||
this.resultLandingInfo.objIdentifier = data["header"]["id"];
|
||||
//TODO relcan ?
|
||||
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
|
||||
this.resultLandingInfo.resultType = data[0].resulttype.classid;
|
||||
|
||||
// res['result']['metadata']['oaf:entity']['oaf:result']
|
||||
if (data[0] != null) {
|
||||
let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer
|
||||
this.resultLandingInfo.resultType = data['header']['recordType'];
|
||||
let date: string = (data['result']['publicationdate'] ? data['result']['publicationdate'] : '') + ''; // transform to string in case it is an integer
|
||||
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
||||
this.resultLandingInfo.dateofacceptance = data[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null;
|
||||
this.resultLandingInfo.publisher = data[0].publisher;
|
||||
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description ? data[0].description : []);
|
||||
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null;
|
||||
this.resultLandingInfo.dateofacceptance = data['result']['publicationdate'] ? Dates.getDate(data['result']['publicationdate']) : null;
|
||||
this.resultLandingInfo.publisher = data['result']['publisher'];
|
||||
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data['result']['description'] ? data['result']['description'] : []);
|
||||
this.resultLandingInfo.embargoEndDate = data['result']['embargoenddate'] ? Dates.getDate(data['result']['embargoenddate']) : null;
|
||||
|
||||
if(data[0].hasOwnProperty("publiclyfunded") && data[0].publiclyfunded) {
|
||||
this.resultLandingInfo.publiclyFunded = data[0].publiclyfunded;
|
||||
|
||||
if (data['result'].hasOwnProperty("publiclyFunded") && data['result'].publiclyFunded) {
|
||||
this.resultLandingInfo.publiclyFunded = data['result'].publiclyFunded;
|
||||
}
|
||||
if((data[0].hasOwnProperty("isgreen") && data[0].isgreen)
|
||||
|| (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor)
|
||||
|| (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) {
|
||||
//TODO check duplicates - are we going to keep one?
|
||||
if ((data['result'].hasOwnProperty("isGreen") && data['result'].isGreen)
|
||||
|| (data['result'].hasOwnProperty("openAccessColor") && data['result'].openAccessColor)
|
||||
|| (data['result'].hasOwnProperty("isInDiamondJournal") && data['result'].isInDiamondJournal)) {
|
||||
this.resultLandingInfo.oaRoutes = {
|
||||
"green": data[0].isgreen,
|
||||
"oaColor": data[0].openaccesscolor,
|
||||
"isInDiamondJournal":data[0].isindiamondjournal
|
||||
"green": data['result'].isGreen,
|
||||
"oaColor": data['result'].openAccessColor,
|
||||
"isInDiamondJournal": data['result'].isInDiamondJournal
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//TODO continue from here
|
||||
if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
|
||||
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
|
||||
}
|
||||
|
@ -451,7 +455,9 @@ export class ResultLandingService {
|
|||
}
|
||||
|
||||
this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults);
|
||||
}catch (e){
|
||||
|
||||
}
|
||||
return this.resultLandingInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -234,14 +234,16 @@ export class SearchResearchResultsService {
|
|||
/////////////////////////// Athena Code ///////////////////////////
|
||||
if (resData['pid']) {
|
||||
if (!Array.isArray(resData['pid'])) {
|
||||
if (resData['pid'].type && resData['pid'].type == 'doi') {
|
||||
//TODO change to "doi"
|
||||
if (resData['pid'].type && resData['pid'].type == 'Digital Object Identifier') {
|
||||
if (resData['pid'].value != '' && resData['pid'].value != null) {
|
||||
result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", ""));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData['pid'].length; i++) {
|
||||
if (resData['pid'][i].type == 'doi') {
|
||||
//TODO change to "doi"
|
||||
if (resData['pid'][i].type == 'Digital Object Identifier') {
|
||||
if (resData['pid'][i].value != '' && resData['pid'][i].value != null && resData['pid'][i].value) {
|
||||
result.DOIs.push((resData['pid'][i].value + "").replace("https://doi.org/", ""));
|
||||
}
|
||||
|
@ -307,7 +309,6 @@ export class SearchResearchResultsService {
|
|||
result['id'] = canId;
|
||||
}
|
||||
result['relcanId'] = result['id'];
|
||||
|
||||
if (resData['links']) {
|
||||
let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1;
|
||||
|
||||
|
@ -379,27 +380,28 @@ export class SearchResearchResultsService {
|
|||
if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') {
|
||||
result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate);
|
||||
}
|
||||
// TODO continue from here
|
||||
if (!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
|
||||
if (!Array.isArray(resData['result'].publisher)) {
|
||||
result.publisher = resData['result'].publisher;
|
||||
} else {
|
||||
for (let i = 0; i < resData.publisher.length; i++) {
|
||||
for (let i = 0; i < resData.publisher['result'].length; i++) {
|
||||
if (result.publisher != undefined) {
|
||||
result.publisher += ', ' + resData['publisher'][i];
|
||||
result.publisher += ', ' + resData['result']['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
result.publisher = resData['result']['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo DOUBLEcheck with connect
|
||||
if (resData['context'] != null) {
|
||||
result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context']));
|
||||
}
|
||||
if (resData.dateofacceptance && resData.dateofacceptance != null) {
|
||||
let date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer
|
||||
if (resData['result'].publicationdate && resData['result'].publicationdate != null) {
|
||||
let date: string = (resData['result'].publicationdate ? resData['result'].publicationdate : '') + ''; // transform to string in case it is an integer
|
||||
result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
||||
result.dateofacceptance = resData.dateofacceptance ? Dates.getDate(resData.dateofacceptance) : null;
|
||||
result.dateofacceptance = resData['result'].publicationdate ? Dates.getDate(resData['result'].publicationdate) : null;
|
||||
}
|
||||
if (resData.journal && resData.journal != null) {
|
||||
if (resData['result'].journal && resData['result'].journal != null) {
|
||||
result.journal = {
|
||||
"journal": "",
|
||||
"issn": "",
|
||||
|
@ -410,14 +412,14 @@ export class SearchResearchResultsService {
|
|||
"start_page": "",
|
||||
"end_page": ""
|
||||
}
|
||||
result.journal['journal'] = resData.journal.content;
|
||||
result.journal['issn'] = resData.journal.issn;
|
||||
result.journal['lissn'] = resData.journal.lissn;
|
||||
result.journal['eissn'] = resData.journal.eissn;
|
||||
result.journal['issue'] = resData.journal.iss;
|
||||
result.journal['volume'] = resData.journal.vol;
|
||||
result.journal['start_page'] = resData.journal.sp;
|
||||
result.journal['end_page'] = resData.journal.ep;
|
||||
result.journal['journal'] = resData['result'].journal.name;
|
||||
result.journal['issn'] = resData['result'].journal.issnPrinted;
|
||||
result.journal['lissn'] = resData['result'].journal.issnLinking;
|
||||
result.journal['eissn'] = resData['result'].journal.issnOnline;
|
||||
result.journal['issue'] = resData['result'].journal.iss;
|
||||
result.journal['volume'] = resData['result'].journal.vol;
|
||||
result.journal['start_page'] = resData['result'].journal.sp;
|
||||
result.journal['end_page'] = resData['result'].journal.ep;
|
||||
}
|
||||
|
||||
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
|
||||
|
@ -425,16 +427,17 @@ export class SearchResearchResultsService {
|
|||
result['journal'] ? result['journal'].journal : null, result.identifiers);
|
||||
|
||||
|
||||
if (resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) {
|
||||
result.publiclyFunded = resData.publiclyfunded;
|
||||
if (resData['result'].hasOwnProperty("publiclyFunded") && resData['result'].publiclyFunded) {
|
||||
result.publiclyFunded = resData['result'].publiclyFunded;
|
||||
}
|
||||
if ((resData.hasOwnProperty("isgreen") && resData.isgreen)
|
||||
|| (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor)
|
||||
|| (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) {
|
||||
//TODO check duplicates - are we going to keep one?
|
||||
if ((resData['result'].hasOwnProperty("isGreen") && resData['result'].isGreen)
|
||||
|| (resData['result'].hasOwnProperty("openAccessColor") && resData['result'].openAccessColor)
|
||||
|| (resData['result'].hasOwnProperty("isInDiamondJournal") && resData['result'].isInDiamondJournal)) {
|
||||
result.oaRoutes = {
|
||||
"green": resData.isgreen,
|
||||
"oaColor": resData.openaccesscolor,
|
||||
"isInDiamondJournal": resData.isindiamondjournal
|
||||
"green": resData['result'].isGreen,
|
||||
"oaColor": resData['result'].openAccessColor,
|
||||
"isInDiamondJournal": resData['result'].isInDiamondJournal
|
||||
};
|
||||
}
|
||||
}catch (e){
|
||||
|
|
Loading…
Reference in New Issue