adding missing files from previous incomplete commit ( r43486)

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43487 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2016-08-05 10:55:11 +00:00
parent 6dc2747cd4
commit dccf449e80
12 changed files with 1450 additions and 0 deletions

View File

@ -0,0 +1,26 @@
export class DatasetInfo {
title: { "name": string, "url": string, "accessMode": string};
authors: { "name": string, "url": string}[];
date: string;
embargoEndDate: string;
type: string;
downloadFrom: Map<string, {"url": string[], "accessMode": string[]}>; //key is name
publishedIn: Map<string, {"url": string[], "accessMode": string[]}>; //key is name
identifiers: Map<string, string[]>;
publisher: string;
subjects: string[];
classifiedSubjects: Map<string, string[]>;
description: string;
bestlicense: string;
collectedFrom: { "name": string, "url": string}[];
fundedByProjects: { "url": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "new": boolean}[];
//relatedPublications: { "name": string, "url": string, "date": string, "trust": string}[];
//relatedResearchData: { "name": string, "url": string, "date": string, "trust": string}[];
//similarPublications: { "name": string, "url": string, "date": string, "trust": string}[];
//similarDatasets: { "name": string, "url": string, "date": string, "trust": string}[];
relatedResearchResults: { "name": string, "url": string, "date": string, "trust": string, "class": string}[];
similarResearchResults: {"name": string, "url": string, "date": string, "trust": string, "class": string}[];
contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string}[];
}

View File

@ -0,0 +1,9 @@
export class PersonInfo {
fullname: string;
firstname: string;
secondnames: string;
country: string;
publications: any;
researchData: any;
}

View File

