First draft for advanced search for datasets , organizations, people

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44384 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-11-03 15:24:23 +00:00
parent 5c0d7681ef
commit 599c9cbcfc
13 changed files with 408 additions and 16 deletions

View File

@ -22,6 +22,10 @@ import { SearchPeopleComponent } from './searchPages/searchPeople.component';
import { AdvancedSearchPublicationsComponent } from './searchPages/advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './searchPages/advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './searchPages/advanced/advancedSearchProjects.component';
import { AdvancedSearchDatasetsComponent } from './searchPages/advanced/advancedSearchDatasets.component';
import { AdvancedSearchPeopleComponent } from './searchPages/advanced/advancedSearchPeople.component';
import { AdvancedSearchOrganizationsComponent } from './searchPages/advanced/advancedSearchOrganizations.component';
import { DepositComponent } from './deposit/deposit.component';
import { DepositResultComponent } from './deposit/depositResult.component';
@ -58,6 +62,9 @@ const appRoutes: Routes = [
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent },
{ path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent },
{ path: 'search/advanced/datasets', component: AdvancedSearchDatasetsComponent },
{ path: 'search/advanced/people', component: AdvancedSearchPeopleComponent },
{ path: 'search/advanced/organizations', component: AdvancedSearchOrganizationsComponent },
{ path: 'deposit', component: DepositComponent},
{ path: 'deposit-results', component: DepositResultComponent},
{ path: 'test', component: TestComponent},

View File

