[Library | new-theme]: #7963 - Parse field "eoscifguidelines" in result landing page to get eosc subjects.

1. resultLanding.service.ts: Added in parsing field "eoscifgiudelines" (resultLandingInfo.eoscSubjects).
2. parsingFunctions.class.ts: Added method "parseEoscSubjects()" | Method "checkAndAddEoscSubject()" updated - do not add eosc subjects in classifiedSubjects.
3. resultLanding.component.html: In <showSubjects> added [eoscSubjects]="resultLandingInfo.eoscSubjects".
4. showSubjects.component.ts: Added @Input() eoscSubjects: any[]; and show them as classifiedSubjects too.
This commit is contained in:
Konstantina Galouni 2022-08-30 11:35:42 +03:00
parent 27b47975aa
commit 2c27854213
4 changed files with 92 additions and 45 deletions

View File

@ -569,7 +569,29 @@ export class ParsingFunctions {
}
return identifiers;
}
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseEoscSubjects(_subjects: any): any[] {
let eoscSubjectsFound = [];
let setOfEoscSubjects: Set<string> = new Set();
let subject;
let length = Array.isArray(_subjects) ? _subjects.length : 1;
for (let i = 0; i < length; i++) {
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
let content: string = subject.code+"";
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
let found: boolean = checkAndAddEoscSubjectResp["found"];
if(found) {
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
}
}
return eoscSubjectsFound;
}
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseAllSubjects(_subjects: any, vocabulary: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] {
let eoscSubjectsFound = [];
@ -589,11 +611,10 @@ export class ParsingFunctions {
if (subject.classid != "") {
if (subject.classid == "keyword") {
let content: string = subject.content+"";
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content);
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
let found: boolean = checkAndAddEoscSubjectResp["found"];
if(found) {
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
} else {
if (subjects == undefined) {
@ -619,11 +640,10 @@ export class ParsingFunctions {
}
let content: string = subject.content+"";
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content);
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
let found: boolean = checkAndAddEoscSubjectResp["found"];
if(found) {
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
} else {
if (!classifiedSubjects.has(subject.classname)) {
@ -634,11 +654,10 @@ export class ParsingFunctions {
}
} else {
let content: string = subject.content+"";
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content);
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
let found: boolean = checkAndAddEoscSubjectResp["found"];
if(found) {
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"];
eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
} else {
let classname: string = subject.classname + "";
@ -653,29 +672,20 @@ export class ParsingFunctions {
return [subjects, otherSubjects, classifiedSubjects, fos, sdg, eoscSubjectsFound];
}
checkAndAddEoscSubject(setOfEoscSubjects: Set<string>, classifiedSubjects, eoscSubjectsFound, subject, content) {
checkAndAddEoscSubject(setOfEoscSubjects: Set<string>, eoscSubjectsFound, subject, content) {
let found: boolean = false;
if(!setOfEoscSubjects.has(content)) {
// looping through our declared array
this.eoscSubjects.forEach(item => {
if (content && content == item.label) {
if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>();
}
if (!classifiedSubjects.has("EOSC")) {
classifiedSubjects.set("EOSC", new Array<string>());
}
found = true;
eoscSubjectsFound.push(item);
setOfEoscSubjects.add(content);
classifiedSubjects.get("EOSC").push(item.value);
}
});
}
return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "classifiedSubjects": classifiedSubjects, "eoscSubjectsFound": eoscSubjectsFound};
return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "eoscSubjectsFound": eoscSubjectsFound};
}
parseContexts(_contexts: any): Context[] {

View File

@ -13,11 +13,12 @@ import {properties} from "../../../../environments/environment";
@Component({
selector: 'showSubjects',
template: `
<ng-container *ngIf="classifiedSubjects && classifiedSubjects.size > 0">
<ng-container *ngIf="(classifiedSubjects && classifiedSubjects.size > 0) || (eoscSubjects && eoscSubjects.length > 0)">
<div class="uk-text-meta">
Subjects by Vocabulary
</div>
<ng-container *ngTemplateOutlet="subjects_by_vocabulary_template; context: {customClasses: 'multi-line-ellipsis lines-2', id: 'content'}"></ng-container>
<ng-container *ngTemplateOutlet="eosc_subjects_template"></ng-container>
<div *ngIf="isClassifiedLarge" class="uk-text-right">
<a (click)="openSubjectsByVocabularyModal()" class="view-more-less-link">View all</a>
</div>
@ -73,10 +74,30 @@ import {properties} from "../../../../environments/environment";
</p>
</div>
</ng-template>
<ng-template #eosc_subjects_template let-customClasses="customClasses" let-id="id">
<div class="uk-flex-wrap uk-margin-medium-right"
[ngClass]="customClasses">
<p class="uk-flex uk-flex-middle uk-margin-bottom">
<span #classifiedContent [id]="id+'_eosc'">
<span class="uk-margin-small-top uk-display-inline-block">
<span uk-icon="tag"></span>
<span class="uk-text-bold uk-margin-small-right"> EOSC: </span>
</span>
<span *ngFor="let subject of eoscSubjects; let j=index" class="uk-margin-small-top uk-width-auto uk-display-inline-block">
<span class="uk-border-rounded uk-label uk-label-small uk-label-primary uk-text-truncate uk-margin-small-right">
{{subject.value}}
</span>
</span>
</span>
</p>
</div>
</ng-template>
<modal-alert #subjectsByVocabularyModal *ngIf="classifiedSubjects && classifiedSubjects.size > 0" large="true">
<modal-alert #subjectsByVocabularyModal *ngIf="(classifiedSubjects && classifiedSubjects.size > 0) || (eoscSubjects && eoscSubjects.length > 0)" large="true">
<div class="uk-text-small">
<ng-container *ngTemplateOutlet="subjects_by_vocabulary_template"></ng-container>
<ng-container *ngTemplateOutlet="eosc_subjects_template"></ng-container>
</div>
</modal-alert>
`
@ -86,6 +107,7 @@ export class ShowSubjectsComponent {
@Input() subjects: string[];
@Input() otherSubjects: Map<string, string[]>;
@Input() classifiedSubjects: Map<string, string[]>;
@Input() eoscSubjects: any[];
isLarge: boolean = false;
isClassifiedLarge: boolean = false;
properties = properties;
@ -156,6 +178,12 @@ export class ShowSubjectsComponent {
}
});
}
if(typeof document !== "undefined" && this.eoscSubjects && this.classifiedContent) {
let tag = this.classifiedContent.find(tag => tag.nativeElement.id === "content_eosc");
if(tag && tag.nativeElement.offsetHeight > overflow) {
this.isClassifiedLarge = true;
}
}
}
public getKeys(map) {

View File

@ -283,7 +283,8 @@
resultLandingInfo.classifiedSubjects" class="uk-margin-medium-bottom">
<showSubjects [subjects]="resultLandingInfo.subjects"
[otherSubjects]="resultLandingInfo.otherSubjects"
[classifiedSubjects]="resultLandingInfo.classifiedSubjects">
[classifiedSubjects]="resultLandingInfo.classifiedSubjects"
[eoscSubjects]="resultLandingInfo.eoscSubjects">
</showSubjects>
</div>
<!-- Related Organizations-->

View File

@ -87,16 +87,17 @@ export class ResultLandingService {
res[1]['oaf:result']['pid'], // 4
res[1]['oaf:result']['journal'], // 5
res[1]['oaf:result']['language'], // 6
res[1]['oaf:result']['subject'], // 7
res[1]['oaf:result']['context'], // 8
res[1]['oaf:result']['creator'], // 9
res[1]['oaf:result']['country'] , // 10
res[1]['oaf:result']['programmingLanguage'], // 11 - software
res[1]['oaf:result']['eoscifgiudelines'], // 7
res[1]['oaf:result']['subject'], // 8
res[1]['oaf:result']['context'], // 9
res[1]['oaf:result']['creator'], // 10
res[1]['oaf:result']['country'] , // 11
res[1]['oaf:result']['programmingLanguage'], // 12 - software
//res[1]['oaf:result']['resulttype'],
(res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined)
? res[1]['extraInfo']['references']['reference'] : null, // 12
res[0], // 13
res[2], // 14
? res[1]['extraInfo']['references']['reference'] : null, // 13
res[0], // 14
res[2], // 15
]))
.pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, subjectsVocabulary, relationsVocabulary, properties)));
}
@ -128,8 +129,8 @@ export class ResultLandingService {
this.resultLandingInfo = new ResultLandingInfo();
// res
this.resultLandingInfo.record = data[14];
this.resultLandingInfo.objIdentifier = data[14]["result"]["header"]["dri:objIdentifier"];
this.resultLandingInfo.record = data[15];
this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"];
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
this.resultLandingInfo.resultType = data[0].resulttype.classid;
@ -332,13 +333,18 @@ export class ResultLandingService {
}
// res['result']['metadata']['oaf:entity']['oaf:result']['country']
if(data[10] != null) {
this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[10]);
if(data[11] != null) {
this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[11]);
}
// res['result']['metadata']['oaf:entity']['oaf:result']['eoscifguidelines']
if(data[7] != null) {
this.resultLandingInfo.eoscSubjects = this.parsingFunctions.parseEoscSubjects(data[7]);
}
// res['result']['metadata']['oaf:entity']['oaf:result']['subject']
if(data[7] != null) {
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7], subjectsVocabulary);
if(data[8] != null) {
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary);
this.resultLandingInfo.subjects = subjectResults[0];
this.resultLandingInfo.otherSubjects = subjectResults[1];
this.resultLandingInfo.classifiedSubjects = subjectResults[2];
@ -353,7 +359,9 @@ export class ResultLandingService {
})
}
this.resultLandingInfo.eoscSubjects = subjectResults[5];
if(!this.resultLandingInfo.eoscSubjects) {
this.resultLandingInfo.eoscSubjects = subjectResults[5];
}
}
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
@ -361,34 +369,34 @@ export class ResultLandingService {
this.resultLandingInfo.journal, this.resultLandingInfo.identifiers);
// res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage']
if(data[11] != null) {
this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[11]);
if(data[12] != null) {
this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]);
}
// res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference']
if(data[12] != null) {
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[12]);
if(data[13] != null) {
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
}
// res['result']['metadata']['oaf:entity']['oaf:result']['context']
if(data[8] != null) {
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[8]);
if(data[9] != null) {
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]);
}
// res['result']['header']['dri:status']
if(data[13] != null && data[13] == "under curation") {
if(data[14] != null && data[14] == "under curation") {
this.resultLandingInfo.underCurationMessage = true;
} else {
this.resultLandingInfo.underCurationMessage = false;
}
// res['result']['metadata']['oaf:entity']['oaf:result']['creator']
if(data[9] != null) {
if(data[10] != null) {
if(this.resultLandingInfo.authors == undefined) {
this.resultLandingInfo.authors = new Array<{"fullName": string, "orcid": string, "orcid_pending": string}>();
}
let authors = data[9];
let authors = data[10];
let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) {