2018-11-27 15:13:56 +01:00
|
|
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
2017-12-20 14:34:32 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
2018-10-12 17:17:31 +02:00
|
|
|
import { Observable } from 'rxjs';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { environment } from '../../../../environments/environment';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { BaseHttpParams } from '../../../common/http/base-http-params';
|
|
|
|
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition';
|
|
|
|
import { DatasetProfileModel } from '../../model/dataset/dataset-profile';
|
|
|
|
import { DatasetWizardModel } from '../../model/dataset/dataset-wizard';
|
|
|
|
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { RequestItem } from '../../query/request-item';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { BaseHttpService } from '../http/base-http.service';
|
2017-12-20 14:34:32 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class DatasetWizardService {
|
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
private actionUrl: string;
|
2019-02-06 11:48:05 +01:00
|
|
|
private headers = new HttpHeaders();
|
2017-12-20 14:34:32 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
2018-11-27 15:13:56 +01:00
|
|
|
this.actionUrl = environment.Server + 'datasetwizard/';
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2017-12-20 14:34:32 +01:00
|
|
|
|
2019-01-31 16:53:37 +01:00
|
|
|
// public userDmps(criteria: RequestItem<DmpCriteria>): Observable<DmpModel[]> {
|
|
|
|
// return this.http.post<DmpModel[]>(this.actionUrl + 'userDmps', criteria, { headers: this.headers });
|
|
|
|
// }
|
2017-12-21 10:26:11 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public getAvailableProfiles(criteria: RequestItem<DatasetProfileCriteria>): Observable<DatasetProfileModel[]> {
|
|
|
|
return this.http.post<DatasetProfileModel[]>(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers });
|
|
|
|
}
|
2017-12-22 14:42:47 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public getSingle(id: String): Observable<DatasetWizardModel> {
|
2019-02-06 11:48:05 +01:00
|
|
|
return this.http.get<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers }); // + 'getSingle/'
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2017-12-22 14:42:47 +01:00
|
|
|
|
2019-04-01 12:42:46 +02:00
|
|
|
public getSinglePublic(id: String): Observable<DatasetWizardModel> {
|
|
|
|
return this.http.get<DatasetWizardModel>(this.actionUrl + 'public/' + id, { headers: this.headers }); // + 'getSingle/'
|
|
|
|
}
|
|
|
|
|
2018-11-30 15:57:20 +01:00
|
|
|
public delete(id: string): Observable<DatasetWizardModel> {
|
2019-01-31 16:53:37 +01:00
|
|
|
return this.http.delete<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers });
|
2018-11-30 15:57:20 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
createDataset(datasetModel: DatasetWizardModel): Observable<DatasetWizardModel> {
|
2019-01-31 16:53:37 +01:00
|
|
|
return this.http.post<DatasetWizardModel>(this.actionUrl, datasetModel, { headers: this.headers });
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-01-09 15:26:27 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
2019-02-06 11:48:05 +01:00
|
|
|
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: this.headers });
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-03-06 15:58:38 +01:00
|
|
|
|
2019-03-26 15:45:27 +01:00
|
|
|
public downloadDOCX(id: string): Observable<HttpResponse<Blob>> {
|
|
|
|
let headerDocx: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
|
|
|
|
return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDocx });
|
|
|
|
}
|
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
2019-02-06 11:48:05 +01:00
|
|
|
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
|
|
|
return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerXml }); // + 'getXml/'
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-01-25 09:14:43 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
public getDefinition(id: String): Observable<DatasetProfileDefinitionModel> {
|
|
|
|
return this.http.get<DatasetProfileDefinitionModel>(this.actionUrl + 'get/' + id, { headers: this.headers });
|
|
|
|
}
|
2018-10-12 10:22:23 +02:00
|
|
|
|
|
|
|
unlock(id: String): Observable<DatasetWizardModel> {
|
|
|
|
return this.http.get<DatasetWizardModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
|
|
|
}
|
2019-04-15 11:34:12 +02:00
|
|
|
|
2019-09-23 10:17:03 +02:00
|
|
|
public uploadXml(fileList: FileList, datasetTitle: string, dmpId: string, datasetProfileId: string): Observable<any> {
|
2019-04-15 11:34:12 +02:00
|
|
|
const formData: FormData = new FormData();
|
|
|
|
if (fileList instanceof FileList) {
|
|
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
|
|
formData.append('file', fileList[i], datasetTitle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
formData.append('file', fileList);
|
|
|
|
}
|
|
|
|
formData.append('dmpId', dmpId);
|
|
|
|
formData.append('datasetProfileId', datasetProfileId);
|
|
|
|
|
|
|
|
const params = new BaseHttpParams();
|
|
|
|
params.interceptorContext = {
|
|
|
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
|
|
|
};
|
|
|
|
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
|
|
|
|
}
|
2019-04-22 11:11:21 +02:00
|
|
|
|
|
|
|
public updateDatasetProfile(id: String): Observable<DatasetWizardModel> {
|
2019-09-23 10:17:03 +02:00
|
|
|
return this.http.get<DatasetWizardModel>(this.actionUrl + "profile/" + id, { headers: this.headers });
|
2019-04-22 11:11:21 +02:00
|
|
|
}
|
2017-12-20 14:34:32 +01:00
|
|
|
}
|