Search Dataproviders completed | bug fixed in search Publications (title)

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43956 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2016-10-06 13:23:27 +00:00
parent ebb572a02f
commit e65a23539f
13 changed files with 317 additions and 34 deletions

View File

@ -15,6 +15,7 @@ import { DataProviderComponent } from './landingPages/dataProvider/dataProvider.
import { SearchComponent } from './searchPages/find/search.component';
import { SearchPublicationsComponent } from './searchPages/searchPublications.component';
import { AdvancedSearchPublicationsComponent } from './searchPages/advancedSearchPublications.component';
import { SearchDataprovidersComponent } from './searchPages/searchDataproviders.component';
import { DepositComponent } from './deposit/deposit.component';
import { DepositResultComponent } from './deposit/depositResult.component';
import { ErrorPageComponent } from './error/errorPage.component';
@ -24,10 +25,10 @@ import { SearchAllComponent } from './searchAll/searchAll.component';
const appRoutes: Routes = [
{ path: '', component: SearchComponent, pathMatch: 'full' },
{ path: 'claims', component: ClaimsAdminComponent },
{ path: 'home', component: HomeComponent },
{ path: 'claim', component: ClaimComponent },
{ path: 'myclaims', component: MyClaimsComponent },
{ path: 'claims', component: ClaimsAdminComponent },
{ path: 'home', component: HomeComponent },
{ path: 'claim', component: ClaimComponent },
{ path: 'myclaims', component: MyClaimsComponent },
{ path: 'search/person', component: PersonComponent },
{ path: 'search/project', component: ProjectComponent },
{ path: 'search/organization', component: OrganizationComponent },
@ -38,14 +39,15 @@ const appRoutes: Routes = [
{ path: 'linking', component: LinkingComponent },
{ path: 'bulk-linking', component: BulkLinkingComponent},
{ path: 'search/find/publications', component: SearchPublicationsComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
{ path: 'deposit', component: DepositComponent},
{ path: 'deposit-results', component: DepositResultComponent},
{ path: 'deposit-results', component: DepositResultComponent},
{ path: 'test', component: TestComponent},
{ path: 'search', component: SearchAllComponent },
{ path: 'error', component: ErrorPageComponent},
{ path: 'error', component: ErrorPageComponent},
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
];

View File

@ -20,14 +20,16 @@ import {SearchFilterComponent} from './searchUtils/searchFilter.component';
import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.component';
import { SearchPublicationsComponent } from './searchPublications.component';
import { AdvancedSearchPublicationsComponent } from './advancedSearchPublications.component';
import { SearchDataprovidersComponent } from './searchDataproviders.component';
import {SearchComponent} from './find/search.component';
@NgModule({
imports: [
CommonModule, FormsModule,
UtilsModule,
ServicesModule,
ServicesModule
],
declarations: [
@ -41,9 +43,9 @@ import {SearchComponent} from './find/search.component';
AdvancedSearchFormComponent,
SearchPublicationsComponent,
AdvancedSearchPublicationsComponent,
SearchDataprovidersComponent,
SearchComponent
],
providers:[
// SearchPublicationsService
@ -52,6 +54,7 @@ import {SearchComponent} from './find/search.component';
SearchAllComponent,
AdvancedSearchPublicationsComponent,
SearchPublicationsComponent,
SearchDataprovidersComponent,
SearchComponent
]
})

View File

@ -0,0 +1,147 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../services/searchDataproviders.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
@Component({
selector: 'search-dataproviders',
template: `
<search-page pageTitle="Search Dataproviders" type="datasource" [(filters)] = "filters"
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" >
</search-page>
`
})
export class SearchDataprovidersComponent {
public results =[];
private filters =[];
public totalResults:number = 0 ;
private baseUrl:string;
public status:number;
private keyword = '';
private page :number = 1;
private size :number = 10;
private sub: any;
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) {
//this.results =[];
//this.filters =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
}
private ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => {
this.keyword = (params['keyword']?params['keyword']:'');
this.page = (params['page']=== undefined)?1:+params['page'];
for(var i=0; i<5 ; i++){
var values = [];
for(var j=0; j<10 ; j++){
var value:Value = {name: "name"+j, id: "filter_"+i+ "_id_"+j, number:j, selected:false}
values.push(value);
}
values.sort((n2,n1) => {
if (n1.number > n2.number) {
return 1;
}
if (n1.number < n2.number) {
return -1;
}
return 0;
});
var filter:Filter = {title: "title"+i, filterId: "filter_"+i, originalFilterId: "filter_"+i, values : values, countSelectedValues:0, "filterOperator": 'and'}
if(i==0) {
var values = [];
for(var j=0; j<10 ; j++){
var value:Value = {name: "MYname"+j, id: "MYfilter_"+i+ "_id_"+j, number:j, selected:false}
values.push(value);
}
values.sort((n2,n1) => {
if (n1.number > n2.number) {
return 1;
}
if (n1.number < n2.number) {
return -1;
}
return 0;
});
var filter1:Filter = {title: "MYtitle"+i, filterId: "MYfilter_"+i, originalFilterId: "MYfilter_"+i, values : values, countSelectedValues:0, "filterOperator": 'or'}
this.filters.push(filter1);
this.getResults(this.keyword, this.page, this.size);
}
console.info(params);
if(params[filter.filterId] != undefined) {
let values = params[filter.filterId].split(",");
for(let value of values) {
for(let filterValue of filter.values) {
if(filterValue.id == value) {
filterValue.selected = true;
filter.countSelectedValues++;
}
}
}
}
}
});
}
private ngOnDestroy() {
this.sub.unsubscribe();
}
public getResults(parameters:string, page: number, size: number){
console.info("getResults: Execute search query "+parameters);
this._searchDataprovidersService.searchDataproviders(parameters, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("searchPubl total="+this.totalResults);
this.results = data[1];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
if(this.totalResults == 0 ){
this.status = errorCodes.NONE;
}
},
err => {
console.error(err);
console.info("error");
//TODO check erros (service not available, bad request)
// if( ){
// this.status = ErrorCodes.ERROR;
// }
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.NOT_AVAILABLE;
}
);
}
private setFilters(){
//TODO set filters from
}
private queryChanged($event) {
var parameters = $event.value;
console.info("queryChanged: Execute search query "+parameters);
this.getResults(parameters, this.page, this.size);
}
}