@ -0,0 +1,326 @@
import {Component, ViewChild} from '@angular/core';
import {JSONP_PROVIDERS} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {DatasetService} from '../../services/dataset.service';
import {DatasetInfo} from '../../entities/datasetInfo';
import { RouteParams} from '@angular/router-deprecated';
import { InlineClaimContextComponent} from '../../claimPages/inlineClaimContext/inlineClaimContext.component';
import { InlineClaimProjectComponent} from '../../claimPages/inlineClaimProject/inlineClaimProject.component';
import {TabPagingComponent} from '../tabPaging.component.ts';
import {TabTableComponent} from '../tabTable.component.ts';
import {ShowTitleComponent} from '../showTitle.component.ts';
import {ShowAuthorsComponent} from '../showAuthors.component.ts';
import {ShowIdentifiersComponent} from '../showIdentifiers.component.ts';
import {ShowSubjectsComponent} from '../showSubjects.component.ts';
@Component({
selector: 'dataset',
template: `
<div class="container dataset">
<div class="container-header" >
<div *ngIf="datasetInfo != null" >
<showTitle [title]="datasetInfo.title"></showTitle>
</div>
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="errorMessage.length > 0" class="alert alert-danger" role="alert">{{errorMessage}}</div>
</div>
<div class="row row-offcanvas row-offcanvas-right" >
<div class="col-xs-6 col-sm-9 sidebar-offcanvas" *ngIf="datasetInfo != null">
<div>
<showAuthors [authors]="datasetInfo.authors"></showAuthors>
<span *ngIf="datasetInfo.date != ''">({{datasetInfo.date}})</span>
</div>
<dl class="dl-horizontal">
<dt *ngIf="datasetInfo.publisher != undefined && datasetInfo.publisher != ''">Publisher: </dt>
<dd *ngIf="datasetInfo.publisher != undefined && datasetInfo.publisher != ''">{{datasetInfo.publisher}}</dd>
<dt *ngIf="datasetInfo.type != undefined"> Type: </dt>
<dd *ngIf="datasetInfo.type != undefined">{{datasetInfo.type}}</dd>
<dt *ngIf="datasetInfo.embargoEndDate != undefined && datasetInfo.embargoEndDate != ''">Embargo end date: </dt>
<dd *ngIf="datasetInfo.embargoEndDate != undefined && datasetInfo.embargoEndDate != ''">{{datasetInfo.embargoEndDate}}</dd>
<showIdentifiers [identifiers]="datasetInfo.identifiers"></showIdentifiers>
<showSubjects [subjects]="datasetInfo.subjects" [classifiedSubjects]="datasetInfo.classifiedSubjects"></showSubjects>
</dl>
<blockquote *ngIf="datasetInfo.description != ''">
<div class="text-justify" [innerHTML]="datasetInfo.description"></div>
</blockquote>
<ul class="nav nav-tabs">
<li class="active">
<!--a data-toggle="tab" href="#relatedPublicationsTab">
Related Publications
<span *ngIf="datasetInfo.isRelatedTo == undefined" class="badge">0</span>
<span *ngIf="datasetInfo.isRelatedTo != undefined" class="badge">
{{datasetInfo.relatedPublications.length}}
</span>
</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#dataTab">
Related Research Results
<span *ngIf="datasetInfo.relatedResearchData == undefined" class="badge">0</span>
<span *ngIf="datasetInfo.relatedResearchData != undefined" class="badge">
{{datasetInfo.relatedResearchData.length}}
</span>
</a>
</li-->
<a data-toggle="tab" href="#relatedTab">
Related Research Results
<span *ngIf="datasetInfo.relatedResearchResults == undefined" class="badge">0</span>
<span *ngIf="datasetInfo.relatedResearchResults != undefined" class="badge">
{{datasetInfo.relatedResearchResults.length}}
</span>
</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#similarTab">
Similar Research Results
<span *ngIf="datasetInfo.similarResearchResults == undefined" class="badge">0</span>
<span *ngIf="datasetInfo.similarResearchResults != undefined" class="badge">
{{datasetInfo.similarResearchResults.length}}
</span>
</a>
</li>
</ul>
<div class="tab-content">
<!--div id="relatedPublicationsTab" class="tab-pane fade in active panel-body">
<div *ngIf="datasetInfo.isRelatedTo == undefined" class = "alert alert-info " >
There are no related publications
</div>
<div *ngIf="datasetInfo.isRelatedTo != undefined">
<p>
The results below are discovered through our pilot algorithms.
<a href="mailto:">Let us know how we are doing!</a>
</p>
<tabTable [info]="datasetInfo.isRelatedTo"></tabTable>
</div>
</div-->
<div id="relatedTab" class="tab-pane fade in active panel-body">
<div *ngIf="datasetInfo.relatedResearchResults == undefined" class = "alert alert-info " >
There are no related research results
</div>
<div *ngIf="datasetInfo.relatedResearchResults != undefined">
<p>
The results below are discovered through our pilot algorithms.
<a href="mailto:">Let us know how we are doing!</a>
</p>
<tabTable [info]="datasetInfo.relatedResearchResults"></tabTable>
</div>
</div>
<div id="similarTab" class="tab-pane fade panel-body">
<div *ngIf="datasetInfo.similarResearchResults == undefined" class = "alert alert-info " >
There are no similar research results
</div>
<div *ngIf="datasetInfo.similarResearchResults != undefined">
<p>
The results below are discovered through our pilot algorithms.
<a href="mailto:">Let us know how we are doing!</a>
</p>
<tabTable [info]="datasetInfo.similarResearchResults"></tabTable>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-3" *ngIf="datasetInfo != null">
<ul class="list-group mainFunctionsBlock">
<li class="list-group-item">
<dl class="functionsSection">
<dt >Share - Bookmark</dt>
<dd>
</dd>
</dl>
</li>
<li class="list-group-item" *ngIf="datasetInfo.collectedFrom != undefined">
<dl class="functionsSection">
<dt>Collected from</dt>
<dd *ngFor="let item of datasetInfo.collectedFrom">
<a href="{{item['url']}}">
{{item['name']}}
</a>
</dd>
</dl>
</li>
<li class="list-group-item" *ngIf="datasetInfo.downloadFrom != undefined && datasetInfo.downloadFrom.size > 0">
<dl class="functionsSection">
<dt class="title">Download from</dt>
<dd class="line" *ngFor="let key of datasetInfo.downloadFrom.keys()">
<div *ngIf="datasetInfo.downloadFrom.get(key)['url'].length > 1">
{{key}}
<span *ngFor="let url of datasetInfo.downloadFrom.get(key)['url']; let i=index;">
<a href="{{url}}">
[{{i+1}}]
</a>
</span>
</div>
<a *ngIf="datasetInfo.downloadFrom.get(key)['url'].length == 1" href="{{datasetInfo.downloadFrom.get(key)['url']}}">
{{key}}
</a>
</dd>
</dl>
</li>
<li class="list-group-item">
<dl class="functionsSection" *ngIf="datasetInfo.fundedByProjects != undefined">
<dt class="title">Funded By</dt>
<dd
title="{{item['title']}}
| Project Code: {{item['acronym']}}
| Funder: {{item['funderName']}} ({{item['funderShortname']}})
| Funding: {{item['funding']}}"
class="line" *ngFor="let item of datasetInfo.fundedByProjects">
<a *ngIf="!item['new']" href="{{item['url']}}">
{{item['funderShortname']?item['funderShortname']:item['funderName']}}
| {{ item['acronym']?item['acronym']:item['title']}}
</a>
<a *ngIf="item['new']" href="{{item['url']}}">
<mark>
{{item['funderShortname']?item['funderShortname']:item['funderName']}}
| {{ item['acronym']?item['acronym']:item['title']}}
</mark>
</a>
</dd>
</dl>
<!--dl class="functionsSection" *ngIf="datasetInfo.fundedByProjects == undefined">
<dt class="title">Funded By</dt>
</dl-->
<button (click)="toggleClaimProject()" class = "btn btn-default btn-xs" >Add more Projects</button>
<inline-claim-project *ngIf="result " inline="true" inlineType ="dataset" [inlineEntity]="result" (projectAdded)="projectAdded($event)" ></inline-claim-project>
</li>
<!--li class="list-group-item">
<dl class="functionsSection" *ngIf="datasetInfo.contexts != undefined">
<dt class="title">Related to </dt>
<dd class="line" *ngFor="let item of datasetInfo.contexts">
<span>{{item['labelContext']}}</span>
<span *ngIf="item['labelCategory'] != null">-> {{item['labelCategory']}}</span>
<span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
</dd>
</dl>
<dl class="functionsSection" *ngIf="datasetInfo.contexts == undefined">
<dt class="title">Related to </dt>
</dl>
<button (click)=" toggleClaimContext()" class = "btn btn-default btn-xs" >Add Contexts</button>
<inline-claim-context inline="true" inlineType ="dataset" [inlineEntity]="result" ></inline-claim-context>
</li-->
</ul>
</div>
</div>
</div>
`,
providers:[JSONP_PROVIDERS, DatasetService],
directives:[InlineClaimContextComponent, InlineClaimProjectComponent,
TabTableComponent, ShowTitleComponent, ShowAuthorsComponent,
ShowIdentifiersComponent, ShowSubjectsComponent]
})
export class DatasetComponent {
constructor (private _datasetService: DatasetService, private _routeParams: RouteParams) {
console.info('dataset constructor');
this.params = _routeParams;
}
ngOnInit() {
this.getDatasetInfo();
}
private datasetInfo: DatasetInfo;
private params: RouteParams;
private showStyle: boolean = false;
private showAllReferences: boolean = false;
private showAllRelResData: boolean = false;
private showAllSimilPubl: boolean = false;
private showAllBioentities: boolean = false;
private result ;
private claimInline:string = "none" ;
@ViewChild (InlineClaimProjectComponent) inlineClaimProject : InlineClaimProjectComponent ;
@ViewChild (InlineClaimContextComponent) inlineClaimContext : InlineClaimContextComponent ;
public warningMessage = "";
public errorMessage = "";
getDatasetInfo() {
this.warningMessage = '';
this.errorMessage=""
if(this.params.get("datasetId")==null || this.params.get("datasetId")==''){
this.warningMessage="No valid dataset id";
console.info("novalid");
}else{
console.info("do request");
this._datasetService.getDatasetInfo(this.params.get("datasetId")).subscribe(
data => {
this.datasetInfo = data;
this.result = []
let result_ ={id: this.params.get("datasetId"), type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.bestlicense, embargoEndDate: ''};
this.result.push(result_);
},
err => {
console.error(err)
console.info("error");
this.errorMessage = 'No dataset found';
}
);
}
}
/********** Methods for Inline Claim of project / dataset ******/
toggleClaimProject(){
this.inlineClaimProject.toggle();
}
projectAdded($event){
var projects =$event.value;
if(projects){
for(var i=0; i < projects.length; i++){
if(this.datasetInfo.fundedByProjects == undefined) {
this.datasetInfo.fundedByProjects = new Array<
{ "url": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "new": boolean
}>();
}
var project =projects[i];
let counter = this.datasetInfo.fundedByProjects.length;
this.datasetInfo.fundedByProjects[counter]['url'] =
"http://localhost:3000/project?projectId="+project.projectId;
this.datasetInfo.fundedByProjects[counter]['acronym'] = project.projectAcronym;
this.datasetInfo.fundedByProjects[counter]['title'] = project.projectName;
this.datasetInfo.fundedByProjects[counter]['funderShortname'] = project.selectedFunderId;
this.datasetInfo.fundedByProjects[counter]['funderName'] = project.selectedFunderName;
this.datasetInfo.fundedByProjects[counter]['new'] = true;
}
}
}
toggleClaimContext(){
this.inlineClaimContext.toggle();
}
contextAdded($event){
var contexts =$event.value;
if(contexts){
for(var i=0; i < contexts.length; i++){
}
}
}
}

