Skip to content

Commit

Permalink
chore: remove legacy asset property "originator"
Browse files Browse the repository at this point in the history
- it used to be a hack in MS7 to include the endpoint in assets
- this property will be removed in our EDC 0 compatible EDC
  • Loading branch information
richardtreier committed Aug 28, 2023
1 parent 60b2898 commit bd60199
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ export class AssetPropertyGridGroupBuilder {
return {
icon: 'link',
label: 'Connector Endpoint',
labelTitle: AssetProperties.originator,
...this.propertyGridUtils.guessValue(endpoint),
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/core/services/api/contract-offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class ContractOfferService {
): ContractOffer {
return {
...contractOfferDto,
asset: this.assetPropertyMapper.buildAssetFromProperties(
contractOfferDto.asset.properties,
{connectorEndpoint},
),
asset: this.assetPropertyMapper.buildAsset({
connectorEndpoint,
properties: contractOfferDto.asset.properties,
}),
};
}
}
1 change: 0 additions & 1 deletion src/app/core/services/asset-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const AssetProperties = {
id: `${edc}id`,
name: `${sovity}name`,
contentType: `${sovity}contenttype`,
originator: `${sovity}originator`,
originatorOrganization: `${sovity}originatorOrganization`,
description: `${sovity}description`,
version: `${sovity}version`,
Expand Down
14 changes: 6 additions & 8 deletions src/app/core/services/asset-property-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export class AssetPropertyMapper {
private activeFeatureSet: ActiveFeatureSet,
) {}

buildAssetFromProperties(
props: Record<string, string | null>,
opts?: {connectorEndpoint?: string},
): Asset {
buildAsset(opts: {
connectorEndpoint: string;
properties: Record<string, string | null>;
}): Asset {
const props = opts.properties;
const language = props[AssetProperties.language]
? this.languageSelectItemService.findById(
props[AssetProperties.language]!,
Expand Down Expand Up @@ -64,7 +65,7 @@ export class AssetPropertyMapper {
name: props[AssetProperties.name] ?? id,
version: props[AssetProperties.version],
contentType: props[AssetProperties.contentType],
originator: opts?.connectorEndpoint ?? props[AssetProperties.originator],
originator: opts.connectorEndpoint,
originatorOrganization:
props[AssetProperties.curatorOrganizationName] ??
'Unknown Organization',
Expand Down Expand Up @@ -109,9 +110,6 @@ export class AssetPropertyMapper {
props[AssetProperties.id] = trimmedOrNull(metadata?.id);
props[AssetProperties.name] = trimmedOrNull(metadata?.name);
props[AssetProperties.version] = trimmedOrNull(metadata?.version);
props[AssetProperties.originator] = trimmedOrNull(
this.config.connectorEndpoint,
);
props[AssetProperties.curatorOrganizationName] = trimmedOrNull(
this.config.curatorOrganizationName,
);
Expand Down
21 changes: 12 additions & 9 deletions src/app/core/services/asset-service-mapped.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Injectable} from '@angular/core';
import {Inject, Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {APP_CONFIG, AppConfig} from '../config/app-config';
import {EdcApiService} from './api/edc-api.service';
import {AssetPropertyMapper} from './asset-property-mapper';
import {Asset} from './models/asset';
Expand All @@ -13,19 +14,21 @@ import {Asset} from './models/asset';
})
export class AssetServiceMapped {
constructor(
@Inject(APP_CONFIG) private config: AppConfig,
private assetPropertyMapper: AssetPropertyMapper,
private edcApiService: EdcApiService,
) {}

fetchAssets(): Observable<Asset[]> {
return this.edcApiService
.getAssetPage()
.pipe(
map((assetPage) =>
assetPage.assets.map((asset) =>
this.assetPropertyMapper.buildAssetFromProperties(asset.properties),
),
return this.edcApiService.getAssetPage().pipe(
map((assetPage) =>
assetPage.assets.map((asset) =>
this.assetPropertyMapper.buildAsset({
connectorEndpoint: this.config.connectorEndpoint,
properties: asset.properties,
}),
),
);
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export class BrokerCatalogMapper {
private buildUiDataOffer(offer: CatalogDataOffer): BrokerDataOffer {
return {
...offer,
asset: this.assetPropertyMapper.buildAssetFromProperties(
offer.properties,
),
asset: this.assetPropertyMapper.buildAsset({
connectorEndpoint: offer.connectorEndpoint,
properties: offer.properties,
}),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {BehaviorSubject, Subject} from 'rxjs';
import {filter, map, switchMap} from 'rxjs/operators';
import {AssetDetailDialogDataService} from '../../../../component-library/catalog/asset-detail-dialog/asset-detail-dialog-data.service';
import {AssetDetailDialogService} from '../../../../component-library/catalog/asset-detail-dialog/asset-detail-dialog.service';
import {EdcApiService} from '../../../../core/services/api/edc-api.service';
import {AssetPropertyMapper} from '../../../../core/services/asset-property-mapper';
import {AssetServiceMapped} from '../../../../core/services/asset-service-mapped';
import {Asset} from '../../../../core/services/models/asset';
import {Fetched} from '../../../../core/services/models/fetched';
import {AssetCreateDialogResult} from '../asset-create-dialog/asset-create-dialog-result';
Expand All @@ -27,28 +26,23 @@ export class AssetPageComponent implements OnInit, OnDestroy {
private fetch$ = new BehaviorSubject(null);

constructor(
private edcApiService: EdcApiService,
private assetServiceMapped: AssetServiceMapped,
private assetDetailDialogDataService: AssetDetailDialogDataService,
private assetDetailDialogService: AssetDetailDialogService,
private dialog: MatDialog,
private assetPropertyMapper: AssetPropertyMapper,
) {}

ngOnInit(): void {
this.fetch$
.pipe(
switchMap(() => {
return this.edcApiService.getAssetPage().pipe(
return this.assetServiceMapped.fetchAssets().pipe(
map(
(assetPage): AssetList => ({
filteredAssets: assetPage.assets
.map((asset) =>
this.assetPropertyMapper.buildAssetFromProperties(
asset.properties,
),
)
.filter((asset) => asset.name?.includes(this.searchText)),
numTotalAssets: assetPage.assets.length,
(assets): AssetList => ({
filteredAssets: assets.filter((asset) =>
asset.name?.includes(this.searchText),
),
numTotalAssets: assets.length,
}),
),
Fetched.wrap({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class ContractAgreementCardMappedService {
buildContractAgreementCardMapped(
contractAgreement: ContractAgreementCard,
): ContractAgreementCardMapped {
let asset = this.assetPropertyMapper.buildAssetFromProperties(
contractAgreement.asset.properties,
{connectorEndpoint: contractAgreement.counterPartyAddress},
);
let asset = this.assetPropertyMapper.buildAsset({
connectorEndpoint: contractAgreement.counterPartyAddress,
properties: contractAgreement.asset.properties,
});

return {
...contractAgreement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import {Component, OnDestroy, OnInit} from '@angular/core';
import {MatDialogRef} from '@angular/material/dialog';
import {Subject} from 'rxjs';
import {finalize, takeUntil} from 'rxjs/operators';
import {EdcApiService} from '../../../../core/services/api/edc-api.service';
import {
ContractDefinitionService,
PolicyDefinition,
PolicyService,
} from '../../../../core/services/api/legacy-managent-api-client';
import {AssetEntryBuilder} from '../../../../core/services/asset-entry-builder';
import {AssetPropertyMapper} from '../../../../core/services/asset-property-mapper';
import {AssetServiceMapped} from '../../../../core/services/asset-service-mapped';
import {ContractDefinitionBuilder} from '../../../../core/services/contract-definition-builder';
import {Asset} from '../../../../core/services/models/asset';
import {NotificationService} from '../../../../core/services/notification.service';
Expand All @@ -28,11 +27,10 @@ export class ContractDefinitionEditorDialog implements OnInit, OnDestroy {
loading = false;

constructor(
private edcApiService: EdcApiService,
private assetServiceMapped: AssetServiceMapped,
public form: ContractDefinitionEditorDialogForm,
private notificationService: NotificationService,
private policyService: PolicyService,
private assetPropertyMapper: AssetPropertyMapper,
private contractDefinitionService: ContractDefinitionService,
private contractDefinitionBuilder: ContractDefinitionBuilder,
private dialogRef: MatDialogRef<ContractDefinitionEditorDialog>,
Expand All @@ -46,13 +44,11 @@ export class ContractDefinitionEditorDialog implements OnInit, OnDestroy {
.subscribe((polices) => {
this.policies = polices;
});
this.edcApiService
.getAssetPage()
this.assetServiceMapped
.fetchAssets()
.pipe(takeUntil(this.ngOnDestroy$))
.subscribe((assetPage) => {
this.assets = assetPage.assets.map((it) =>
this.assetPropertyMapper.buildAssetFromProperties(it.properties),
);
.subscribe((assets) => {
this.assets = assets;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<a
class="link"
href="javascript:void(0)"
(click)="onAssetDetailsClick(item.transferProcessId)">
(click)="onAssetDetailsClick(item)">
<mat-icon class="mat-icon-[14px]">open_in_new</mat-icon>
<div>
{{ item.assetName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ export class TransferHistoryPageComponent implements OnInit, OnDestroy {
);
}

loadAssetDetails(transferProcessId: string): Observable<Asset> {
loadAssetDetails(item: TransferHistoryEntry): Observable<Asset> {
return this.edcApiService
.getTransferProcessAsset(transferProcessId)
.getTransferProcessAsset(item.transferProcessId)
.pipe(
map((asset) =>
this.assetPropertyMapper.buildAssetFromProperties(asset.properties),
this.assetPropertyMapper.buildAsset({
connectorEndpoint: item.counterPartyConnectorEndpoint,
properties: asset.properties,
}),
),
);
}

onAssetDetailsClick(transferProcessId: string) {
this.loadAssetDetails(transferProcessId).subscribe({
onAssetDetailsClick(item: TransferHistoryEntry) {
this.loadAssetDetails(item).subscribe({
next: (asset) => {
const data = this.assetDetailDialogDataService.assetDetails(
asset,
Expand Down

0 comments on commit bd60199

Please sign in to comment.