Linking: in bulk mode search also in datacite, change the info layout

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47473 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-06-12 12:48:05 +00:00
parent df7c2e965d
commit fbf296640d
9 changed files with 143 additions and 99 deletions

View File

@ -249,7 +249,6 @@ getCommunities () {
console.log("displaySubcategory: "+id+" value:"+ this.conceptsClassDisplay[id]); console.log("displaySubcategory: "+id+" value:"+ this.conceptsClassDisplay[id]);
} }
browseConcepts (categoryId) { browseConcepts (categoryId) {
this.conceptsCategoryLoading[categoryId] = true;
if(!Session.isValidAndRemove()){ if(!Session.isValidAndRemove()){
this.saveStateAndRedirectLogin(); this.saveStateAndRedirectLogin();
}else{ }else{
@ -261,6 +260,7 @@ getCommunities () {
} }
this.conceptsClass[categoryId] = []; this.conceptsClass[categoryId] = [];
var token=Session.getUserJwt(); var token=Session.getUserJwt();
this.conceptsCategoryLoading[categoryId] = true;
this._contextService.getConcepts(categoryId, "",token,false).subscribe( this._contextService.getConcepts(categoryId, "",token,false).subscribe(
data => { data => {
for(var i=0;i<data.length; i++){ for(var i=0;i<data.length; i++){

View File

@ -13,6 +13,69 @@ export class ClaimResult{
public publisher: string; public publisher: string;
public description: string; public description: string;
public resourceType:string; public resourceType:string;
public static generateResult(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){
var result: ClaimResult = new ClaimResult();
result.id = itemId;
result.type = itemType;
result.source = itemSource;
result.title = (Array.isArray(itemTitle) && itemTitle.length > 0 )?itemTitle[0]:itemTitle;
result.url = itemUrl;
result.accessRights = 'OPEN';
result.date = date;
result.result = item;
if(item.publisher){
result.publisher = item.publisher;
}
if(itemSource == 'datacite'){
result.publisher = item.attributes['container-title'];
if(item.attributes.author){
result.authors =[]
for(var i=0; i< item.attributes.author.length; i++){
result.authors.push((item.attributes.author[i].family)?item.attributes.author[i].family+', '+item.attributes.author[i].given:item.attributes.author[i].literal);
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
}else if (itemSource == 'openaire'){
//TODO put right access rights
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date};
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date};
result.embargoEndDate = accessmode;
}else if(itemSource == 'crossref'){
date = (date == null) ? null : date.substring(0,10);
result.date = date;
result.resourceType = item.type;
result.description = item.abstract;
if(item.author){
result.authors =[]
for(var i=0; i< item.author.length; i++){
result.authors.push(item.author[i].family +" "+ item.author[i].given );
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
}else if (itemSource == 'orcid'){
date = (date == null) ? null : date + "-01.-01"
result.date = date;
if(item['work-type']){
result.resourceType = item.type;
}
if(item.contributors){
result.authors =[]
for(var i=0; i< item.contributors.length; i++){
result.authors.push(item.contributors[i]);
}
}
}
return result;
}
} }
export class ClaimProject{ export class ClaimProject{
public funderId: string; public funderId: string;

View File

@ -507,67 +507,15 @@ openaireDataPageChange($event) {
} }
add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){ add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){
console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle); console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle);
var result: ClaimResult = new ClaimResult(); var result: ClaimResult = ClaimResult.generateResult(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode);
result.id = itemId;
result.type = itemType;
result.source = itemSource;
result.title = (Array.isArray(itemTitle) && itemTitle.length > 0 )?itemTitle[0]:itemTitle;
result.url = itemUrl;
result.accessRights = 'OPEN';
result.embargoEndDate = this.nextDate;
result.date = date;
result.result = item;
if(item.publisher){
result.publisher = item.publisher;
}
if(itemSource == 'datacite'){ if (itemSource == 'orcid'){
if(result.authors.length ==0 ){
result.publisher = item.attributes['container-title'];
if(item.attributes.author){
result.authors =[]
for(var i=0; i< item.attributes.author.length; i++){
result.authors.push((item.attributes.author[i].family)?item.attributes.author[i].family+', '+item.attributes.author[i].given:item.attributes.author[i].literal);
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
}else if (itemSource == 'openaire'){
//TODO put right access rights
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date};
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date};
result.embargoEndDate = accessmode;
}else if(itemSource == 'crossref'){
date = (date == null) ? null : date.substring(0,10);
result.date = date;
result.resourceType = item.type;
result.description = item.abstract;
if(item.author){
result.authors =[]
for(var i=0; i< item.author.length; i++){
result.authors.push(item.author[i].family +" "+ item.author[i].given );
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
}else if (itemSource == 'orcid'){
date = (date == null) ? null : date + "-01.-01"
result.date = date;
if(item['work-type']){
result.resourceType = item.type;
}
if(item.contributors){
result.authors =[]
for(var i=0; i< item.contributors.length; i++){
result.authors.push(item.contributors[i]);
}
}else{
result.authors.push(this.authorGivenName + ', '+ this.authorFamilyName); result.authors.push(this.authorGivenName + ', '+ this.authorFamilyName);
} }
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
} }
var found:boolean = this.isSelected( result.id); var found:boolean = this.isSelected( result.id);

View File

@ -4,7 +4,8 @@ import { SharedModule } from '../../shared/shared.module';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import {ClaimResultSearchFormComponent} from './claimResultSearchForm.component'; import {ClaimResultSearchFormComponent} from './claimResultSearchForm.component';
import {SearchDataciteService} from './service/searchDatacite.service'; import {SearchDataciteServiceModule} from './service/searchDataciteService.module';
import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module'; import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module';
import {SearchOrcidService} from './service/searchOrcid.service'; import {SearchOrcidService} from './service/searchOrcid.service';
@ -14,10 +15,10 @@ import {PagingModule } from '../../utils/paging.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, CommonModule, PublicationsServiceModule, DatasetsServiceModule, PagingModule, SearchCrossrefServiceModule SharedModule, CommonModule, PublicationsServiceModule, DatasetsServiceModule, PagingModule, SearchCrossrefServiceModule, SearchDataciteServiceModule
], ],
providers:[ providers:[
SearchDataciteService, SearchOrcidService SearchOrcidService
], ],
declarations: [ declarations: [
ClaimResultSearchFormComponent ClaimResultSearchFormComponent

View File

@ -26,6 +26,22 @@ export class SearchDataciteService {
}); });
//.catch(this.handleError); //.catch(this.handleError);
} }
getDataciteResultByDOI (doi: string):any {
console.info("Fetch datacite resultt by DOI: "+doi);
let url = OpenaireProperties.getSearchDataciteAPIURL()+'/'+doi;
let key = url;
if (this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get( url)
.map(request => <any> request.json())
.do(items => console.info(items))
// .do(items => console.log("Datacite Results: total results = "+items.meta.total+" doi = "+doi))
.do(res => {
this._cache.set(key, res);
});
//.catch(this.handleError);
}
private handleError (error: Response) { private handleError (error: Response) {

View File

@ -1,9 +1,12 @@
import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core'; import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service'; import {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service';
import {SearchDataciteService} from '../../claim-utils/service/searchDatacite.service';
import {ModalLoading} from '../../../utils/modal/loading.component'; import {ModalLoading} from '../../../utils/modal/loading.component';
import {Dates, DOI} from '../../../utils/string-utils.class'; import {Dates, DOI} from '../../../utils/string-utils.class';
import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; import {OpenaireProperties} from '../../../utils/properties/openaireProperties';
import {ClaimResult} from '../../claim-utils/claimEntities.class';
@Component({ @Component({
@ -11,15 +14,41 @@ import {OpenaireProperties} from '../../../utils/properties/openaireProperties';
template: ` template: `
<div class="uk-animation uk-margin-top" style="min-height:350px;"> <div class="uk-animation uk-margin-top" style="min-height:350px;">
<form class=" uk-padding uk-panel uk-background-muted "> <form class=" uk-padding uk-panel uk-background-muted ">
<div class="uk-clearfix">
<a class="uk-float-right" uk-toggle="target: #uploadInfo; animation: uk-animation-fade"><span uk-icon="icon: info"></span> More information about bulk upload? </a>
</div>
<div id="uploadInfo" class="uk-card uk-card-default uk-card-body uk-margin-small" hidden>
<a uk-toggle="target: #uploadInfo; animation: uk-animation-fade" class="uk-float-right"><span uk-icon="icon: close"></span></a>
<div class="uk-text-bold"><span uk-icon="icon: info"></span> Upload information:</div>
Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef or Datacite.
Available results will be linked with the selected Projects and Contexts.
<div class="uk-article-meta">
CSV format:
<ul class="uk-list">
<li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li>
<li>The value "DOI" is required </li>
<li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li>
<li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li>
<li>In case access mode is not available default value is "OPEN".</li>
</ul>
</div>
</div>
<div for="exampleInputFile">Upload a DOI csv file:</div> <div for="exampleInputFile">Upload a DOI csv file:</div>
<label for="exampleInputFile">Select a file</label> <label for="exampleInputFile">Select a file</label>
<input id="exampleInputFile" type="file" (change)="fileChangeEvent($event)" placeholder="Upload file..." /> <input id="exampleInputFile" type="file" (change)="fileChangeEvent($event)" placeholder="Upload file..." />
<button class="uk-button uk-button-success" [class.disabled]="!enableUpload" type="button" (click)="upload()">Upload</button> <button class="uk-button uk-button-success" [class.disabled]="!enableUpload" type="button" (click)="upload()">Upload</button>
<button class="uk-button uk-button-primary" uk-toggle="target: #uploadInfo; animation: uk-animation-fade"><span uk-icon="icon: info"></span> </button>
<div *ngIf="showReport" class="uk-alert uk-alert-primary" role="alert" > <div *ngIf="showReport" class="uk-alert uk-alert-primary" role="alert" >
<div>Uploaded file contains {{allIds.length}} rows. {{foundIds.length}} results were sucefully fetched from CrossRef.</div> <a class="uk-alert-close" uk-close></a>
<div>Uploaded file contains {{allIds.length}} rows. {{foundIds.length}} results were sucefully fetched from CrossRef and Datacite.</div>
<div *ngIf ="duplicateIds.length > 0" >{{duplicateIds.length}} duplicate DOIs.</div> <div *ngIf ="duplicateIds.length > 0" >{{duplicateIds.length}} duplicate DOIs.</div>
<div *ngIf = "notFoundIds.length > 0" >Couldn't be fetched from crossref: <div *ngIf = "notFoundIds.length > 0" >Couldn't be found:
<ul class=""> <ul class="">
<li *ngFor="let id of notFoundIds">"{{id}}"</li> <li *ngFor="let id of notFoundIds">"{{id}}"</li>
</ul> </ul>
@ -37,23 +66,6 @@ import {OpenaireProperties} from '../../../utils/properties/openaireProperties';
</form> </form>
<div id="uploadInfo" class="uk-card uk-card-default uk-card-body uk-margin-small" hidden>
<a uk-toggle="target: #uploadInfo; animation: uk-animation-fade" class="uk-float-right"><span uk-icon="icon: close"></span></a>
<div class="uk-text-bold"><span uk-icon="icon: info"></span> Upload information:</div>
Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef.
Available results will be linked with the selected Projects and Contexts.
<div class="uk-article-meta">
CSV format:
<ul class="uk-list">
<li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li>
<li>The value "DOI" is required </li>
<li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li>
<li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li>
<li>In case access mode is not available default value is "OPEN".</li>
</ul>
</div>
</div>
</div> </div>
` `
@ -80,10 +92,8 @@ export class BulkClaimComponent {
errorMessage = ""; errorMessage = "";
infoMEssage = ""; infoMEssage = "";
enableUpload:boolean = true; enableUpload:boolean = true;
constructor(private _searchCrossrefService: SearchCrossrefService) { constructor(private _searchCrossrefService: SearchCrossrefService, private _searchDataciteService: SearchDataciteService) {
this.filesToUpload = []; this.filesToUpload = [];
} }
ngOnInit() {} ngOnInit() {}
@ -189,15 +199,14 @@ export class BulkClaimComponent {
var crossrefResult = data.items[0]; var crossrefResult = data.items[0];
if(data.items.length > 0){ if(data.items.length > 0){
this.foundIds.push(id); this.foundIds.push(id);
var result = {id: id, type :'publication', source : 'crossref', var result: ClaimResult = ClaimResult.generateResult(crossrefResult, id,"crossref","publication", crossrefResult.URL, crossrefResult.title, crossrefResult.created['date-time'], accessMode);
title: crossrefResult.title,url: crossrefResult.URL, result: crossrefResult, accessRights: accessMode, embargoEndDate: date, date : crossrefResult.created['date-time']}; result.embargoEndDate = date;
this.results.push(result); this.results.push(result);
}else{
this.notFoundIds.push(id);
}
this.endOfFetching(); this.endOfFetching();
}else{
this.searchInDatacite(id,accessMode,date);
// this.notFoundIds.push(id);
}
}, },
err => { err => {
console.log(err); console.log(err);
@ -207,17 +216,16 @@ export class BulkClaimComponent {
); );
} }
searchInDatacite(id:string,accessMode:string,date:string){ searchInDatacite(id:string,accessMode:string,date:string){
this._searchCrossrefService.searchCrossrefByDOIs([id]).subscribe( this._searchDataciteService.getDataciteResultByDOI(id).subscribe(
data => { item => {
var dataciteResult = item.data;
if(dataciteResult != null && dataciteResult.attributes!= null ){
var crossrefResult = data.items[0];
if(data.items.length > 0){
this.foundIds.push(id); this.foundIds.push(id);
var result = {id: id, type :'dataset', source : 'datacite', var result: ClaimResult = ClaimResult.generateResult(dataciteResult, id,"datacite","dataset", 'http://dx.doi.org/'+dataciteResult.attributes.doi, dataciteResult.attributes.title, dataciteResult.attributes.published, accessMode);
title: crossrefResult.title,url: crossrefResult.URL, result: crossrefResult, accessRights: accessMode, embargoEndDate: date, date : crossrefResult.created['date-time']}; result.embargoEndDate = date;
this.results.push(result); this.results.push(result);
}else{ }else{
this.notFoundIds.push(id); this.notFoundIds.push(id);
} }

View File

@ -4,6 +4,8 @@ import { SharedModule } from '../../../shared/shared.module';
import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; import {LoadingModalModule} from '../../../utils/modal/loadingModal.module';
import {BulkClaimComponent} from './bulkClaim.component'; import {BulkClaimComponent} from './bulkClaim.component';
import {SearchCrossrefServiceModule} from '../../claim-utils/service/searchCrossrefService.module'; import {SearchCrossrefServiceModule} from '../../claim-utils/service/searchCrossrefService.module';
import {SearchDataciteServiceModule} from '../../claim-utils/service/searchDataciteService.module';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, LoadingModalModule, SearchCrossrefServiceModule SharedModule, LoadingModalModule, SearchCrossrefServiceModule

View File

@ -14,7 +14,12 @@ import { Meta} from '../../../angular2-meta';
<div class="page-header"> <div class="page-header">
<h1>Linking</h1> <h1>Linking</h1>
</div> </div>
<!--ul class="uk-breadcrumb">
<li><a > Select Projects</a></li>
<li><a > Select Communities</a></li>
<li><a > Select Research Results</a></li>
<li class="uk-active"><a > Complete metadata</a></li>
</ul-->
<!--ul class="uk-pagination uk-margin-remove-bottom"> <!--ul class="uk-pagination uk-margin-remove-bottom">
<li *ngIf="show != 'result' " (click)="prev()"><a><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li> <li *ngIf="show != 'result' " (click)="prev()"><a><span class="uk-margin-small-right" uk-pagination-previous></span> Previous</a></li>
<li *ngIf="show != 'claim' " (click)="next()" class="uk-margin-auto-left"><a>Next <span class="uk-margin-small-left" uk-pagination-next></span></a></li> <li *ngIf="show != 'claim' " (click)="next()" class="uk-margin-auto-left"><a>Next <span class="uk-margin-small-left" uk-pagination-next></span></a></li>
@ -34,7 +39,7 @@ import { Meta} from '../../../angular2-meta';
<a>Projects ({{projects.length}})</a> <a>Projects ({{projects.length}})</a>
</li> </li>
<li> <li>
<a>Contexts ({{contexts.length}})</a> <a>Communities ({{contexts.length}})</a>
</li> </li>
</ul> </ul>
<ul id="tabs" class="uk-switcher uk-margin-left uk-width-1-1"> <ul id="tabs" class="uk-switcher uk-margin-left uk-width-1-1">

View File

@ -56,6 +56,7 @@ import {Dates} from '../../../utils/string-utils.class';
<!-- Datacite --> <!-- Datacite -->
<!--span *ngIf="pub.result.attributes['container-title']" class="uk-article-meta">Publisher: {{pub.result.attributes['container-title']}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span> <!--span *ngIf="pub.result.attributes['container-title']" class="uk-article-meta">Publisher: {{pub.result.attributes['container-title']}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
<div *ngIf="pub.result.attributes.author && pub.result.attributes.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.attributes.author.slice(0,10) let i = index">{{(author.family)?author.family+', '+author.given:author.literal}}{{(i < (pub.result.attributes.author.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.attributes.author.slice(0,10).length-1 && pub.result.attributes.author.length > 10)?"...":""}}</span></div--> <div *ngIf="pub.result.attributes.author && pub.result.attributes.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.attributes.author.slice(0,10) let i = index">{{(author.family)?author.family+', '+author.given:author.literal}}{{(i < (pub.result.attributes.author.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.attributes.author.slice(0,10).length-1 && pub.result.attributes.author.length > 10)?"...":""}}</span></div-->
<div class="uk-badge">{{pub.source}}</div>
</div> </div>
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-1-3 uk-grid"> <div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-1-3 uk-grid">
<div class="uk-width-1-3 uk-padding-remove-left"> <div class="uk-width-1-3 uk-padding-remove-left">