View File

@ -0,0 +1,137 @@
import {Component} from '@angular/core';
import {JSONP_PROVIDERS} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import { RouteParams } from '@angular/router-deprecated';
import {PersonService} from '../../services/person.service';
import {PersonInfo} from '../../entities/personInfo';
@Component({
selector: 'person',
template: `
<div>
<div class="container person">
<div class="container-header" >
<div *ngIf="personInfo != null">
<h3>{{personInfo.fullname}}</h3>
</div>
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="errorMessage.length > 0" class="alert alert-danger" role="alert">{{errorMessage}}</div>
</div>
<div class="row row-offcanvas row-offcanvas-right" >
<div class="col-xs-6 col-sm-9 sidebar-offcanvas" *ngIf="personInfo != null">
<dl class="dl-horizontal">
<dt *ngIf="personInfo.secondnames != undefined && personInfo.secondnames != ''">Last name: </dt>
<dd *ngIf="personInfo.secondnames != undefined && personInfo.secondnames != ''">{{personInfo.secondnames}}</dd>
<dt *ngIf="personInfo.firstname != undefined && personInfo.firstname != ''">First name: </dt>
<dd *ngIf="personInfo.firstname != undefined && personInfo.firstname != ''">{{personInfo.firstname}}</dd>
<dt *ngIf="personInfo.country != undefined && personInfo.country != ''">Country: </dt>
<dd *ngIf="personInfo.country != undefined && personInfo.country != ''">{{personInfo.country}}</dd>
</dl>
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#publicationsTab">
Publications
</a>
</li>
<li role="presentation">
<a data-toggle="tab" href="#researchDataTab">
Research Data
</a>
</li>
</ul>
<div class="tab-content">
<div id="publicationsTab" class="tab-pane fade in active panel-body">
<div *ngIf="personInfo.publications == undefined" class = "alert alert-info " >
There are no publications
</div>
<div *ngIf="personInfo.publications != undefined">
<p>
The results below are discovered through our pilot algorithms.
<a href="mailto:">Let us know how we are doing!</a>
</p>
</div>
</div>
<div id="researchDataTab" class="tab-pane fade panel-body">
<div *ngIf="personInfo.researchData == undefined" class = "alert alert-info ">
There are no research data
</div>
<div *ngIf="personInfo.researchData != undefined">
<p>
The results below are discovered through our pilot algorithms.
<a href="mailto:">Let us know how we are doing!</a>
</p>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-3" *ngIf="personInfo != null">
<ul class="list-group mainFunctionsBlock">
<li class="list-group-item">
<dl class="functionsSection">
<dt >Share - Bookmark</dt>
<dd>
</dd>
</dl>
</li>
</ul>
</div>
</div>
</div>
</div>
`,
providers:[JSONP_PROVIDERS, PersonService]
})
export class PersonComponent {
constructor (private _personService: PersonService,
private _routeParams: RouteParams) {
console.info('person constructor');
this.params = _routeParams;
}
ngOnInit() {
console.info('person init');
this.getPersonInfo();
}
personInfo: PersonInfo;
params: RouteParams;
public warningMessage = "";
public errorMessage = "";
getPersonInfo () {
console.info("inside getProjectInfo of component");
this.warningMessage = '';
this.errorMessage=""
if(this.params.get("personId")==null || this.params.get("personId")==''){
this.warningMessage="No valid person id";
console.info("novalid");
} else {
console.info("do request");
this._personService.getPersonInfo(this.params.get('personId')).subscribe(
data => {
this.personInfo = data;
},
err => {
console.error(err)
console.info("error");
this.errorMessage = 'No person found';
}
);
}
}
}

