1. Add landing, search and advanced search page with appropriate services for 'Other Research Products'.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52817 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-07-25 13:30:12 +00:00
parent 4b7b13f8c7
commit 2196741bc4
12 changed files with 1767 additions and 0 deletions

View File

@ -0,0 +1,185 @@
<div id="tm-main" class=" uk-section uk-margin-small-top tm-middle">
<div uk-grid uk-grid>
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first">
<div class="uk-container uk-margin-top orp">
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning uk-margin-large-top" role="alert">{{warningMessage}}</div>
<div *ngIf="errorMessage.length > 0" class="uk-alert uk-alert-danger uk-margin-large-top" role="alert">{{errorMessage}}</div>
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><img class="loading-gif uk-align-center" ></div>
<div *ngIf="orpInfo != null" uk-grid class="uk-grid-large">
<div class="uk-width-expand@m uk-width-1-1@s">
<schema2jsonld *ngIf="orpInfo.record" [data]=orpInfo.record [URL]="properties.baseLink+'/search/orp?orpId='+orpId"></schema2jsonld>
<showTitle [titleName]="orpInfo.title"></showTitle>
<span *ngIf="orpInfo.types && orpInfo.types.length > 0"class="uk-label custom-label label-orp " title="Type">{{orpInfo.types.join(", ")}}</span>
<span *ngIf="orpInfo.languages && orpInfo.languages.length > 0" class="uk-label custom-label label-language " title="Language">{{orpInfo.languages.join(", ")}}</span>
<span *ngIf="orpInfo.countries && orpInfo.countries.length > 0" class="uk-label custom-label label-country " title="Country">{{orpInfo.countries.join(", ")}}</span>
<span *ngIf="orpInfo.accessMode" [class]="'uk-label custom-label label-'+ orpInfo.accessMode " title="Access Mode">{{orpInfo.accessMode}}</span>
<span *ngIf="orpInfo.underCurationMessage" class="uk-label custom-label label-underCuration">
<span uk-tooltip="pos:right; delay:10"
title="{{buildCurationTooltip()}}">
<i>Record in preview</i>
<i class="uk-icon-info-circle"></i>
</span>
</span>
<div class= " uk-margin-top">
<showAuthors [authors]="orpInfo.authors" searchPage="orps"></showAuthors>
<span *ngIf="orpInfo.date != ''">({{orpInfo.date}})</span>
</div>
<ul class="uk-list">
<li *ngIf="orpInfo.publisher"><span class="uk-text-bold">Publisher:</span> {{orpInfo.publisher}}</li>
<li *ngIf="orpInfo.embargoEndDate"><span class="uk-text-bold">Embargo end date:</span> {{orpInfo.embargoEndDate}}</li>
<li *ngIf="orpInfo.identifiers && orpInfo.identifiers.size > 0">
<showIdentifiers [identifiers]="orpInfo.identifiers"></showIdentifiers>
</li>
<li *ngIf="orpInfo.subjects ||orpInfo.otherSubjects || orpInfo.classifiedSubjects">
<showSubjects [subjects]="orpInfo.subjects"
[otherSubjects]="orpInfo.otherSubjects"
[classifiedSubjects]="orpInfo.classifiedSubjects">
</showSubjects>
</li>
</ul>
<div *ngIf="orpInfo.description" class="uk-margin-bottom uk-text-justify descriptionText">
{{orpInfo.description}}
</div>
<ul class="custom-accordion" uk-accordion>
<li *ngIf="orpInfo.relatedResearchResults" (click)="activeTab='Related Research Results'">
<a class="uk-accordion-title" href="#">
Related Research Results
<span class="uk-badge uk-badge-notification">
{{relatedResearchResultsNum | number}}
</span>
</a>
<div class="uk-accordion-content">
<div>
<div *ngFor="let provenanceaction of getKeys(orpInfo.relatedResearchResults)">
<div class="uk-text-large uk-margin-bottom">{{provenanceaction}}</div>
<tabTable [percentageName]="trust" [info]="orpInfo.relatedResearchResults.get(provenanceaction)" [(properties)]=properties></tabTable>
</div>
</div>
</div>
</li>
<li *ngIf="orpInfo.similarResearchResults" (click)="activeTab='Similar Research Results'">
<a class="uk-accordion-title" href="#">
Similar Research Results
<span class="uk-badge uk-badge-notification">
{{orpInfo.similarResearchResults.length | number}}
</span>
</a>
<div class="uk-accordion-content">
<div>
<tabTable [percentageName]="similarity" [info]="orpInfo.similarResearchResults" [(properties)]=properties></tabTable>
</div>
</div>
</li>
<li (click)="metricsClicked=true; activeTab='Metrics'">
<a class="uk-accordion-title" href="#">
Metrics
</a>
<div class="uk-accordion-content">
<metrics [pageViews]="pageViews"
[id]="orpId" [entityType]="'results'" [entity]="'Other Research Product'"
(metricsResults)="metricsResults($event)" [(properties)] = properties>
</metrics>
<i-frame *ngIf="metricsClicked && totalViews > 0"
[url]=viewsFrameUrl width="100%" height="250">
</i-frame>
<i-frame *ngIf="metricsClicked && totalDownloads > 0"
[url]=downloadsFrameUrl width="100%" height="250">
</i-frame>
</div>
</li>
</ul>
</div>
<div class="uk-width-large@m uk-width-1-1@s">
<div class=" uk-padding-small">
<div>
<div class="sideInfoTitle uk-margin-small-bottom">Share - Bookmark</div>
<addThis></addThis>
</div>
<altmetrics *ngIf="orpInfo.identifiers && orpInfo.identifiers.get('doi')"
id="{{orpInfo.identifiers.get('doi')[0]}}" type="doi">
</altmetrics>
<ul class="uk-list">
<li *ngIf="orpInfo.hostedBy_collectedFrom && orpInfo.hostedBy_collectedFrom.length > 0">
<availableOn [availableOn]="orpInfo.hostedBy_collectedFrom"></availableOn>
</li>
<li *ngIf="orpInfo.fundedByProjects != undefined && orpInfo.fundedByProjects.length > 0">
<fundedBy [fundedByProjects]="orpInfo.fundedByProjects"></fundedBy>
</li>
<li *ngIf="orpInfo.contexts && orpInfo.contexts.length >0 ">
<dl class="uk-description-list-line" >
<dt class="sideInfoTitle">Related to </dt>
<dd class="line" *ngFor="let item of orpInfo.contexts">
<span *ngIf = "!item['inline']" >
<span>{{item['labelContext']}}</span>
<span *ngIf="item['labelCategory']">-> {{item['labelCategory']}}</span>
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
</span>
<mark *ngIf = "item['inline']" >
<span>{{item['labelContext']}}</span>
<span *ngIf="item['labelCategory']">-> {{item['labelCategory']}}</span>
<span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
</mark>
</dd>
</dl>
</li>
<li>
<ul uk-accordion class="uk-padding-remove citation-accordion">
<li>
<div class="sideInfoTitle uk-accordion-title cite-this-button uk-width-1-1" type="button">
Cite this reasearch data
</div>
<div class="uk-accordion-content">
<citeThis [result]="orpInfo" [id]="orpId" type="other research product"></citeThis>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<!-- Claiming FAB -->
<div class="uk-inline">
<div class=" uk-float-right " style="z-index: 200; bottom: 55px; position: fixed; right: 45%;">
<button style=" box-shadow: 0 1px 10px #444444" class=" uk-button uk-button-danger ">
<span class="uk-icon">
<svg icon="link" ratio="1" xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 20 20" height="25"><path d="M10.625,12.375 L7.525,15.475 C6.825,16.175 5.925,16.175 5.225,15.475 L4.525,14.775 C3.825,14.074 3.825,13.175 4.525,12.475 L7.625,9.375" fill="none" stroke="#000" stroke-width="1.1"></path><path d="M9.325,7.375 L12.425,4.275 C13.125,3.575 14.025,3.575 14.724,4.275 L15.425,4.975 C16.125,5.675 16.125,6.575 15.425,7.275 L12.325,10.375" fill="none" stroke="#000" stroke-width="1.1"></path><path d="M7.925,11.875 L11.925,7.975" fill="none" stroke="#000" stroke-width="1.1"></path></svg>
</span> Link this other research product to
</button>
<div uk-dropdown="pos: top-right; mode:click" style="background: transparent !important;box-shadow: none; max-width: 70px !important; min-width: 70px !important;">
<ul class="uk-iconnav uk-iconnav-vertical">
<li uk-tooltip="pos:left;" title="<div class='tooltip-custom-font-size uk-light '>Projects</div>">
<a class=" uk-icon-button uk-button-primary shadowBox" style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[orpId,'orp','project'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
<span class="uk-icon" >
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="album" ratio="1"><rect x="5" y="2" width="10" height="1"></rect><rect x="3" y="4" width="14" height="1"></rect><rect fill="none" stroke="#000" x="1.5" y="6.5" width="17" height="11"></rect></svg></span>
</a>
</li>
<li uk-tooltip="pos:left;" title="<div class='tooltip-custom-font-size uk-light '>Communities</div>">
<a class=" uk-icon-button uk-button-primary shadowBox" style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[orpId,'orp','context'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
<span class="uk-icon" >
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="users" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="7.7" cy="8.6" r="3.5"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M1,18.1 C1.7,14.6 4.4,12.1 7.6,12.1 C10.9,12.1 13.7,14.8 14.3,18.3"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M11.4,4 C12.8,2.4 15.4,2.8 16.3,4.7 C17.2,6.6 15.7,8.9 13.6,8.9 C16.5,8.9 18.8,11.3 19.2,14.1"></path></svg></span>
</a>
</li>
<li uk-tooltip="pos:left;" title="<div class='tooltip-custom-font-size uk-light uk-margin-small'>Other research results</div>">
<a class=" uk-icon-button uk-button-primary shadowBox" style="padding: 6px;" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[orpId,'orp','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
<span class="uk-icon" >
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="copy" ratio="1"><rect fill="none" stroke="#000" x="3.5" y="2.5" width="12" height="16"></rect><polyline fill="none" stroke="#000" points="5 0.5 17.5 0.5 17.5 17"></polyline></svg></span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,182 @@
import {Component, ViewChild} from '@angular/core';
import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {OrpInfo} from '../../utils/entities/orpInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {RouterHelper} from '../../utils/routerHelper.class';
import {OrpService} from './orp.service';
import {PiwikService} from '../../utils/piwik/piwik.service';
@Component({
selector: 'orp',
templateUrl: 'orp.component.html',
})
export class OrpComponent {
@Input() piwikSiteId = null;
public orpInfo: OrpInfo;
public orpId : string ;
// APP BOX variables
public showAllCollectedFrom: boolean = false;
public showAllDownloadFrom: boolean = false;
public showAllPublishedIn: boolean = false;
// Metrics tab variables
public metricsClicked: boolean;
public viewsFrameUrl: string;
public downloadsFrameUrl: string;
public totalViews: number;
public totalDownloads: number;
public pageViews: number;
// Active tab variable for responsiveness
public activeTab: string = "Related Research Results";
// Map counting variable
public relatedResearchResultsNum: number = 0;
// Message variables
public warningMessage = "";
public errorMessage = "";
public showLoading: boolean = true;
public routerHelper:RouterHelper = new RouterHelper();
private result ;
sub: any; piwiksub: any; infoSub: any;
properties:EnvProperties;
constructor (private element: ElementRef,
private _orpService: OrpService,
private _piwikService:PiwikService,
private route: ActivatedRoute,
private _meta: Meta,
private _title: Title,
private _router: Router) {
}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.updateUrl(data.envSpecific.baseLink+this._router.url);
});
this.sub = this.route.queryParams.subscribe(params => {
this.orpInfo = null;
this.updateTitle("Other Research Product");
this.updateDescription("Other Research Product, search, open access");
this.orpId = params['orpId'];
console.info("Id is :"+this.orpId);
if(this.orpId){
this.getOrpInfo(this.orpId);
}else{
this.showLoading = false;
this.warningMessage="No valid other research product id";
}
this.metricsClicked = false;
this.viewsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.orpId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
this.downloadsFrameUrl = this.properties.framesAPIURL+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.orpId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
});
}
ngOnDestroy() {
this.sub.unsubscribe();
if(this.piwiksub){
this.piwiksub.unsubscribe();
}
if(this.infoSub) {
this.infoSub.unsubscribe();
}
}
private getOrpInfo(id:string) {
this.warningMessage = '';
this.errorMessage=""
this.showLoading = true;
this.orpInfo = null;
this.infoSub = this._orpService.getOrpInfo(id, this. properties).subscribe(
data => {
this.orpInfo = data;
if(this.orpInfo.title){
this.updateTitle(this.orpInfo.title);
this.updateDescription("Other Research Product, search, repositories, open access,"+this.orpInfo.title);
}
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, this.orpInfo.title, this.piwikSiteId).subscribe();
}
this.result = []
this.result = {id: id, type :"orp", source : "openaire", title: this.orpInfo.title,url: '', result: '', accessRights: this.orpInfo.accessMode, embargoEndDate: ''};
let relatedResearchResultsNum = 0;
if(this.orpInfo.relatedResearchResults != undefined) {
this.orpInfo.relatedResearchResults.forEach(function (value, key, map) {
relatedResearchResultsNum += value.length;
});
}
this.relatedResearchResultsNum = relatedResearchResultsNum;
this.showLoading = false;
},
err => {
console.log(err)
console.info("error");
this.errorMessage = 'No other research product found';
this.showLoading = false;
}
);
}
public metricsResults($event) {
this.totalViews = $event.totalViews;
this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews;
}
private updateDescription(description:string){
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
}
private updateTitle(title:string){
var _prefix ="OpenAIRE | ";
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'");
}
private updateUrl(url:string){
this._meta.updateTag({content:url},"property='og:url'");
}
public buildCurationTooltip() {
let tooltipContent: string = "<div class='uk-padding-small uk-light'>";
tooltipContent += "<h4>Record in preview</h4>";
tooltipContent += "<p>Bibliographic record accepted by the system, but not yet processed by <br> OpenAIRE tools for information quality improvement and de-duplication</p></di>";
return tooltipContent;
}
public getKeys( map) {
return Array.from(map.keys());
}
}

