81 lines
3.7 KiB
TypeScript
81 lines
3.7 KiB
TypeScript
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||
|
import { Injectable } from '@angular/core';
|
||
|
import { Observable } from 'rxjs';
|
||
|
import { environment } from '../../../../environments/environment';
|
||
|
import { DynamicFieldProjectCriteria } from '../../../models/dynamic-field-project/DynamicFieldProjectCriteria';
|
||
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
||
|
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||
|
import { DatasetProfileModel } from '../../model/dataset/dataset-profile';
|
||
|
import { DmpModel } from '../../model/dmp/dmp';
|
||
|
import { DmpListingModel } from '../../model/dmp/dmp-listing';
|
||
|
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
||
|
import { DmpCriteria } from '../../query/dmp/dmp-criteria';
|
||
|
import { RequestItem } from '../../query/request-item';
|
||
|
import { BaseHttpService } from '../http/base-http.service';
|
||
|
|
||
|
@Injectable()
|
||
|
export class DmpService {
|
||
|
|
||
|
private actionUrl: string;
|
||
|
private headers: HttpHeaders;
|
||
|
|
||
|
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||
|
this.actionUrl = environment.Server + 'dmps/';
|
||
|
}
|
||
|
|
||
|
getPaged(dataTableRequest: DataTableRequest<DmpCriteria>): Observable<DataTableData<DmpListingModel>> {
|
||
|
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
getSingle(id: String): Observable<DmpModel> {
|
||
|
return this.http.get<DmpModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
unlock(id: String): Observable<DmpModel> {
|
||
|
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||
|
}
|
||
|
createDmp(dataManagementPlanModel: DmpModel): Observable<DmpModel> {
|
||
|
return this.http.post<DmpModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
inactivate(id: String): Observable<DmpModel> {
|
||
|
return this.http.delete<DmpModel>(this.actionUrl + 'inactivate/' + id, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
searchDMPProfiles(dataSetProfileRequest: RequestItem<DatasetProfileCriteria>): Observable<DatasetProfileModel[]> {
|
||
|
return this.http.post<DatasetProfileModel[]>(this.actionUrl + 'datasetprofiles/get', dataSetProfileRequest, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
newVersion(dataManagementPlanModel: DmpModel, id: String): Observable<DmpModel> {
|
||
|
return this.http.post<DmpModel>(this.actionUrl + 'new/' + id, dataManagementPlanModel, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
clone(dataManagementPlanModel: DmpModel, id: String): Observable<DmpModel> {
|
||
|
return this.http.post<DmpModel>(this.actionUrl + 'clone/' + id, dataManagementPlanModel, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
delete(id: String): Observable<DmpModel> {
|
||
|
return this.http.delete<DmpModel>(this.actionUrl + 'delete/' + id, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
getDynamicField(requestItem: RequestItem<DynamicFieldProjectCriteria>): any {
|
||
|
return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
get(requestItem: RequestItem<DmpCriteria>): Observable<DmpListingModel[]> {
|
||
|
return this.http.post<DmpListingModel[]>(this.actionUrl + 'get', requestItem, { headers: this.headers });
|
||
|
}
|
||
|
|
||
|
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||
|
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response' });
|
||
|
}
|
||
|
|
||
|
public downloadDocx(id: string): Observable<HttpResponse<Blob>> {
|
||
|
return this.httpClient.get(this.actionUrl + 'getWord/' + id, { responseType: 'blob', observe: 'response' });
|
||
|
}
|
||
|
|
||
|
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
||
|
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response' });
|
||
|
}
|
||
|
}
|