diff --git a/deposit/searchDataprovidersToDeposit.component.ts b/deposit/searchDataprovidersToDeposit.component.ts index ae0b7017..c2747378 100644 --- a/deposit/searchDataprovidersToDeposit.component.ts +++ b/deposit/searchDataprovidersToDeposit.component.ts @@ -5,15 +5,14 @@ import {SearchDataprovidersService} from '../services/searchDataproviders.servic import {ErrorCodes} from '../utils/properties/errorCodes'; import {ErrorMessagesComponent} from '../utils/errorMessages.component'; import {SearchFields} from '../utils/properties/searchFields'; -import {SearchPageComponent } from '../searchPages/searchUtils/searchPage.component'; + import {SearchUtilsClass} from '../searchPages/searchUtils/searchUtils.class'; import {EnvProperties} from '../utils/properties/env-properties'; -import {StringUtils} from "../utils/string-utils.class"; import {ZenodoInformationClass} from "./utils/zenodoInformation.class"; import {RouterHelper} from "../utils/routerHelper.class"; @Component({ - selector: 'search-dataproviders', + selector: 'deposit-search-dataproviders', template: `
@@ -29,22 +28,8 @@ import {RouterHelper} from "../utils/routerHelper.class";
- - + + ` }) export class SearchDataprovidersToDepositComponent { @@ -71,7 +56,7 @@ export class SearchDataprovidersToDepositComponent { properties:EnvProperties; - @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + // @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; @Input() public communityId: string = null; @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); @@ -94,34 +79,34 @@ export class SearchDataprovidersToDepositComponent { this.baseUrl = this.properties.depositSearchPage; this.pagingLimit = this.properties.pagingLimit; }); - this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; - this.searchPage.keywordFields = this.keywordFields; - var firstLoad =true; - - this.sub = this.route.queryParams.subscribe(params => { - this.loadPaging = true; - if(params['page'] && this.searchUtils.page != params['page']) { - this.loadPaging = false; - this.oldTotalResults = this.searchUtils.totalResults; - } - - this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - var refine = true; - if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ - refine = false; - - } - firstLoad = false; - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; - this.searchUtils.size = (params['size']=== undefined)?5:+params['size']; - if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { - this.searchUtils.size = 5; - } - this.searchPage.usedBy = "deposit"; - var queryParameters = this.searchPage.getQueryParametersFromUrl(params); - this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); - }); + // this.searchPage.refineFields = this.refineFields; + // this.searchPage.fieldIdsMap = this.fieldIdsMap; + // this.searchPage.keywordFields = this.keywordFields; + // var firstLoad =true; + // + // this.sub = this.route.queryParams.subscribe(params => { + // this.loadPaging = true; + // if(params['page'] && this.searchUtils.page != params['page']) { + // this.loadPaging = false; + // this.oldTotalResults = this.searchUtils.totalResults; + // } + // + // this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + // var refine = true; + // if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + // refine = false; + // + // } + // firstLoad = false; + // this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + // this.searchUtils.size = (params['size']=== undefined)?5:+params['size']; + // if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { + // this.searchUtils.size = 5; + // } + // this.searchPage.usedBy = "deposit"; + // var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + // this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + // }); } public ngOnDestroy() { @@ -133,7 +118,7 @@ export class SearchDataprovidersToDepositComponent { } } - public getResults(keyword:string,refine:boolean, page: number, size: number){ + /*public getResults(keyword:string,refine:boolean, page: number, size: number){ var parameters = ""; if(keyword.length > 0){ //parameters = "q="+ keyword; @@ -201,7 +186,7 @@ export class SearchDataprovidersToDepositComponent { ); } } - +*/ private handleError(message: string, error) { console.error("Content Providers simple Search Page: "+message, error); diff --git a/deposit/searchDataprovidersToDeposit.module.ts b/deposit/searchDataprovidersToDeposit.module.ts index 72f4f4b2..3b2129d7 100644 --- a/deposit/searchDataprovidersToDeposit.module.ts +++ b/deposit/searchDataprovidersToDeposit.module.ts @@ -9,16 +9,17 @@ import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.mod import {DataProvidersServiceModule} from '../services/dataProvidersService.module'; import {SearchFormModule} from '../searchPages/searchUtils/searchForm.module'; -import {SearchPageModule} from '../searchPages/searchUtils/searchPage.module'; +// import {SearchPageModule} from '../searchPages/searchUtils/searchPage.module'; import {FreeGuard} from'../login/freeGuard.guard'; import {IsRouteEnabled} from '../error/isRouteEnabled.guard'; +import {SearchDataProvidersModule} from "../searchPages/searchDataProviders.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, DataProvidersServiceModule, - SearchFormModule, SearchResultsModule, SearchPageModule + SearchFormModule, SearchResultsModule, SearchDataProvidersModule ], declarations: [ diff --git a/searchPages/searchDataProviders.component.ts b/searchPages/searchDataProviders.component.ts index c6ad37c6..34bd9709 100644 --- a/searchPages/searchDataProviders.component.ts +++ b/searchPages/searchDataProviders.component.ts @@ -31,11 +31,13 @@ import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class"; [openaireLink]=openaireLink [includeOnlyResultsAndFilter]="includeOnlyResultsAndFilter" [piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix" - searchFormClass="datasourcesSearchForm" + [searchFormClass]="type!='deposit'?'datasourcesSearchForm':''" [entitiesSelection]="type=='all'" [showAdvancedSearchLink]="type=='all'" [filters]="filters" [simpleView]="simpleView" formPlaceholderText="Search by title, country, organization, subject, type..." - [showResultCount]="type!='registries'"> + [showResultCount]="(type=='all' || type == 'deposit')" [showLastIndex]="type!='deposit'" + [tableViewLink]="tableViewLink"> + ` @@ -46,6 +48,7 @@ export class SearchDataProvidersComponent { private errorMessages: ErrorMessagesComponent; @Input() piwikSiteId = null; @Input() customFilter:SearchCustomFilter= null; +@Input() tableViewLink; public results =[]; public filters =[]; public searchUtils:SearchUtilsClass = new SearchUtilsClass(); @@ -63,9 +66,9 @@ export class SearchDataProvidersComponent { public pagingLimit: number = 0; public isPiwikEnabled; properties:EnvProperties; - @Input() type: "all" | "registries" | "journals" | "compatible" ="all"; - public refineFields: string[] = DatasourcesHelperClass.getrefineFields(this.type); - pageTitle = DatasourcesHelperClass.getTitle(this.type); + @Input() type: "all" | "registries" | "journals" | "compatible" | "deposit" = "all"; + public refineFields: string[]; + pageTitle; @ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent; @Input() simpleView: boolean = true; @Input() simpleSearchLink: string = ""; @@ -79,11 +82,10 @@ export class SearchDataProvidersComponent { this.errorCodes = new ErrorCodes(); this.errorMessages = new ErrorMessagesComponent(); this.searchUtils.status = this.errorCodes.LOADING; - - //console.info("Con -base url:"+this.searchUtils.baseUrl ); - } ngOnInit() { + this.refineFields = DatasourcesHelperClass.getrefineFields(this.type); + this.pageTitle = DatasourcesHelperClass.getTitle(this.type); this.route.data .subscribe((data: { envSpecific: EnvProperties }) => { this.properties= data.envSpecific; @@ -119,6 +121,11 @@ export class SearchDataProvidersComponent { this.searchPage.fieldIds = this.fieldIds; this.selectedFields =[]; + if(this.type == "deposit"){ + this.searchPage.keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS; + this.searchPage.usedBy = "deposit"; + } + console.log(this.refineFields) this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "dataprovider"); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); }); @@ -153,12 +160,13 @@ export class SearchDataProvidersComponent { //console.info("Advanced Search for Content Providers: Execute search query "+parameters); let datasourceQueryPrefix = DatasourcesHelperClass.getQueryPrefix(this.type); - this._searchDataProvidersService.advancedSearchDataproviders( datasourceQueryPrefix +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' and ':'') + parameters, page, size, this.properties, (refine && this.type=="all") ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe( + this._searchDataProvidersService.advancedSearchDataproviders( datasourceQueryPrefix +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' and (':'') + parameters +(datasourceQueryPrefix.length > 0 && parameters.length > 0 ?' ) ':''), page, size, this.properties, (refine && (this.type=="all" || this.type == "deposit")) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery, (this.type == "deposit")).subscribe( data => { this.searchUtils.totalResults = data[0]; this.results = data[1]; + console.log(this.results); if (refine) { - this.filters = this.searchPage.prepareFiltersToShow(this.type=="all"?data[2]:this.filters); + this.filters = this.searchPage.prepareFiltersToShow((this.type=="all" || this.type == "deposit")?data[2]:this.filters); }else{ this.searchPage.buildPageURLParameters(this.filters, [], false); } diff --git a/searchPages/searchUtils/datasourcesHelper.class.ts b/searchPages/searchUtils/datasourcesHelper.class.ts index 10ad7d2c..7ca32c2d 100644 --- a/searchPages/searchUtils/datasourcesHelper.class.ts +++ b/searchPages/searchUtils/datasourcesHelper.class.ts @@ -3,7 +3,8 @@ import {SearchFields} from "../../utils/properties/searchFields"; export class DatasourcesHelperClass { - public static getrefineFields(type: "all" | "registries" | "journals" | "compatible") { + public static getrefineFields(type: "all" | "registries" | "journals" | "compatible" | "deposit") { + console.log("Get RF "+ type) let searchFields:SearchFields = new SearchFields(); if (type == "registries") { return searchFields.ENTITY_REGISTRIES_FIELDS; @@ -12,24 +13,25 @@ export class DatasourcesHelperClass { } else if (type == "compatible") { return searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; + } else if (type == "deposit") { + return searchFields.DEPOSIT_DATASOURCE_REFINE_FIELDS; } else { return searchFields.DATASOURCE_REFINE_FIELDS; } } - public static getTitle(type: "all" | "registries" | "journals" | "compatible") { + public static getTitle(type: "all" | "registries" | "journals" | "compatible" | "deposit") { if (type == "registries") { return "Entity Registries" } else if (type == "journals") { return "Journals" - } else if (type == "compatible") { return "Compatible Content Providers"; } else { return "Content Providers" } } - public static getQueryPrefix(type: "all" | "registries" | "journals" | "compatible"): string { + public static getQueryPrefix(type: "all" | "registries" | "journals" | "compatible" | "deposit"): string { if (type == "registries") { return ' datasourcetypeuiid = other '; } else if (type == "journals") { @@ -38,12 +40,14 @@ export class DatasourcesHelperClass { } else if (type == "compatible") { return ' oaftype exact datasource and datasourcecompatibilityid <> notCompatible and datasourcetypeuiid <> other and datasourcetypeuiid <> "pubsrepository::journal" and datasourcetypeuiid <> "aggregator::pubsrepository::journals" '; + }else if (type == "deposit") { + return ' oaftype exact datasource '; } else { return ""; } } - public static createFilters(type: "all" | "registries" | "journals" | "compatible"): Filter[] { + public static createFilters(type: "all" | "registries" | "journals" | "compatible" | "deposit"): Filter[] { if (type == "registries") { return this.createRegistriesFilters(); } else if (type == "journals") { diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index 7a54c6f4..01877340 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -1,8 +1,16 @@ -
-
-
+
+ +
@@ -71,14 +79,14 @@
- - - - - - - - + + + + + + + + @@ -173,14 +181,14 @@
- - - - - - - - + + + + + + + + @@ -272,6 +280,16 @@ [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults"> + + + + + Table view + + +
@@ -280,11 +298,18 @@
- + [showLoading]="true" [properties]=properties> + +
@@ -300,7 +325,7 @@
- Last index information diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index e5b17b41..b28e6d14 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -17,6 +17,7 @@ import {HelperService} from "../../utils/helper/helper.service"; import {SearchFields} from "../../utils/properties/searchFields"; import {RefineResultsUtils} from "../../services/servicesUtils/refineResults.class"; import {RangeFilter} from "../../utils/rangeFilter/rangeFilterHelperClasses.class"; +import {ZenodoInformationClass} from "../../deposit/utils/zenodoInformation.class"; @Component({ selector: 'new-search-page', @@ -60,6 +61,8 @@ export class NewSearchPageComponent { @Input() showRefine: boolean = true; @Input() tableViewLink: string; @Input() usedBy: string = "search"; + @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); + @Input() showLastIndex: boolean = true; @Input() showResultCount: boolean = true; @Input() showMoreFilterValuesInline: boolean = true; @Input() filterValuesNum: number = 6; @@ -663,14 +666,37 @@ export class NewSearchPageComponent { } } if (doisParams.length > 0) { - params += this.createQuotedKeywordQuery(this.selectedFields[i],countParams,true, true) + " or " + doisParams; + params += this.createQuotedKeywordQuery(this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId ,countParams,true, true) + " or " + doisParams; } else { - params += this.createQuotedKeywordQuery(this.selectedFields[i],countParams,true); + params += this.createQuotedKeywordQuery(this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId,countParams,true); } + //TODO deposit case + console.log(this.usedBy) + console.log(this.keywordFields) + + if(this.usedBy == "deposit") { + + if(this.keywordFields.length > 0) { + params += " or (" + } + for(let j=0; j< this.keywordFields.length ; j++) { + if(j > 0) { + params += " or " + } + params += this.createQuotedKeywordQuery(this.selectedFields[i].value, this.keywordFields[j].name, " or ", countParams,false); + // let field = this.keywordFields[i]; + //keywordQuery += field.name+field.equalityOperator+StringUtils.URIEncode(keyword); + // params += field.name+field.equalityOperator+StringUtils.quote(StringUtils.URIEncode(keyword)); + } + if(this.keywordFields.length > 0) { + params += " ) " + } + } + } 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 == "=") { - params+=this.createQuotedKeywordQuery(this.selectedFields[i], countParams, false); + params+=this.createQuotedKeywordQuery(this.selectedFields[i].value, this.selectedFields[i].id, this.selectedFields[i].operatorId, countParams, false); }else{ params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " ") + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + encodeURIComponent(this.selectedFields[i].value) + '"' + " "; @@ -688,26 +714,26 @@ export class NewSearchPageComponent { return params; } - createQuotedKeywordQuery(field:AdvancedField, countParams:number, isSearchAll:boolean, forceQuotted:boolean=false){ + createQuotedKeywordQuery(fieldValue, fieldId, fieldOperator, countParams:number, isSearchAll:boolean, forceQuotted:boolean=false){ let params = ""; - let quotedParts = (field.value)?field.value.match(/(["'])(.*?)*?\1/g):[]; - params+= (countParams == 0 ? "" : field.operatorId) + " ("; + let quotedParts = (fieldValue)?fieldValue.match(/(["'])(.*?)*?\1/g):[]; + params+= (countParams == 0 ? "" : fieldOperator) + " ("; if(forceQuotted){ - return this.getQuotedQueryPart(field.id, '"'+ field.value+'"',isSearchAll); + return this.getQuotedQueryPart(fieldId, '"'+ fieldValue+'"',isSearchAll); } - if(quotedParts && quotedParts.length == 1 && quotedParts[0] == field.value ){ - params+=this.getQuotedQueryPart(field.id, field.value,isSearchAll); + if(quotedParts && quotedParts.length == 1 && quotedParts[0] == fieldValue ){ + params+=this.getQuotedQueryPart(fieldId, fieldValue,isSearchAll); }else if( quotedParts && quotedParts.length > 0){ for(let i=0; i< quotedParts.length; i++){ params+=(i>0)?" and ":""; - params+=this.getQuotedQueryPart(field.id, quotedParts[i],isSearchAll); + params+=this.getQuotedQueryPart(fieldId, quotedParts[i],isSearchAll); } let startPoint = 0; let endPoint = 0; for(let i=0; i< quotedParts.length; i++){ - let index = field.value.indexOf(quotedParts[i]); - endPoint = (i+1 0) { - params += " and " + this.getNoQuotedQueryPart(field.id, field.value.substring(startPoint, endPoint), isSearchAll); + if(decodeURIComponent(fieldValue.substring(startPoint,endPoint)).split(" ").join("").length > 0) { + params += " and " + this.getNoQuotedQueryPart(fieldId, fieldValue.substring(startPoint, endPoint), isSearchAll); } // console.log("For "+i+" " +params+" SP "+ startPoint+" EP: "+endPoint); - // startPoint = (i+1 0){ - params+=" and " + this.getNoQuotedQueryPart(field.id, field.value.substring(startPoint,field.value.length),isSearchAll); + if(startPoint !=fieldValue.length && decodeURIComponent(fieldValue.substring(startPoint,fieldValue.length)).split(" ").join("").length > 0){ + params+=" and " + this.getNoQuotedQueryPart(fieldId, fieldValue.substring(startPoint,fieldValue.length),isSearchAll); } }else{ - params+=this.getNoQuotedQueryPart(field.id, field.value,isSearchAll); + params+=this.getNoQuotedQueryPart(fieldId, fieldValue,isSearchAll); } params += " )"; return params; } private getQuotedQueryPart(fieldId:string, value:string, isSearchAll:boolean){ - return " ("+(isSearchAll?"__all":fieldId)+" exact "+StringUtils.URIEncode(value)+")"; + return (isSearchAll?"__all":fieldId)+" exact "+StringUtils.URIEncode(value); } private getNoQuotedQueryPart(fieldId:string, value:string, isSearchAll:boolean){ if(isSearchAll){ - return " (" + value + ")" + return value ; }else{ - return " ("+fieldId+"="+ StringUtils.URIEncode(value)+")"; + return fieldId+"="+ StringUtils.URIEncode(value); } } @@ -751,6 +777,7 @@ export class NewSearchPageComponent { getSearchAPIQueryForRefineFields(URLparams, firstLoad: boolean) { var allFqs = ""; + console.log(this.refineFields) for (var i = 0; i < this.refineFields.length; i++) { var filterId = this.refineFields[i]; @@ -1246,12 +1273,15 @@ export class NewSearchPageComponent { * @param fieldIds * @param selectedFields * @param refineFields + * @param rangeFields * @param fieldIdsMap * @param customFilter * @param params + * @param entityType + * @param quickFilter */ prepareSearchPage(fieldIds, selectedFields, refineFields, rangeFields, fieldIdsMap, customFilter, params, entityType, quickFilter=null){ - //console.log("prepareSearchPage"); + console.log(this.refineFields); this.entityType = entityType; this.fieldIds = fieldIds; this.selectedFields = selectedFields; diff --git a/searchPages/searchUtils/searchPageTableView.component.html b/searchPages/searchUtils/searchPageTableView.component.html index 3717f3b4..8ab142b7 100644 --- a/searchPages/searchUtils/searchPageTableView.component.html +++ b/searchPages/searchUtils/searchPageTableView.component.html @@ -51,7 +51,7 @@
-
+
@@ -99,17 +99,18 @@ Clear All - +
@@ -163,7 +164,7 @@ Clear All - +
@@ -183,9 +184,21 @@
-
-
- +
+
+
+ +
+
diff --git a/services/searchDataproviders.service.ts b/services/searchDataproviders.service.ts index d849b099..ba25a1e3 100644 --- a/services/searchDataproviders.service.ts +++ b/services/searchDataproviders.service.ts @@ -36,9 +36,8 @@ export class SearchDataprovidersService { .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)])); } //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb")) - advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any { - // &type=datasources - let url = properties.searchAPIURLLAst+"resources2/?format=json"; + advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, depositQuery:boolean = false ):any { + let url = properties.searchAPIURLLAst+"resources"+(depositQuery?'':2)+"/?format=json"; if(params!= null && params != '' ) { url +="&query=(" + params + ")"; @@ -358,7 +357,7 @@ export class SearchDataprovidersService { let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1; for(let i=0; i