View File

@ -0,0 +1,42 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {SharedModule} from '../../shared/shared.module';
import {OrpComponent} from './orp.component';
import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module';
import {LandingModule} from '../landing-utils/landing.module';
import {ResultLandingModule} from '../landing-utils/resultLanding.module';
import {MetricsModule} from '../landing-utils/metrics.module';
import {AltMetricsModule} from '../../utils/altmetrics.module';
import {ConfigurationServiceModule} from '../../utils/configuration/configurationService.module';
import {IFrameModule} from '../../utils/iframe.module';
import {OrpService} from './orp.service';
import {FreeGuard} from'../../login/freeGuard.guard';
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
import {Schema2jsonldModule} from '../landing-utils/schema2jsonld/schema2jsonld.module';
@NgModule({
imports: [
CommonModule, FormsModule, SharedModule, RouterModule, LandingModule,
CiteThisModule, ResultLandingModule, MetricsModule, IFrameModule,
AltMetricsModule, ConfigurationServiceModule, Schema2jsonldModule
],
declarations: [
OrpComponent
],
providers:[
OrpService, FreeGuard, IsRouteEnabled
],
exports: [
OrpComponent
]
})
export class OrpModule { }

View File

@ -0,0 +1,206 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {OrpInfo} from '../../utils/entities/orpInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../../utils/properties/env-properties';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
@Injectable()
export class OrpService {
constructor(private http: Http ) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
orpInfo: OrpInfo;
getOrpInfo (id: string, properties:EnvProperties):any {
console.info("getOrpInfo in service");
let url = properties.searchAPIURLLAst+'other/'+id+"?format=json";
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.do(res => console.info(res['result']['metadata']['oaf:entity']))
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'],res])
.map(res => [res[1],
res[1]['title'],
res[1]['rels']['rel'],
res[1]['children'],
res[1]['pid'],
res[1]['subject'],
res[1]['bestaccessright'],
res[1]['collectedfrom'],
res[1]['context'],
res[0],
res[1]['creator'],
res[1]['language'],
res[1]['country'],
res[2]
]).map(res => this.parseOrpInfo(res));
}
private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
}
parseOrpInfo (data: any):any {
this.orpInfo = new OrpInfo();
this.orpInfo.record = data[13];
if(data[0] != null) {
var date:string = (data[0].dateofacceptance)+""; // transform to string in case it is an integer
this.orpInfo.date = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
this.orpInfo.dateofacceptance = data[0].dateofacceptance;
this.orpInfo.publisher = data[0].publisher;
if(!Array.isArray(data[0].description)) {
this.orpInfo.description = data[0].description;
} else {
this.orpInfo.description = data[0].description[0];
}
this.orpInfo.embargoEndDate = data[0].embargoenddate;
}
if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classid")) {
this.orpInfo.accessMode = data[0]['bestaccessright'].classid;
}
if(data[1] != null) {
if(Array.isArray(data[1])) {
this.orpInfo.title = data[1][0].content;
} else {
this.orpInfo.title = data[1].content;
}
}
if(data[2] != null) {
let relation;
let length = data[2].length!=undefined ? data[2].length : 1;
for(let i=0; i<length; i++) {
relation = data[2].length!=undefined ? data[2][i] : data[2];
if(relation.hasOwnProperty("to")) {
if(relation['to'].class == "isProducedBy") {
this.orpInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.orpInfo.fundedByProjects, relation, this.orpInfo.projectsProvenanceVocabulary);
} else if(relation['to'].class == "isRelatedTo") {
let provenanceAction: string;
if(relation.provenanceaction in this.orpInfo.researchResultsProvenanceVocabulary) {
provenanceAction = this.orpInfo.researchResultsProvenanceVocabulary[relation.provenanceaction];
} else {
provenanceAction = "Other"
}
this.orpInfo.relatedResearchResults = this.parsingFunctions.parseRelatedResearchResults(this.orpInfo.relatedResearchResults, relation, provenanceAction);
} else if(relation['to'].class == "hasAmongTopNSimilarDocuments") {
this.orpInfo.similarResearchResults = this.parsingFunctions.parseSimilarResearchResults(this.orpInfo.similarResearchResults, relation);
}
}
}
}
if(data[3] != null) {
if(data[3].hasOwnProperty("instance")) {
this.orpInfo.hostedBy_collectedFrom = new Array<{ "downloadName": string, "downloadUrl": string[],
"collectedName": string, "collectedId": string,
"accessMode": string[], "bestAccessMode": string,
"type": string, "year":string}>();
this.orpInfo.types = new Array<string>();
let types = new Set<string>();
let counter = 0;
let instance;
let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1;
for(let i=0; i<length; i++) {
instance = data[3]['instance'].length!=undefined ? data[3]['instance'][i] : data[3]['instance'];
this.parsingFunctions.parseTypes(this.orpInfo.types, types, instance);
if(instance.hasOwnProperty("webresource")) {
let url;
if(instance['webresource'].length == undefined) {
url = instance['webresource'].url;
} else{
url = instance['webresource'][0].url;
}
if(instance.hasOwnProperty("hostedby")) {
counter = this.parsingFunctions.parseHostedBy_collectedFrom(this.orpInfo.hostedBy_collectedFrom, instance, data[0], url, counter/*, this.orpInfo.title*/, this.orpInfo.accessMode);
}
}
}
}
}
if(data[4] != null) {
this.orpInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]);
}
if(data[5] != null) {
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>] = this.parsingFunctions.parseAllSubjects(data[5]);
this.orpInfo.subjects = subjectResults[0];
this.orpInfo.otherSubjects = subjectResults[1];
this.orpInfo.classifiedSubjects = subjectResults[2];
}
this.orpInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
this.orpInfo.hostedBy_collectedFrom, this.orpInfo.publisher,
null, this.orpInfo.identifiers/*, this.orpInfo.title*/);
if(data[8] != null) {
this.orpInfo.contexts = this.parsingFunctions.parseContexts(data[8]);
}
if(data[9] != null && data[9] == "under curation") {
this.orpInfo.underCurationMessage = true;
} else {
this.orpInfo.underCurationMessage = false;
}
if(data[10] != null) {
if(this.orpInfo.authors == undefined) {
this.orpInfo.authors = new Array<string>();
}
let authors = data[10];
let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors;
this.orpInfo.authors[author.rank-1] = author.content;
}
this.orpInfo.authors = this.orpInfo.authors.filter(function (item) {
return (item != undefined);
});
}
if(data[11] != null) {
this.orpInfo.languages = this.parsingFunctions.parseLanguages(data[11]);
}
if(data[12] != null) {
this.orpInfo.countries = this.parsingFunctions.parseCountries(data[12]);
}
if(this.orpInfo.relatedResearchResults) {
let self = this;
this.orpInfo.relatedResearchResults.forEach(function (value, key, map) {
self.orpInfo.relatedResearchResults.set(key, self.parsingFunctions.sortByPercentage(value));
});
}
this.orpInfo.similarResearchResults = this.parsingFunctions.sortByPercentage(this.orpInfo.similarResearchResults);
return this.orpInfo;
}
}

