From 51dbad03d725bcc2fa87244f7c4ccef66c92a4f5 Mon Sep 17 00:00:00 2001
From: "konstantina.galouni" <kgalouni@di.uoa.gr>
Date: Wed, 20 Dec 2023 23:55:00 +0200
Subject: [PATCH] [angular-16-irish-monitor | DONE | ADDED]: Added parsing of
 peer-reviewed (refereed on instances), publicly funded and OA Routes (green,
 oa color, diamond journal) | Display peer-reviewed on instances and publicly
 funded (and projects) in metadata line (entity-metadata). 1.
 feedback.component.html & resultLanding.component.html: In <landing-header>
 added parameters publiclyFunded and projects. 2. landing-header.component.ts
 & result-preview.component.html: In <entity-metadata> added parameters
 publiclyFunded and projects | Added field @Input() publiclyFunded. 3.
 availableOn.component.ts: Display peer-reviewed. 4.
 entity-metadata.component.ts: Display publicly funded | Added field @Input()
 publiclyFunded: boolean. 5. parsingFunctions.class.ts: Added parsing of
 peer-reviewed (instance.refereed). 6. resultLanding.service.ts &
 searchResearchResults.service.ts: Added parsing of publicly funded and OA
 Routes (green, oa color, diamond journal). 7. resultLandingInfo.ts &
 searchResult.ts: In ResultLandingInfo and in SearchResult added fields
 oaRoutes: OARoutes; and publiclyFunded: boolean; 8. result-preview.ts: In
 HostedByCollectedFrom added field peerReviewed?: boolean; | Set interface
 OARoutes | In ResultPreview added fields oaRoutes: OARoutes; and
 publiclyFunded: boolean; | In methods "searchResultConvert()" and
 "resultLandingInfoConvert()" set oaRoutes and publiclyFunded.

---
 landingPages/feedback/feedback.component.html    |  3 ++-
 .../landing-utils/availableOn.component.ts       |  4 +++-
 .../landing-utils/entity-metadata.component.ts   |  4 ++++
 .../landing-header/landing-header.component.ts   |  3 ++-
 .../landing-utils/parsingFunctions.class.ts      |  7 ++++++-
 landingPages/result/resultLanding.component.html |  2 ++
 landingPages/result/resultLanding.service.ts     | 13 +++++++++++++
 services/searchResearchResults.service.ts        | 16 +++++++++++++++-
 utils/entities/resultLandingInfo.ts              |  5 ++++-
 utils/entities/searchResult.ts                   | 13 ++++++++++++-
 .../result-preview/result-preview.component.html |  3 ++-
 utils/result-preview/result-preview.ts           | 16 ++++++++++++++++
 12 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/landingPages/feedback/feedback.component.html b/landingPages/feedback/feedback.component.html
index 837c76bc..9a569781 100644
--- a/landingPages/feedback/feedback.component.html
+++ b/landingPages/feedback/feedback.component.html
@@ -9,7 +9,8 @@
       <landing-header *ngIf="resultLandingInfo" [properties]="properties" [title]="title"
                       [subTitle]="resultLandingInfo.subtitle" [underCuration]="resultLandingInfo.underCurationMessage"
                       [entityType]="entityType" [types]="resultLandingInfo.types"
-                      [year]="resultLandingInfo.date" [embargoEndDate]="resultLandingInfo.embargoEndDate">
+                      [year]="resultLandingInfo.date" [embargoEndDate]="resultLandingInfo.embargoEndDate"
+                      [publiclyFunded]="resultLandingInfo.publiclyFunded" [projects]="resultLandingInfo.fundedByProjects">
       </landing-header>
       <landing-header *ngIf="organizationInfo" [properties]="properties" [title]="title"
                       [subTitle]="(organizationInfo.name && organizationInfo.title.name !== organizationInfo.name)?organizationInfo.name:null"
