Skip to content

Commit f881e90

Browse files
committed
Merge branch 'feature/422762_adapt_catalog' into 'develop'
feature/422762_adapt_catalog See merge request upm-inesdata/connector-management-interface!5
2 parents 557463c + 6fd0c94 commit f881e90

File tree

8 files changed

+84
-77
lines changed

8 files changed

+84
-77
lines changed

src/app/pages/catalog/catalog-browser/catalog-browser.component.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
</div>
1818

1919
<div fxLayout="row wrap" fxLayoutAlign="start start">
20-
<mat-card *ngFor="let contractOffer of filteredContractOffers" class="asset-card">
2120

21+
<mat-card *ngFor="let contractOffer of filteredContractOffers" class="asset-card">
2222
<mat-card-header>
2323
<mat-icon mat-card-avatar>sim_card</mat-icon>
2424
<mat-card-title>{{contractOffer.properties.name}}</mat-card-title>
@@ -73,8 +73,14 @@
7373

7474
</mat-card-content>
7575

76-
<mat-divider inset></mat-divider>
76+
<mat-divider></mat-divider>
7777
<mat-card-actions class="card-actions">
78+
<button
79+
[disabled]="isBusy(contractOffer) || isNegotiated(contractOffer)"
80+
color="accent" mat-stroked-button>
81+
<mat-icon>drive_file_rename_outline</mat-icon>
82+
Negotiate
83+
</button>
7884
</mat-card-actions>
7985
<mat-card-footer>
8086
<mat-progress-bar *ngIf="isBusy(contractOffer)" color="accent" mode="indeterminate"></mat-progress-bar>

src/app/pages/catalog/catalog-browser/catalog-browser.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ mat-paginator {
4242
align-items: center;
4343
gap: 10px;
4444
}
45+
46+
mat-expansion-panel {
47+
margin-bottom: 10px !important;
48+
}

src/app/pages/catalog/catalog-browser/catalog-browser.component.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {Component, Inject, OnInit} from '@angular/core';
2-
import {MatDialog} from '@angular/material/dialog';
3-
import {BehaviorSubject, Observable, of} from 'rxjs';
4-
import {map, switchMap} from 'rxjs/operators';
5-
import {CatalogBrowserService} from "../../../shared/services/catalog-browser.service";
6-
import {NotificationService} from "../../../shared/services/notification.service";
7-
import {Router} from "@angular/router";
8-
import {TransferProcessStates} from "../../../shared/models/transfer-process-states";
9-
import {ContractOffer} from "../../../shared/models/contract-offer";
10-
import {NegotiationResult} from "../../../shared/models/negotiation-result";
11-
import {ContractNegotiation, ContractNegotiationRequest} from "../../../shared/models/edc-connector-entities";
1+
import { Component, Inject, OnInit } from '@angular/core';
2+
import { MatDialog } from '@angular/material/dialog';
3+
import { BehaviorSubject, Observable, of } from 'rxjs';
4+
import { map, switchMap } from 'rxjs/operators';
5+
import { CatalogBrowserService } from "../../../shared/services/catalog-browser.service";
6+
import { NotificationService } from "../../../shared/services/notification.service";
7+
import { Router } from "@angular/router";
8+
import { TransferProcessStates } from "../../../shared/models/transfer-process-states";
9+
import { ContractOffer } from "../../../shared/models/contract-offer";
10+
import { NegotiationResult } from "../../../shared/models/negotiation-result";
11+
import { ContractNegotiation, ContractNegotiationRequest } from "../../../shared/models/edc-connector-entities";
1212