View File

@ -0,0 +1,169 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchOrpsService} from '../../services/searchOrps.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
selector: 'advanced-search-orps',
template: `
<advanced-search-page pageTitle="Advanced Search for Other Research Products" entityType="other"
type = "other research products"
[(results)] = "results"
[(searchUtils)] = "searchUtils"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
(queryChange)="queryChanged($event)"
[csvParams]="csvParams" csvPath="other" simpleSearchLink="/search/find/other"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults" [(connectCommunityId)]=connectCommunityId [piwikSiteId]=piwikSiteId >
</advanced-search-page>
`
})
export class AdvancedSearchOrpsComponent {
private errorCodes: ErrorCodes;
properties:EnvProperties;
@Input() piwikSiteId = null;
@Input() connectCommunityId: string;
public results =[];
public filters =[];
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
public searchFields:SearchFields = new SearchFields();
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
public fieldIdsMap= this.searchFields.RESULT_FIELDS;
public selectedFields:AdvancedField[] = [];
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact other) )";
public csvParams: string;
public disableForms: boolean = false;
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
public pagingLimit: number = 0;
public isPiwikEnabled;
constructor (private route: ActivatedRoute, private _searchOrpsService: SearchOrpsService ) {
this.results =[];
this.errorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties= data.envSpecific;
this.searchUtils.baseUrl = data.envSpecific.searchLinkToAdvancedOrps;
this.pagingLimit = data.envSpecific.pagingLimit;
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
});
this.searchUtils.status = this.errorCodes.LOADING;
this.sub = this.route.queryParams.subscribe(params => {
if(params['page'] && this.searchUtils.page != params['page']) {
this.loadPaging = false;
this.oldTotalResults = this.searchUtils.totalResults;
}
let page = (params['page']=== undefined)?1:+params['page'];
this.searchUtils.page = ( page <= 0 ) ? 1 : page;
this.searchPage.fieldIds = this.fieldIds;
this.selectedFields =[];
this.searchPage.selectedFields = this.selectedFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.connectCommunityId = this.connectCommunityId;
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size);
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
sub: any;
public getResults(parameters:string, page: number, size: number){
if(page > this.pagingLimit) {
size=0;
}
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
if(parameters!= null && parameters != '' ) {
this.csvParams ="&fq=( "+this.resourcesQuery + "and (" + parameters + "))";
}else{
this.csvParams ="&fq="+this.resourcesQuery;
}
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = [];
this.searchUtils.totalResults = 0;
console.info("Advanced Search for Other Research Products: Execute search query "+parameters);
this._searchOrpsService.advancedSearchOrps(parameters, page, size, this.properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products total="+this.searchUtils.totalResults);
this.results = data[1];
this.searchPage.updateBaseUrlWithParameters();
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
if(this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
if(totalPages < page) {
this.searchUtils.totalResults = 0;
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
},
err => {
console.log(err);
console.info("error");
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
this.disableForms = false;
}
);
}
}
private setFilters(){
//TODO set filters from
}
public queryChanged($event) {
this.loadPaging = true;
var parameters = $event.value;
this.getResults(parameters, this.searchUtils.page,this.searchUtils.size);
console.info("queryChanged: Execute search query "+parameters);
}
}