diff --git a/landingPages/landing-utils/availableOn.component.ts b/landingPages/landing-utils/availableOn.component.ts
index 336d0c75..ece98bab 100644
--- a/landingPages/landing-utils/availableOn.component.ts
+++ b/landingPages/landing-utils/availableOn.component.ts
@@ -82,10 +82,12 @@ import {RouterHelper} from "../../utils/routerHelper.class";
               {{instance.downloadNames.join("; ")}}
             </a>
           </span>
-          <div *ngIf="instance.types?.length > 0 || instance.years?.length > 0" class="uk-text-meta">
+          <div *ngIf="instance.types?.length > 0 || instance.years?.length > 0 || instance.peerReviewed" class="uk-text-meta">
             <span *ngIf="instance.types?.length > 0" class="uk-text-capitalize">{{instance.types.join(" . ")}}</span>
             <span *ngIf="instance.types?.length > 0 && instance.years?.length > 0"> . </span>
             <span *ngIf="instance.years?.length > 0">{{instance.years.join(" . ")}}</span>
+            <span *ngIf="(instance.types?.length > 0 || instance.years?.length > 0) && instance.peerReviewed"> . </span>
+            <span *ngIf="instance.peerReviewed">Peer-reviewed</span>
           </div>
           <div *ngIf="instance.license" class="uk-text-meta uk-text-truncate" uk-tooltip [title]="instance.license">
             License:
diff --git a/landingPages/landing-utils/entity-metadata.component.ts b/landingPages/landing-utils/entity-metadata.component.ts
index 62f8a0a9..d9e0cf98 100644
--- a/landingPages/landing-utils/entity-metadata.component.ts
+++ b/landingPages/landing-utils/entity-metadata.component.ts
@@ -148,6 +148,9 @@ import {RouterHelper} from "../../utils/routerHelper.class";
       <ng-container *ngIf="thematic">
         <span>Thematic</span>
       </ng-container>
+      <ng-container *ngIf="publiclyFunded">
+        <span>Publicly funded</span>
+      </ng-container>
       <!-- Projects -->
       <span *ngIf="projects && projects.length > 0"
         [attr.uk-tooltip]="projects.length > projectsLimit ? 'cls: uk-invisible' : 'pos: top; cls: uk-active'" title="Funded by">