View File

@ -31,15 +31,13 @@ export class SearchPublicationsComponent {
private sub: any;
constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) {
this.results =[];
this.filters =[];
//this.results =[];
//this.filters =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
}
private ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => {
this.keyword = (params['keyword']?params['keyword']:'');

View File

@ -62,12 +62,10 @@ export class SearchPageComponent {
@Input() size: number = 10;
@Input() status: number;
@Input() totalResults: number = 0;
@Input() keyword:string = '';
@Input() keyword: string = '';
@Output() queryChange = new EventEmitter();
@Input() baseUrl:string = '';
test= { value: 0};
@Output() queryChange = new EventEmitter();
constructor (private location: Location) {
}
@ -77,6 +75,7 @@ export class SearchPageComponent {
console.log(" search page st: "+this.status);
//this.totalResults = this.totalResults;
console.info("searchPage total="+this.totalResults);
console.info("searchPage: results.length = "+this.results.length);
}
changekeyword(){
@ -162,6 +161,7 @@ export class SearchPageComponent {
this.page = page;
var urlParameters = this.createUrlParameters();
var queryParameters = this.createQueryParameters();
console.info(location.pathname);
this.location.go(location.pathname,urlParameters);
this.queryChange.emit({
value: queryParameters

View File

@ -13,7 +13,7 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<li *ngFor="let result of results">
<h4>
<a class="custom-external" href="{{result['title'].url}}" target="_blank">
<a href="{{result['title'].url}}">
<p *ngIf="result['title'].name != undefined && result['title'].name != ''">
{{result['title'].name}}
</p>
@ -26,13 +26,13 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<div>
<span *ngIf="result['authors'] != undefined">
<span *ngFor="let author of result['authors'].slice(0,15)">
<a class="custom-external" href="{{author['url']}}" target="_blank">
<a href="{{author['url']}}">
{{author['name']}};
</a>
</span>
<span *ngIf="result['authors'].length > 15">...</span>
</span>
<span *ngIf="result.year != ''">
<span *ngIf="result.year != undefined && result.year != ''">
({{result.year}})
</span>
</div>
@ -40,8 +40,7 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<div *ngIf="result['projects'] != undefined">
<span> Projects: </span>
<span *ngFor="let project of result['projects'] let i=index">
<a *ngIf="project.url != undefined"
class="custom-external" href="{{project.url}}" target="_blank">
<a *ngIf="project.url != undefined" href="{{project.url}}">
{{project['funderShortname']?project['funderShortname']:project['funderName']}}
| {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})
</a>
@ -57,7 +56,39 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<div class="text-justify" [innerHTML]="result.description"></div>
</blockquote>
<mark *ngIf="result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
<mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
<div *ngIf="result['organizations'] != undefined">
<span> Organizations: </span>
<span *ngFor="let organization of result['organizations'] let i=index">
<a *ngIf="organization.url != undefined" href="{{organization.url}}">
{{organization.name}}
</a>
<span *ngIf="organization.url == undefined">
{{organization.name}}
</span>
<span *ngIf="i < result['organizations'].length-1"> ,</span>
</span>
</div>
<div *ngIf="result['type'] != undefined && result['type'] != ''">Type: {{result['type']}}</div>
<div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
<span>Website URL: </span>
<span>
<a class="custom-external" href="{{result['websiteURL']}}" target="_blank">
{{result['websiteURL']}}
</a>
</span>
</div>
<div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
<span>OAI-PMH URL: </span>
<span>
<a class="custom-external" href="{{result['OAIPMHURL']}}" target="_blank">
{{result['OAIPMHURL']}}
</a>
</span>
</div>
<hr>
</li>
@ -72,7 +103,7 @@ export class SearchResultComponent {
@Input() status: number;
errorCodes:ErrorCodes = new ErrorCodes();
private errorMessage: string = "";
private errorMessage: string = "No results found";
/*
@Input() title;
@Input() id;

View File

@ -93,7 +93,7 @@ export class DataProviderService {
this.dataProviderInfo.organizations[counter] = {"name": "", "url": ""};
this.dataProviderInfo.organizations[counter]['name'] = mydata.legalname;
this.dataProviderInfo.organizations[counter]['url'] = mydata.websiteUrl;
this.dataProviderInfo.organizations[counter]['url'] = OpenaireProperties.getsearchLinkToOrganization()+mydata['to'].content;
counter++;
}

View File

@ -14,7 +14,7 @@ export class OrganizationService {
getOrganizationInfo (id: string):any {
console.info("getOrganizationInfo in service");
let url = OpenaireProperties.getSearchAPIURL()+'organisations/'+id;
let url = OpenaireProperties.getSearchAPIURL()+'organizations/'+id;
return this.http.get(url)
.map(res => <any> res.json())

View File

@ -0,0 +1,93 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {SearchResult} from '../utils/entities/searchResult';
@Injectable()
export class SearchDataprovidersService {
constructor(private http: Http) {}
searchDataproviders (params: string, page: number, size: number):any {
console.info("In searchDataproviders");
let link = OpenaireProperties.getSearchAPIURL()+"datasources";
let url = link+"?";
if(params != '') {
url += "q="+params+"&page="+page+"&size="+size;
} else {
url += "page="+page+"&size="+size;
}
return this.http.get(url)
.map(res => <any> res.json())
.do(res => console.info(res))
//.map(res => []);
.map(res => [res['meta'].total, this.parseResults(res['results'])])
;
}
parseResults(data: any): SearchResult[] {
let results: SearchResult[] = [];
let length = Array.isArray(data) ? data.length : 1;
for(let i=0; i<length; i++) {
let resData = length > 1 ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
var result: SearchResult = new SearchResult();
result['title'] = {"name": '', "url": '', "accessMode": ''};
result['title'].name = resData.officialname;
result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['datasourcetype'].hasOwnProperty("classname")) {
result['type'] = resData['datasourcetype'].classname;
}
if(resData['accessinfopackage'] != '') {
if(Array.isArray(resData['accessinfopackage'])) {
result['OAIPMHURL'] = resData['accessinfopackage'][0];
} else {
result['OAIPMHURL'] = resData['accessinfopackage'];
}
}
result['websiteURL'] = resData.websiteurl;
if(resData['rels'].hasOwnProperty("rel")) {
let counter = 0;
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
for(let i=0; i<relLength; i++) {
let relation = relLength > 1 ? resData['rels']['rel'][i] : resData['rels']['rel'];
if(relation.hasOwnProperty("to")) {
if(relation['to'].class == "provides" && relation['to'].type == "organization") {
if(result['organizations'] == undefined) {
result['organizations'] = new Array<{"name": string, "url": string}>();
}
result['organizations'][counter] = {"name": "", "url": ""};
result['organizations'][counter]['name'] = relation.legalname;
result['organizations'][counter]['url'] = OpenaireProperties.getsearchLinkToOrganization()+relation['to'].content;
counter++;
}
}
}
}
results.push(result);
}
return results;
}
}

View File

@ -42,9 +42,17 @@ export class SearchPublicationsService {
var result: SearchResult = new SearchResult();
result['title'] = {"name": '', "url": '', "accessMode": ''};
if(resData['title'].hasOwnProperty("content")) {
result['title'].name = resData['title'].content;
if(Array.isArray(resData['title'])) {
resData['title'][0].hasOwnProperty("content") {
result['title'].name = resData['title'][0].content;
}
} else {
resData['title'].hasOwnProperty("content") {
result['title'].name = resData['title'].content;
}
}
result['title'].url = OpenaireProperties.getsearchLinkToPublication();
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['bestlicense'].hasOwnProperty("classid")) {

View File

@ -16,13 +16,13 @@ import { SearchDataciteService } from './searchDatacite.service';
import { SearchOrcidService } from './searchOrcid.service';
import {SearchPublicationsService} from './searchPublications.service';
import {DataProviderService} from './dataProvider.service';
import {SearchDataprovidersService} from './searchDataproviders.service';
@NgModule({
imports: [
CommonModule, FormsModule,
CommonModule, FormsModule
],
declarations: [
],
@ -30,7 +30,7 @@ import {DataProviderService} from './dataProvider.service';
ContextsService, DatasetService, OpenaireProjectsService,OrganizationService,
PersonService, ProjectService, PublicationService, SearchCrossrefService,
SearchCrossrefService, SearchDataciteService, SearchOrcidService,
SearchPublicationsService, DataProviderService
SearchPublicationsService, SearchDataprovidersService, DataProviderService
],
exports: [

View File

@ -11,7 +11,7 @@ export class SearchResult {
//datasets:
publisher: string;
//dataproviders & projects:
organizations: { "name": string, "url": string};
organizations: { "name": string, "url": string }[];
//projects:
funders: string;
//organizations:

View File

@ -68,6 +68,7 @@ app.get('/search/publication', ngApp);
app.get('/search', ngApp);
app.get('/search/find/publications', ngApp);
app.get('/search/advanced/publications', ngApp);
app.get('/search/find/dataproviders', ngApp);
app.get('/deposit', ngApp);
app.get('/deposit-result', ngApp);
app.get('/error', ngApp);