View File

@ -0,0 +1,28 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import{AdvancedSearchOrpsComponent} from './advancedSearchOrps.component';
import {OrpsServiceModule} from '../../services/orpsService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
@NgModule({
imports: [
CommonModule, FormsModule,
OrpsServiceModule,
AdvancedSearchPageModule
],
declarations: [
AdvancedSearchOrpsComponent
],
providers:[FreeGuard, IsRouteEnabled],
exports: [
AdvancedSearchOrpsComponent
]
})
export class AdvancedSearchOrpsModule { }

View File

@ -0,0 +1,268 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchOrpsService} from '../../services/searchOrps.service';
import {SearchResult} from '../../utils/entities/searchResult';
import { ErrorCodes} from '../../utils/properties/errorCodes';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import {DOI} from '../../utils/string-utils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
selector: 'search-orps',
template: `
<search-page pageTitle="Search Other Research Products"
formPlaceholderText = "Search for Other Research Products"
type="other research products" entityType="other" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
[csvParams]="csvParams" csvPath="other" advancedSearchLink="/search/advanced/other"
[disableForms]="disableForms"
[loadPaging]="loadPaging"
[oldTotalResults]="oldTotalResults"
searchFormClass="orpsSearchForm"
[(openaireLink)]=openaireLink
[(advancedSearchParameters)]=advancedSearchParameters
[piwikSiteId]=piwikSiteId
[(connectCommunityId)]=connectCommunityId >
</search-page>
`
})
export class SearchOrpsComponent {
private errorCodes: ErrorCodes;
@Input() piwikSiteId = null;
public results =[];
public filters: Filter[] =[];
public baseUrl:string;
@Input() openaireLink: string ;
@Input() connectCommunityId: string;
@Input() advancedSearchParameters ;
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
private sub: any;
private subResults: any;
private searchFields:SearchFields = new SearchFields();
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
public fieldIdsMap=this.searchFields.RESULT_FIELDS;
private urlParams : Map<string, string>;
private _location:Location;
public csvParams: string;
public disableForms: boolean = false;
public loadPaging: boolean = true;
public oldTotalResults: number = 0;
pagingLimit = 0;
properties: EnvProperties;
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
constructor (private route: ActivatedRoute, private _searchOrpsService: SearchOrpsService ) {
this.errorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.searchUtils.page =1;
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.baseUrl = data.envSpecific.searchLinkToOrps;
this.pagingLimit = data.envSpecific.pagingLimit;
});
this.searchPage.refineFields = this.refineFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.type = "other research products";
var firstLoad =true;
this.sub = this.route.queryParams.subscribe(params => {
if(params['page'] && this.searchUtils.page != params['page']) {
this.loadPaging = false;
this.oldTotalResults = this.searchUtils.totalResults;
}
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
var refine = true;
if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
refine = false;
}
firstLoad = false;
this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
this.searchPage.connectCommunityId = this.connectCommunityId;
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});
}
public ngOnDestroy() {
if(this.sub){
this.sub.unsubscribe();
}
if(this.subResults){
this.subResults.unsubscribe();
}
}
public getResultsForEntity(entity:string, id:string, page: number, size: number){
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id;
}
if(parameters != "") {
this._searchOrpsService.searchOrpsForEntity(parameters, page, size, this.properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){
var parameters;
if(resultsFrom == "collectedFrom") {
parameters = "orps?fq=collectedfromdatasourceid exact "+'"'+id+'"';
} else if(resultsFrom == "hostedBy") {
parameters = "orps?fq=resulthostingdatasourceid exact "+'"'+id+'"';
}
if(parameters != "") {
this._searchOrpsService.searchOrpsForDataproviders(parameters, page, size, this.properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public getResults(keyword:string,refine:boolean, page: number, size: number){
var parameters = "";
if(keyword.length > 0){
var DOIs:string[] = DOI.getDOIsFromString(keyword);
var doisParams = "";
for(var i =0 ;i < DOIs.length; i++){
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
}
if(doisParams.length > 0){
parameters += "&"+doisParams;
}else{
parameters = "q=" + keyword;
}
}
this._getResults(parameters,refine,page,size);
}
private _getResults(parameters:string,refine:boolean, page: number, size: number){
if(page > this.pagingLimit) {
size=0;
}
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
this.csvParams = parameters;
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = [];
this.searchUtils.totalResults = 0;
this.subResults = this._searchOrpsService.searchOrps(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(), this.properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
if(refine){
this.filters = data[2];
}
this.searchPage.checkSelectedFilters(this.filters);
this.searchPage.updateBaseUrlWithParameters(this.filters);
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
if(this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
if(totalPages < page) {
this.searchUtils.totalResults = 0;
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
this.disableForms = false;
}
);
}
}
private setFilters(){
//TODO set filters from
}
public queryChanged($event) {
this.loadPaging = true;
var parameters = $event.value;
this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size);
}
}

View File

@ -0,0 +1,32 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import{SearchOrpsComponent} from './searchOrps.component';
import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {OrpsServiceModule} from '../../services/orpsService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module';
//import {SearchFilterModalModule} from '../searchUtils/searchFilterModal.module';
import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
@NgModule({
imports: [
CommonModule, FormsModule,
OrpsServiceModule,
SearchFormModule, SearchResultsModule, SearchPageModule
],
declarations: [
SearchOrpsComponent
],
providers:[FreeGuard, IsRouteEnabled],
exports: [
SearchOrpsComponent
]
})
export class SearchOrpsModule { }

View File

@ -0,0 +1,20 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {SearchOrpsService} from './searchOrps.service';
@NgModule({
imports: [
CommonModule, FormsModule
],
declarations: [
],
providers:[
SearchOrpsService
],
exports: [
]
})
export class OrpsServiceModule { }

View File

@ -0,0 +1,366 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
import{EnvProperties} from '../utils/properties/env-properties';
@Injectable()
export class SearchOrpsService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: Http ) {}
searchOrps (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
let link = properties.searchAPIURLLAst+"other";
let url = link+"?";
if(params!= null && params != '' ) {
url += params;
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
url += "&page="+ (page-1) +"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
}
searchOrpById (id: string , properties:EnvProperties):any {
let url = properties.searchAPIURLLAst+"other/"+id+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseResults(res));
}
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
let link = properties.searchAPIURLLAst+"other";
let url = link+"?"+"&format=json";
if(params!= null && params != '' ) {
url += params;
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
url += "&page="+(page-1)+"&size="+size;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults']))
}
searchOrpsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
let link = properties.searchAPIURLLAst+"other";
let url = link+"?";
var doisParams = "";
for(var i =0 ;i < DOIs.length; i++){
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
}
if(doisParams.length > 0){
url += "&"+doisParams;
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
url += "&page="+ (page-1) +"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
}
advancedSearchOrps (params: string, page: number, size: number, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
var basicQuery = "(oaftype exact result) and (resulttypeid exact other) "
url += "?query=";
if(params!= null && params != '' ) {
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
}else{
url +=" ( "+basicQuery+ " ) ";
}
url += "&page="+(page-1)+"&size="+size;
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
searchOrpsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+"/other"+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
searchOrpsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
}
parseResults(data: any): SearchResult[] {
let results: SearchResult[] = [];
let length = Array.isArray(data) ? data.length : 1;
for(let i=0; i<length; i++) {
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
var result: SearchResult = new SearchResult();
result.entityType = "other";
result.types = new Array<string>();
let types = new Set<string>();
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
let instance;
for(let i=0; i<length; i++) {
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
this.parsingFunctions.parseTypes(result.types, types, instance);
}
if(resData['language'] && resData['language'] != null) {
result.languages = new Array<string>();
if(!Array.isArray(resData['language'])) {
if(resData['language'].classname != "Undetermined" && resData['language'].classname) {
result.languages.push(resData['language'].classname);
}
} else {
for(let i=0; i<resData['language'].length; i++) {
if(resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
result.languages.push(resData['language'][i].classname);
}
}
}
}
if(resData['country'] && resData['country'] != null) {
result.countriesForResults = new Array<string>();
if(!Array.isArray(resData['country'])) {
if(resData['country'].classname != "Undetermined" && resData['country'].classname) {
result.countriesForResults.push(resData['country'].classname);
}
} else {
for(let i=0; i<resData['country'].length; i++) {
if(resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
result.countriesForResults.push(resData['country'][i].classname);
}
}
}
}
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
if(Array.isArray(resData['title'])) {
result['title'].name = resData['title'][0].content;
} else {
result['title'].name = resData['title'].content;
}
//result['title'].url = OpenaireProperties.getsearchLinkToOrp();
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classid")) {
result['title'].accessMode = resData['bestaccessright'].classid;
}
if(resData['rels'].hasOwnProperty("rel")) {
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
for(let j=0; j<relLength; j++) {
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
if(relation.hasOwnProperty("to")) {
/*if(relation['to'].class == "hasAuthor") {
if(result['authors'] == undefined) {
result['authors'] = new Array<{"name": string, "id": string}>();
}
result['authors'].push({"name": relation.fullname, "id": relation['to'].content});
} else */if(relation['to'].class == "isProducedBy") {
result['projects'] = this.parseProjects(result['projects'], relation);
}
}
}
}
if(resData.hasOwnProperty("creator") && resData['creator'] != null) {
if(result['authors'] == undefined) {
result['authors'] = new Array<string>();
}
let authors = resData['creator'];
let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors;
result.authors[author.rank-1] = author.content;
}
result.authors = result.authors.filter(function (item) {
return (item != undefined);
});
}
var date:string = (resData.dateofacceptance)+""; // transform to string in case it is an integer
result.year = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
if(!Array.isArray(resData.description)) {
result.description = resData.description;
} else {
result.description = resData.description[0];
}
if(result.description && result.description.length > this.sizeOfDescription) {
result.description = result.description.substring(0, this.sizeOfDescription)+"...";
}
result.embargoEndDate = resData.embargoenddate;
if(!Array.isArray(resData.publisher)) {
result.publisher = resData.publisher;
} else {
for(let i=0; i<resData.publisher.length; i++) {
if(result.publisher != undefined){
result.publisher += ', '+resData['publisher'][i];
} else {
result.publisher = resData['publisher'][i];
}
}
}
results.push(result);
}
return results;
}
parseProjects(projects: { "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"code": string }[], relation: any ) : {
"id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"code": string }[] {
if(projects == undefined) {
projects = new Array<
{ "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"code": string
}>();
}
let countProjects = projects.length;
projects[countProjects] = {
"id": "", "acronym": "", "title": "",
"funderShortname": "", "funderName": "",
"code": ""
}
if(relation.title != 'unidentified') {
projects[countProjects]['id'] =
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
projects[countProjects]['acronym'] = relation.acronym;
projects[countProjects]['title'] = relation.title;
projects[countProjects]['code'] = relation.code;
} else {
projects[countProjects]['id'] = "";
projects[countProjects]['acronym'] = "";
projects[countProjects]['title'] = "";
projects[countProjects]['code'] = "";
}
if(relation.hasOwnProperty("funding")) {
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
for(let z=0; z<fundingLength; z++) {
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
if(fundingData.hasOwnProperty("funder")) {
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
projects[countProjects]['funderName'] = fundingData['funder'].name;
}
}
}
return projects;
}
parseRefineResults(id: string, data: any): any {
var results:any = [];
if(data.hasOwnProperty("resulthostingdatasource")) {
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
for(let i=0; i<length; i++) {
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
let result: {"name": string, "id": string, "count": number} = {"name": "", "id": "", "count": 0};
result['name'] = datasource.name;
result['id'] = datasource.id.split("||")[0];
//result['url'] = OpenaireProperties.getsearchLinkToDataProvider()+result['id'];
result['count'] = datasource.count;
if(result['id'] != id && result['name'] != "Unknown Repository") {
results.push(result);
}
}
}
return results;
}
numOfOrps(url: string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
}
numOfEntityOrps(id: string, entity: string, properties:EnvProperties):any {
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id+"/other/count";
}
let url = properties.searchAPIURLLAst+parameters+"?format=json";
return this.numOfOrps(url, properties);
}
numOfSearchOrps(params: string, properties:EnvProperties):any {
let url = properties.searchAPIURLLAst+"other/count?format=json";
if(params != "") {
url += "&q=" + params;
}
return this.numOfOrps(url, properties);
}
}

