[Library | new-theme]: parsingFunctions.class.ts: [Bug fix - #8074] In method "parseResults()", updated how title of each related research is parsed (prioritize classid = "main title").
This commit is contained in:
parent
bdce56aff9
commit
89e769f030
|
@ -399,42 +399,6 @@ export class ParsingFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
// publication & dataset & software & orp landing : for relatedResearchResults
|
// 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, relationName: string): RelationResult[] {
|
parseResults(researchResults: RelationResult[], relation, provenanceAction: string, relationName: string): RelationResult[] {
|
||||||
if (researchResults == undefined) {
|
if (researchResults == undefined) {
|
||||||
researchResults = [];
|
researchResults = [];
|
||||||
|
@ -465,8 +429,17 @@ export class ParsingFunctions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
researchResult['id'] = relation['to'].content;
|
researchResult['id'] = relation['to'].content;
|
||||||
let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : (relation['title']?relation['title'].content:null);
|
if(Array.isArray(relation['title'])) {
|
||||||
researchResult['name'] = titleName;
|
for(let i=0; i<relation['title'].length; i++) {
|
||||||
|
if(relation['title'][i] && relation['title'][i].content) {
|
||||||
|
if(!researchResult['name'] || relation['title'][i].classid == "main title") {
|
||||||
|
researchResult['name'] = String(relation['title'][i].content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
researchResult['name'] = (relation['title'] && relation['title'].content) ? String(relation['title'].content) : "";
|
||||||
|
}
|
||||||
if(!researchResult['name']) {
|
if(!researchResult['name']) {
|
||||||
researchResult['name'] = "[no title available]";
|
researchResult['name'] = "[no title available]";
|
||||||
}
|
}
|
||||||
|
@ -489,50 +462,6 @@ export class ParsingFunctions {
|
||||||
return researchResults;
|
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[] {
|
sortByPercentage(results: RelationResult[]): RelationResult[] {
|
||||||
if (results) {
|
if (results) {
|
||||||
return results.sort(function (a, b) {
|
return results.sort(function (a, b) {
|
||||||
|
|
Loading…
Reference in New Issue