adding search page for projects

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43957 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-10-06 14:49:19 +00:00
parent e65a23539f
commit a3d93c97dd
12 changed files with 318 additions and 20 deletions

View File

@ -14,8 +14,9 @@ import { PublicationComponent } from './landingPages/publication/publication.com
import { DataProviderComponent } from './landingPages/dataProvider/dataProvider.component'
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 { SearchProjectsComponent } from './searchPages/searchProjects.component';
import { AdvancedSearchPublicationsComponent } from './searchPages/advancedSearchPublications.component';
import { DepositComponent } from './deposit/deposit.component';
import { DepositResultComponent } from './deposit/depositResult.component';
import { ErrorPageComponent } from './error/errorPage.component';
@ -26,9 +27,9 @@ 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: '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 },
@ -39,15 +40,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/find/dataproviders', component: SearchDataprovidersComponent },
{ path: 'search/find/projects', component: SearchProjectsComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ 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: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
{ path: 'error', component: ErrorPageComponent},
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
];

View File

@ -21,6 +21,7 @@ import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.comp
import { SearchPublicationsComponent } from './searchPublications.component';
import { AdvancedSearchPublicationsComponent } from './advancedSearchPublications.component';
import { SearchDataprovidersComponent } from './searchDataproviders.component';
import { SearchProjectsComponent } from './searchProjects.component';
import {SearchComponent} from './find/search.component';
@ -44,7 +45,8 @@ import {SearchComponent} from './find/search.component';
SearchPublicationsComponent,
AdvancedSearchPublicationsComponent,
SearchDataprovidersComponent,
SearchComponent
SearchComponent,
SearchProjectsComponent
],
providers:[
@ -54,6 +56,7 @@ import {SearchComponent} from './find/search.component';
SearchAllComponent,
AdvancedSearchPublicationsComponent,
SearchPublicationsComponent,
SearchProjectsComponent,
SearchDataprovidersComponent,
SearchComponent
]

View File