48
utils/entities/orpInfo.ts Normal file
View File

@ -0,0 +1,48 @@
export class OrpInfo {
underCurationMessage: boolean;
title: string;
accessMode: string;
authors: string[];
date: string;
dateofacceptance: string;
embargoEndDate: string;
types: string[];
hostedBy_collectedFrom: { "downloadName": string, "downloadUrl": string[],
"collectedName": string, "collectedId": string,
"accessMode": string[], "bestAccessMode": string,
"type": string, "year":string}[];
identifiers: Map<string, string[]>;
publisher: string;
languages: string[];
countries: string[];
subjects: string[];
otherSubjects: Map<string, string[]>;
classifiedSubjects: Map<string, string[]>;
description: string;
projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string,
"sysimport:crosswalk:entityregistry": string,
"sysimport:crosswalk:datasetarchive": string,
"iis": string,
"sysimport:mining:repository": string,
"user:claim:pid": string,
"user:claim:search": string,
"user:claim:datacite": string
} = {
"sysimport:crosswalk:repository": "Repository",
"sysimport:crosswalk:entityregistry": "Repository",
"sysimport:crosswalk:datasetarchive": "Repository",
"iis": "OpenAIRE",
"sysimport:mining:repository": "OpenAIRE",
"user:claim:pid": "User",
"user:claim:search": "User",
"user:claim:datacite": "User"
};
fundedByProjects: { "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "code": string, "provenanceAction": string, "inline": boolean}[];
researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"};
relatedResearchResults: Map<string, { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]>; // percentage is for trust
similarResearchResults: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[]; // percentage is for similarity
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
record;
}

