2019-01-18 18:03:45 +01:00
|
|
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { environment } from '../../../../environments/environment';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { BaseHttpParams } from '../../../../common/http/base-http-params';
|
|
|
|
import { InterceptorType } from '../../../../common/http/interceptors/interceptor-type';
|
2019-08-01 09:54:40 +02:00
|
|
|
import { DynamicFieldGrantCriteria } from '../../../models/dynamic-field-grant/DynamicFieldGrantCriteria';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
|
|
|
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { DatasetProfileModel } from '../../model/dataset/dataset-profile';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { DatasetsToBeFinalized } from '../../model/dataset/datasets-toBeFinalized';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { DmpModel } from '../../model/dmp/dmp';
|
|
|
|
import { DmpListingModel } from '../../model/dmp/dmp-listing';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { DmpOverviewModel } from '../../model/dmp/dmp-overview';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
|
|
|
import { DmpCriteria } from '../../query/dmp/dmp-criteria';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { RequestItem } from '../../query/request-item';
|
|
|
|
import { BaseHttpService } from '../http/base-http.service';
|
2020-03-26 17:44:12 +01:00
|
|
|
import { ConfigurationService } from '../configuration/configuration.service';
|
2020-07-07 11:22:45 +02:00
|
|
|
import { UserInfoListingModel } from '@app/core/model/user/user-info-listing';
|
2020-07-09 13:28:55 +02:00
|
|
|
import { VersionListingModel } from '@app/core/model/version/version-listing.model';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class DmpService {
|
|
|
|
|
|
|
|
private actionUrl: string;
|
2019-02-06 11:46:14 +01:00
|
|
|
private headers = new HttpHeaders();
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2020-03-26 17:44:12 +01:00
|
|
|
constructor(private http: BaseHttpService, private httpClient: HttpClient, private configurationService: ConfigurationService) {
|
|
|
|
this.actionUrl = configurationService.server + 'dmps/';
|
2019-02-06 11:46:14 +01:00
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
2019-01-31 14:56:53 +01:00
|
|
|
getPaged(dataTableRequest: DataTableRequest<DmpCriteria>, fieldsGroup?: string): Observable<DataTableData<DmpListingModel>> {
|
|
|
|
if (fieldsGroup) {
|
|
|
|
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers });
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers });
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getSingle(id: String): Observable<DmpModel> {
|
2019-01-29 12:05:36 +01:00
|
|
|
return this.http.get<DmpModel>(this.actionUrl + id, { headers: this.headers }); //'getSingle/' +
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 16:05:15 +02:00
|
|
|
getSinglePublic(id: String): Observable<DmpModel> {
|
|
|
|
return this.http.get<DmpModel>(this.actionUrl + 'public/' + id, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
2019-06-11 10:25:32 +02:00
|
|
|
getOverviewSingle(id: string): Observable<DmpOverviewModel> {
|
2019-05-21 15:42:28 +02:00
|
|
|
return this.http.get<DmpOverviewModel>(this.actionUrl + 'overview/' + id, { headers: this.headers });
|
2019-05-17 17:21:56 +02:00
|
|
|
}
|
|
|
|
|
2019-06-11 10:25:32 +02:00
|
|
|
getOverviewSinglePublic(id: string): Observable<DmpOverviewModel> {
|
|
|
|
return this.http.get<DmpOverviewModel>(this.actionUrl + 'publicOverview/' + id, { headers: this.headers })
|
|
|
|
}
|
|
|
|
|
2020-07-09 13:28:55 +02:00
|
|
|
getAllVersions(id: string): Observable<VersionListingModel[]> {
|
|
|
|
return this.http.get<VersionListingModel[]>(this.actionUrl + 'versions/' + id, { headers: this.headers })
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
unlock(id: String): Observable<DmpModel> {
|
|
|
|
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
|
|
|
}
|
2019-03-05 12:59:34 +01:00
|
|
|
|
2019-07-02 12:19:15 +02:00
|
|
|
createDmp(dataManagementPlanModel: DmpModel): Observable<String> {
|
|
|
|
return this.http.post<String>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
2020-07-27 12:09:30 +02:00
|
|
|
createDmpWithDatasets(dataManagementPlanModel: DmpModel): Observable<String> {
|
|
|
|
return this.http.post<String>(this.actionUrl + 'full', dataManagementPlanModel, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
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> {
|
2019-01-29 12:05:36 +01:00
|
|
|
return this.http.delete<DmpModel>(this.actionUrl + id, { headers: this.headers }); // + 'delete/'
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
publish(id: String): Observable<DmpModel> {
|
|
|
|
return this.http.get<DmpModel>(this.actionUrl + 'makepublic/' + id, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
|
|
|
finalize(datasetsToBeFinalized: DatasetsToBeFinalized, id: String): Observable<DmpModel> {
|
|
|
|
return this.http.post<DmpModel>(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
2020-07-27 12:09:30 +02:00
|
|
|
unfinalize(id: String): Observable<DmpModel> {
|
2020-05-26 13:31:47 +02:00
|
|
|
return this.http.post<DmpModel>(this.actionUrl + 'unfinalize/' + id, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
2020-07-07 11:22:45 +02:00
|
|
|
updateUsers(id: string, users: UserInfoListingModel[]): Observable<DmpModel> {
|
2020-07-27 12:09:30 +02:00
|
|
|
return this.http.post<DmpModel>(`${this.actionUrl}updateusers/${id}`, users, { headers: this.headers });
|
2020-07-07 11:22:45 +02:00
|
|
|
}
|
|
|
|
|
2019-07-05 13:01:24 +02:00
|
|
|
getDoi(id: string): Observable<string> {
|
2019-09-23 10:17:03 +02:00
|
|
|
return this.http.post<string>(this.actionUrl + 'createZenodoDoi/' + id, { headers: this.headers });
|
2019-07-05 13:01:24 +02:00
|
|
|
}
|
|
|
|
|
2019-08-01 09:54:40 +02:00
|
|
|
getDynamicField(requestItem: RequestItem<DynamicFieldGrantCriteria>): any {
|
2019-01-18 18:03:45 +01:00
|
|
|
return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers });
|
|
|
|
}
|
|
|
|
|
|
|
|
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
2019-02-06 11:46:14 +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/"
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public downloadDocx(id: string): Observable<HttpResponse<Blob>> {
|
2019-02-06 11:46:14 +01:00
|
|
|
let headerDoc: HttpHeaders = this.headers.set('Content-Type', 'application/msword')
|
|
|
|
return this.httpClient.get(this.actionUrl + id, { responseType: 'blob', observe: 'response', headers: headerDoc });
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public downloadPDF(id: string): Observable<HttpResponse<Blob>> {
|
2019-02-06 11:46:14 +01:00
|
|
|
let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf')
|
|
|
|
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf });
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|
2019-03-05 12:59:34 +01:00
|
|
|
|
2019-06-04 16:04:04 +02:00
|
|
|
public downloadJson(id: string): Observable<HttpResponse<Blob>> {
|
|
|
|
return this.httpClient.get(this.actionUrl + 'rda/' + id, { responseType: 'blob', observe: 'response' });
|
|
|
|
}
|
|
|
|
|
2020-05-29 12:39:18 +02:00
|
|
|
public uploadXml(fileList: FileList, dmpTitle: string, dmpProfiles: any[]): Observable<any> {
|
2019-03-05 12:59:34 +01:00
|
|
|
const formData: FormData = new FormData();
|
|
|
|
if (fileList instanceof FileList) {
|
|
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
|
|
formData.append('file', fileList[i], dmpTitle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
formData.append('file', fileList);
|
|
|
|
}
|
2020-05-29 12:39:18 +02:00
|
|
|
for (let j = 0; j < dmpProfiles.length; j++) {
|
|
|
|
formData.append('profiles', dmpProfiles[j].id);
|
|
|
|
}
|
2019-03-05 12:59:34 +01:00
|
|
|
const params = new BaseHttpParams();
|
|
|
|
params.interceptorContext = {
|
|
|
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
|
|
|
};
|
|
|
|
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
|
|
|
|
}
|
2019-04-26 16:05:15 +02:00
|
|
|
|
2019-06-11 10:25:32 +02:00
|
|
|
getPublicPaged(dataTableRequest: DataTableRequest<ExploreDmpCriteriaModel>, fieldsGroup?: string): Observable<DataTableData<DmpListingModel>> {
|
|
|
|
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'public/paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers });
|
2019-04-26 16:05:15 +02:00
|
|
|
}
|
2019-06-12 11:13:50 +02:00
|
|
|
|
|
|
|
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {
|
|
|
|
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetProfilesUsedByDmps/paged', dataTableRequest);
|
|
|
|
}
|
2020-04-01 17:16:06 +02:00
|
|
|
|
|
|
|
generateIndex() {
|
|
|
|
return this.http.post(this.actionUrl + 'index', {});
|
|
|
|
}
|
|
|
|
|
|
|
|
clearIndex() {
|
|
|
|
return this.http.delete(this.actionUrl + 'index');
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|