2017-12-19 13:53:46 +01:00
|
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
2020-03-16 14:09:46 +01:00
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
2019-06-14 15:06:58 +02:00
|
|
|
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
|
2020-03-16 14:09:46 +01:00
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
2018-10-30 12:37:52 +01:00
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
2020-11-11 15:43:13 +01:00
|
|
|
import {Subscriber} from "rxjs";
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
export class FetchDataproviders {
|
|
|
|
private errorCodes: ErrorCodes;
|
2019-02-19 16:26:59 +01:00
|
|
|
private errorMessages: ErrorMessagesComponent;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public results = [];
|
|
|
|
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
|
2020-11-11 15:43:13 +01:00
|
|
|
subscriptions = [];
|
2020-03-16 14:09:46 +01:00
|
|
|
public CSV: any = {
|
|
|
|
"columnNames": ["Title", "Type", "Coutries", "Compatibility"],
|
|
|
|
"export": []
|
|
|
|
};
|
2017-12-19 13:53:46 +01:00
|
|
|
public CSVDownloaded = false;
|
|
|
|
public csvParams: string;
|
2019-02-12 12:15:21 +01:00
|
|
|
public loadPaging: boolean = true;
|
|
|
|
public oldTotalResults: number = 0;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
constructor(private _searchDataprovidersService: SearchDataprovidersService) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.errorCodes = new ErrorCodes();
|
2019-02-19 16:26:59 +01:00
|
|
|
this.errorMessages = new ErrorMessagesComponent();
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
public clearSubscriptions() {
|
|
|
|
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getResultsByKeyword(keyword: string, page: number, size: number, properties: EnvProperties, customFilter: SearchCustomFilter = null) {
|
2017-12-19 13:53:46 +01:00
|
|
|
var parameters = "";
|
2020-03-16 14:09:46 +01:00
|
|
|
if (keyword.length > 0) {
|
2018-10-30 12:37:52 +01:00
|
|
|
parameters = "q=" + StringUtils.URIEncode(keyword);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-06-14 15:06:58 +02:00
|
|
|
var refineParams = null;
|
2020-03-16 14:09:46 +01:00
|
|
|
if (customFilter) {
|
|
|
|
refineParams = (refineParams ? (refineParams + '&') : '') + "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId)));
|
2019-06-14 15:06:58 +02:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.push(this._searchDataprovidersService.searchDataproviders(parameters, refineParams, page, size, [], properties).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
//ar errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
*/
|
|
|
|
this.handleError("Error getting content providers for keyword: " + keyword, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getResultsForHome(size: number, properties: EnvProperties) {
|
2018-05-10 16:36:33 +02:00
|
|
|
let page = 1;
|
|
|
|
var parameters = "&sortBy=resultdateofacceptance,descending";//"orderby=date";
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2018-05-10 16:36:33 +02:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.searchDataproviders(parameters, null, page, size, [], properties).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers with parameters: " + parameters + " for Home", err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public getNumForEntity(entity: string, id: string, properties: EnvProperties) {
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
|
|
|
|
if (id != "" && entity != "") {
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.numOfEntityDataproviders(id, entity, properties).subscribe(
|
2018-05-10 16:36:33 +02:00
|
|
|
data => {
|
2020-03-16 14:09:46 +01:00
|
|
|
this.searchUtils.totalResults = data;
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
2018-05-10 16:36:33 +02:00
|
|
|
},
|
|
|
|
err => {
|
2020-03-16 14:09:46 +01:00
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers for " + entity + " with id: " + id, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
2018-05-10 16:36:33 +02:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2018-05-10 16:36:33 +02:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getNumForSearch(keyword: string, properties: EnvProperties, refineParams: string = null) {
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.numOfSearchDataproviders(keyword, properties, refineParams).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data;
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting number of content providers for keyword: " + keyword, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getResultsForDeposit(id: string, type: string, page: number, size: number, properties: EnvProperties) {
|
2017-12-19 13:53:46 +01:00
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2019-02-12 12:15:21 +01:00
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
this.loadPaging = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
if (id != "") {
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.searchDataprovidersForDeposit(id, type, page, size, properties).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
if (this.searchUtils.status == this.errorCodes.DONE) {
|
|
|
|
// Page out of limit!!!
|
|
|
|
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
|
|
|
}
|
|
|
|
if (totalPages < page) {
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loadPaging = true;
|
|
|
|
this.oldTotalResults = this.searchUtils.totalResults;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers in share " + type + " for organization with id: " + id, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
|
|
|
|
this.loadPaging = true;
|
|
|
|
this.oldTotalResults = 0;
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public getResultsBySubjectsForDeposit(subject: string, type: string, page: number, size: number, properties: EnvProperties) {
|
2017-12-19 13:53:46 +01:00
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2019-02-12 12:15:21 +01:00
|
|
|
this.results = [];
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
this.loadPaging = false;
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.searchDataProvidersBySubjects(subject, type, page, size, properties).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Dataproviders forDeposit: [subject:"+subject+", type:"+type+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
|
|
|
if (this.searchUtils.status == this.errorCodes.DONE) {
|
|
|
|
// Page out of limit!!!
|
|
|
|
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
if (totalPages < page) {
|
|
|
|
this.searchUtils.totalResults = 0;
|
|
|
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loadPaging = true;
|
|
|
|
this.oldTotalResults = this.searchUtils.totalResults;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers in share " + type + " by subject: " + subject, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
|
|
|
|
this.loadPaging = true;
|
|
|
|
this.oldTotalResults = 0;
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public getResultsForEntity(entity: string, id: string, page: number, size: number, properties: EnvProperties) {
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
var parameters = "";
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
if (entity == "organization") {
|
|
|
|
parameters = "organizations/" + id;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
if (parameters != "") {
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size, properties).subscribe(
|
2017-12-19 13:53:46 +01:00
|
|
|
data => {
|
2020-03-16 14:09:46 +01:00
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
},
|
|
|
|
err => {
|
2020-03-16 14:09:46 +01:00
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers for " + entity + " with id: " + id, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public getResultsForDataproviders(id: string, page: number, size: number, properties: EnvProperties) {
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
2020-11-11 15:43:13 +01:00
|
|
|
|
|
|
|
this.subscriptions.push(this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size, properties).subscribe(
|
2020-03-16 14:09:46 +01:00
|
|
|
data => {
|
|
|
|
this.searchUtils.totalResults = data[0];
|
|
|
|
//console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]");
|
|
|
|
this.results = data[1];
|
|
|
|
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
|
|
|
if (this.searchUtils.totalResults == 0) {
|
|
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
},
|
|
|
|
err => {
|
|
|
|
/*console.log(err);
|
|
|
|
//TODO check erros (service not available, bad request)
|
|
|
|
// if( ){
|
|
|
|
// this.searchUtils.status = ErrorCodes.ERROR;
|
|
|
|
// }
|
|
|
|
//var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
//this.searchUtils.status = errorCodes.ERROR;
|
|
|
|
if(err.status == '404') {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
|
|
|
} else if(err.status == '500') {
|
|
|
|
this.searchUtils.status = this.errorCodes.ERROR;
|
|
|
|
} else {
|
|
|
|
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
|
|
|
}*/
|
|
|
|
this.handleError("Error getting content providers for entity registry with id: " + id, err);
|
|
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
|
|
|
}
|
2020-11-11 15:43:13 +01:00
|
|
|
));
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2019-02-19 16:26:59 +01:00
|
|
|
private handleError(message: string, error) {
|
2020-03-16 14:09:46 +01:00
|
|
|
console.error("Fetch Content Providers (class): " + message, error);
|
2019-02-19 16:26:59 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|