@ -35,7 +35,7 @@ export class SearchDataprovidersComponent {
//this.filters =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchPublications();
this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders();
}
private ngOnInit() {

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 {SearchProjectsService} from '../services/searchProjects.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
@Component({
selector: 'search-projects',
template: `
<search-page pageTitle="Search Projects" type="project" [(filters)] = "filters"
[(results)] = "results" [(totalResults)] = "totalResults" [(keyword)] = "keyword"
[(page)] = "page" [(size)] = "size" [(status)] = "status" [baseUrl] = "baseUrl" (queryChange)="queryChanged($event)" >
</search-page>
`
})
export class SearchProjectsComponent {
public results =[];
private filters =[];
public totalResults:number = 0 ;
public status:number;
private baseUrl:string;
private keyword = '';
private page :number = 1;
private size :number = 10;
private sub: any;
constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) {
//this.results =[];
//this.filters =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchProjects();
}
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._searchProjectsService.searchProjects(parameters, page, size).subscribe(
data => {
this.totalResults = data[0];
console.info("search Projects 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

@ -59,6 +59,17 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
<mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
<div *ngIf="result['funders'] != undefined">
<span> Funders: </span>
<span *ngFor="let funder of result['funders'] let i=index">
<span *ngIf="funder.funderShortname">
{{funder.funderShortname}}
</span>
<span *ngIf="i < result['funders'].length-1"> ,</span>
</span>
</div>
<span *ngIf="result.startYear && result.endYear"> ({{result.startYear}} - {{result.endYear}})</span>
<div *ngIf="result['organizations'] != undefined">
<span> Organizations: </span>
<span *ngFor="let organization of result['organizations'] let i=index">

View File

@ -0,0 +1,119 @@
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 SearchProjectsService {
private sizeOfDescription: number = 497;
constructor(private http: Http) {}
searchProjects (params: string, page: number, size: number):any {
console.info("In searchProjects");
let link = OpenaireProperties.getSearchAPIURL()+"projects";
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 => [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:project'] : data['result']['metadata']['oaf:entity']['oaf:project'];
var result: SearchResult = new SearchResult();
result['title'] = {"name": '', "url": '', "accessMode": ''};
if(Array.isArray(resData['title'])) {
// resData['title'][0].hasOwnProperty("content") {
result['title'].name = resData['title'][0];
// }
} else {
// resData['title'].hasOwnProperty("content") {
result['title'].name = resData['title'];
// }
}
// if(resData['title'].hasOwnProperty("content")) {
// result['title'].name = resData['title'].content;
// }
result['title'].url = OpenaireProperties.getsearchLinkToProject();
result['title'].url += length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(resData['rels'].hasOwnProperty("rel")) {
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
for(let j=0; j<relLength; j++) {
let relation = relLength > 1 ? resData['rels']['rel'][j] : resData['rels']['rel'];
if(relation.hasOwnProperty("to")) {
if(relation['to'].class == "hasParticipant") {
if(result['organizations'] == undefined) {
result['organizations'] = new Array<
{ "name": string, "url": string}>();
}
let countOrganizations = result['organizations'].length;
result['organizations'][countOrganizations] = { "name": "", "url": "" }
result['organizations'][countOrganizations]['url'] =
OpenaireProperties.getsearchLinkToOrganization() + relation['to'].content;
result['organizations'][countOrganizations]['name'] = relation.legalname;
}
}
}
}
if(resData.hasOwnProperty("fundingtree")) {
if(result['funders'] == undefined) {
result['funders'] = new Array<
{"funderShortname": string, "funderName": string}>();
}
let fundingLength = Array.isArray(resData['fundingtree']) ? resData['fundingtree'].length : 1;
for(let z=0; z<fundingLength; z++) {
let fundingData = fundingLength > 1 ? resData['fundingtree'][z] : resData['fundingtree'];
let countFunders = result['funders'].length;
if(fundingData.hasOwnProperty("funder")) {
result['funders'][countFunders] = {"funderShortname": "", "funderName": ""};
result['funders'][countFunders]['funderShortname'] = fundingData['funder'].shortname;
result['funders'][countFunders]['funderName'] = fundingData['funder'].name;
}
}
}
if(resData.hasOwnProperty("startdate")) {
result.startYear = resData.startdate.split('-')[0];
}
if(resData.hasOwnProperty("enddate")) {
result.endYear = resData.enddate.split('-')[0];
}
results.push(result);
}
return results;
}
}

View File

@ -44,13 +44,13 @@ export class SearchPublicationsService {
result['title'] = {"name": '', "url": '', "accessMode": ''};
if(Array.isArray(resData['title'])) {
resData['title'][0].hasOwnProperty("content") {
// resData['title'][0].hasOwnProperty("content") {
result['title'].name = resData['title'][0].content;
}
// }
} else {
resData['title'].hasOwnProperty("content") {
// resData['title'].hasOwnProperty("content") {
result['title'].name = resData['title'].content;
}
// }
}
result['title'].url = OpenaireProperties.getsearchLinkToPublication();

View File

@ -18,6 +18,7 @@ import {SearchPublicationsService} from './searchPublications.service';
import {DataProviderService} from './dataProvider.service';
import {SearchDataprovidersService} from './searchDataproviders.service';
import {SearchProjectsService} from './searchProjects.service';
@NgModule({
@ -30,7 +31,8 @@ import {SearchDataprovidersService} from './searchDataproviders.service';
ContextsService, DatasetService, OpenaireProjectsService,OrganizationService,
PersonService, ProjectService, PublicationService, SearchCrossrefService,
SearchCrossrefService, SearchDataciteService, SearchOrcidService,
SearchPublicationsService, SearchDataprovidersService, DataProviderService
SearchPublicationsService, SearchDataprovidersService, DataProviderService,
SearchProjectsService
],
exports: [

View File

@ -25,8 +25,11 @@ import 'rxjs/Rx';
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Search <span class=""></span></a>
<ul class="dropdown-menu">
<li><a href="/search/find/publications">Publications</a></li>
<li><a href="#">Datasets</a></li>
<li><a href="#">Projects</a></li>
<li><a href="/search/find/">Datasets</a></li>
<li><a href="/search/find/projects">Projects</a></li>
<li><a href="/search/find/dataproviders">Data Providers</a></li>
<li><a href="/search/find/">Organizations</a></li>
<li><a href="/search/find/">People</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>

View File

@ -11,9 +11,11 @@ export class SearchResult {
//datasets:
publisher: string;
//dataproviders & projects:
organizations: { "name": string, "url": string }[];
organizations: { "name": string, "url": string}[];
//projects:
funders: string;
funders: {"funderShortname": string, "funderName": string}[];
startYear:number;
endYear:number;
//organizations:
country: string;
//dataproviders:

View File

@ -9,7 +9,10 @@ export class OpenaireProperties {
private static searchLinkToOrganization = "search/organization?organizationId=";
//Search pages
private static searchLinkToPublications = "search/find/publications?keyword=";
private static searchLinkToDataProviders = "search/find/dataproviders?keyword=";
private static searchLinkToProjects = "search/find/projects?keyword=";
getLinkToSearchProjects
// Services - APIs
// public claimsAPIURL = "http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"
@ -73,6 +76,12 @@ export class OpenaireProperties {
public static getLinkToSearchPublications():string{
return this.baseSearchLink + this.searchLinkToPublications;
}
public static getLinkToSearchProjects():string{
return this.baseSearchLink + this.searchLinkToProjects;
}
public static getLinkToSearchDataProviders():string{
return this.baseSearchLink + this.searchLinkToDataProviders;
}
// Services - APIs' getters
public static getSearchAPIURL():string{

View File

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