1313
interface RunningTransferProcess {
1414
processId: string;
@@ -32,17 +32,17 @@ export class CatalogBrowserComponent implements OnInit {
3232
private pollingHandleNegotiation?: any;
3333

3434
constructor(private apiService: CatalogBrowserService,
35-
public dialog: MatDialog,
36-
private router: Router,
37-
private notificationService: NotificationService,
38-
@Inject('HOME_CONNECTOR_STORAGE_ACCOUNT') private homeConnectorStorageAccount: string) {
35+
public dialog: MatDialog,
36+
private router: Router,
37+
private notificationService: NotificationService,
38+
@Inject('HOME_CONNECTOR_STORAGE_ACCOUNT') private homeConnectorStorageAccount: string) {
3939
}
4040

4141
ngOnInit(): void {
4242
this.filteredContractOffers$ = this.fetch$
4343
.pipe(
4444
switchMap(() => {
45-
const contractOffers$ = this.apiService.getContractOffersFromConnector();
45+
const contractOffers$ = this.apiService.getContractOffers();
4646
return !!this.searchText ?
4747
contractOffers$.pipe(map(contractOffers => contractOffers.filter(contractOffer => contractOffer.id.toLowerCase().includes(this.searchText))))
4848
:

src/app/pages/contracts/contract-viewer/contract-viewer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ContractViewerComponent implements OnInit {
7474
*/
7575
private getContractOfferForAssetId(assetId: string): Observable<ContractOffer> {
7676
//return this.catalogService.getContractOffers()
77-
return this.catalogService.getContractOffersFromConnector()
77+
return this.catalogService.getContractOffers()
7878
.pipe(
7979
map(offers => offers.find(o => o.assetId === assetId)),
8080
map(o => {

src/app/shared/models/catalog.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { DataService } from "./data-service";
44
export interface Catalog {
55
id?: string;
66
assets?: Array<Asset>;
7-
"dcat:dataset": Array<any>;
7+
"http://www.w3.org/ns/dcat#dataset": Array<any>;
88
"dcat:service": DataService;
9-
"edc:originator"?: string;
9+
"originator": string;
10+
participantId: string;
1011
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import {PolicyInput} from "./edc-connector-entities";
2+
import {DataService} from "./data-service";
23

34
export interface ContractOffer {
45
id: string;
5-
policy: PolicyInput;
6-
originator: string;
76
assetId: string;
87
properties: any;
8+
"dcat:dataset": Array<any>;
9+
"dcat:service": DataService;
10+
policy: PolicyInput;
11+
originator: string;
912
}

src/app/shared/services/catalog-browser.service.ts

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,59 +35,60 @@ export class CatalogBrowserService {
3535
@Inject(CONNECTOR_CATALOG_API) private catalogApiUrl: string) {
3636
}
3737

38-
getContractOffersFromConnector(): Observable<ContractOffer[]> {
38+
getContractOffers(): Observable<ContractOffer[]> {
3939
let url = this.catalogApiUrl || this.managementApiUrl;
40-
return this.post<Catalog>(url + "/v2/catalog/request").pipe(
41-
map(catalog => {
42-
const arr: ContractOffer[] = [];
43-
let datasets = catalog["dcat:dataset"];
44-
40+
return this.post<Catalog[]>(url)
41+
.pipe(map(catalogs => catalogs.map(catalog => {
42+
const arr = Array<ContractOffer>();
43+
let datasets = catalog["http://www.w3.org/ns/dcat#dataset"];
4544
if (!Array.isArray(datasets)) {
4645
datasets = [datasets];
4746
}
4847

49-
datasets.forEach(dataSet => {
50-
const properties: { [key: string]: string } = {
51-
id: dataSet["id"],
52-
name: dataSet["name"],
53-
version: dataSet["version"],
54-
type: dataSet["type"],
55-
contentType: dataSet["contenttype"]
48+
for (const dataset of datasets) {
49+
const properties: { [key: string]: string; } = {
50+
id: dataset["id"],
51+
name: dataset["name"],
52+
version: dataset["version"],
53+
type: dataset["type"],
54+
contentType: dataset["contenttype"]
55+
}
56+
const assetId = dataset["@id"];
57+
58+
const hasPolicy = dataset["odrl:hasPolicy"];
59+
const policy: PolicyInput = {
60+
"@type": "set",
61+
"@context": "http://www.w3.org/ns/odrl.jsonld",
62+
"uid": hasPolicy["@id"],
63+
"assignee": hasPolicy["assignee"],
64+
"assigner": hasPolicy["assigner"],
65+
"obligation": hasPolicy["odrl:obligations"],
66+
"permission": hasPolicy["odrl:permissions"],
67+
"prohibition": hasPolicy["odrl:prohibitions"],
68+
"target": hasPolicy["odrl:target"]
5669
};
5770

58-
const assetId = dataSet["@id"];
59-
const hasPolicy = dataSet["odrl:hasPolicy"];
60-
61-
62-
63-
hasPolicy.forEach((element: PolicyElement) => {
64-
const policy: PolicyInput = {
65-
"@type": "set",
66-
"@context": "http://www.w3.org/ns/odrl.jsonld",
67-
"uid": element["@id"],
68-
"assignee": element["assignee"],
69-
"assigner": element["assigner"],
70-
"obligation": element["odrl:obligations"],
71-
"permission": element["odrl:permissions"],
72-
"prohibition": element["odrl:prohibitions"],
73-
"target": element["odrl:target"]
74-
};
75-
76-
const newContractOffer: ContractOffer = {
77-
assetId: assetId,
78-
properties: properties,
79-
id: hasPolicy["@id"],
80-
originator: catalog["edc:originator"] ?? catalog["dcat:service"]["endpointUrl"],
81-
policy: policy
82-
};
83-
84-
arr.push(newContractOffer);
85-
});
86-
});
71+
const newContractOffer: ContractOffer = {
72+
assetId: assetId,
73+
properties: properties,
74+
"dcat:service": catalog["dcat:service"],
75+
"dcat:dataset": datasets,
76+
id: hasPolicy["@id"],
77+
originator: catalog["originator"],
78+
policy: policy
79+
};
8780

81+
arr.push(newContractOffer)
82+
}
8883
return arr;
89-
})
90-
);
84+
})), reduce((acc, val) => {
85+
for (const subArray of val) {
86+
for (const item of subArray) {
87+
acc.push(item);
88+
}
89+
}
90+
return acc;
91+
}, new Array<ContractOffer>()));
9192
}
9293

9394
initiateTransfer(transferRequest: TransferProcessInput): Observable<string> {
@@ -110,16 +111,8 @@ export class CatalogBrowserService {
110111
params?: HttpParams | { [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>; })
111112
: Observable<T> {
112113
const url = `${urlPath}`;
113-
const fetchCatalogData = {
114-
"@context": {
115-
"@vocab": "https://w3id.org/edc/v0.0.1/ns/"
116-
},
117-
"counterPartyAddress": "http://localhost:19194/protocol",
118-
"protocol": "dataspace-protocol-http"
119-
};
120114
let headers = new HttpHeaders({"Content-type": "application/json"});
121-
//return this.catchError(this.httpClient.post<T>(url, "{\"edc:operandLeft\": \"\",\"edc:operandRight\": \"\",\"edc:operator\": \"\",\"edc:Criterion\":\"\"}", {headers, params}), url, 'POST');
122-
return this.catchError(this.httpClient.post<T>(url, fetchCatalogData, {headers, params}), url, 'POST');
115+
return this.catchError(this.httpClient.post<T>(url, "{\"edc:operandLeft\": \"\",\"edc:operandRight\": \"\",\"edc:operator\": \"\",\"edc:Criterion\":\"\"}", {headers, params}), url, 'POST');
123116
}
124117

125118
private catchError<T>(observable: Observable<T>, url: string, method: string): Observable<T> {

src/assets/config/app.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"apiKey": "ApiKeyDefaultValue",
33
"managementApiUrl": "http://localhost:29193/management",
4-
"catalogUrl": "http://localhost:29193/management",
4+
"catalogUrl": "http://localhost:29193/management/federatedcatalog",
55
"storageAccount": "company2assets",
66
"storageExplorerLinkTemplate": "storageexplorer://v=1",
77
"theme": "theme-2"

0 commit comments

Comments
 (0)