New files for software entity added (forgotten from previous commit)
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@49484 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
ac9857eb32
commit
131bbd64b8
|
@ -0,0 +1,15 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import {SoftwareComponent } from './software.component';
|
||||||
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
|
import {PreviousRouteRecorder} from'../../utils/piwik/previousRouteRecorder.guard';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild([
|
||||||
|
{ path: '', component: SoftwareComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] }
|
||||||
|
])
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SoftwareRoutingModule { }
|
|
@ -0,0 +1,423 @@
|
||||||
|
<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 software">
|
||||||
|
|
||||||
|
<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 *ngIf="showLoading" class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><img src="./assets/loading.gif" class="uk-align-center" alt="Loading"></div>
|
||||||
|
|
||||||
|
<div *ngIf="softwareInfo != null" uk-grid>
|
||||||
|
<div class="uk-width-3-4@l uk-width-3-4@xl uk-width-3-4@m uk-width-1-1@s">
|
||||||
|
<showTitle [title]="softwareInfo.title"></showTitle>
|
||||||
|
<span *ngIf="softwareInfo.types.length > 0"class="uk-label custom-label label-blue label-software " title="Type">{{softwareInfo.types.join(", ")}}</span>
|
||||||
|
<span *ngIf="softwareInfo.title && softwareInfo.title.accessMode" [class]="'uk-label custom-label label-green label-'+ softwareInfo.title.accessMode " ><!--span [class]="softwareInfo.title.accessMode" -->{{softwareInfo.title.accessMode}}<!--/span--></span>
|
||||||
|
<span *ngIf="softwareInfo.underCurationMessage" class="uk-label custom-label label-yellow " >
|
||||||
|
<span uk-tooltip="pos:right; delay:10"
|
||||||
|
title="{{buildCurationTooltip()}}">
|
||||||
|
<i>Record in preview</i>
|
||||||
|
<i class="uk-icon-info-circle"></i>
|
||||||
|
</span></span>
|
||||||
|
<!--div *ngIf="softwareInfo.underCurationMessage">
|
||||||
|
<span uk-tooltip="pos:right; delay:10"
|
||||||
|
title="{{buildCurationTooltip()}}">
|
||||||
|
<i>Record in preview</i>
|
||||||
|
<i class="uk-icon-info-circle"></i>
|
||||||
|
</span>
|
||||||
|
</div-->
|
||||||
|
|
||||||
|
<div class= " uk-margin-top">
|
||||||
|
<showAuthors [authors]="softwareInfo.authors" searchPage="software"></showAuthors>
|
||||||
|
<span *ngIf="softwareInfo.date != ''">({{softwareInfo.date}})</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="uk-list">
|
||||||
|
<li *ngIf="softwareInfo.publisher"><span class="uk-text-bold">Publisher:</span> {{softwareInfo.publisher}}</li>
|
||||||
|
|
||||||
|
<li *ngIf="softwareInfo.embargoEndDate"><span class="uk-text-bold">Embargo end date:</span> {{softwareInfo.embargoEndDate}}</li>
|
||||||
|
<li *ngIf="softwareInfo.identifiers && softwareInfo.identifiers.size > 0">
|
||||||
|
<showIdentifiers [identifiers]="softwareInfo.identifiers"></showIdentifiers>
|
||||||
|
</li>
|
||||||
|
<li *ngIf="softwareInfo.subjects ||softwareInfo.otherSubjects || softwareInfo.classifiedSubjects">
|
||||||
|
<showSubjects [subjects]="softwareInfo.subjects"
|
||||||
|
[otherSubjects]="softwareInfo.otherSubjects"
|
||||||
|
[classifiedSubjects]="softwareInfo.classifiedSubjects">
|
||||||
|
</showSubjects>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div *ngIf="softwareInfo.description" class="uk-margin-bottom uk-text-justify descriptionText">
|
||||||
|
{{softwareInfo.description}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="uk-clearfix"><div class="uk-button-group uk-float-right uk-margin-top">
|
||||||
|
<button class="uk-button uk-button-small uk-button-action">
|
||||||
|
<span class="uk-icon" >
|
||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="link" ratio="1"><path fill="none" stroke="#000" stroke-width="1.1" 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"></path><path fill="none" stroke="#000" stroke-width="1.1" 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"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M7.925,11.875 L11.925,7.975"></path></svg></span>
|
||||||
|
Link this software to
|
||||||
|
</button>
|
||||||
|
<div class="uk-inline">
|
||||||
|
<button class="uk-button uk-button-small uk-button-action" type="button">
|
||||||
|
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="triangle-down" ratio="1"><polygon points="5 7 15 7 10 12"></polygon></svg></span>
|
||||||
|
</button>
|
||||||
|
<div uk-dropdown="mode: click; boundary: ! .uk-button-group; boundary-align: true;"
|
||||||
|
class="uk-dropdown uk-dropdown-boundary uk-dropdown-bottom-left" style="top: 40px; left: -236.5px;">
|
||||||
|
<ul class="uk-nav uk-dropdown-nav uk-padding-small" >
|
||||||
|
<li><a class="uk-width-1-1" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','project'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Projects</a></li>
|
||||||
|
<li><a class="uk-width-1-1"[queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','context'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Communities</a></li>
|
||||||
|
<li><a class="uk-width-1-1" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Other research results</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="uk-tab uk-visible@m" uk-tab="connect: #tab-content">
|
||||||
|
<li (click)="activeTab='Related Research Results'"
|
||||||
|
[class]="activeTab == 'Related Research Results'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Related Research Results
|
||||||
|
<span class="uk-badge uk-badge-notification">
|
||||||
|
{{relatedResearchResultsNum}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li (click)="activeTab='Similar Research Results'"
|
||||||
|
[class]="activeTab == 'Similar Research Results'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Similar Research Results
|
||||||
|
<span *ngIf="!softwareInfo.similarResearchResults" class="uk-badge uk-badge-notification">0</span>
|
||||||
|
<span *ngIf="softwareInfo.similarResearchResults" class="uk-badge uk-badge-notification">
|
||||||
|
{{softwareInfo.similarResearchResults.length}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li (click)="metricsClicked=true; activeTab='Metrics'"
|
||||||
|
[class]="activeTab == 'Metrics'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Metrics <!--i class="icon-line-chart"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 36 36" style="fill:currentColor;">
|
||||||
|
<path d="M4.415 31.713h31.704v4.529h-36.233v-36.233h4.529zM10.077 29.447c-1.877 0-3.396-1.521-3.396-3.396s1.521-3.396 3.396-3.396c0.101 0 0.199 0.006 0.297 0.014l3.652-6.086c-0.348-0.534-0.551-1.171-0.551-1.855 0-1.877 1.521-3.396 3.396-3.396s3.396 1.521 3.396 3.396c0 0.685-0.203 1.321-0.551 1.855l3.652 6.086c0.098-0.009 0.196-0.014 0.297-0.014 0.076 0 0.151 0.004 0.225 0.009l6.028-10.549c-0.373-0.546-0.592-1.204-0.592-1.916 0-1.877 1.521-3.396 3.396-3.396s3.396 1.521 3.396 3.396c0 1.877-1.521 3.396-3.396 3.396-0.076 0-0.151-0.004-0.225-0.009l-6.028 10.549c0.373 0.546 0.592 1.204 0.592 1.916 0 1.877-1.521 3.396-3.396 3.396s-3.396-1.521-3.396-3.396c0-0.684 0.203-1.321 0.551-1.855l-3.652-6.086c-0.098 0.009-0.196 0.014-0.297 0.014s-0.199-0.006-0.297-0.014l-3.652 6.086c0.348 0.534 0.551 1.171 0.551 1.855 0 1.877-1.521 3.396-3.396 3.396z"></path>
|
||||||
|
</svg></i-->
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<button class="uk-button uk-button-default uk-hidden@m" type="button">
|
||||||
|
<span uk-navbar-toggle-icon></span> <span class="uk-margin-small-left">{{activeTab}}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<ul id="toggle-small-tabs" class="uk-subnav uk-subnav-pill uk-dropdown uk-hidden@m" uk-switcher="connect: #tab-content" uk-dropdown="mode: click" uk-toggle="target: #toggle-small-tabs">
|
||||||
|
<li (click)="activeTab='Related Research Results'"
|
||||||
|
[class]="activeTab == 'Related Research Results'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Related Research Results
|
||||||
|
<span class="uk-badge uk-badge-notification">
|
||||||
|
{{relatedResearchResultsNum}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li (click)="activeTab='Similar Research Results'"
|
||||||
|
[class]="activeTab == 'Similar Research Results'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Similar Research Results
|
||||||
|
<span *ngIf="!softwareInfo.similarResearchResults" class="uk-badge uk-badge-notification">0</span>
|
||||||
|
<span *ngIf="softwareInfo.similarResearchResults" class="uk-badge uk-badge-notification">
|
||||||
|
{{softwareInfo.similarResearchResults.length}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li (click)="metricsClicked=true; activeTab='Metrics'"
|
||||||
|
[class]="activeTab == 'Metrics'?'uk-active':''">
|
||||||
|
<a>
|
||||||
|
Metrics<!--i class="icon-line-chart"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 36 36" style="fill:currentColor;">
|
||||||
|
<path d="M4.415 31.713h31.704v4.529h-36.233v-36.233h4.529zM10.077 29.447c-1.877 0-3.396-1.521-3.396-3.396s1.521-3.396 3.396-3.396c0.101 0 0.199 0.006 0.297 0.014l3.652-6.086c-0.348-0.534-0.551-1.171-0.551-1.855 0-1.877 1.521-3.396 3.396-3.396s3.396 1.521 3.396 3.396c0 0.685-0.203 1.321-0.551 1.855l3.652 6.086c0.098-0.009 0.196-0.014 0.297-0.014 0.076 0 0.151 0.004 0.225 0.009l6.028-10.549c-0.373-0.546-0.592-1.204-0.592-1.916 0-1.877 1.521-3.396 3.396-3.396s3.396 1.521 3.396 3.396c0 1.877-1.521 3.396-3.396 3.396-0.076 0-0.151-0.004-0.225-0.009l-6.028 10.549c0.373 0.546 0.592 1.204 0.592 1.916 0 1.877-1.521 3.396-3.396 3.396s-3.396-1.521-3.396-3.396c0-0.684 0.203-1.321 0.551-1.855l-3.652-6.086c-0.098 0.009-0.196 0.014-0.297 0.014s-0.199-0.006-0.297-0.014l-3.652 6.086c0.348 0.534 0.551 1.171 0.551 1.855 0 1.877-1.521 3.396-3.396 3.396z"></path>
|
||||||
|
</svg></i-->
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!--ul id="tab-content" class="uk-switcher uk-margin custom-tab-content"-->
|
||||||
|
<div class="uk-margin custom-tab-content">
|
||||||
|
<div *ngIf="activeTab=='Related Research Results'" class="uk-animation-fade">
|
||||||
|
<div *ngIf="!softwareInfo.relatedResearchResults" class = "uk-alert uk-alert-primary" >
|
||||||
|
No related research results available
|
||||||
|
</div>
|
||||||
|
<div *ngIf="softwareInfo.relatedResearchResults">
|
||||||
|
<div *ngFor="let provenanceaction of softwareInfo.relatedResearchResults.keys()">
|
||||||
|
<div class="uk-text-large">{{provenanceaction}}</div>
|
||||||
|
|
||||||
|
<tabTable [info]="softwareInfo.relatedResearchResults.get(provenanceaction)"></tabTable>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="activeTab=='Similar Research Results'" class="uk-animation-fade">
|
||||||
|
<div *ngIf="!softwareInfo.similarResearchResults" class = "uk-alert uk-alert-primary" >
|
||||||
|
No similar research results available
|
||||||
|
</div>
|
||||||
|
<div *ngIf="softwareInfo.similarResearchResults">
|
||||||
|
<tabTable [info]="softwareInfo.similarResearchResults"></tabTable>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="activeTab=='Metrics'" class="uk-animation-fade">
|
||||||
|
<!-- Page Views: {{pageViews}} -->
|
||||||
|
<metrics [pageViews]="pageViews"
|
||||||
|
[id]="softwareId" [entityType]="'results'" [entity]="'Software'"
|
||||||
|
(metricsResults)="metricsResults($event)">
|
||||||
|
</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>
|
||||||
|
<!--/ul-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="uk-width-1-4@l uk-width-1-4@xl uk-width-1-4@m uk-width-1-1@s">
|
||||||
|
<div >
|
||||||
|
Share - Bookmark
|
||||||
|
<addThis></addThis>
|
||||||
|
</div>
|
||||||
|
<altmetrics *ngIf="softwareInfo.identifiers && softwareInfo.identifiers.get('doi')"
|
||||||
|
id="{{softwareInfo.identifiers.get('doi')[0]}}" type="doi">
|
||||||
|
</altmetrics >
|
||||||
|
<ul class="uk-list ">
|
||||||
|
|
||||||
|
<li *ngIf="softwareInfo.downloadFrom && softwareInfo.downloadFrom.size > 0">
|
||||||
|
<dl class="uk-description-list-line">
|
||||||
|
<dt class="title">Download from</dt>
|
||||||
|
<dd class="line"
|
||||||
|
*ngFor="let key of softwareInfo.downloadFrom.keys() let i=index" >
|
||||||
|
<div *ngIf="i<5 || showAllDownloadFrom"
|
||||||
|
class="{{softwareInfo.downloadFrom.get(key)['bestAccessMode']}}">
|
||||||
|
<span [class]="softwareInfo.downloadFrom.get(key)['url'].length > 0 ? 'custom-external custom-icon' : ''">
|
||||||
|
<span *ngIf="softwareInfo.downloadFrom.get(key)['url'].length > 1">
|
||||||
|
{{key}}
|
||||||
|
<span *ngFor="let url of softwareInfo.downloadFrom.get(key)['url']; let i=index;">
|
||||||
|
<a href="{{url}}" target="_blank"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.downloadFrom.get(key)['accessMode'][i] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.downloadFrom.get(key)['accessMode'][i]">
|
||||||
|
[{{i+1}}]
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<a *ngIf="softwareInfo.downloadFrom.get(key)['url'].length == 1"
|
||||||
|
href="{{softwareInfo.downloadFrom.get(key)['url']}}"
|
||||||
|
target="_blank"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.downloadFrom.get(key)['bestAccessMode'] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.downloadFrom.get(key)['bestAccessMode']">
|
||||||
|
{{key}}
|
||||||
|
</a>
|
||||||
|
<span *ngIf="softwareInfo.downloadFrom.get(key)['url'].length == 0"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.downloadFrom.get(key)['bestAccessMode'] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.downloadFrom.get(key)['bestAccessMode']">
|
||||||
|
{{key}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="showAllDownloadFrom" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllDownloadFrom = !showAllDownloadFrom;">
|
||||||
|
View less
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="!showAllDownloadFrom && softwareInfo.downloadFrom.size > 5">...</dd>
|
||||||
|
<dd *ngIf="!showAllDownloadFrom && softwareInfo.downloadFrom.size > 5" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllDownloadFrom = !showAllDownloadFrom;">
|
||||||
|
View more
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
<li *ngIf="softwareInfo.publishedIn && softwareInfo.publishedIn.size > 0">
|
||||||
|
<dl class="uk-description-list-line">
|
||||||
|
<dt class="title">Published in</dt>
|
||||||
|
<dd class="line" *ngFor="let key of softwareInfo.publishedIn.keys() let i=index">
|
||||||
|
<div *ngIf="i<5 || showAllPublishedIn" class="{{softwareInfo.publishedIn.get(key)['bestAccessMode']}}">
|
||||||
|
<span [class]="softwareInfo.publishedIn.get(key)['url'].length > 0 ? 'custom-external custom-icon' : ''">
|
||||||
|
<span *ngIf="softwareInfo.publishedIn.get(key)['url'].length > 1">
|
||||||
|
{{key}}
|
||||||
|
<span *ngFor="let url of softwareInfo.publishedIn.get(key)['url']; let i=index">
|
||||||
|
<a href="{{url}}" target="_blank"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.publishedIn.get(key)['accessMode'][i] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.publishedIn.get(key)['accessMode'][i]">
|
||||||
|
[{{i+1}}]
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<a *ngIf="softwareInfo.publishedIn.get(key)['url'].length == 1"
|
||||||
|
href="{{softwareInfo.publishedIn.get(key)['url']}}"
|
||||||
|
target="_blank"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.publishedIn.get(key)['bestAccessMode'] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.publishedIn.get(key)['bestAccessMode']">
|
||||||
|
{{key}}
|
||||||
|
</a>
|
||||||
|
<span *ngIf="softwareInfo.publishedIn.get(key)['url'].length == 0"
|
||||||
|
[attr.uk-tooltip]="softwareInfo.publishedIn.get(key)['bestAccessMode'] ? 'pos:right; delay:10' : 'cls: uk-invisible'"
|
||||||
|
[title]="softwareInfo.publishedIn.get(key)['bestAccessMode']">
|
||||||
|
{{key}}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="showAllPublishedIn" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllPublishedIn = !showAllPublishedIn;">
|
||||||
|
View less
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="!showAllPublishedIn && softwareInfo.publishedIn.size > 5">...</dd>
|
||||||
|
<dd *ngIf="!showAllPublishedIn && softwareInfo.publishedIn.length > 5" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllPublishedIn = !showAllPublishedIn;">
|
||||||
|
View more
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
<li *ngIf="softwareInfo.fundedByProjects != undefined && softwareInfo.fundedByProjects.length > 0">
|
||||||
|
<dl class="uk-description-list-line" >
|
||||||
|
<dt class="title">Funded By</dt>
|
||||||
|
<dd class="line"
|
||||||
|
*ngFor="let item of softwareInfo.fundedByProjects let i=index">
|
||||||
|
<div *ngIf="i<5 || showAllFundedBy">
|
||||||
|
<span uk-tooltip="pos:right; delay:10"
|
||||||
|
title="{{buildFundingTooltip(item)}}">
|
||||||
|
|
||||||
|
<a *ngIf="!item['inline'] && item.id"
|
||||||
|
[queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
|
||||||
|
<span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
|
||||||
|
<span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
|
||||||
|
<span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a *ngIf="item['inline'] && item.id"
|
||||||
|
[queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
|
||||||
|
<mark>
|
||||||
|
<span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
|
||||||
|
<span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
|
||||||
|
<span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
|
||||||
|
</mark>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<span class="clickable" *ngIf="!item['inline'] && !item.id">
|
||||||
|
<span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
|
||||||
|
<span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
|
||||||
|
<span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="clickable" *ngIf="item['inline'] && !item.id">
|
||||||
|
<mark>
|
||||||
|
<span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
|
||||||
|
<span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
|
||||||
|
<span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
|
||||||
|
</mark>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="uk-icon">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" icon="info" ratio="1"><path d="M12.13,11.59 C11.97,12.84 10.35,14.12 9.1,14.16 C6.17,14.2 9.89,9.46 8.74,8.37 C9.3,8.16 10.62,7.83 10.62,8.81 C10.62,9.63 10.12,10.55 9.88,11.32 C8.66,15.16 12.13,11.15 12.14,11.18 C12.16,11.21 12.16,11.35 12.13,11.59 C12.08,11.95 12.16,11.35 12.13,11.59 L12.13,11.59 Z M11.56,5.67 C11.56,6.67 9.36,7.15 9.36,6.03 C9.36,5 11.56,4.54 11.56,5.67 L11.56,5.67 Z"></path><circle fill="none" stroke="#000" stroke-width="1.1" cx="10" cy="10" r="9"></circle></svg>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="showAllFundedBy" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllFundedBy = !showAllFundedBy;">
|
||||||
|
View less
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="!showAllFundedBy && softwareInfo.fundedByProjects && softwareInfo.fundedByProjects.length > 5">...</dd>
|
||||||
|
<dd *ngIf="!showAllFundedBy && softwareInfo.fundedByProjects && softwareInfo.fundedByProjects.length > 5" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllFundedBy = !showAllFundedBy;">
|
||||||
|
View more
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li *ngIf="softwareInfo.contexts && softwareInfo.contexts.length >0 ">
|
||||||
|
<dl class="uk-description-list-line" >
|
||||||
|
<dt class="title">Related to </dt>
|
||||||
|
<dd class="line" *ngFor="let item of softwareInfo.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><citeThis [result]="softwareInfo" [id]="softwareId" type="software"></citeThis></li>
|
||||||
|
<li *ngIf="softwareInfo.collectedFrom && softwareInfo.collectedFrom.length > 0">
|
||||||
|
<dl class="uk-description-list-line">
|
||||||
|
<dt>Collected from</dt>
|
||||||
|
<dd *ngFor="let item of softwareInfo.collectedFrom let i=index">
|
||||||
|
<!--a href="{{item['url']}}"-->
|
||||||
|
<a *ngIf="i<5 || showAllCollectedFrom"
|
||||||
|
[queryParams]="{datasourceId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataprovider">
|
||||||
|
{{item['name']}}
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="showAllCollectedFrom" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllCollectedFrom = !showAllCollectedFrom;">
|
||||||
|
View less
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
<dd *ngIf="!showAllCollectedFrom && softwareInfo.collectedFrom.length > 5">...</dd>
|
||||||
|
<dd *ngIf="!showAllCollectedFrom && softwareInfo.collectedFrom.length > 5" class="uk-text-right">
|
||||||
|
<a class="uk-text-muted" (click)="showAllCollectedFrom = !showAllCollectedFrom;">
|
||||||
|
View more
|
||||||
|
</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!--div class="uk-card uk-card-default uk-padding-small uk-card-body">
|
||||||
|
<div class="uk-card-title">
|
||||||
|
<span class="" uk-tooltip="pos:right; delay:5"
|
||||||
|
title='<div id="linkinginfo" class= "uk-margin uk-padding-small">
|
||||||
|
<p>Do you think that information is missing about a project, a community or other research results related to this software?</p>
|
||||||
|
<p>You are able to enhance it! Please follow the links and create the missing relations.</p>
|
||||||
|
</div>'>
|
||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="link" ratio="1"><path fill="none" stroke="#000" stroke-width="1.1" 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"></path><path fill="none" stroke="#000" stroke-width="1.1" 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"></path><path fill="none" stroke="#000" stroke-width="1.1" d="M7.925,11.875 L11.925,7.975"></path></svg></span>
|
||||||
|
Link this software to</div>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<div class="uk-clearfix">
|
||||||
|
|
||||||
|
<div><a class="uk-button-text uk-width-1-1" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','project'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Projects</a></div>
|
||||||
|
<div><a class=" uk-button-text uk-width-1-1"[queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','context'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Communities</a></div>
|
||||||
|
<div><a class=" uk-button-text uk-width-1-1" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[softwareId,'software','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" >
|
||||||
|
Other research results</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div-->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,220 @@
|
||||||
|
import {Component, ViewChild, ElementRef} from '@angular/core';
|
||||||
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
import {SoftwareService} from './software.service';
|
||||||
|
import {SoftwareInfo} from '../../utils/entities/softwareInfo';
|
||||||
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties'
|
||||||
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
|
import { Meta} from '../../../angular2-meta';
|
||||||
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'software',
|
||||||
|
templateUrl: 'software.component.html',
|
||||||
|
})
|
||||||
|
|
||||||
|
export class SoftwareComponent {
|
||||||
|
public softwareInfo: SoftwareInfo;
|
||||||
|
public softwareId : string ;
|
||||||
|
|
||||||
|
// APP BOX variables
|
||||||
|
public showAllCollectedFrom: boolean = false;
|
||||||
|
public showAllDownloadFrom: boolean = false;
|
||||||
|
public showAllPublishedIn: boolean = false;
|
||||||
|
public showAllFundedBy: 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;
|
||||||
|
|
||||||
|
constructor (private element: ElementRef,
|
||||||
|
private _softwareService: SoftwareService,
|
||||||
|
private _piwikService:PiwikService,
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private _meta: Meta,
|
||||||
|
private _router: Router) {
|
||||||
|
this.updateUrl(OpenaireProperties.getBaseLink()+this._router.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.sub = this.route.queryParams.subscribe(params => {
|
||||||
|
this.softwareInfo = null;
|
||||||
|
this.updateTitle("Software");
|
||||||
|
this.updateDescription("Software, search, open access");
|
||||||
|
|
||||||
|
this.softwareId = params['softwareId'];
|
||||||
|
console.info("Id is :"+this.softwareId);
|
||||||
|
|
||||||
|
if(this.softwareId){
|
||||||
|
this.getSoftwareInfo(this.softwareId);
|
||||||
|
}else{
|
||||||
|
this.showLoading = false;
|
||||||
|
this.warningMessage="No valid software id";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.metricsClicked = false;
|
||||||
|
|
||||||
|
this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.softwareId+'", "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.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resViewsTimeline", "resTitle":"'+this.softwareId+'", "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(124, 181, 236, 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 = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.softwareId+'", "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';
|
||||||
|
/*this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloadTimeline", "resTitle":"'+this.softwareId+'", "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';
|
||||||
|
*/
|
||||||
|
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 getSoftwareInfo(id:string) {
|
||||||
|
this.warningMessage = '';
|
||||||
|
this.errorMessage=""
|
||||||
|
this.showLoading = true;
|
||||||
|
|
||||||
|
this.infoSub = this._softwareService.getSoftwareInfo(id).subscribe(
|
||||||
|
data => {
|
||||||
|
this.softwareInfo = data;
|
||||||
|
this.updateTitle(this.softwareInfo.title.name);
|
||||||
|
this.updateDescription("Software, search, repositories, open access,"+this.softwareInfo.title.name);
|
||||||
|
if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){
|
||||||
|
this.piwiksub = this._piwikService.trackView(this.softwareInfo.title.name).subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.result = []
|
||||||
|
this.result = {id: id, type :"software", source : "openaire", title: this.softwareInfo.title,url: '', result: '', accessRights: this.softwareInfo.title.accessMode, embargoEndDate: ''};
|
||||||
|
|
||||||
|
let relatedResearchResultsNum = 0;
|
||||||
|
if(this.softwareInfo.relatedResearchResults != undefined) {
|
||||||
|
this.softwareInfo.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 software found';
|
||||||
|
this.showLoading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// showChange($event) {
|
||||||
|
// this.showAllReferences=$event.value;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public metricsResults($event) {
|
||||||
|
this.totalViews = $event.totalViews;
|
||||||
|
this.totalDownloads = $event.totalDownloads;
|
||||||
|
this.pageViews = $event.pageViews;
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateDescription(description:string){
|
||||||
|
this._meta.updateMeta("description", description);
|
||||||
|
this._meta.updateProperty("og:description", description);
|
||||||
|
}
|
||||||
|
private updateTitle(title:string){
|
||||||
|
var _prefix ="OpenAIRE | ";
|
||||||
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
||||||
|
this._meta.setTitle(_title );
|
||||||
|
this._meta.updateProperty("og:title",_title);
|
||||||
|
}
|
||||||
|
private updateUrl(url:string){
|
||||||
|
this._meta.updateProperty("og:url", 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 buildFundingTooltip(item: { "id": string, "acronym": string, "title": string,
|
||||||
|
"funderShortname": string, "funderName": string,
|
||||||
|
"funding": string, "code": string, "provenanceAction":string, "inline": boolean}) {
|
||||||
|
let tooltipContent: string = "<div class='tooltip-custom-font-size uk-light uk-padding-small'>";
|
||||||
|
|
||||||
|
if(item.title) {
|
||||||
|
tooltipContent += "<h5>"+item.title+"</h5>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.code || item.funderName || item.funderShortname || item.funding) {
|
||||||
|
tooltipContent += "<p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.code) {
|
||||||
|
tooltipContent += "<div>Project Code: "+item.code + "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.funderName || item.funderShortname) {
|
||||||
|
tooltipContent += "<div>Funder: ";
|
||||||
|
if(item.funderName && item.funderShortname) {
|
||||||
|
tooltipContent += item.funderName + " ("+ item.funderShortname +")";
|
||||||
|
} else if(item.funderName) {
|
||||||
|
tooltipContent += item.funderName;
|
||||||
|
} else {
|
||||||
|
tooltipContent += item.funderShortname;
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltipContent += "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.funding) {
|
||||||
|
tooltipContent += "<div>Funding: "+ item.funding + "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.code || item.funderName || item.funderShortname || item.funding) {
|
||||||
|
tooltipContent += "</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item.provenanceAction == 'Repository') {
|
||||||
|
tooltipContent += "Provided by Repository";
|
||||||
|
} else if(item.provenanceAction == 'Algorithm') {
|
||||||
|
tooltipContent += "Inferred by Algorithm";
|
||||||
|
} else if(item.provenanceAction == 'USer') {
|
||||||
|
tooltipContent += "Claimed by User";
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltipContent+="</div>"
|
||||||
|
return tooltipContent;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
//import {MaterialModule} from '@angular/material';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import { SoftwareService } from './software.service';
|
||||||
|
import { SoftwareComponent } from './software.component';
|
||||||
|
import { SoftwareRoutingModule } from './software-routing.module';
|
||||||
|
import { MetricsModule } from '../landing-utils/metrics.module';
|
||||||
|
import { IFrameModule } from '../../utils/iframe.module';
|
||||||
|
import { AltMetricsModule } from '../../utils/altmetrics.module';
|
||||||
|
import { CiteThisModule } from '../landing-utils/citeThis/citeThis.module';
|
||||||
|
import { PagingModule } from '../../utils/paging.module';
|
||||||
|
|
||||||
|
import { ResultLandingModule } from '../landing-utils/resultLanding.module';
|
||||||
|
import { LandingModule } from '../landing-utils/landing.module';
|
||||||
|
import { FreeGuard } from'../../login/freeGuard.guard';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule, LandingModule,SharedModule, RouterModule, CiteThisModule, PagingModule,
|
||||||
|
ResultLandingModule, SoftwareRoutingModule, IFrameModule, MetricsModule, AltMetricsModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
SoftwareComponent
|
||||||
|
],
|
||||||
|
providers:[
|
||||||
|
SoftwareService, FreeGuard
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
SoftwareComponent
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SoftwareModule { }
|
|
@ -0,0 +1,215 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {Http, Response} from '@angular/http';
|
||||||
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
import {SoftwareInfo} from '../../utils/entities/softwareInfo';
|
||||||
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
||||||
|
import 'rxjs/add/observable/of';
|
||||||
|
import 'rxjs/add/operator/do';
|
||||||
|
import 'rxjs/add/operator/share';
|
||||||
|
import { CacheService } from '../../shared/cache.service';
|
||||||
|
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SoftwareService {
|
||||||
|
|
||||||
|
constructor(private http: Http, public _cache: CacheService) {
|
||||||
|
this.parsingFunctions = new ParsingFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public parsingFunctions: ParsingFunctions;
|
||||||
|
softwareInfo: SoftwareInfo;
|
||||||
|
|
||||||
|
getSoftwareInfo (id: string):any {
|
||||||
|
console.info("getSoftwareInfo in service");
|
||||||
|
|
||||||
|
let url = OpenaireProperties. getSearchAPIURLLast()+'software/'+id+"?format=json";
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => this.parseSoftwareInfo(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.http.get(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']])
|
||||||
|
.map(res => [res[1],
|
||||||
|
res[1]['title'],
|
||||||
|
res[1]['rels']['rel'],
|
||||||
|
res[1]['children'],
|
||||||
|
res[1]['pid'],
|
||||||
|
res[1]['subject'],
|
||||||
|
res[1]['bestlicense'],
|
||||||
|
res[1]['collectedfrom'],
|
||||||
|
res[1]['context'],
|
||||||
|
//res[1]['resulttype'],
|
||||||
|
res[0]
|
||||||
|
]).do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => this.parseSoftwareInfo(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');
|
||||||
|
}
|
||||||
|
|
||||||
|
parseSoftwareInfo (data: any):any {
|
||||||
|
this.softwareInfo = new SoftwareInfo();
|
||||||
|
|
||||||
|
if(data[0] != null) {
|
||||||
|
var date:string = (data[0].dateofacceptance)+""; // transform to string in case it is an integer
|
||||||
|
this.softwareInfo.date = (date && (date).indexOf('-') !== -1)?date.split('-')[0]:date;
|
||||||
|
this.softwareInfo.dateofacceptance = data[0].dateofacceptance;
|
||||||
|
this.softwareInfo.publisher = data[0].publisher;
|
||||||
|
if(!Array.isArray(data[0].description)) {
|
||||||
|
this.softwareInfo.description = data[0].description;
|
||||||
|
} else {
|
||||||
|
this.softwareInfo.description = data[0].description[0];
|
||||||
|
}
|
||||||
|
this.softwareInfo.embargoEndDate = data[0].embargoenddate;
|
||||||
|
}
|
||||||
|
this.softwareInfo.title = {"name": "", "url": "", "accessMode": ""};
|
||||||
|
if(data[0]['bestlicense'].hasOwnProperty("classid")) {
|
||||||
|
this.softwareInfo.title.accessMode = data[0]['bestlicense'].classid;
|
||||||
|
}
|
||||||
|
if(data[1] != null) {
|
||||||
|
if(Array.isArray(data[1])) {
|
||||||
|
this.softwareInfo.title['name'] = data[1][0].content;
|
||||||
|
} else {
|
||||||
|
this.softwareInfo.title['name'] = 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 == "hasAuthor") {
|
||||||
|
if(this.softwareInfo.authors == undefined) {
|
||||||
|
this.softwareInfo.authors = new Array<{"name": string, "id": string}>();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.softwareInfo.authors[relation.ranking-1] = {"name": "", "id": ""};
|
||||||
|
this.softwareInfo.authors[relation.ranking-1]['name'] = relation.fullname;
|
||||||
|
} else if(relation['to'].class == "isProducedBy") {
|
||||||
|
this.softwareInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.softwareInfo.fundedByProjects, relation, this.softwareInfo.projectsProvenanceVocabulary);
|
||||||
|
} else if(relation['to'].class == "isRelatedTo") {
|
||||||
|
let provenanceAction: string;
|
||||||
|
if(relation.provenanceaction in this.softwareInfo.researchResultsProvenanceVocabulary) {
|
||||||
|
provenanceAction = this.softwareInfo.researchResultsProvenanceVocabulary[relation.provenanceaction];
|
||||||
|
} else {
|
||||||
|
provenanceAction = "Other"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.softwareInfo.relatedResearchResults = this.parsingFunctions.parseRelatedResearchResults(this.softwareInfo.relatedResearchResults, relation, provenanceAction);
|
||||||
|
|
||||||
|
} else if(relation['to'].class == "hasAmongTopNSimilarDocuments") {
|
||||||
|
this.softwareInfo.similarResearchResults = this.parsingFunctions.parseSimilarResearchResults(this.softwareInfo.similarResearchResults, relation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.softwareInfo.authors != undefined) {
|
||||||
|
this.softwareInfo.authors = this.softwareInfo.authors.filter(function (item) {
|
||||||
|
return (item != undefined);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data[3] != null) {
|
||||||
|
if(data[3].hasOwnProperty("instance")) {
|
||||||
|
this.softwareInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>();
|
||||||
|
this.softwareInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>()
|
||||||
|
|
||||||
|
this.softwareInfo.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.softwareInfo.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")) {
|
||||||
|
if(instance['hostedby'].name != "other resources" && instance['hostedby'].name != "Unknown Repository") {
|
||||||
|
this.parsingFunctions.parseDownloadFrom(this.softwareInfo.downloadFrom, instance, url);
|
||||||
|
} else {
|
||||||
|
counter = this.parsingFunctions.parsePublishedIn(this.softwareInfo.publishedIn, instance, data[0], url, counter);
|
||||||
|
}
|
||||||
|
if(this.softwareInfo.title != undefined) {
|
||||||
|
if(!this.softwareInfo.title['url']) {
|
||||||
|
this.softwareInfo.title['url'] = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.parsingFunctions.changeBestAccessMode(this.softwareInfo.title['accessMode'], instance['licence'])) {
|
||||||
|
this.softwareInfo.title['accessMode'] = instance['licence'].classid;
|
||||||
|
this.softwareInfo.title['url'] = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data[4] != null) {
|
||||||
|
this.softwareInfo.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.softwareInfo.subjects = subjectResults[0];
|
||||||
|
this.softwareInfo.otherSubjects = subjectResults[1];
|
||||||
|
this.softwareInfo.classifiedSubjects = subjectResults[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(data[6] != null) {
|
||||||
|
// this.softwareInfo.bestlicense = data[6].classid;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(data[7] != null) {
|
||||||
|
this.softwareInfo.collectedFrom = this.parsingFunctions.parseCollectedFrom(data[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// null argument is for journal
|
||||||
|
this.softwareInfo.downloadFrom = this.parsingFunctions.addPublisherToDownloadFrom(
|
||||||
|
this.softwareInfo.downloadFrom, this.softwareInfo.publisher,
|
||||||
|
null, this.softwareInfo.identifiers, this.softwareInfo.title);
|
||||||
|
|
||||||
|
if(data[8] != null) {
|
||||||
|
this.softwareInfo.contexts = this.parsingFunctions.parseContexts(data[8]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(data[9] != null && this.softwareInfo.type == undefined) {
|
||||||
|
// if(data[9].hasOwnProperty('classname')) {
|
||||||
|
// this.softwareInfo.type = data[9].classname;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(data[9] != null && data[9] == "under curation") {
|
||||||
|
this.softwareInfo.underCurationMessage = true;
|
||||||
|
} else {
|
||||||
|
this.softwareInfo.underCurationMessage = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.softwareInfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import{AdvancedSearchSoftwareComponent} from './advancedSearchSoftware.component';
|
||||||
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
|
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild([
|
||||||
|
{ path: '', component: AdvancedSearchSoftwareComponent, canActivate: [FreeGuard],canDeactivate: [PreviousRouteRecorder] }
|
||||||
|
|
||||||
|
])
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AdvancedSearchSoftwareRoutingModule { }
|
|
@ -0,0 +1,161 @@
|
||||||
|
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 {SearchSoftwareService} from '../../services/searchSoftware.service';
|
||||||
|
import {SearchResult} from '../../utils/entities/searchResult';
|
||||||
|
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
|
||||||
|
import {SearchFields} from '../../utils/properties/searchFields';
|
||||||
|
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'advanced-search-software',
|
||||||
|
template: `
|
||||||
|
<advanced-search-page pageTitle="Advanced Search for Software" entityType="software"
|
||||||
|
type = "software"
|
||||||
|
[(results)] = "results"
|
||||||
|
[(searchUtils)] = "searchUtils"
|
||||||
|
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||||
|
(queryChange)="queryChanged($event)"
|
||||||
|
[csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/software"
|
||||||
|
[disableForms]="disableForms"
|
||||||
|
[loadPaging]="loadPaging"
|
||||||
|
[oldTotalResults]="oldTotalResults">
|
||||||
|
</advanced-search-page>
|
||||||
|
|
||||||
|
`
|
||||||
|
})
|
||||||
|
|
||||||
|
export class AdvancedSearchSoftwareComponent {
|
||||||
|
private errorCodes: ErrorCodes;
|
||||||
|
|
||||||
|
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 software) )";
|
||||||
|
public csvParams: string;
|
||||||
|
public disableForms: boolean = false;
|
||||||
|
public loadPaging: boolean = true;
|
||||||
|
public oldTotalResults: number = 0;
|
||||||
|
|
||||||
|
constructor (private route: ActivatedRoute, private _searchSoftwareService: SearchSoftwareService ) {
|
||||||
|
this.results =[];
|
||||||
|
this.errorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedSoftware;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
ngOnInit() {
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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.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(parameters!= null && parameters != '' ) {
|
||||||
|
this.csvParams ="&type=software&query=( "+this.resourcesQuery + "and (" + parameters + "))";
|
||||||
|
}else{
|
||||||
|
this.csvParams ="&type=software&query="+this.resourcesQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
//this.searchPage.openLoading();
|
||||||
|
this.disableForms = true;
|
||||||
|
this.results = [];
|
||||||
|
this.searchUtils.totalResults = 0;
|
||||||
|
|
||||||
|
console.info("Advanced Search for Software: Execute search query "+parameters);
|
||||||
|
this._searchSoftwareService.advancedSearchSoftware(parameters, page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software total="+this.searchUtils.totalResults);
|
||||||
|
this.results = data[1];
|
||||||
|
this.searchPage.updateBaseUrlWithParameters();
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.DONE;
|
||||||
|
if(this.searchUtils.totalResults == 0 ){
|
||||||
|
this.searchUtils.status = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
//this.searchPage.closeLoading();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
|
||||||
|
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.searchPage.closeLoading();
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import{ AdvancedSearchSoftwareRoutingModule} from './advancedSearchSoftware-routing.module';
|
||||||
|
import{AdvancedSearchSoftwareComponent} from './advancedSearchSoftware.component';
|
||||||
|
|
||||||
|
|
||||||
|
import {SoftwareServiceModule} from '../../services/softwareService.module';
|
||||||
|
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
|
||||||
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule,
|
||||||
|
SoftwareServiceModule,
|
||||||
|
AdvancedSearchSoftwareRoutingModule, AdvancedSearchPageModule
|
||||||
|
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
AdvancedSearchSoftwareComponent
|
||||||
|
],
|
||||||
|
providers:[FreeGuard
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
AdvancedSearchSoftwareComponent
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class AdvancedSearchSoftwareModule { }
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import {SearchSoftwareComponent} from './searchSoftware.component';
|
||||||
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
|
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild([
|
||||||
|
{ path: '', component: SearchSoftwareComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] }
|
||||||
|
|
||||||
|
])
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SearchSoftwareRoutingModule { }
|
|
@ -0,0 +1,275 @@
|
||||||
|
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 {SearchSoftwareService} from '../../services/searchSoftware.service';
|
||||||
|
import {SearchResult} from '../../utils/entities/searchResult';
|
||||||
|
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
import {SearchFields} from '../../utils/properties/searchFields';
|
||||||
|
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
||||||
|
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
|
||||||
|
import {DOI} from '../../utils/string-utils.class';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'search-software',
|
||||||
|
template: `
|
||||||
|
|
||||||
|
<search-page pageTitle="Search Software"
|
||||||
|
formPlaceholderText = "Search for Software"
|
||||||
|
type="software" entityType="software" [(filters)] = "filters"
|
||||||
|
[(results)] = "results" [(searchUtils)] = "searchUtils"
|
||||||
|
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"
|
||||||
|
[csvParams]="csvParams" csvPath="software" advancedSearchLink="/search/advanced/software"
|
||||||
|
[disableForms]="disableForms"
|
||||||
|
[loadPaging]="loadPaging"
|
||||||
|
[oldTotalResults]="oldTotalResults"
|
||||||
|
searchFormClass="softwareSearchForm">
|
||||||
|
</search-page>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
|
||||||
|
export class SearchSoftwareComponent {
|
||||||
|
private errorCodes: ErrorCodes;
|
||||||
|
|
||||||
|
public results =[];
|
||||||
|
public filters: Filter[] =[];
|
||||||
|
// public totalResults:number = 0 ;
|
||||||
|
public baseUrl:string;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||||
|
constructor (private route: ActivatedRoute, private _searchSoftwareService: SearchSoftwareService ) {
|
||||||
|
|
||||||
|
this.errorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
this.searchUtils.page =1;
|
||||||
|
this.baseUrl = OpenaireProperties.getLinkToSearchSoftware();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnInit() {
|
||||||
|
this.searchPage.refineFields = this.refineFields;
|
||||||
|
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||||
|
this.searchPage.type = "software";
|
||||||
|
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'];
|
||||||
|
|
||||||
|
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._searchSoftwareService.searchSoftwareForEntity(parameters, page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||||
|
this.results = data[1];
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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 = "software?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||||
|
} else if(resultsFrom == "hostedBy") {
|
||||||
|
parameters = "software?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parameters != "") {
|
||||||
|
|
||||||
|
this._searchSoftwareService.searchSoftwareForDataproviders(parameters, page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||||
|
this.results = data[1];
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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){
|
||||||
|
this.csvParams = parameters;
|
||||||
|
|
||||||
|
// if(!refine && !this.searchPage){
|
||||||
|
// this.searchPage = new SearchPageComponent(this._location);
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
//this.searchPage.openLoading();
|
||||||
|
this.disableForms = true;
|
||||||
|
this.results = [];
|
||||||
|
this.searchUtils.totalResults = 0;
|
||||||
|
|
||||||
|
this.subResults = this._searchSoftwareService.searchSoftware(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software: [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);
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.DONE;
|
||||||
|
if(this.searchUtils.totalResults == 0 ){
|
||||||
|
this.searchUtils.status = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
//this.searchPage.closeLoading();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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.searchPage.closeLoading();
|
||||||
|
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, "searchPage");
|
||||||
|
this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import{ SearchSoftwareRoutingModule} from './searchSoftware-routing.module';
|
||||||
|
import{SearchSoftwareComponent} from './searchSoftware.component';
|
||||||
|
|
||||||
|
import {SearchResultsModule } from '../searchUtils/searchResults.module';
|
||||||
|
|
||||||
|
import {SoftwareServiceModule} from '../../services/softwareService.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';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule,
|
||||||
|
|
||||||
|
SoftwareServiceModule,
|
||||||
|
SearchFormModule, SearchResultsModule, SearchSoftwareRoutingModule, SearchPageModule
|
||||||
|
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
SearchSoftwareComponent
|
||||||
|
],
|
||||||
|
providers:[FreeGuard
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
SearchSoftwareComponent
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SearchSoftwareModule { }
|
|
@ -0,0 +1,347 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {Http, Response} from '@angular/http';
|
||||||
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
import {OpenaireProperties} from '../utils/properties/openaireProperties';
|
||||||
|
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 { CacheService } from '../shared/cache.service';
|
||||||
|
@Injectable()
|
||||||
|
export class SearchSoftwareService {
|
||||||
|
private sizeOfDescription: number = 270;
|
||||||
|
|
||||||
|
constructor(private http: Http, public _cache: CacheService) {}
|
||||||
|
|
||||||
|
searchSoftware (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any {
|
||||||
|
|
||||||
|
let link = OpenaireProperties.getSearchAPIURLLast()+"software";
|
||||||
|
|
||||||
|
let url = link+"?";
|
||||||
|
if(params!= null && params != '' ) {
|
||||||
|
url += params;
|
||||||
|
}
|
||||||
|
if(refineParams!= null && refineParams != '' ) {
|
||||||
|
url += refineParams;
|
||||||
|
}
|
||||||
|
url += "&page="+ (page-1) +"&size="+size+"&format=json";
|
||||||
|
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
//.do(res => console.info(res))
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
|
||||||
|
}
|
||||||
|
searchSoftwareById (id: string ):any {
|
||||||
|
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+"software/"+id+"?format=json";
|
||||||
|
let key = url+"-searchById";
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => this.parseResults(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => this.parseResults(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number ):any {
|
||||||
|
|
||||||
|
let link = OpenaireProperties.getSearchAPIURLLast()+"software";
|
||||||
|
|
||||||
|
let url = link+"?"+"&format=json";
|
||||||
|
if(params!= null && params != '' ) {
|
||||||
|
url += params;
|
||||||
|
}
|
||||||
|
if(refineParams!= null && refineParams != '' ) {
|
||||||
|
url += refineParams;
|
||||||
|
}
|
||||||
|
url += "&page="+(page-1)+"&size="+size;
|
||||||
|
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => this.parseRefineResults(id, res['refineResults']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => this.parseRefineResults(id, res['refineResults']))
|
||||||
|
}
|
||||||
|
|
||||||
|
searchSoftwareByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any {
|
||||||
|
let link = OpenaireProperties.getSearchAPIURLLast()+"software";
|
||||||
|
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";
|
||||||
|
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
//.do(res => console.info(res))
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
|
||||||
|
}
|
||||||
|
advancedSearchSoftware (params: string, page: number, size: number ):any {
|
||||||
|
let url = OpenaireProperties.getSearchResourcesAPIURL();
|
||||||
|
var basicQuery = "(oaftype exact result) and (resulttypeid exact software) "
|
||||||
|
url += "?query=";
|
||||||
|
if(params!= null && params != '' ) {
|
||||||
|
url +=" ( "+basicQuery+ " ) " +" and (" + params + ")";
|
||||||
|
}else{
|
||||||
|
url +=" ( "+basicQuery+ " ) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
url += "&page="+(page-1)+"&size="+size;
|
||||||
|
url += "&format=json";
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key));
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
//.do(res => console.info(res))
|
||||||
|
.map(res => [res['meta'].total, this.parseResults(res['results'])])
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
searchSoftwareForEntity (params: string, page: number, size: number):any {
|
||||||
|
let link = OpenaireProperties.getSearchAPIURLLast();
|
||||||
|
let url = link+params+"/software"+"?format=json";
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
||||||
|
}
|
||||||
|
|
||||||
|
searchSoftwareForDataproviders(params: string, page: number, size: number):any {
|
||||||
|
let link = OpenaireProperties.getSearchAPIURLLast();
|
||||||
|
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
})
|
||||||
|
.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['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.getsearchLinkToSoftware();
|
||||||
|
//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['bestlicense'].hasOwnProperty("classid")) {
|
||||||
|
result['title'].accessMode = resData['bestlicense'].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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfSoftware(url: string):any {
|
||||||
|
let key = url;
|
||||||
|
if (this._cache.has(key)) {
|
||||||
|
return Observable.of(this._cache.get(key));
|
||||||
|
}
|
||||||
|
return this.http.get(url)
|
||||||
|
.map(res => <any> res.json())
|
||||||
|
.map(res => res.total)
|
||||||
|
.do(res => {
|
||||||
|
this._cache.set(key, res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfEntitySoftware(id: string, entity: string):any {
|
||||||
|
var parameters = "";
|
||||||
|
|
||||||
|
if(entity == "project") {
|
||||||
|
parameters = "projects/"+id+"/software/count";
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+parameters+"?format=json";
|
||||||
|
return this.numOfSoftware(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfSearchSoftware(params: string):any {
|
||||||
|
let url = OpenaireProperties.getSearchAPIURLLast()+"software/count?format=json";
|
||||||
|
if(params != "") {
|
||||||
|
url += "&q=" + params;
|
||||||
|
}
|
||||||
|
return this.numOfSoftware(url);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import {SearchSoftwareService} from './searchSoftware.service';
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule, FormsModule
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
],
|
||||||
|
providers:[
|
||||||
|
SearchSoftwareService
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SoftwareServiceModule { }
|
|
@ -0,0 +1,44 @@
|
||||||
|
export class SoftwareInfo {
|
||||||
|
underCurationMessage: boolean;
|
||||||
|
title: { "name": string, "url": string, "accessMode": string};
|
||||||
|
authors: { "name": string, "id": string}[];
|
||||||
|
date: string;
|
||||||
|
dateofacceptance: string;
|
||||||
|
embargoEndDate: string;
|
||||||
|
types: string[];
|
||||||
|
downloadFrom: Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>; //key is name
|
||||||
|
publishedIn: Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>; //key is name
|
||||||
|
identifiers: Map<string, string[]>;
|
||||||
|
publisher: string;
|
||||||
|
subjects: string[];
|
||||||
|
otherSubjects: Map<string, string[]>;
|
||||||
|
classifiedSubjects: Map<string, string[]>;
|
||||||
|
description: string;
|
||||||
|
//bestlicense: string;
|
||||||
|
collectedFrom: { "name": string, "id": 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": "Algorithm",
|
||||||
|
"sysimport:mining:repository": "Algorithm",
|
||||||
|
"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, "trust": number, "class": string}[]>;
|
||||||
|
similarResearchResults: { "name": string, "id": string, "date": string, "trust": number, "class": string}[];
|
||||||
|
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}[];
|
||||||
|
}
|
|
@ -0,0 +1,253 @@
|
||||||
|
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
||||||
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
|
||||||
|
import {DOI} from '../../utils/string-utils.class';
|
||||||
|
import {Subject} from 'rxjs/Subject';
|
||||||
|
|
||||||
|
export class FetchSoftware{
|
||||||
|
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 _searchSoftwareService: SearchSoftwareService ) {
|
||||||
|
|
||||||
|
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){
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
|
||||||
|
this.subResults = this._searchSoftwareService.searchSoftware(parameters,null, page, size, []).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||||
|
this.results = data[1];
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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){
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
|
||||||
|
|
||||||
|
if(id != "" && entity != "") {
|
||||||
|
this._searchSoftwareService.numOfEntitySoftware(id, entity).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data;
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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){
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
|
||||||
|
var parameters = "";
|
||||||
|
|
||||||
|
if(entity == "project") {
|
||||||
|
parameters = "projects/"+id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parameters != "") {
|
||||||
|
|
||||||
|
this._searchSoftwareService.searchSoftwareForEntity(parameters, page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||||
|
this.results = data[1];
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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 errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
|
||||||
|
var parameters;
|
||||||
|
if(resultsFrom == "collectedFrom") {
|
||||||
|
parameters = "software?fq=collectedfromdatasourceid exact "+'"'+id+'"';
|
||||||
|
} else if(resultsFrom == "hostedBy") {
|
||||||
|
parameters = "software?fq=resulthostingdatasourceid exact "+'"'+id+'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parameters != "") {
|
||||||
|
|
||||||
|
this._searchSoftwareService.searchSoftwareForDataproviders(parameters, page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.searchUtils.totalResults = data[0];
|
||||||
|
console.info("search Software for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
||||||
|
this.results = data[1];
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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){
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
|
||||||
|
this.subResults = this._searchSoftwareService.searchAggregators(id, '&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe(
|
||||||
|
data => {
|
||||||
|
this.results = data;
|
||||||
|
this.searchUtils.totalResults = this.results.length;
|
||||||
|
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
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( ){
|
||||||
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||||
|
// }
|
||||||
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
//this.searchUtils.status = errorCodes.ERROR;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue