In claiming: add pub/data search in Openaire, In claimsAdmin: make a new request when page size changes

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44087 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-10-14 13:41:31 +00:00
parent a6db6539f8
commit 926e88f516
20 changed files with 366 additions and 218 deletions

View File

@ -1,15 +1,17 @@
import { Component, Input, Output, EventEmitter} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { SearchDataciteService } from '../../services/searchDatacite.service';
import {SearchDatasetsService} from '../../services/searchDatasets.service';
import {ClaimResult} from '../../utils/entities/claimEntities.class';
import { ErrorCodes} from '../../utils/properties/openaireProperties';
@Component({
selector: 'claim-dataset',
template: `
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div>
<!--div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div-->
<div class="panel ">
<div class="">
@ -23,7 +25,7 @@ import {ClaimResult} from '../../utils/entities/claimEntities.class';
<div class = "panel-body">
<div *ngIf="dataciteResultsNum != null && dataciteResultsNum > 0">
<p > {{dataciteResultsNum }} Total Results </p>
<paging-no-load [currentPage]="page" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
<paging-no-load [currentPage]="datacitePage" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="datacitePageChange($event)"> </paging-no-load>
</div>
<div *ngIf="dataciteResultsNum == null || dataciteResultsNum == 0" class="alert alert-info" role="alert">No results found</div>
<div >
@ -38,7 +40,7 @@ import {ClaimResult} from '../../utils/entities/claimEntities.class';
<a *ngIf="item.doi" target="_blank" href="{{'http://dx.doi.org/'+item.doi}}" >{{item.title}}</a>
<span *ngIf="!item.doi" >{{item.title}}</span>
</span>
<span *ngIf="!isSelected(item.doi)" (click)="add(item, item.doi,'dataset','datacite',item.title,'http://dx.doi.org/'+item.doi, null)" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
<span *ngIf="!isSelected(item.doi)" (click)="add(item, item.doi,'dataset','datacite',item.title,'http://dx.doi.org/'+item.doi, null,'OPEN')" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
</li>
</ul>
@ -47,10 +49,23 @@ import {ClaimResult} from '../../utils/entities/claimEntities.class';
</div>
<div id="openaire" class="tab-pane fade">
<div class = "panel-body">
<div class = "alert alert-info " > Under Development....
</div>
<div *ngIf="openaireResultsNum == null || openaireResultsNum == 0" class="alert alert-info" role="alert">No results found</div>
</div>
<div *ngIf="openaireResultsNum != null && openaireResultsNum > 0">
<paging-no-load [currentPage]="openairePage" [totalResults]="openaireResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePageChange($event)"> </paging-no-load>
</div>
<div >
<ul *ngIf="openaireResults.length > 0 " class="list-group">
<li *ngFor=" let result of openaireResults " [class]="(isSelected(result.id))?'list-group-item panel-footer':'list-group-item'">
<span >
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
</span>
<span *ngIf="!isSelected(result.id)"
(click)="add(result, result.id, 'dataset', 'openaire', result['title'].name, result['title'].url, result.year, result['title'].accessMode)" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
</li>
</ul>
<div *ngIf="openaireResults.length == 0" class = "alert alert-info " > No results found </div>
</div>
</div>
</div>
</div>
</div>
@ -58,7 +73,7 @@ import {ClaimResult} from '../../utils/entities/claimEntities.class';
`
})
export class ClaimDatasetComponent {
constructor (private _searchDataciteService: SearchDataciteService) {
constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService){
var myDate = new Date();
this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
@ -66,24 +81,29 @@ export class ClaimDatasetComponent {
}
ngOnInit() {
if(this.keyword !=null && this.keyword.length > 0){
this.searchDatacite(this.keyword,this.size,this.page);
this.search(this.keyword,this.size,1);
}
}
private page : number = 1;
@Input() public select:boolean = true ;
@Input() public keyword:string = '';
@Input() public selectedDatasets = [] ;
@Output() datasetsChange = new EventEmitter();
private size:number = 10;
private navigateTo: string = "Search";
private source: string = "datacite";
private type : string = "dataset";
@Input() public select:boolean = true ;
@Input() public keyword:string = '';
@Input() public selectedDatasets = [] ;
@Output() datasetsChange = new EventEmitter();
private errorCodes:ErrorCodes = new ErrorCodes();
dataciteResults=[];
dataciteResultsNum : Observable<number> = null;
dataciteStatus = this.errorCodes.NONE;
datacitePage : number = 1;
openaireResults=[];
openaireResultsNum : Observable<number> = null ;
openaireResultsNum:number = 0 ;
openaireStatus = this.errorCodes.NONE;
openairePage : number = 1;
public warningMessage = "";
public infoMessage = "";
@ -92,6 +112,7 @@ export class ClaimDatasetComponent {
private nextDate = '';
public search(term: string, size : number, page : number){
this.searchDatacite(term,10,1);
this.searchOpenaire(term,10,1);
//TODO add openaire search
}
private searchDatacite (term: string, size : number, page : number) {
@ -100,24 +121,55 @@ export class ClaimDatasetComponent {
this.infoMessage = "";
}
private searchOpenaire (term: string, size : number, page : number) {
this._searchDatasetsService.searchDatasets(term, page, size, "claim").subscribe(
data => {
if(data != null) {
this.openairePage=page;
this.openaireResultsNum = data[0];
this.openaireResults = data[1];
this.openaireStatus = this.errorCodes.DONE;
if(this.openaireResultsNum == 0){
this.openaireStatus = this.errorCodes.NONE;
}
}
},
err => {
console.error(err.status);
this.openaireStatus = this.errorCodes.ERROR;
}
);
getDataciteResults (term: string, size : number, page : number) {
this.warningMessage = "";
this.infoMessage = "";
}
private getDataciteResults (term: string, size : number, page : number) {
this._searchDataciteService.searchDataciteResults(term, size, page).subscribe(
data => {
this.dataciteResults = data.docs;
this.page=page;
this.datacitePage=page;
this.dataciteResultsNum = data.numFound;
this.dataciteStatus = this.errorCodes.DONE;
},
err => console.error(err)
err => {
console.error(err);
this.dataciteStatus = this.errorCodes.ERROR;
}
);
}
add(item, itemId,itemType,itemSource,itemTitle, itemUrl, date){
add(item, itemId,itemType,itemSource,itemTitle, itemUrl, date, accessmode){
console.log(' adding dataset '+ itemSource+" "+ itemTitle);
var result: ClaimResult ;
if(itemSource == 'datacite'){
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};
}
var found:boolean = this.isSelected( result.id);
this.warningMessage = "";
@ -133,10 +185,18 @@ export class ClaimDatasetComponent {
}
pageChange($event) {
this.page=$event.value;
datacitePageChange($event) {
this.datacitePage=$event.value;
this.dataciteResults=[];
this.searchDatacite(this.keyword,10,this.page);
this.searchDatacite(this.keyword,10,this.datacitePage);
this.warningMessage = "";
this.infoMessage = "";
}
openairePageChange($event) {
this.openairePage=$event.value;
this.openaireResults=[];
this.searchOpenaire(this.keyword,10,this.openairePage);
this.warningMessage = "";
this.infoMessage = "";

View File

@ -6,10 +6,14 @@
<li><a data-toggle="tab" href="#orcid">Orcid ({{ (orcidResultsNum)?orcidResultsNum:0}})</a></li>
</ul>
<div class="tab-content">
<div id="crossref" class="tab-pane fade in active">
<div id="crossref" class="active tab-pane fade in">
<div class="panel-body" >
<div *ngIf="crossrefStatus == errorCodes.LOADING" class="alert alert-info" role="alert">Loading...</div>
<div *ngIf="crossrefStatus != errorCodes.LOADING && crossrefResults.length == 0" class="alert alert-info" role="alert">No Results found</div>
<div *ngIf="crossrefStatus == errorCodes.ERROR" class="alert alert-warning" role="alert">An Error Occured</div>
<div *ngIf="crossrefStatus == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
<div *ngIf="crossrefResultsNum != null && crossrefResultsNum > 0">
<paging-no-load [currentPage]="page" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
<paging-no-load [currentPage]="crossrefPage" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="crossrefPageChange($event)"> </paging-no-load>
</div>
<div >
<ul *ngIf="crossrefResults.length > 0 " class="list-group">
@ -18,22 +22,39 @@
<a *ngIf="item.URL" target="_blank" href="{{item.URL}}" >{{item.title}}</a>
<span *ngIf="!item.URL" >{{item.title}}</span>
</span>
<span *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'])" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
<span *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'],'OPEN')" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
</li>
</ul>
<div *ngIf="crossrefResults.length == 0" class = "alert alert-info " > No results found </div>
</div>
</div>
</div>
</div>
<div id="openaire" class="tab-pane fade">
<div class = "panel-body">
<div class = "alert alert-info " > Under Development....
<div *ngIf="openaireStatus == errorCodes.LOADING" class="alert alert-info" role="alert">Loading...</div>
<div *ngIf="openaireStatus == errorCodes.NONE" class="alert alert-info" role="alert">No Results found</div>
<div *ngIf="openaireStatus == errorCodes.ERROR" class="alert alert-warning" role="alert">An Error Occured</div>
<div *ngIf="openaireStatus == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
<div *ngIf="openaireResultsNum != null && openaireResultsNum > 0">
<paging-no-load [currentPage]="openairePage" [totalResults]="openaireResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePageChange($event)"> </paging-no-load>
</div>
</div>
<div >
<ul *ngIf="openaireResults.length > 0 " class="list-group">
<li *ngFor=" let result of openaireResults " [class]="(isSelected(result.id))?'list-group-item panel-footer':'list-group-item'">
<span >
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
</span>
<span *ngIf="!isSelected(result.id)" (click)="add(result, result.id, 'openaire', 'publication', result['title'].url, result['title'].name, result.year,result['title'].accessMode)" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
</li>
</ul>
</div>
</div>
</div>
<div id="orcid" class="tab-pane fade">
<div class="panel-body" >
<div *ngIf="orcidResultsNum == null" class = "alert alert-info " > No results found </div>
<div *ngIf="orcidStatus == errorCodes.LOADING" class="alert alert-info" role="alert">Loading...</div>
<div *ngIf="orcidStatus == errorCodes.ERROR" class="alert alert-warning" role="alert">An Error Occured</div>
<div *ngIf="orcidStatus == errorCodes.NOT_AVAILABLE" class="alert alert-danger" role="alert">Service not available</div>
<div *ngIf="orcidResultsNum != null" class="panel-body">
<div class = "alert alert-warning " > Not the right author? Choose one of these:
@ -57,14 +78,14 @@
</span>
<div *ngIf=" ((orcidResultsNum >0) && (totalPages > 1) && ( 0 < page && page <= totalPages )) " >
<paging-no-load [currentPage]="page" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
<paging-no-load [currentPage]="orcidPage" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
</div>
<div >
<ul *ngIf="orcidResultsNum >0 && orcidResultsToShow.length > 0 " class="list-group">
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['put-code']))?'list-group-item panel-footer':'list-group-item'">
<span *ngIf="!item.URL" >{{item['work-title']['title'].value}}</span>
<span *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null)" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
<span *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')" aria-hidden="true" class= " btn glyphicon glyphicon-plus"></span>
</li>
</ul>
<div *ngIf="orcidResultsNum == 0" class = "alert alert-info " > No results found </div>
@ -74,5 +95,3 @@
</div>
</div>
</div>

View File

@ -3,6 +3,8 @@ import {Observable} from 'rxjs/Observable';
import { ActivatedRoute } from '@angular/router';
import {SearchCrossrefService} from '../../services/searchCrossref.service';
import {SearchOrcidService} from '../../services/searchOrcid.service';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import { ErrorCodes} from '../../utils/properties/openaireProperties';
import {ClaimResult} from '../../utils/entities/claimEntities.class';
@ -12,7 +14,7 @@ import {ClaimResult} from '../../utils/entities/claimEntities.class';
})
export class ClaimPublicationComponent {
constructor (private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService,
constructor (private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService,
private route: ActivatedRoute) {
var myDate = new Date();
this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
@ -21,12 +23,12 @@ export class ClaimPublicationComponent {
}
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
let page = +params['page'];
let size = +params['size'];
this.page = ( page <= 0 ) ? 1 : page;
this.size = ( size <= 0 ) ? 10 : size;
// let page = +params['page'];
// let size = +params['size'];
// this.page = ( page <= 0 ) ? 1 : page;
// this.size = ( size <= 0 ) ? 10 : size;
if(this.keyword !=null && this.keyword.length > 0){
this.search(this.keyword,this.size,this.page);
this.search(this.keyword);
}
});
@ -34,25 +36,32 @@ export class ClaimPublicationComponent {
ngOnDestroy() {
this.sub.unsubscribe();
}
@Input() public keyword:string = "";
@Input() public select:boolean = true ;
@Input() public selectedPublications = [] ;
@Output() publicationsChange = new EventEmitter();
sub: any;
page : number = 1;
size:number = 10;
@Input() public keyword:string = "";
navigateTo: string = "Search";
source: string = "crossref";
type : string = "publication";
@Input() public select:boolean = true ;
@Input() public selectedPublications = [] ;
@Output() publicationsChange = new EventEmitter();
errorCodes:ErrorCodes = new ErrorCodes();
crossrefResults=[];
crossrefResultsNum : Observable<number> ;
crossrefPage : number = 1;
crossrefStatus:number = this.errorCodes.NONE;
openaireResults = [];
openaireResultsNum: number ;
openairePage : number = 1;
openaireStatus:number = this.errorCodes.NONE;
orcidResults: string[];
orcidResultsNum: number ;
totalPages: number;
orcidResultsToShow: string[];
orcidPage : number = 1;
orcidStatus:number = this.errorCodes.NONE;
authorId: string;
authorGivenName: string;
authorFamilyName: string;
@ -69,130 +78,43 @@ ngOnDestroy() {
todayDate = '';
nextDate = '';
private searchOrcid (term: string) {
this.authorIds = new Array<string>();
this.authorGivenNames = new Array<string>();
this.authorFamilyNames = new Array<string>();
this.getOrcidAuthor(term);
console.info('searchOrcid in searchOrcid file');
}
private readData(data: any) {
this.authorIds.push(data[2].path);
if(data[0] != null) {
this.authorGivenNames.push(data[0].value);
} else {
this.authorGivenNames.push("");
}
if(data[1] != null) {
this.authorFamilyNames.push(data[1].value);
} else {
this.authorFamilyNames.push("");
}
}
private getOrcidAuthor (term: string) {
this.orcidResultsNum = null;
//passing structures in order to fill them in service
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
this.authorGivenNames, this.authorFamilyNames).subscribe(
data => {
if(data != null && data == true) {
this.getOrcidResultsById(0);
}
},
err => this.errorHandler(err, term)
);
}
private errorHandler(err: any, term: string) {
if(err.status == 404){
this.getOrcidAuthors(term);
} else {
console.error(err.status);
}
}
private getOrcidAuthors (term: string) {
this.orcidResultsNum = null;
//passing structures in order to fill them in service
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
this.authorGivenNames, this.authorFamilyNames).subscribe(
data => {
if(data != null && data == true) {
this.getOrcidResultsById(0);
}
},
err => console.error(err.status)
);
}
private getOrcidResultsById (index:number) {
if(this.authorIds.length > index) {
let id = this.authorIds[index];
console.info("getOrcidResultsById: "+id);
this._searchOrcidService.searchOrcidPublications(id).subscribe(
data => {
if(data != null) {
this.orcidResults=data['orcid-work'];
this.orcidResultsNum = data['orcid-work'].length;
this.page = 1;
if((this.orcidResultsNum % this.size) == 0){
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
} else{
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1));
}
this.orcidResultsToShow = this.orcidResults.slice(0,10);
} else {
this.orcidResultsNum = 0;
this.totalPages=0;
}
this.authorGivenName = this.authorGivenNames[index];
this.authorFamilyName = this.authorFamilyNames[index];
this.authorId = id;
},
err => console.error(err.status)
);
console.info("totalPages = " +this.totalPages);
}
}
public search(term: string, size : number, page : number){
public search(term: string){
this.warningMessage = "";
this.infoMessage = "";
this.getCrossrefResults(term,size,page);
this.getCrossrefResults(term, this.size,1);
this.searchOrcid(term);
this.searchOpenaire(term, this.size, 1);
}
private getCrossrefResults (term: string, size : number, page : number) {
this.crossrefStatus = this.errorCodes.LOADING;
if(term.split(' ').length == 1 ){
this._searchCrossrefService.searchCrossrefByDOI(term).subscribe(
data => {
if(data != null) {
this.crossrefResults = data.items;
this.page=page;
this.crossrefPage=page;
this.crossrefResultsNum = data['total-results'];
if(data.items == 0){
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
data => {
if(data != null) {
this.crossrefResults = data.items;
this.page=page;
this.crossrefPage=page;
this.crossrefResultsNum = data['total-results'];
this.crossrefStatus = this.errorCodes.DONE;
}
this.crossrefStatus = this.errorCodes.ERROR;
},
err => console.error(err.status)
err =>{
console.error(err.status);
this.crossrefStatus = this.errorCodes.ERROR;
}
);
}
}
@ -202,10 +124,16 @@ private getCrossrefResults (term: string, size : number, page : number) {
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
data => {
this.crossrefResults = data.items;
this.page=page;
this.crossrefPage=page;
this.crossrefResultsNum = data['total-results'];
this.crossrefStatus = this.errorCodes.DONE;
},
err => console.error(err.status)
err => {
console.error(err.status);
this.crossrefStatus = this.errorCodes.ERROR;
}
);
}
);
@ -217,17 +145,163 @@ private getCrossrefResults (term: string, size : number, page : number) {
data => {
if(data != null) {
this.crossrefResults = data.items;
this.page=page;
this.crossrefPage=page;
this.crossrefResultsNum = data['total-results'];
this.crossrefStatus = this.errorCodes.DONE;
}
this.crossrefStatus = this.errorCodes.ERROR;
},
err => console.error(err.status)
err => {
console.error(err.status);
this.crossrefStatus = this.errorCodes.ERROR;
}
);
}
}
private searchOpenaire(term: string, size : number, page : number) {
this.openaireStatus = this.errorCodes.LOADING;
this._searchPublicationsService.searchPublications(term, page, size, "claim").subscribe(
data => {
if(data != null) {
this.openairePage=page;
this.openaireResultsNum = data[0];
this.openaireResults = data[1];
this.openaireStatus = this.errorCodes.DONE;
if(this.openaireResultsNum == 0){
this.openaireStatus = this.errorCodes.NONE;
}
}else {
this.openaireStatus = this.errorCodes.ERROR;
}
},
err => {
console.error(err.status);
this.openaireStatus = this.errorCodes.ERROR;
}
);
}
private searchOrcid (term: string) {
this.orcidStatus = this.errorCodes.LOADING;
this.authorIds = new Array<string>();
this.authorGivenNames = new Array<string>();
this.authorFamilyNames = new Array<string>();
this.getOrcidAuthor(term);
console.info('searchOrcid in searchOrcid file');
}
private readData(data: any) {
this.authorIds.push(data[2].path);
if(data[0] != null) {
this.authorGivenNames.push(data[0].value);
} else {
this.authorGivenNames.push("");
}
if(data[1] != null) {
this.authorFamilyNames.push(data[1].value);
} else {
this.authorFamilyNames.push("");
}
}
private getOrcidAuthor (term: string) {
this.orcidResultsNum = null;
//passing structures in order to fill them in service
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
this.authorGivenNames, this.authorFamilyNames).subscribe(
data => {
if(data != null && data == true) {
this.getOrcidResultsById(0);
}
this.orcidStatus = this.errorCodes.NONE;
},
err => this.errorHandler(err, term)
);
}
private errorHandler(err: any, term: string) {
if(err.status == 404){
this.getOrcidAuthors(term);
} else {
console.error(err.status);
this.orcidStatus = this.errorCodes.ERROR;
}
}
private getOrcidAuthors (term: string) {
this.orcidResultsNum = null;
//passing structures in order to fill them in service
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
this.authorGivenNames, this.authorFamilyNames).subscribe(
data => {
if(data != null && data == true) {
this.getOrcidResultsById(0);
}else{
this.orcidStatus = this.errorCodes.ERROR;
}
},
err => {
console.error(err.status);
this.orcidStatus = this.errorCodes.ERROR;
}
);
}
private add(item, id, itemSource, itemType, itemUrl, itemTitle, date){
private getOrcidResultsById (index:number) {
if(this.authorIds.length > index) {
let id = this.authorIds[index];
console.info("getOrcidResultsById: "+id);
this._searchOrcidService.searchOrcidPublications(id).subscribe(
data => {
if(data != null) {
this.orcidResults=data['orcid-work'];
this.orcidResultsNum = data['orcid-work'].length;
this.orcidPage = 1;
if((this.orcidResultsNum % this.size) == 0){
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
} else{
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1));
}
this.orcidResultsToShow = this.orcidResults.slice(0,10);
this.orcidStatus = this.errorCodes.DONE;
if(this.orcidResultsNum == 0){
this.orcidStatus = this.errorCodes.NONE;
}
} else {
this.orcidResultsNum = 0;
this.totalPages=0;
this.orcidStatus = this.errorCodes.NONE;
}
this.authorGivenName = this.authorGivenNames[index];
this.authorFamilyName = this.authorFamilyNames[index];
this.authorId = id;
},
err => {
console.error(err.status);
this.orcidStatus = this.errorCodes.ERROR;
}
);
}
}
private add(item, id, itemSource, itemType, itemUrl, itemTitle, date, accessMode){
var result: ClaimResult ;
if(itemSource == 'crossref'){
date = (date == null) ? null : date.substring(0,10);
@ -236,6 +310,8 @@ private getCrossrefResults (term: string, size : number, page : number) {
date = (date == null) ? null : date + "-01.-01"
result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date};
}else if (itemSource == 'openaire'){
//TODO put right access rights
result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: null, date};
}
console.info("Added result:"+result.date);
@ -264,16 +340,21 @@ private getCrossrefResults (term: string, size : number, page : number) {
}
}
private pageChange($event) {
this.page=$event.value;
private crossrefPageChange($event) {
this.crossrefPage=$event.value;
this.crossrefResults=[];
this.getCrossrefResults(this.keyword,this.size,this.page);
}
private orcidPageChange($event) {
this.page=$event.value;
console.log("Crossref chaenged "+this.crossrefPage);
this.getCrossrefResults(this.keyword,this.size,this.crossrefPage);
}
private orcidPageChange($event) {
this.orcidPage=$event.value;
this.orcidResultsToShow=[];
this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size);
}
}
private openairePageChange($event) {
this.openairePage=$event.value;
this.searchOpenaire(this.keyword,this.size,this.openairePage);
}
private isSelected(id:string){

View File

@ -86,7 +86,7 @@ export class ClaimResultComponent {
if(this.searchType=='dataset'){
this.claimDatasetComponent.search(this.keyword,10,1);
}else{
this.claimPublicationComponent.search(this.keyword,10,1);
this.claimPublicationComponent.search(this.keyword);
}
}

View File

@ -33,10 +33,10 @@
{{size}}
</button>
<ul class="dropdown-menu" aria-labelledby="pagingDropdown">
<li *ngIf="resultsNum > 10" ><a (click)="size=10 " >10 </a></li>
<li *ngIf="resultsNum > 20" ><a (click)="size = 20 " >20 </a></li>
<li *ngIf="resultsNum > 30" ><a (click)="size = 30 " >30 </a></li>
<li *ngIf="resultsNum > 50" ><a (click)="size = 50 " >50 </a></li>
<li *ngIf="resultsNum > 10" ><a (click)="changeSize(10) " >10 </a></li>
<li *ngIf="resultsNum > 20" ><a (click)="changeSize(20)" >20 </a></li>
<li *ngIf="resultsNum > 30" ><a (click)="changeSize(30)" >30 </a></li>
<li *ngIf="resultsNum > 50" ><a (click)="changeSize(40)" >50 </a></li>
</ul>
</span>
</div>

View File

@ -219,9 +219,11 @@ export class ClaimsComponent {
params+=(this.keyword==''?"":(params.length>0?'&':'')+"keyword="+this.keyword);
return params;
}
changeLength(){
changeSize(size: number ){
this.size = size;
this.goTo();
}
clearFilters(){
this.keyword = '';
this.inputkeyword = '';

View File

@ -19,7 +19,7 @@ import {ModalLoading} from '../../../utils/modal/loading.component';
</form>
<p class="help-block">Upload a csv file with DOIs. For each DOI, metadata will be fetched from CrossRef. Available Results can be linked with the selected Projects and Contexts</p>
<div *ngIf="showReport" class="alert alert-info" role="alert" >
{{all}} DOIs found in . {{found}} fetched from CrossRef, {{duplicate}} were duplicates and {{notFound}} not found in crossref.
{{all}} DOIs found. {{found}} fetched from CrossRef, {{duplicate}} were duplicates and {{notFound}} not found in crossref.
</div>
<div *ngIf="errorMessage.length > 0 "> <div class="alert alert-danger" role="alert">{{errorMessage}}</div></div>

View File

@ -186,6 +186,7 @@ export class SearchComponent {
private keywordChanged($event){
this.keyword = $event.value;
console.info("Search Find: search with keyword \"" + this.keyword + "\"" );
this.searchPublications();
this.searchProjects();
this.searchDataProviders();

View File

@ -54,13 +54,13 @@ export class SearchDataprovidersComponent {
}
public getResults(parameters:string, page: number, size: number, flag: string){
console.info("getResults: Execute search query "+parameters);
console.log("Search Dataproviders: Execute search query "+parameters);
this._searchDataprovidersService.searchDataproviders(parameters, page, size, flag).subscribe(
data => {
this.totalResults = data[0];
console.info("searchPubl total="+this.totalResults);
this.results = data[1];
console.log("Search Dataproviders: results: "+this.totalResults);
this.results = data[1];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
if(this.totalResults == 0 ){
@ -86,7 +86,6 @@ export class SearchDataprovidersComponent {
private queryChanged($event) {
var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size, "searchPage");
}

View File

@ -79,12 +79,11 @@ export class SearchDatasetsComponent {
);
}
public getResults(parameters:string, page: number, size: number, flag: string){
console.info("getResults: Execute search query "+parameters);
console.info("Search Datasets: Execute search query "+parameters);
this._searchDatasetsService.searchDatasets(parameters, page, size, flag).subscribe(
data => {
this.totalResults = data[0];
console.info("searchDataset total="+this.totalResults);
console.info("Search Datasets: results="+this.totalResults);
this.results = data[1];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
@ -111,7 +110,6 @@ export class SearchDatasetsComponent {
private queryChanged($event) {
var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size, "searchPage");
}
}

View File

@ -111,12 +111,10 @@ export class AdvancedSearchFormComponent {
@Output() keywordsChange = new EventEmitter();
constructor () {
console.info("AdvancedSearchFormComponent constructor");
}
}
ngOnInit() {
console.info("AdvancedSearchFormComponent ngOnInit");
}
}
keywordsChanged() {
this.keywordsChange.emit({

View File

@ -67,8 +67,7 @@ export class AdvancedSearchPageComponent {
}
ngOnInit() {
console.info(" page - value: "+this.page);
this.totalResults = this.results.length;
this.totalResults = this.results.length;
}
private createUrlParameters(){

View File

@ -22,8 +22,7 @@ export class SearchFormComponent {
@Output() keywordChange = new EventEmitter();
constructor () {
console.info("SearchFormComponent constructor");
}
}
ngOnInit() {

View File

@ -60,8 +60,7 @@ export class SearchPageComponent {
private searchFields:SearchFields = new SearchFields();
constructor (private location: Location) {
console.log("Search page constr"+ this.refineParameters.length);
}
ngOnInit() {

View File

@ -147,6 +147,5 @@ export class SearchResultComponent {
}
ngOnInit() {
console.log(" search page st: "+this.status);
}
}
}

View File

@ -53,11 +53,10 @@ export class ClaimsService {
deleteClaimById(claimId:string):any{
console.warn('Trying to delete claim with id : '+claimId);
let url = this.baseUrl +"claims/"+claimId;
console.warn('Delete url: '+url);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.delete( url, options).map(request => <any> request.json())
.do(request => console.info("After delete" ))
// .do(request => console.info("After delete" ))
.catch(this.handleError);
}
@ -70,11 +69,10 @@ export class ClaimsService {
url=url+(url.length >0 ?"&":"")+"claimId="+claimId;
}
url= this.baseUrl +"claims/bulk?"+url;
console.warn('Delete url: '+url);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.delete( url, options).map(request => <any> request.json())
.do(request => console.info("After delete" ))
// .do(request => console.info("After delete" ))
.catch(this.handleError);
}

View File

@ -12,11 +12,9 @@ export class SearchDatasetsService {
searchDatasets (params: string, page: number, size: number, flag: string):any {
console.info("In searchDatasets");
let link, url;
if(flag == 'searchPage') {
if(flag == 'searchPage' || flag == 'claim') {
link = OpenaireProperties.getSearchAPIURL()+"datasets";
url = link+"?";
@ -62,6 +60,7 @@ export class SearchDatasetsService {
result['title'].url = OpenaireProperties.getsearchLinkToDataset();
result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
result['id'] = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['bestlicense'].hasOwnProperty("classid")) {
result['title'].accessMode = resData['bestlicense'].classid;
}

View File

@ -16,7 +16,7 @@ export class SearchPublicationsService {
let link, url;
if(flag == 'searchPage') {
if(flag == 'searchPage' || flag == 'claim') {
link = OpenaireProperties.getSearchAPIURL()+"publications";
url = link+"?";
@ -65,6 +65,7 @@ export class SearchPublicationsService {
result['title'].url = OpenaireProperties.getsearchLinkToPublication();
result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
result['id'] = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['bestlicense'].hasOwnProperty("classid")) {
result['title'].accessMode = resData['bestlicense'].classid;
}

View File

@ -12,12 +12,9 @@ export class RefineResultsService {
getRefineResults(fields:string[]):any {
console.info("In get RefineResults:");
return this.http.get('./refineResults.json')
.map(res => <any> res.json())
.do(res => console.log(res))
// .do(res => console.log(res))
.map(res => this.parseRefineResults(res['refineResults'],fields))
;
}
@ -27,22 +24,20 @@ export class RefineResultsService {
var filters:Filter[] = [];
for(let j=0; j<data.length; j++) {
var filter:Filter = new Filter();
console.log("Parsing field :" + fields[j] );
var filter:Filter = new Filter();
filter.title = searchFields.FIELDS_NAMES[fields[j]];
filter.filterId = fields[j];
filter.originalFilterId = fields[j];
let field = data[j][fields[j]];
for(let i=0; i<field.length; i++) {
var value:Value = new Value();
value.name = field[i].name;
value.number = field[i].count;
value.id = field[i].id;
filter.values.push(value);
filter.title = searchFields.FIELDS_NAMES[fields[j]];
filter.filterId = fields[j];
filter.originalFilterId = fields[j];
let field = data[j][fields[j]];
for(let i=0; i<field.length; i++) {
var value:Value = new Value();
value.name = field[i].name;
value.number = field[i].count;
value.id = field[i].id;
filter.values.push(value);
}
filters.push(filter);
}
filters.push(filter);
}
return filters;
}

View File

@ -1,6 +1,7 @@
export class SearchResult {
title: { "name": string, "url": string, "accessMode": string};
id:string;
DOI:string;
//publications & organizations:
projects: {"funderShortname": string, "funderName": string, "acronym": string, "title": string, "code": string, "url": string}[];
//datasets & publications