@ -0,0 +1,112 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchDatasetsService} from '../../services/searchDatasets.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'advanced-search-datasets',
template: `
<advanced-search-page pageTitle="Advanced Search Datasets" entityType="dataset"
[(results)] = "results" [(totalResults)] = "totalResults"
[(page)] = "page" [(size)] = "size" [baseUrl] = "baseUrl"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[(status)] = "status"
(queryChange)="queryChanged($event)">
</advanced-search-page>
`
})
export class AdvancedSearchDatasetsComponent {
private results =[];
private filters =[];
private totalResults:number = 0 ;
private page :number = 1;
private size :number = 10;
public status:number;
private baseUrl: string;
private searchFields:SearchFields = new SearchFields();
private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_DATASET_PARAM;
private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATASET_FIELDS_MAP;
private selectedFields:AdvancedField[] = [];
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) {
this.results =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications();
}
ngOnInit() {
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.sub = this.route.queryParams.subscribe(params => {
let page = (params['page']=== undefined)?1:+params['page'];
this.page = ( page <= 0 ) ? 1 : page;
this.searchPage.fieldIds = this.fieldIds;
this.searchPage.selectedFields = this.selectedFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.searchPage.createQueryParameters(), this.page, this.size);
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
sub: any;
public getResults(parameters:string, page: number, size: number){
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.LOADING;
console.info("Advanced Search Datasets: Execute search query "+parameters);
this._searchDatasetsService.searchDatasets(parameters, null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("search Datasets total="+this.totalResults);
this.results = data[1];
this.searchPage.updateBaseUrlWithParameters();
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;
this.getResults(parameters, this.page,this.size);
console.info("queryChanged: Execute search query "+parameters);
}
}

View File

@ -0,0 +1,112 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'advanced-search-organizations',
template: `
<advanced-search-page pageTitle="Advanced Search Organizations" entityType="dataset"
[(results)] = "results" [(totalResults)] = "totalResults"
[(page)] = "page" [(size)] = "size" [baseUrl] = "baseUrl"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[(status)] = "status"
(queryChange)="queryChanged($event)">
</advanced-search-page>
`
})
export class AdvancedSearchOrganizationsComponent {
private results =[];
private filters =[];
private totalResults:number = 0 ;
private page :number = 1;
private size :number = 10;
public status:number;
private baseUrl: string;
private searchFields:SearchFields = new SearchFields();
private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_ORGANIZATION_PARAM;
private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.ORGANIZATION_FIELDS_MAP;
private selectedFields:AdvancedField[] = [];
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) {
this.results =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications();
}
ngOnInit() {
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.sub = this.route.queryParams.subscribe(params => {
let page = (params['page']=== undefined)?1:+params['page'];
this.page = ( page <= 0 ) ? 1 : page;
this.searchPage.fieldIds = this.fieldIds;
this.searchPage.selectedFields = this.selectedFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.searchPage.createQueryParameters(), this.page, this.size);
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
sub: any;
public getResults(parameters:string, page: number, size: number){
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.LOADING;
console.info("Advanced Search Organizations: Execute search query "+parameters);
this._searchOrganizationsService.searchOrganizations(parameters, null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("search Organizations total="+this.totalResults);
this.results = data[1];
this.searchPage.updateBaseUrlWithParameters();
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;
this.getResults(parameters, this.page,this.size);
console.info("queryChanged: Execute search query "+parameters);
}
}

View File

@ -0,0 +1,112 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchPeopleService} from '../../services/searchPeople.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'advanced-search-organizations',
template: `
<advanced-search-page pageTitle="Advanced Search People" entityType="dataset"
[(results)] = "results" [(totalResults)] = "totalResults"
[(page)] = "page" [(size)] = "size" [baseUrl] = "baseUrl"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[(status)] = "status"
(queryChange)="queryChanged($event)">
</advanced-search-page>
`
})
export class AdvancedSearchPeopleComponent {
private results =[];
private filters =[];
private totalResults:number = 0 ;
private page :number = 1;
private size :number = 10;
public status:number;
private baseUrl: string;
private searchFields:SearchFields = new SearchFields();
private fieldIds: string[] = this.searchFields.ADVANCED_SEARCH_PERSON_PARAM;
private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PERSON_FIELDS_MAP;
private selectedFields:AdvancedField[] = [];
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
constructor (private route: ActivatedRoute, private _searchPeopleService: SearchPeopleService ) {
this.results =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications();
}
ngOnInit() {
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.sub = this.route.queryParams.subscribe(params => {
let page = (params['page']=== undefined)?1:+params['page'];
this.page = ( page <= 0 ) ? 1 : page;
this.searchPage.fieldIds = this.fieldIds;
this.searchPage.selectedFields = this.selectedFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.searchPage.createQueryParameters(), this.page, this.size);
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
sub: any;
public getResults(parameters:string, page: number, size: number){
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.LOADING;
console.info("Advanced Search People: Execute search query "+parameters);
this._searchPeopleService.searchPeople(parameters, null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("search People total="+this.totalResults);
this.results = data[1];
this.searchPage.updateBaseUrlWithParameters();
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;
this.getResults(parameters, this.page,this.size);
console.info("queryChanged: Execute search query "+parameters);
}
}

View File

@ -13,7 +13,7 @@ import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'advanced-search-projects',
template: `
<advanced-search-page pageTitle="Advanced Search projects" entityType="project"
<advanced-search-page pageTitle="Advanced Search Projects" entityType="project"
[(results)] = "results" [(totalResults)] = "totalResults"
[(page)] = "page" [(size)] = "size" [baseUrl] = "baseUrl"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"

View File

@ -34,6 +34,10 @@ import {SearchEntityRegistriesComponent} from './dataProviders/entityRegistries.
import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjects.component';
import { AdvancedSearchDatasetsComponent } from './advanced/advancedSearchDatasets.component';
import { AdvancedSearchPeopleComponent } from './advanced/advancedSearchPeople.component';
import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchOrganizations.component';
@NgModule({
imports: [
@ -53,9 +57,8 @@ import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjec
SearchPagingComponent,
AdvancedSearchFormComponent,
SearchPublicationsComponent,
AdvancedSearchPublicationsComponent,
AdvancedSearchDataProvidersComponent,
AdvancedSearchProjectsComponent,
AdvancedSearchPublicationsComponent, AdvancedSearchDataProvidersComponent, AdvancedSearchProjectsComponent,
AdvancedSearchDatasetsComponent, AdvancedSearchPeopleComponent, AdvancedSearchOrganizationsComponent,
SearchDataprovidersComponent,
SearchComponent,
SearchProjectsComponent,

View File

@ -13,13 +13,18 @@ export class ISVocabulariesService {
return this.getLanguagesJsonFile();
}else if ( field == "type" && (entity == "publication")){
return this.getPublicationTypesJsonFile();
}else if( field == "access" && (entity == "publication")){
}else if ( field == "type" && (entity == "dataset")){
return this.getDatasetTypesJsonFile();
}else if( field == "access" && (entity == "publication" || entity == "dataset")){
return this.getAccessModeJsonFile();
} else if( field == "type" && (entity == "dataprovider")){
return this.getDataProviderTypesJsonFile();
} else if( field == "compatibility" && (entity == "dataprovider")){
return this.getDataProviderCompatibilityJsonFile();
} else if( field == "country" ){
return this.getCountryJsonFile();
}
return null;
}
getLanguages ():any {
@ -50,6 +55,21 @@ export class ISVocabulariesService {
var lang = JSON.parse(JSON.stringify(require('../utils/vocabularies/publicationTypes.json')));
return this.parse(lang["terms"]);
}
getDatasetTypes ():any {
let url = this.api+"dnet:dataCite_resource.json";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res['terms'])
.map(res => this.parse(res));
}
getDatasetTypesJsonFile ():any {
var lang = JSON.parse(JSON.stringify(require('../utils/vocabularies/dnet:dataCite_resource.json')));
return this.parse(lang["terms"]);
}
getAccessMode ():any {
console.info("Get AccessMode from IS");
let url = this.api+"dnet:access_modes.json";
@ -104,7 +124,20 @@ export class ISVocabulariesService {
}
private handleError (error: Response) {
getCountryCompatibility ():any {
let url = this.api+"dnet:countries.json";
return this.http.get(url)
.map(res => <any> res.json())
.map(res => res['terms'])
.map(res => this.parse(res));
}
getCountryJsonFile ():any {
var lang = JSON.parse(JSON.stringify(require('../utils/vocabularies/countries.json')));
return this.parse(lang["terms"]);
}
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);

View File

@ -35,7 +35,11 @@ import 'rxjs/Rx';
<li><a href="/search/entity-registries">Entity Registries</a></li>
<li role="separator" class="divider"></li>
<li><a href="/search/advanced/publications">Advanced Search Publications</a></li>
<li><a href="/search/advanced/datasets">Advanced Search Research Data</a></li>
<li><a href="/search/advanced/projects">Advanced Search Projects</a></li>
<li><a href="/search/advanced/dataproviders">Advanced Search Data Providers</a></li>
<li><a href="/search/advanced/organizations">Advanced Search Organizations</a></li>
<li><a href="/search/advanced/people">Advanced Search People</a></li>
</ul>
</li>
<li class="dropdown">

View File

@ -104,15 +104,15 @@ export class SearchFields {
//ORGANIZATION
public ORGANIZATION_INDEX:string[] = ["organizationcountryid","organizationeclegalbody"];
public ADVANCED_SEARCH_ORGANIZATION_INDEX_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
public ORGANIZATION_INDEX_PARAM_MAP:{ [key:string]:string } = {["organizationlegalname"]:"contenttype", ["organizationlegalshortname"]:"compatibility",
public ADVANCED_SEARCH_ORGANIZATION_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
public ORGANIZATION_INDEX_PARAM_MAP:{ [key:string]:string } = {["organizationlegalname"]:"contenttype", ["organizationlegalshortname"]:"type",
["organizationcountryid"]:"country",["organizationeclegalbody"]:"type"};
public ORGANIZATION_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={
["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null},
["contenttype"]:{name:"Legal Name",operator:"cn", type:"keyword" , indexField:"organizationlegalname"},
["compatibility"]:{name:"Legal Short Name",operator:"cm", type:"keyword", indexField:"organizationlegalshortname"},
["country"]:{name:"Country",operator:"pb", type:"keyword", indexField:"organizationcountryid"},
["type"]:{name:"Type",operator:"fn", type:"refine", indexField:"organizationeclegalbody"},
["country"]:{name:"Country",operator:"cu", type:"vocabulary", indexField:"organizationcountryid"},
["type"]:{name:"Type",operator:"tp", type:"refine", indexField:"organizationeclegalbody"},
};
@ -120,10 +120,10 @@ export class SearchFields {
//PERSON
public PERSON_INDEX:string[] = [];
public ADVANCED_SEARCH_PERSON_INDEX_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
public PERSON_INDEX_INDEX_PARAM_MAP:{ [key:string]:string } = {["personsecondnames"]:"surname", ["personfirstname"]:"name",
public ADVANCED_SEARCH_PERSON_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
public PERSON_INDEX_PARAM_MAP:{ [key:string]:string } = {["personsecondnames"]:"surname", ["personfirstname"]:"name",
["personfullname"]:"fullname"};
public PERSON_INDEX_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={
public PERSON_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} ={
["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null},
["surname"]:{name:"Surname",operator:"sr", type:"keyword" , indexField:"personsecondnames"},
["name"]:{name:"Name",operator:"nm", type:"keyword", indexField:"personfirstname"},

View File

@ -99,13 +99,14 @@ export class StaticAutocomplete2Component {
this.listUpdated.emit({
value: this.list
});
if(this.list == null || this.list.length == 0 ){
this.warningMessage = "There are no results"
return
}
this.done = true;
if(this.keyword != ""){
this.filter();
}
if(this.list.length == 0 ){
this.warningMessage = "There are no results"
}
}
filter() {
if(this.done){
@ -207,6 +208,9 @@ export class StaticAutocomplete2Component {
}
private getSelectedNameFromGivenId(){
if(this.list == null ){
return;
}
for( var i = 0; i < this.list.length; i++){
if(this.list[i].id == this.selectedValue){
this.selectedValue = this.list[i].label;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"id":"a48f6872-4055-484f-b365-a9c11f5ff152_Vm9jYWJ1bGFyeURTUmVzb3VyY2VzL1ZvY2FidWxhcnlEU1Jlc291cmNlVHlwZQ==","name":"dnet:dataCite_resource","description":"dnet:dataCite_resource","code":"dnet:dataCite_resource","terms":[{"englishName":"UNKNOWN","nativeName":"UNKNOWN","encoding":"OPENAIRE","code":"UNKNOWN"},{"englishName":"clinical trial","nativeName":"clinical trial","encoding":"OPENAIRE","code":"clinicalTrial"},{"englishName":"collection","nativeName":"collection","encoding":"OPENAIRE","code":"collection"},{"englishName":"dataset","nativeName":"dataset","encoding":"OPENAIRE","code":"dataset"},{"englishName":"event","nativeName":"event","encoding":"OPENAIRE","code":"event"},{"englishName":"film","nativeName":"film","encoding":"OPENAIRE","code":"film"},{"englishName":"image","nativeName":"image","encoding":"OPENAIRE","code":"image"},{"englishName":"interactiveResource","nativeName":"interactiveResource","encoding":"OPENAIRE","code":"interactiveResource"},{"englishName":"model","nativeName":"model","encoding":"OPENAIRE","code":"model"},{"englishName":"physicalObject","nativeName":"physicalObject","encoding":"OPENAIRE","code":"physicalObject"},{"englishName":"service","nativeName":"service","encoding":"OPENAIRE","code":"service"},{"englishName":"software","nativeName":"software","encoding":"OPENAIRE","code":"software"},{"englishName":"sound","nativeName":"sound","encoding":"OPENAIRE","code":"sound"},{"englishName":"text","nativeName":"text","encoding":"OPENAIRE","code":"text"}]}

View File

@ -89,6 +89,9 @@ app.get('/search/find/publications', ngApp);
app.get('/search/advanced/publications', ngApp);
app.get('/search/advanced/dataproviders', ngApp);
app.get('/search/advanced/projects', ngApp);
app.get('/search/advanced/organizations', ngApp);
app.get('/search/advanced/people', ngApp);
app.get('/search/advanced/datasets', ngApp);
app.get('/search/find/dataproviders', ngApp);
app.get('/search/find/projects', ngApp);
app.get('/search/find/datasets', ngApp);