@@ -244,6 +247,7 @@ export class EntityMetadataComponent {
   @Input() type; // data provider landing
   @Input() provenanceAction: string; // search result
   @Input() relationName: string; // search result
+  @Input() publiclyFunded: boolean; // search result
   @Input() projects: Project[];
   @Input() organizations: Organization[];
   @Input() subjects: string[];
diff --git a/landingPages/landing-utils/landing-header/landing-header.component.ts b/landingPages/landing-utils/landing-header/landing-header.component.ts
index adfe3268..649a6ec1 100644
--- a/landingPages/landing-utils/landing-header/landing-header.component.ts
+++ b/landingPages/landing-utils/landing-header/landing-header.component.ts
@@ -21,7 +21,7 @@ import {AlertModal} from "../../../utils/modal/alert";
 												 [languages]="languages" [programmingLanguages]="programmingLanguages"
 												 [compatibility]="compatibility" [aggregationStatus]="aggregationStatus"
 												 [thematic]="thematic" [type]="type" [prevPath]="prevPath"
-                         [countries]="countries" [projects]="projects"
+                         [countries]="countries" [publiclyFunded]="publiclyFunded" [projects]="projects"
 				></entity-metadata>
 			</div>
 			<div *ngIf="authors">
@@ -63,5 +63,6 @@ export class LandingHeaderComponent {
 	@Input() type; // data provider landing
   @Input() prevPath: string = "";
   @Input() countries;
+  @Input() publiclyFunded;
   @Input() projects;
 }
diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts
index 112eb192..105c54cf 100644
--- a/landingPages/landing-utils/parsingFunctions.class.ts
+++ b/landingPages/landing-utils/parsingFunctions.class.ts
@@ -265,7 +265,8 @@ export class ParsingFunctions {
       "types": [],
       "years": [],
       "license": "",
-      "fulltext": ""
+      "fulltext": "",
+      "peerReviewed": null
     };
 
     if (instance.hasOwnProperty("hostedby")) {
@@ -358,6 +359,10 @@ export class ParsingFunctions {
     if(instance.hasOwnProperty("fulltext")) {
       available.fulltext = instance['fulltext'];
     }
+
+    if(instance.hasOwnProperty("refereed") && instance.refereed.classname == "peerReviewed") {
+      available.peerReviewed = true;
+    }
     
     hostedBy_collectedFrom.push(available);
   }
diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html
index 7d6a9ccd..63e7d5cd 100644
--- a/landingPages/result/resultLanding.component.html
+++ b/landingPages/result/resultLanding.component.html
@@ -228,6 +228,7 @@
                                   [publisher]="resultLandingInfo.publisher" [journal]="resultLandingInfo.journal"
                                   [languages]="resultLandingInfo.languages" [programmingLanguages]="resultLandingInfo.programmingLanguages"
                                   [prevPath]="prevPath" [countries]="resultLandingInfo.countries"
+                                  [publiclyFunded]="resultLandingInfo.publiclyFunded"
                                   [projects]="resultLandingInfo.fundedByProjects">
                   </landing-header>
                   <!-- Labels -->
@@ -522,6 +523,7 @@
                       [date]="resultLandingInfo.dateofacceptance" [embargoEndDate]="resultLandingInfo.embargoEndDate"
                       [publisher]="resultLandingInfo.publisher" [journal]="resultLandingInfo.journal"
                       [languages]="resultLandingInfo.languages" [programmingLanguages]="resultLandingInfo.programmingLanguages"
+                      [publiclyFunded]="resultLandingInfo.publiclyFunded" [projects]="resultLandingInfo.fundedByProjects"
                       [isMobile]="true" [prevPath]="prevPath">
       </landing-header>
       <div class="uk-text-small">
diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts
index 263bba8e..85817115 100644
--- a/landingPages/result/resultLanding.service.ts
+++ b/landingPages/result/resultLanding.service.ts
@@ -141,6 +141,19 @@ export class ResultLandingService {
       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;
+
+      if(data[0].hasOwnProperty("publiclyfunded") && data[0].publiclyfunded) {
+        this.resultLandingInfo.publiclyFunded = data[0].publiclyfunded;
+      }
+      if((data[0].hasOwnProperty("isgreen") && data[0].isgreen)
+        || (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor)
+        || (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) {
+        this.resultLandingInfo.oaRoutes = {
+          "green": data[0].isgreen,
+          "oaColor": data[0].openaccesscolor,
+          "isInDiamondJournal":data[0].isindiamondjournal
+        };
+      }
     }
 
     if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
diff --git a/services/searchResearchResults.service.ts b/services/searchResearchResults.service.ts
index 388f109e..17719ce9 100644
--- a/services/searchResearchResults.service.ts
+++ b/services/searchResearchResults.service.ts
@@ -416,7 +416,21 @@ export class SearchResearchResultsService {
       result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
         result.hostedBy_collectedFrom, result.publisher,
         result['journal']?result['journal'].journal:null, result.identifiers);
-      
+
+
+      if(resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) {
+        result.publiclyFunded = resData.publiclyfunded;
+      }
+      if((resData.hasOwnProperty("isgreen") && resData.isgreen)
+        || (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor)
+        || (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) {
+        result.oaRoutes = {
+          "green": resData.isgreen,
+          "oaColor": resData.openaccesscolor,
+          "isInDiamondJournal":resData.isindiamondjournal
+        };
+      }
+
       results.push(result);
     }
     return results;
diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts
index 1e2f7740..16eb7ae1 100644
--- a/utils/entities/resultLandingInfo.ts
+++ b/utils/entities/resultLandingInfo.ts
@@ -1,7 +1,7 @@
 import {
   Author,
   HostedByCollectedFrom,
-  Journal,
+  Journal, OARoutes,
   Organization,
   Project,
   RelationResult
@@ -95,6 +95,9 @@ export class ResultLandingInfo {
   fos: {"id": string, "label": string}[] = [];
   sdg: string[];
   eoscSubjects: any[];
+
+  oaRoutes: OARoutes;
+  publiclyFunded: boolean;
   
   // // percentage is for trust
   // relatedResearchResults: RelationResult[];
diff --git a/utils/entities/searchResult.ts b/utils/entities/searchResult.ts
index c8221930..c8c73e67 100644
--- a/utils/entities/searchResult.ts
+++ b/utils/entities/searchResult.ts
@@ -1,4 +1,12 @@
-import {Author, HostedByCollectedFrom, Journal, Organization, Project, ResultTitle} from "../result-preview/result-preview";
+import {
+  Author,
+  HostedByCollectedFrom,
+  Journal,
+  OARoutes,
+  Organization,
+  Project,
+  ResultTitle
+} from "../result-preview/result-preview";
 import {Measure, Metric} from "./resultLandingInfo";
 
 export class SearchResult {
@@ -66,6 +74,9 @@ export class SearchResult {
   types: string[];
   enermapsId: string;
 
+  oaRoutes: OARoutes;
+  publiclyFunded: boolean;
+
   constructor() {
   }
 
diff --git a/utils/result-preview/result-preview.component.html b/utils/result-preview/result-preview.component.html
index 2e1e2358..e67e8eef 100644
--- a/utils/result-preview/result-preview.component.html
+++ b/utils/result-preview/result-preview.component.html
@@ -85,7 +85,8 @@
                                [embargoEndDate]="result.embargoEndDate"
                                [publisher]="result.publisher" [countries]="result.countries"
                                [languages]="result.languages" [programmingLanguages]="result.programmingLanguages"
-                               [compatibilityString]="result.compatibility" [type]="type" [projects]="result.projects"
+                               [compatibilityString]="result.compatibility" [type]="type"
+                               [publiclyFunded]="result.publiclyFunded" [projects]="result.projects"
                                [subjects]="showSubjects?result.subjects:null" [organizations]="showOrganizations?result.organizations:null"
                                [relationName]="relationName" [provenanceAction]="provenanceAction" [prevPath]="prevPath"
               ></entity-metadata>
diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts
index 11ee68c5..542e34f2 100644
--- a/utils/result-preview/result-preview.ts
+++ b/utils/result-preview/result-preview.ts
@@ -12,6 +12,7 @@ export interface HostedByCollectedFrom {
   accessRightIcon: string;
   license?: string;
   fulltext?: string;
+  peerReviewed?: boolean;
 }
 
 export interface Journal {
@@ -72,6 +73,12 @@ export interface Organization {
   trust?: number;
 }
 
+export interface OARoutes {
+  green: boolean;
+  oaColor: "gold" | "hybrid" | "bronze";
+  isInDiamondJournal: boolean;
+}
+
 export class ResultPreview {
   objId: string;
   relcanId: string;
@@ -148,6 +155,9 @@ export class ResultPreview {
   //enermaps id - image
   enermapsId: string;
 
+  oaRoutes: OARoutes;
+  publiclyFunded: boolean;
+
   public static searchResultConvert(result: SearchResult, type: string): ResultPreview {
     let resultPreview: ResultPreview = new ResultPreview();
     resultPreview.id = result.id;
@@ -207,6 +217,9 @@ export class ResultPreview {
     resultPreview.enermapsId = result.enermapsId;
     resultPreview.measure = result.measure;
     resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom;
+
+    resultPreview.oaRoutes = result.oaRoutes;
+    resultPreview.publiclyFunded = result.publiclyFunded;
     return resultPreview;
   }
 
@@ -234,6 +247,9 @@ export class ResultPreview {
     resultPreview.resultType = type;
     resultPreview.identifiers = result.identifiers;
     resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom;
+
+    resultPreview.oaRoutes = result.oaRoutes;
+    resultPreview.publiclyFunded = result.publiclyFunded;
     return resultPreview;
   }