View File

@ -0,0 +1,52 @@
import {Component, Input} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'showAuthors',
template: `
<span *ngIf="authors != undefined">
<div *ngIf="showAll">
<a class="text-muted" (click)="showAll = !showAll;">View less authors</a>
</div>
<span *ngFor="let item of authors.slice(0,30)">
<a class="custom-external" href="{{item['url']}}" target="_blank">
{{item['name']}};
</a>
</span>
<span *ngIf="!showAll && authors.length > 30"> ... </span>
<span *ngIf="showAll">
<span *ngFor="let item of authors.slice(30)">
<a class="custom-external" href="{{item['url']}}" target="_blank">
{{item['name']}};
</a>
</span>
</span>
<span *ngIf="!showAll && authors.length > 30">
<a class="text-muted" (click)="showAll = !showAll;">
view all {{authors.length}} authors
</a>
</span>
<span *ngIf="showAll">
<a class="text-muted" (click)="showAll = !showAll;">View less authors</a>
</span>
</span>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class ShowAuthorsComponent {
@Input() authors: { [key: string]: string }[];
private showAll: boolean = false;
constructor (private _router: Router) {
console.info('showAuthors constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,48 @@
import {Component, Input} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'showIdentifiers',
template: `
<div *ngIf="identifiers != undefined && identifiers.size > 0">
<dt>Identifiers:</dt>
<dd>
<ul class="list-inline">
<li *ngFor="let key of identifiers.keys()">
<div *ngFor="let item of identifiers.get(key)">
<div [ngSwitch]="key">
<template [ngSwitchWhen]="'doi'">
<a class="custom-external" href="http://dx.doi.org/{{item}}" target="_blank">
{{key}}: {{item}}
</a>
</template>
<template [ngSwitchWhen]="'pmc'">
<a class="custom-external" href="http://europepmc.org/articles/{{item}}" target="_blank">
{{key}}: {{item}}
</a>
</template>
</div>
</div>
</li>
</ul>
</dd>
</div>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class ShowIdentifiersComponent {
@Input() identifiers: Map<string, string[]>;//Map<string, string>;
constructor (private _router: Router) {
console.info('showIdentifiers constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,57 @@
import {Component, Input} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'showSubjects',
template: `
<div *ngIf="subjects != undefined">
<dt *ngIf="subjects.length > 0 || classifiedSubjects.size > 0">
Subjects:
</dt>
<dd>
<div *ngIf="subjects.length > 0"> {{subjects}} </div>
<div *ngIf="subjects.length == 0 && classifiedSubjects.size > 0"> - </div>
</dd>
<dd class="col-md-offset-1" *ngIf="classifiedSubjects.size > 0">
<a (click)="showClassifiedSbj = !showClassifiedSbj;">
<div *ngIf="!showClassifiedSbj">
Show additional classifications
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</div>
<div *ngIf="showClassifiedSbj">
Hide additional classifications
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</div>
</a>
<div class="well" *ngIf="showClassifiedSbj">
<div *ngFor="let key of classifiedSubjects.keys()">
Classified by OpenAIRE into
<div>
{{key}}: {{classifiedSubjects.get(key)}}
</div>
</div>
</div>
</dd>
</div>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class ShowSubjectsComponent {
@Input() subjects: string[];
@Input() classifiedSubjects: Map<string, string[]>;
private showClassifiedSbj: boolean = false;
constructor (private _router: Router) {
console.info('showSubjects constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,34 @@
import {Component, Input} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'showTitle',
template: `
<h2 *ngIf="title != undefined">
<div *ngIf="title['url'] != undefined">
<a class="custom-external" href="{{title['url']}}" target="_blank">
<div [innerHTML]="title['name']"></div>
</a>
</div>
<div *ngIf="title['url'] == undefined">
<div [innerHTML]="title['name']"></div>
</div>
</h2>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class ShowTitleComponent {
@Input() title: { [key: string]: string };
constructor (private _router: Router) {
console.info('title constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,33 @@
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'tabPaging',
template: `
<div class="panel panel-default" *ngIf="!showAll && length > 10">
<div class="panel-heading">
<a (click)="changeShowAll.emit({value: true});">
<div class="text-right">view all {{length}}</div>
</a>
</div>
</div>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class TabPagingComponent {
@Input() showAll: boolean;
@Input() length: number;
@Output() changeShowAll: EventEmitter<any> = new EventEmitter();
constructor (private _router: Router) {
console.info('publication:paging constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,58 @@
import {Component, Input} from '@angular/core';
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
@Component({
selector: 'tabTable',
template: `
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Trust</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of info" class="{{item['class']}}">
<td *ngIf="item != undefined">
<span *ngIf="item['class'] == 'dataset'" class="glyphicon glyphicon-star" aria-hidden="true">
</span>
<a *ngIf="item['url'] != '' && item['name'] != ''" class="custom-external" href="{{item['url']}}" target="_blank">
{{item['name']}}
</a>
<p *ngIf="item['url'] == '' && item['name'] != ''">{{item['name']}}</p>
<span *ngIf="item['date'] != ''">
({{item['date']}})
</span>
</td>
<td>
<div *ngIf="item['trust'] != ''" class="progress">
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="29" aria-valuemin="0" aria-valuemax="100" [style.width] = "item['trust']">
{{item['trust']}}
</div>
</div>
<div *ngIf="item['trust'] == ''">
<p>no trust found</p>
</div>
</td>
</tr>
</tbody>
</table>
`
,
directives: [
...ROUTER_DIRECTIVES
]
})
export class TabTableComponent {
@Input() info: { "name": string, "url": string, "date": string, "trust": string}[];//Map<string, string[]>;
constructor (private _router: Router) {
console.info('tabTable constructor');
}
ngOnInit() {
}
}

View File

@ -0,0 +1,616 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {DatasetInfo} from '../entities/datasetInfo';
@Injectable()
export class DatasetService {
constructor(private http: Http) {}
datasetInfo: DatasetInfo;
getDatasetInfo (id: string):any {
console.info("getDatasetInfo in service");
//let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
//let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
return this.http.get(url)
.map(res => <any> res.json())
.do(res => console.info(res['result']['metadata']['oaf:entity']))
.map(res => res['result']['metadata']['oaf:entity']['oaf:result'])
.map(res => [res,
res['title'],
res['rels']['rel'],
res['children'],
res['pid'],
res['subject'],
res['bestlicense'],
res['collectedfrom'],
res['context'],
res['resulttype']
])
.map(res => this.parseDatasetInfo(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.error(error);
return Observable.throw(error || 'Server error');
}
parseDatasetInfo (data: any):any {
this.datasetInfo = new DatasetInfo();
if(data[0] != null) {
this.datasetInfo.date = data[0].dateofacceptance.substring(0,4);
this.datasetInfo.publisher = data[0].publisher;
if(!Array.isArray(data[0].description)) {
this.datasetInfo.description = data[0].description;
} else {
this.datasetInfo.description = data[0].description[0];
}
this.datasetInfo.embargoEndDate = data[0].embargoenddate;
}
if(data[1] != null) {
this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
if(Array.isArray(data[1])) {
this.datasetInfo.title['name'] = data[1][0].content;
} else {
this.datasetInfo.title['name'] = data[1].content;
}
}
if(data[2] != null) {
let mydata;
let counter = 0;
let length = data[2].length!=undefined ? data[2].length : 1;
for(let i=0; i<length; i++) {
mydata = length > 1 ? data[2][i] : data[2];
if(mydata.hasOwnProperty("to")) {
if(mydata['to'].class == "hasAuthor") {
if(this.datasetInfo.authors == undefined) {
this.datasetInfo.authors = new Array<{"name": string, "url": string}>();
}
this.datasetInfo.authors[mydata.ranking-1] = {"name": "", "url": ""};
this.datasetInfo.authors[mydata.ranking-1]['name'] = mydata.fullname;
this.datasetInfo.authors[mydata.ranking-1]['url'] = "https://beta.openaire.eu/search/person?personId="+mydata['to'].content;
} else if(mydata['to'].class == "isProducedBy") {
if(this.datasetInfo.fundedByProjects == undefined) {
this.datasetInfo.fundedByProjects = new Array<
{ "url": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "new": boolean
}>();
}
counter = this.datasetInfo.fundedByProjects.length;
this.datasetInfo.fundedByProjects[counter] = {
"url": "", "acronym": "", "title": "",
"funderShortname": "", "funderName": "",
"funding": "", "new": false
}
this.datasetInfo.fundedByProjects[counter]['url'] =
"http://localhost:3000/project?projectId="+mydata['to'].content;
this.datasetInfo.fundedByProjects[counter]['acronym'] = mydata.acronym;
this.datasetInfo.fundedByProjects[counter]['title'] = mydata.title;
if(mydata.hasOwnProperty("funding")) {
let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1;
for(let j=0; j<length1; j++) {
let funding;
let mydata1 = length1 > 1 ? mydata['funding'][j] : mydata['funding'];
if(mydata1.hasOwnProperty("funder")) {
this.datasetInfo.fundedByProjects[counter]['funderShortname'] = mydata1['funder'].shortname;
this.datasetInfo.fundedByProjects[counter]['funderName'] = mydata1['funder'].name;
}
if(mydata1.hasOwnProperty("funding_level_2")) {
funding = mydata1['funding_level_2'].content;
} else if(mydata1.hasOwnProperty("funding_level_1")) {
funding = mydata1['funding_level_1'].content;
} else if(mydata1.hasOwnProperty("funding_level_0")) {
funding = mydata1['funding_level_0'].content;
}
if(funding != undefined) {
funding = funding.split("::");
if(this.datasetInfo.fundedByProjects[counter]['funding'] != "") {
this.datasetInfo.fundedByProjects[counter]['funding'] += ", "+funding[1];
} else {
this.datasetInfo.fundedByProjects[counter]['funding'] = funding[1];
}
for(let i=2; i<funding.length; i++) {
this.datasetInfo.fundedByProjects[counter]['funding'] += " | " + funding[i];
}
}
}
}
} else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") {
/*if(mydata.hasOwnProperty('resulttype') && mydata['resulttype'].classname == "publication") {
if(this.datasetInfo.similarPublications == undefined) {
this.datasetInfo.similarPublications = new Array<
{ "name": string, "url": string, "date": string, "trust": string}>();
}
let url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
let counter = this.datasetInfo.similarPublications.length;
this.datasetInfo.similarPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""};
this.datasetInfo.similarPublications[counter]['url'] = url;
this.datasetInfo.similarPublications[counter]['name'] = mydata['title'].content;
this.datasetInfo.similarPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4);
this.datasetInfo.similarPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%";
} else if(mydata.hasOwnProperty('resulttype') && mydata['resulttype'].classname == "dataset") {
if(this.datasetInfo.similarDatasets == undefined) {
this.datasetInfo.similarDatasets = new Array<
{ "name": string, "url": string, "date": string, "trust": string}>();
}
let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
let counter = this.datasetInfo.similarDatasets.length;
this.datasetInfo.similarDatasets[counter] = {"name": "", "url": "", "date": "", "trust": ""};
this.datasetInfo.similarDatasets[counter]['url'] = url;
this.datasetInfo.similarDatasets[counter]['name'] = mydata['title'].content;
this.datasetInfo.similarDatasets[counter]['date'] = mydata.dateofacceptance.substring(0,4);
this.datasetInfo.similarDatasets[counter]['trust'] = Math.round(mydata.trust*100)+"%";
}*/
if(this.datasetInfo.similarResearchResults == undefined) {
this.datasetInfo.similarResearchResults = new Array<{
"name": string, "url": string, "date": string,
"trust": string, "class": string}>();
}
counter = this.datasetInfo.similarResearchResults.length;
this.datasetInfo.similarResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
let url;
if(mydata['resulttype'].classname == "publication") {
url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
this.datasetInfo.similarResearchResults[counter]['class'] = "publication";
} else {
url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
this.datasetInfo.similarResearchResults[counter]['class'] = "dataset";
}
this.datasetInfo.similarResearchResults[counter]['url'] = url;
this.datasetInfo.similarResearchResults[counter]['name'] = mydata['title'].content;
this.datasetInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
this.datasetInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
} else if(mydata['to'].class == "isRelatedTo") {
/*if(mydata.hasOwnProperty('resulttype')) {
if(mydata['resulttype'].classname == "publication") {
if(this.datasetInfo.relatedPublications == undefined) {
this.datasetInfo.relatedPublications = new Array<{
"name": string, "url": string, "date": string, "trust": string}>();
}
let url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
counter = this.datasetInfo.relatedPublications.length;
this.datasetInfo.relatedPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""}
this.datasetInfo.relatedPublications[counter]['url'] = url;
this.datasetInfo.relatedPublications[counter]['name'] = mydata['title'].content;
this.datasetInfo.relatedPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
this.datasetInfo.relatedPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%";
} else {
if(this.datasetInfo.relatedResearchData == undefined) {
this.datasetInfo.relatedResearchData = new Array<{
"name": string, "url": string, "date": string, "trust": string}>();
}
let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
counter = this.datasetInfo.relatedResearchData.length;
this.datasetInfo.relatedResearchData[counter] = {"name": "", "url": "", "date": "", "trust": ""}
this.datasetInfo.relatedResearchData[counter]['url'] = url;
this.datasetInfo.relatedResearchData[counter]['name'] = mydata['title'].content;
this.datasetInfo.relatedResearchData[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
this.datasetInfo.relatedResearchData[counter]['trust'] = Math.round(mydata.trust*100)+"%";
}
}*/
if(this.datasetInfo.relatedResearchResults == undefined) {
this.datasetInfo.relatedResearchResults = new Array<{
"name": string, "url": string, "date": string,
"trust": string, "class": string}>();
}
counter = this.datasetInfo.relatedResearchResults.length;
this.datasetInfo.relatedResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
let url;
if(mydata['resulttype'].classname == "publication") {
url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
this.datasetInfo.relatedResearchResults[counter]['class'] = "publication";
} else {
url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
this.datasetInfo.relatedResearchResults[counter]['class'] = "dataset";
}
this.datasetInfo.relatedResearchResults[counter]['url'] = url;
this.datasetInfo.relatedResearchResults[counter]['name'] = mydata['title'].content;
this.datasetInfo.relatedResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
this.datasetInfo.relatedResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
}
}
}
this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) {
return (item != undefined);
});
}
if(data[3] != null) {
if(data[3].hasOwnProperty("instance")) {
this.datasetInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[]}>();
this.datasetInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[]}>()
let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1;
let counter = 0;
let counter1 = 0;
let counter2 = 0;
let mydata;
for(let i=0; i<length; i++) {
mydata = length > 1 ? data[3]['instance'][i] : data[3]['instance'];
if(mydata.hasOwnProperty("webresource")) {
let url;
if(mydata['webresource'].length == undefined) {
url = mydata['webresource'].url;
} else{
url = mydata['webresource'][0].url;
}
if(!this.datasetInfo.downloadFrom.has(url) && mydata.hasOwnProperty("hostedby")) {
if(mydata['hostedby'].name != "other resources" && mydata['hostedby'].name != "Unknown Repository") {
if(!this.datasetInfo.downloadFrom.has(mydata['hostedby'].name)) {
this.datasetInfo.downloadFrom.set(mydata['hostedby'].name, {"url": null, "accessMode": null});
}
if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] == null) {
this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] = new Array<string>();
}
counter2 = this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'].length;
this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'][counter2] = url;
if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] == null) {
this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] = new Array<string>();
}
if(mydata.hasOwnProperty("licence")) {
this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid;
} else {
this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = "";
}
} else {
if(data[0] != null && data[0].hasOwnProperty("source")) {
let key: string;
if(Array.isArray(data[0].source)) {
if(!this.datasetInfo.publishedIn.has(data[0]['source'][counter1])) {
key = data[0]['source'][counter1];
}
} else {
if(!this.datasetInfo.publishedIn.has(data[0]['source'])) {
key = data[0]['source'];
}
}
this.datasetInfo.publishedIn.set(key, {"url": null, "accessMode": null});
if(this.datasetInfo.publishedIn.get(key)['url'] == null) {
this.datasetInfo.publishedIn.get(key)['url'] = new Array<string>();
}
counter2 = this.datasetInfo.publishedIn.get(key)['url'].length;
this.datasetInfo.publishedIn.get(key)['url'][counter2] = url;
if(this.datasetInfo.publishedIn.get(key)['accessMode'] == null) {
this.datasetInfo.publishedIn.get(key)['accessMode'] = new Array<string>();
}
if(mydata.hasOwnProperty("licence")) {
this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid;
} else {
this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = "";
}
counter1++;
}
}
if(this.datasetInfo.title != undefined) {
if(this.datasetInfo.title['url'] == undefined) {
this.datasetInfo.title['url'] = url;
}
switch (this.datasetInfo.title['licence']) {
case undefined:
this.datasetInfo.title['licence'] = mydata['licence'].classid;
this.datasetInfo.title['url'] = url;
break;
case "CLOSED":
if(mydata['licence'].classid == "OPEN" ||
mydata['licence'].classid == "EMBARGO" ||
mydata['licence'].classid == "RESTRICTED") {
this.datasetInfo.title['licence'] = mydata['licence'].classid;
this.datasetInfo.title['url'] = url;
}
break;
case "RESTRICTED":
if(mydata['licence'].classid == "OPEN" ||
mydata['licence'].classid == "EMBARGO") {
this.datasetInfo.title['licence'] = mydata['licence'].classid;
this.datasetInfo.title['url'] = url;
}
break;
case "EMBARGO":
if(mydata['licence'].classid == "OPEN") {
this.datasetInfo.title['licence'] = mydata['licence'].classid;
this.datasetInfo.title['url'] = url;
}
break;
}
}
}
}
}
}
}
if(data[4] != null) {
let counter = 0;
this.datasetInfo.identifiers = new Map<string, string[]>();
if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") {
if(data[4].classname == "doi" || data[4].classname == "pmc") {
if(!this.datasetInfo.identifiers.has(data[4].classname)) {
this.datasetInfo.identifiers.set(data[4].classname, new Array<string>());
}
counter = this.datasetInfo.identifiers.get(data[4].classname).length;
this.datasetInfo.identifiers.get(data[4].classname)[counter] = data[4].content;
}
} else {
for(let i=0; i<data[4].length; i++) {
if(data[4][i].classname == "doi" || data[4][i].classname == "pmc") {
if(!this.datasetInfo.identifiers.has(data[4][i].classname)) {
this.datasetInfo.identifiers.set(data[4][i].classname, new Array<string>());
}
counter = this.datasetInfo.identifiers.get(data[4][i].classname).length;
this.datasetInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content;
}
}
}
}
if(data[5] != null) {
this.datasetInfo.classifiedSubjects = new Map<string, string[]>();
this.datasetInfo.subjects = new Array<string>();
let mydata;
let length = data[5].length!=undefined ? data[5].length : 1;
for(let i=0; i<length; i++) {
mydata = length > 1 ? data[5][i] : data[5];
if(mydata.classid != "") {
if(mydata.inferred == true) {
if(!this.datasetInfo.classifiedSubjects.has(mydata.classid)) {
this.datasetInfo.classifiedSubjects.set(mydata.classid, new Array<string>());
}
let counter = this.datasetInfo.classifiedSubjects.get(mydata.classid).length;
this.datasetInfo.classifiedSubjects.get(mydata.classid)[counter] = mydata.content;
} else {
let counter = this.datasetInfo.subjects.length;
this.datasetInfo.subjects[counter] = mydata.content;
}
}
}
}
if(data[6] != null) {
this.datasetInfo.bestlicense = data[6].classid;
}
if(data[7] != null) {
this.datasetInfo.collectedFrom = new Array<{"name": string, "url": string}>();
let mydata;
let length = data[7].length!=undefined ? data[7].length : 1;
for(let i=0; i<length; i++) {
mydata = length > 1 ? data[7][i] : data[7];
let link = "https://beta.openaire.eu/search/dataprovider?datasourceId=";
this.datasetInfo.collectedFrom[i] = {"name": "", "url": ""};
this.datasetInfo.collectedFrom[i]['name'] = mydata.name;
this.datasetInfo.collectedFrom[i]['url'] = link+mydata.id;
}
}
if(this.datasetInfo.publisher != null
&& this.datasetInfo.identifiers != null
&& this.datasetInfo.identifiers.has("doi")) {
if( this.datasetInfo.downloadFrom == null) {
this.datasetInfo.downloadFrom = new Map<string,{"url": string[], "accessMode": string[]}>();
}
this.datasetInfo.downloadFrom.set(this.datasetInfo.publisher, {"url": null, "accessMode": null});
let url = "http://dx.doi.org/"+this.datasetInfo.identifiers.get("doi");
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'] = new Array<string>();
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'] = new Array<string>();
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'][0] = url;
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'][0] = "";
if(this.datasetInfo.title != undefined && this.datasetInfo.title['url'] == "") {
this.datasetInfo.title['url'] = url;
}
}
if(data[8] != null) {
this.datasetInfo.contexts = new Array<
{ "labelContext": string, "labelCategory": string, "labelConcept": string}>();
let position = 0;
let labels = "";
let mydata;
let length = data[8].length!=undefined ? data[8].length : 1;
for(let i=0; i<length; i++) {
mydata = length > 1 ? data[8][i] : data[8];
if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
if(mydata.hasOwnProperty("category")) {
if(mydata['category'].hasOwnProperty("concept")) {
let mydata1;
let length1 = mydata['category']['concept'].length!=undefined ? mydata['category']['concept'].length : 1;
for(let j=0; j<length1; j++) {
mydata1 = length1 > 1 ? mydata['category']['concept'][j] : mydata['category']['concept'];
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
this.datasetInfo.contexts[position]['labelConcept'] = mydata1.label;
position++;
}
} else {
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
this.datasetInfo.contexts[position]['labelConcept'] = null;
}
} else {
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
this.datasetInfo.contexts[position]['labelCategory'] = null;
this.datasetInfo.contexts[position]['labelConcept'] = null;
}
}
}
}
if(data[9] != null) {
if(data[9].hasOwnProperty('classname')) {
this.datasetInfo.type = data[9].classname;
}
}
//this.printdatasetInfo();
return this.datasetInfo;
}
printDatasetInfo() {
console.info("DATE: "+this.datasetInfo.date);
console.info("PUBLISHER: "+this.datasetInfo.publisher);
console.info("DESCRIPTION: "+this.datasetInfo.description);
console.info("TITLE: "+this.datasetInfo.title);
console.info("AUTHORS: "+this.datasetInfo.authors);
console.info("\nFUNDED BY PROJECTS:");
if(this.datasetInfo.fundedByProjects != undefined) {
this.datasetInfo.fundedByProjects.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
/*
console.info("\nRELATED RESEARCH DATA:");
if(this.datasetInfo.relatedResearchData != undefined) {
this.datasetInfo.relatedResearchData.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
console.info("\nSIMILAR datasetS:");
if(this.datasetInfo.similarPublications != undefined) {
this.datasetInfo.similarPublications.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
*/
console.info("TYPE: "+this.datasetInfo.type);
console.info("\nDOWNLOAD FROM:");
if(this.datasetInfo.downloadFrom != undefined) {
this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
console.info("\nIDENTIFIERS:");
if(this.datasetInfo.identifiers != undefined) {
this.datasetInfo.identifiers.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
console.info("SUBJECTS: "+this.datasetInfo.subjects);
console.info("\nCLASSIFIED OBJECTS:");
if(this.datasetInfo.classifiedSubjects != undefined) {
this.datasetInfo.classifiedSubjects.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
console.info("BEST LICENSE: "+this.datasetInfo.bestlicense);
console.info("\nCOLLECTED FROM:");
if(this.datasetInfo.collectedFrom != undefined) {
this.datasetInfo.collectedFrom.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
console.info("\nDOWNLOAD FROM:");
if(this.datasetInfo.downloadFrom != undefined) {
this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
console.info(key + " = " + value);
});
} else {
console.info("undefined");
}
console.info("\n");
}
}

View File

@ -0,0 +1,54 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {PersonInfo} from '../entities/personInfo';
@Injectable()
export class PersonService {
constructor(private http: Http) {}
personInfo: PersonInfo;
getPersonInfo (id: string):any {
console.info("getPersonInfo in service");
//let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id;
//let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id;
let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/people/'+id;
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:person'])
.map(res => this.parsePersonInfo(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.error(error);
return Observable.throw(error || 'Server error');
}
parsePersonInfo (data: any):any {
console.info("parsePersonInfo");
this.personInfo = new PersonInfo();
if(data != null) {
if(data.hasOwnProperty('firstname')) {
this.personInfo.firstname = data.firstname;
}
if(data.hasOwnProperty('secondnames')) {
this.personInfo.secondnames = data.secondnames;
}
if(data.hasOwnProperty('fullname')) {
this.personInfo.fullname = data.fullname;
}
}
return this.personInfo;
}
}