View File

@ -0,0 +1,221 @@
import {SearchOrpsService} from '../../services/searchOrps.service';
import { ErrorCodes} from '../../utils/properties/errorCodes';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {DOI} from '../../utils/string-utils.class';
import {Subject} from 'rxjs/Subject';
import{EnvProperties} from '../../utils/properties/env-properties';
export class FetchOrps{
private errorCodes: ErrorCodes;
public results =[];
public requestComplete: Subject<void>;
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
private sub: any;
private subResults: any;
public csvParams: string;
constructor ( private _searchOrpsService: SearchOrpsService ) {
this.errorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.requestComplete = new Subject<void>();
}
public ngOnDestroy() {
if(this.sub){
this.sub.unsubscribe();
}
if(this.subResults){
this.subResults.unsubscribe();
}
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
console.info("orps: getResultsByKeyword");
var parameters = "";
if(keyword.length > 0){
var DOIs:string[] = DOI.getDOIsFromString(keyword);
var doisParams = "";
for(var i =0 ;i < DOIs.length; i++){
doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
}
if(doisParams.length > 0){
parameters += "&"+doisParams;
}else{
parameters = "q=" + keyword;
}
}
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchOrpsService.searchOrps(parameters,null, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
public getNumForEntity(entity:string, id:string, properties:EnvProperties){
this.searchUtils.status = this.errorCodes.LOADING;
if(id != "" && entity != "") {
this._searchOrpsService.numOfEntityOrps(id, entity, properties).subscribe(
data => {
this.searchUtils.totalResults = data;
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public getResultsForEntity(entity:string, id:string, page: number, size: number, properties:EnvProperties){
this.searchUtils.status = this.errorCodes.LOADING;
var parameters = "";
if(entity == "project") {
parameters = "projects/"+id;
}
if(parameters != "") {
this._searchOrpsService.searchOrpsForEntity(parameters, page, size, properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number, properties:EnvProperties){
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
var parameters;
if(resultsFrom == "collectedFrom") {
parameters = "other?fq=collectedfromdatasourceid exact "+'"'+id+'"';
} else if(resultsFrom == "hostedBy") {
parameters = "other?fq=resulthostingdatasourceid exact "+'"'+id+'"';
}
if(parameters != "") {
this._searchOrpsService.searchOrpsForDataproviders(parameters, page, size, properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
console.info("search Other Research Products for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
this.results = data[1];
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.log(err);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
}
public getAggregatorResults(id:string, page: number, size: number, properties:EnvProperties){
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchOrpsService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size, properties).subscribe(
data => {
this.results = data;
this.searchUtils.totalResults = this.results.length;
this.searchUtils.status = this.errorCodes.DONE;
if(this.searchUtils.totalResults == 0 ){
this.searchUtils.status = this.errorCodes.NONE;
}
this.requestComplete.complete();
},
err => {
console.log(err);
console.info("status: "+err.status);
//TODO check erros (service not available, bad request)
if(err.status == '404') {
this.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.searchUtils.status = this.errorCodes.ERROR;
} else {
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
this.requestComplete.complete();
}
);
}
}