[Library|Trunk]
New search update keywords query: identify PID, specific query for each pid Entities selection: change select to angular material select String utils - Identifiers: add regex for more PIDs, create class Identifier git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58164 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
c88ec8c54f
commit
2694761594
|
@ -9,20 +9,48 @@ import {Router} from "@angular/router";
|
|||
@Component({
|
||||
selector: 'entities-selection',
|
||||
template: `
|
||||
<select *ngIf="show" [(ngModel)]="selectedEntity" class="uk-select uk-width-auto portal-box uk-text-small" (ngModelChange)="entityChanged()" >
|
||||
<!-- <select *ngIf="show" [(ngModel)]="selectedEntity" class="uk-select uk-width-auto portal-box uk-text-small" (ngModelChange)="entityChanged()" >
|
||||
<option *ngIf="simpleView && (showResearchOutcomes + showDataProviders + showOrganizations + showProjects )>1 " value="all">All content</option>
|
||||
<option *ngIf="showResearchOutcomes" value="result">Research outcomes</option>
|
||||
<option *ngIf="showProjects" value="project">Projects</option>
|
||||
<option *ngIf="showDataProviders" value="dataprovider">Content providers</option>
|
||||
<option *ngIf="showOrganizations" value="organization">Organizations</option>
|
||||
</select>
|
||||
<button *ngIf="!show && currentEntity" class="uk-select uk-width-auto portal-box uk-text-small">
|
||||
</select>-->
|
||||
|
||||
<!--<button *ngIf="!show && currentEntity" class="uk-select uk-width-auto portal-box uk-text-small">
|
||||
<span *ngIf="currentEntity=='all'">All content</span>
|
||||
<span *ngIf="currentEntity=='result'">Research outcomes</span>
|
||||
<span *ngIf="currentEntity=='project'">Projects</span>
|
||||
<span *ngIf="currentEntity=='dataprovider'">Content providers</span>
|
||||
<span *ngIf="currentEntity=='organization'">Organizations</span>
|
||||
</button>
|
||||
</button>-->
|
||||
<!---->
|
||||
|
||||
<span class="entitiesSelection portal-box uk-text-small " style="" >
|
||||
<mat-select *ngIf="show && selectedEntity" [(value)]="selectedEntity"
|
||||
(valueChange)="entityChanged()" [disableOptionCentering]="true" panelClass="entitiesSelectionPanel">
|
||||
<mat-option
|
||||
*ngIf="simpleView && (showResearchOutcomes + showDataProviders + showOrganizations + showProjects )>1 "
|
||||
value="all">All content
|
||||
</mat-option>
|
||||
<mat-option *ngIf="showResearchOutcomes" value="result">Research outcomes</mat-option>
|
||||
<mat-option *ngIf="showProjects" value="project">Projects</mat-option>
|
||||
<mat-option *ngIf="showDataProviders" value="dataprovider">Content providers</mat-option>
|
||||
<mat-option *ngIf="showOrganizations" value="organization">Organizations</mat-option>
|
||||
</mat-select>
|
||||
<mat-select *ngIf="!show && currentEntity" [(value)]="selectedEntity">
|
||||
<mat-option [value]="selectedEntity">
|
||||
<span *ngIf="currentEntity=='all'">All content</span>
|
||||
<span *ngIf="currentEntity=='result'">Research outcomes</span>
|
||||
<span *ngIf="currentEntity=='project'">Projects</span>
|
||||
<span *ngIf="currentEntity=='dataprovider'">Content providers</span>
|
||||
<span *ngIf="currentEntity=='organization'">Organizations</span>
|
||||
</mat-option>
|
||||
|
||||
</mat-select>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
`
|
||||
|
@ -42,6 +70,7 @@ export class EntitiesSelectionComponent {
|
|||
@Input() onChangeNavigate: boolean = true;
|
||||
@Output() selectionChange = new EventEmitter();
|
||||
show = false;
|
||||
|
||||
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {
|
||||
|
||||
|
||||
|
@ -70,7 +99,11 @@ export class EntitiesSelectionComponent {
|
|||
});
|
||||
}
|
||||
this.selectedEntity = this.currentEntity;
|
||||
this.selectionChange.emit({entity:this.selectedEntity, simpleUrl:this.getUrl(true) , advancedUrl:this.getUrl(false)});
|
||||
this.selectionChange.emit({
|
||||
entity: this.selectedEntity,
|
||||
simpleUrl: this.getUrl(true),
|
||||
advancedUrl: this.getUrl(false)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,7 +112,11 @@ export class EntitiesSelectionComponent {
|
|||
if (!this.simpleView) {
|
||||
this.router.navigate([this.getUrl(false)]);
|
||||
} else {
|
||||
this.selectionChange.emit({entity:this.selectedEntity, simpleUrl:this.getUrl(true) , advancedUrl:this.getUrl(false)});
|
||||
this.selectionChange.emit({
|
||||
entity: this.selectedEntity,
|
||||
simpleUrl: this.getUrl(true),
|
||||
advancedUrl: this.getUrl(false)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,12 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
|||
import {RouterModule} from '@angular/router';
|
||||
import {EntitiesSelectionComponent} from "./entitiesSelection.component";
|
||||
import {ConfigurationServiceModule} from "../../utils/configuration/configurationService.module";
|
||||
import {MatSelectModule} from "@angular/material";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ReactiveFormsModule, ConfigurationServiceModule
|
||||
RouterModule, ReactiveFormsModule, ConfigurationServiceModule, MatSelectModule
|
||||
],
|
||||
declarations: [
|
||||
EntitiesSelectionComponent,
|
||||
|
|
|
@ -6,7 +6,7 @@ import {Meta, Title} from '@angular/platform-browser';
|
|||
import {AdvancedField, Filter, Value} from './searchHelperClasses.class';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class';
|
||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||
import {Dates, DOI, StringUtils} from '../../utils/string-utils.class';
|
||||
import {Dates, DOI, Identifier, StringUtils} from '../../utils/string-utils.class';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||
|
||||
|
@ -602,21 +602,24 @@ export class NewSearchPageComponent {
|
|||
if (this.selectedFields[i].id == "q") {
|
||||
var op = "";
|
||||
var doisParams = "";
|
||||
if ((this.type == 'publications' || this.type == 'research data' || this.type == 'software' || this.type == 'other research products')) { //
|
||||
var DOIs: string[] = DOI.getDOIsFromString(this.selectedFields[i].value);
|
||||
for (var i = 0; i < DOIs.length; i++) {
|
||||
doisParams += (doisParams.length > 0 ? " or " : "") + 'pid="' + DOIs[i] + '"';
|
||||
if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) {
|
||||
var DOIs: Identifier[] = Identifier.getIdentifiersFromString(this.selectedFields[i].value);
|
||||
for (let identifier of DOIs) {
|
||||
console.log(identifier)
|
||||
// pidclassid exact \"doi\" and pid exact \"10.1016/j.nima.2015.11.134\"
|
||||
//and (authorid exact \"0000-0001-7291-3210 \" )"
|
||||
if(identifier.class == "ORCID"){
|
||||
doisParams += (doisParams.length > 0 ? " or " : "") +'(authorid="' + identifier.id + '")';
|
||||
}else{
|
||||
doisParams += (doisParams.length > 0 ? " or " : "") +'(pidclassid exact "' + identifier.class + '" and pid="' + identifier.id + '")';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doisParams.length > 0) {
|
||||
params += doisParams;
|
||||
params += this.createQuotedKeywordQuery(this.selectedFields[i],countParams,true, true) + " or " + doisParams;
|
||||
} else {
|
||||
//Remove quotes from keyword search
|
||||
// params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
|
||||
// params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + StringUtils.URIEncode(this.selectedFields[i].value) + " ";
|
||||
params += this.createQuotedKeywordQuery(this.selectedFields[i],countParams,true);
|
||||
}
|
||||
// params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
|
||||
} else if (countParams == 0 && this.selectedFields[i].operatorId == "not" && this.fieldIdsMap[this.selectedFields[i].id].equalityOperator != "=") {
|
||||
params += " " + this.selectedFields[i].id + " <> " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
|
||||
} else if(this.fieldIdsMap[this.selectedFields[i].id].equalityOperator == "=") {
|
||||
|
@ -633,17 +636,18 @@ export class NewSearchPageComponent {
|
|||
if (this.customFilter) {
|
||||
params += (countParams == 0 ? "" : " and ") + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId));
|
||||
}
|
||||
console.log("ParameterS:")
|
||||
console.log(params)
|
||||
// console.log("ParameterS:")
|
||||
// console.log(params)
|
||||
return params;
|
||||
}
|
||||
|
||||
createQuotedKeywordQuery(field:AdvancedField, countParams:number, isSearchAll:boolean){
|
||||
console.log(field)
|
||||
createQuotedKeywordQuery(field:AdvancedField, countParams:number, isSearchAll:boolean, forceQuotted:boolean=false){
|
||||
let params = "";
|
||||
let quotedParts = (field.value)?field.value.match(/(["'])(.*?)*?\1/g):[];
|
||||
console.log(quotedParts)
|
||||
params+= (countParams == 0 ? "" : field.operatorId) + " (";
|
||||
if(forceQuotted){
|
||||
return this.getQuotedQueryPart(field.id, '"'+ field.value+'"',isSearchAll);
|
||||
}
|
||||
if(quotedParts && quotedParts.length == 1 && quotedParts[0] == field.value ){
|
||||
params+=this.getQuotedQueryPart(field.id, field.value,isSearchAll);
|
||||
}else if( quotedParts && quotedParts.length > 0){
|
||||
|
@ -670,7 +674,6 @@ export class NewSearchPageComponent {
|
|||
// console.log("For "+i+" " +params+" SP "+ startPoint+" EP: "+endPoint);
|
||||
// startPoint = (i+1<quotedParts.length)? field.value.indexOf(quotedParts[i+i]):field.value.length;//(startPoint<index )?(index + quotedParts[i].length):field.value.length;
|
||||
startPoint = ((i+1<quotedParts.length)?(field.value.indexOf(quotedParts[i+1])+quotedParts[i+1].length):(endPoint== index?(index+quotedParts[i].length):endPoint));
|
||||
console.log(" Next SP "+ startPoint);
|
||||
}
|
||||
if(startPoint !=field.value.length && decodeURIComponent(field.value.substring(startPoint,field.value.length)).split(" ").join("").length > 0){
|
||||
params+=" and " + this.getNoQuotedQueryPart(field.id, field.value.substring(startPoint,field.value.length),isSearchAll);
|
||||
|
|
|
@ -85,6 +85,18 @@ export class Dates {
|
|||
|
||||
export class DOI{
|
||||
|
||||
public static getDOIsFromString(str:string):string[]{
|
||||
return Identifier.getDOIsFromString(str);
|
||||
}
|
||||
public static isValidDOI(str:string):boolean{
|
||||
return Identifier.isValidDOI(str);
|
||||
}
|
||||
}
|
||||
|
||||
export class Identifier{
|
||||
class: "doi" | "pmc" | "pmid" | "handle"|"ORCID" =null;
|
||||
id:string;
|
||||
|
||||
public static getDOIsFromString(str:string):string[]{
|
||||
var DOIs:string[] = [];
|
||||
var words:string[] = str.split(" ");
|
||||
|
@ -96,17 +108,50 @@ export class DOI{
|
|||
}
|
||||
return DOIs;
|
||||
}
|
||||
public static isValidDOI(str:string):boolean{
|
||||
public static getIdentifiersFromString(str:string):Identifier[]{
|
||||
let identifiers:Identifier[] = [];
|
||||
let words:string[] = str.split(" ");
|
||||
|
||||
for(let id of words){
|
||||
if(id.length > 0 ) {
|
||||
if (Identifier.isValidDOI(id)) {
|
||||
identifiers.push({"class": "doi", "id": id})
|
||||
} else if (Identifier.isValidORCID(id)) {
|
||||
identifiers.push({"class": "ORCID", "id": id})
|
||||
} else if (Identifier.isValidPMCID(id)) {
|
||||
identifiers.push({"class": "pmc", "id": id})
|
||||
} else if (Identifier.isValidPMID(id)) {
|
||||
identifiers.push({"class": "pmid", "id": id})
|
||||
} else if (Identifier.isValidHANDLE(id)) {
|
||||
identifiers.push({"class": "handle", "id": id})
|
||||
}
|
||||
}
|
||||
}
|
||||
return identifiers;
|
||||
}
|
||||
public static isValidDOI(str:string):boolean{
|
||||
var exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g
|
||||
var exp2 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])[[:graph:]])+)\b/g
|
||||
if(str.match(exp1)!=null || str.match(exp2)!=null){
|
||||
// console.log("It's a DOI");
|
||||
return true;
|
||||
return (str.match(exp1)!=null || str.match(exp2)!=null);
|
||||
}
|
||||
return false;
|
||||
public static isValidORCID(str:string):boolean{
|
||||
let exp =/\b\d{4}-\d{4}-\d{4}-(\d{3}X|\d{4})\b/g;
|
||||
return str.match(exp)!=null;
|
||||
}
|
||||
public static isValidPMID(str:string):boolean{
|
||||
let exp =/^\d*$/g;
|
||||
return str.match(exp)!=null;
|
||||
|
||||
}
|
||||
public static isValidPMCID(str:string):boolean{
|
||||
let exp =/^(PMC\d{7})$/g;
|
||||
return str.match(exp)!=null;
|
||||
}
|
||||
|
||||
public static isValidHANDLE(str:string):boolean{
|
||||
let exp =/^[0-9a-zA-Z-]*\/[0-9a-zA-Z-]*$/g;
|
||||
return str.match(exp)!=null;
|
||||
}
|
||||
}
|
||||
export class StringUtils{
|
||||
public static quote(params: string):string {
|
||||
|
|
Loading…
Reference in New Issue