diff --git a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.html b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.html index 69f5f7fd8..afac49b0f 100644 --- a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.html +++ b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.html @@ -3,7 +3,7 @@ attachment - {{contract['@id']}} + {{contract.id}} @@ -11,36 +11,35 @@ category Asset - {{contract["edc:assetId"]}} + {{contract.assetId}} person Provider - {{contract["edc:providerId"]}} + {{contract.providerId}} draw Signing date - {{asDate(contract["edc:contractSigningDate"])}} + {{asDate(contract.mandatoryValue('edc', 'contractSigningDate'))}} - downloading Transfer - + - diff --git a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts index dd2a8e18b..0dc603879 100644 --- a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts +++ b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts @@ -1,13 +1,12 @@ import {Component, Inject, OnInit} from '@angular/core'; import { AssetService, - ContractAgreementDto, ContractAgreementService, IdResponseDto, TransferProcessService, TransferRequestDto } from "../../../mgmt-api-client"; import {from, Observable, of} from "rxjs"; -import { Asset } from "@think-it-labs/edc-connector-client"; +import { Asset, ContractAgreement } from "@think-it-labs/edc-connector-client"; import {ContractOffer} from "../../models/contract-offer"; import {filter, first, map, switchMap, tap} from "rxjs/operators"; import {NotificationService} from "../../services/notification.service"; @@ -32,7 +31,7 @@ interface RunningTransferProcess { }) export class ContractViewerComponent implements OnInit { - contracts$: Observable = of([]); + contracts$: Observable = of([]); private runningTransfers: RunningTransferProcess[] = []; private pollingHandleTransfer?: any; @@ -70,7 +69,7 @@ export class ContractViewerComponent implements OnInit { return assetId ? this.assetService.getAsset(assetId): of(); } - onTransferClicked(contract: ContractAgreementDto) { + onTransferClicked(contract: ContractAgreement) { const dialogRef = this.dialog.open(CatalogBrowserTransferDialog); dialogRef.afterClosed().pipe(first()).subscribe(result => { @@ -94,11 +93,11 @@ export class ContractViewerComponent implements OnInit { return !!this.runningTransfers.find(rt => rt.contractId === contractId); } - private createTransferRequest(contract: ContractAgreementDto, storageTypeId: string): Observable { + private createTransferRequest(contract: ContractAgreement, storageTypeId: string): Observable { return this.getContractOfferForAssetId(contract["edc:assetId"]!).pipe(map(contractOffer => { return { assetId: contractOffer.assetId, - contractId: contract["@id"], + contractId: contract.id, connectorId: "consumer", //doesn't matter, but cannot be null dataDestination: { "type": storageTypeId, diff --git a/src/modules/mgmt-api-client/api/contractAgreement.service.ts b/src/modules/mgmt-api-client/api/contractAgreement.service.ts index 239c81e8a..0f6c7cc50 100644 --- a/src/modules/mgmt-api-client/api/contractAgreement.service.ts +++ b/src/modules/mgmt-api-client/api/contractAgreement.service.ts @@ -11,24 +11,12 @@ */ /* tslint:disable:no-unused-variable member-ordering */ -import { Inject, Injectable, Optional } from '@angular/core'; -import { HttpClient, HttpHeaders, HttpParams, - HttpResponse, HttpEvent, HttpParameterCodec, HttpContext - } from '@angular/common/http'; -import { CustomHttpParameterCodec } from '../encoder'; -import { Observable } from 'rxjs'; - -// @ts-ignore -import { ApiErrorDetail } from '../model/apiErrorDetail'; -// @ts-ignore -import { ContractAgreementDto } from '../model/contractAgreementDto'; -// @ts-ignore -import { QuerySpecDto } from '../model/querySpecDto'; - -// @ts-ignore -import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; -import { Configuration } from '../configuration'; +import { Injectable } from '@angular/core'; +import { HttpResponse, HttpEvent, HttpContext } from '@angular/common/http'; +import { Observable, from } from 'rxjs'; +import { EdcConnectorClient } from '@think-it-labs/edc-connector-client'; +import { ContractAgreement, QuerySpec } from '../model' @Injectable({ @@ -36,268 +24,23 @@ import { Configuration } from '../configurat }) export class ContractAgreementService { - protected basePath = 'http://localhost'; - public defaultHeaders = new HttpHeaders(); - public configuration = new Configuration(); - public encoder: HttpParameterCodec; - - constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { - if (configuration) { - this.configuration = configuration; - } - if (typeof this.configuration.basePath !== 'string') { - if (Array.isArray(basePath) && basePath.length > 0) { - basePath = basePath[0]; - } - - if (typeof basePath !== 'string') { - basePath = this.basePath; - } - this.configuration.basePath = basePath; - } - this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); - } + private contractAgreements = this.edcConnectorClient.management.contractAgreements; + constructor(private edcConnectorClient: EdcConnectorClient) { - // @ts-ignore - private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { - if (typeof value === "object" && value instanceof Date === false) { - httpParams = this.addToHttpParamsRecursive(httpParams, value); - } else { - httpParams = this.addToHttpParamsRecursive(httpParams, value, key); - } - return httpParams; - } - - private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { - if (value == null) { - return httpParams; - } - - if (typeof value === "object") { - if (Array.isArray(value)) { - (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); - } else if (value instanceof Date) { - if (key != null) { - httpParams = httpParams.append(key, (value as Date).toISOString().substr(0, 10)); - } else { - throw Error("key may not be null if value is Date"); - } - } else { - Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( - httpParams, value[k], key != null ? `${key}.${k}` : k)); - } - } else if (key != null) { - httpParams = httpParams.append(key, value); - } else { - throw Error("key may not be null if value is not object or array"); - } - return httpParams; } /** * Gets all contract agreements according to a particular query - * @param offset - * @param limit - * @param filter - * @param sort - * @param sortField - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - * @deprecated - */ - public getAllAgreements(offset?: number, limit?: number, filter?: string, sort?: 'ASC' | 'DESC', sortField?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public getAllAgreements(offset?: number, limit?: number, filter?: string, sort?: 'ASC' | 'DESC', sortField?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public getAllAgreements(offset?: number, limit?: number, filter?: string, sort?: 'ASC' | 'DESC', sortField?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public getAllAgreements(offset?: number, limit?: number, filter?: string, sort?: 'ASC' | 'DESC', sortField?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarQueryParameters = new HttpParams({encoder: this.encoder}); - if (offset !== undefined && offset !== null) { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - offset, 'offset'); - } - if (limit !== undefined && limit !== null) { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - limit, 'limit'); - } - if (filter !== undefined && filter !== null) { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - filter, 'filter'); - } - if (sort !== undefined && sort !== null) { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - sort, 'sort'); - } - if (sortField !== undefined && sortField !== null) { - localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, - sortField, 'sortField'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/v2/contractagreements`; - return this.httpClient.request>('get', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - params: localVarQueryParameters, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Gets an contract agreement with the given ID - * @param id + * @param querySpec * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public getContractAgreement(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public getContractAgreement(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public getContractAgreement(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public getContractAgreement(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (id === null || id === undefined) { - throw new Error('Required parameter id was null or undefined when calling getContractAgreement.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/v2/contractagreements/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Gets all contract agreements according to a particular query - * @param querySpecDto - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public queryAllAgreements(querySpecDto?: QuerySpecDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public queryAllAgreements(querySpecDto?: QuerySpecDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public queryAllAgreements(querySpecDto?: QuerySpecDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; - public queryAllAgreements(querySpecDto?: QuerySpecDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/v2/contractagreements/request`; - return this.httpClient.request>('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: querySpecDto, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); + public queryAllAgreements(querySpec?: QuerySpec, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public queryAllAgreements(querySpec?: QuerySpec, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; + public queryAllAgreements(querySpec?: QuerySpec, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>>; + public queryAllAgreements(querySpec?: QuerySpec): Observable { + return from(this.contractAgreements.queryAll(querySpec)) } } diff --git a/src/modules/mgmt-api-client/api/contractNegotiation.service.ts b/src/modules/mgmt-api-client/api/contractNegotiation.service.ts index 2decfd31d..75037d92c 100644 --- a/src/modules/mgmt-api-client/api/contractNegotiation.service.ts +++ b/src/modules/mgmt-api-client/api/contractNegotiation.service.ts @@ -18,10 +18,6 @@ import { HttpClient, HttpHeaders, HttpParams, import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; -// @ts-ignore -import { ApiErrorDetail } from '../model/apiErrorDetail'; -// @ts-ignore -import { ContractAgreementDto } from '../model/contractAgreementDto'; // @ts-ignore import { ContractNegotiationDto } from '../model/contractNegotiationDto'; // @ts-ignore @@ -219,64 +215,6 @@ export class ContractNegotiationService { ); } - /** - * Gets a contract agreement for a contract negotiation with the given ID - * @param id - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public getAgreementForNegotiation(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public getAgreementForNegotiation(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public getAgreementForNegotiation(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public getAgreementForNegotiation(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (id === null || id === undefined) { - throw new Error('Required parameter id was null or undefined when calling getAgreementForNegotiation.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/v2/contractnegotiations/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/agreement`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - /** * Gets an contract negotiation with the given ID * @param id diff --git a/src/modules/mgmt-api-client/model/contractAgreementDto.ts b/src/modules/mgmt-api-client/model/contractAgreementDto.ts deleted file mode 100644 index a5015e0b2..000000000 --- a/src/modules/mgmt-api-client/model/contractAgreementDto.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * EDC REST API - * EDC REST APIs - merged by OpenApiMerger - * - * The version of the OpenAPI document: 0.0.1-SNAPSHOT - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -import { Policy } from './policy'; - - -export interface ContractAgreementDto { - "edc:assetId": string; - "edc:consumerId": string; - "edc:contractSigningDate"?: number; - "@id": string; - "edc:policy": Policy; - "edc:providerId": string; - "@context": {[key:string] : string} -} - diff --git a/src/modules/mgmt-api-client/model/models.ts b/src/modules/mgmt-api-client/model/models.ts index 69ca07f69..ef14853e5 100644 --- a/src/modules/mgmt-api-client/model/models.ts +++ b/src/modules/mgmt-api-client/model/models.ts @@ -3,7 +3,6 @@ export * from './apiErrorDetail'; export * from './catalog'; export * from './catalogRequestDto'; export * from './constraint'; -export * from './contractAgreementDto'; export * from './contractDefinitionRequestDto'; export * from './contractDefinitionResponseDto'; export * from './contractNegotiationDto';