forked from eclipse-edc/DataDashboard
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
4,012 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/app/core/services/asset-data-source-mapper-legacy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {UiDataSource} from '@sovity.de/edc-client'; | ||
import {AssetDatasourceFormValue} from '../../routes/connector-ui/asset-page/asset-edit-dialog/form/model/asset-datasource-form-model'; | ||
import {HttpDatasourceHeaderFormValue} from '../../routes/connector-ui/asset-page/asset-edit-dialog/form/model/http-datasource-header-form-model'; | ||
import {getAuthFields} from '../utils/form-value-utils'; | ||
import {QueryParamsMapper} from './query-params-mapper'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class AssetDataSourceMapperLegacy { | ||
constructor(private queryParamsMapper: QueryParamsMapper) {} | ||
|
||
buildDataSourceOrNullLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource | null { | ||
if (formValue.dataAddressType === 'Unchanged') { | ||
return null; | ||
} | ||
return this.buildDataSourceLegacy(formValue); | ||
} | ||
|
||
buildDataSourceLegacy(formValue: AssetDatasourceFormValue): UiDataSource { | ||
switch (formValue?.dataAddressType) { | ||
case 'Custom-Data-Address-Json': | ||
return this.buildCustomDataSourceLegacy(formValue); | ||
case 'On-Request': | ||
return this.buildOnRequestDataSourceLegacy(formValue); | ||
case 'Http': | ||
return this.buildHttpDataSourceLegacy(formValue); | ||
default: | ||
throw new Error( | ||
`Invalid Data Address Type ${formValue?.dataAddressType}`, | ||
); | ||
} | ||
} | ||
|
||
private buildCustomDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
const json = JSON.parse(formValue.dataDestination?.trim()!!); | ||
return { | ||
type: 'CUSTOM', | ||
customProperties: json, | ||
}; | ||
} | ||
|
||
private buildHttpDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
const baseUrl = this.queryParamsMapper.getBaseUrlWithoutQueryParams( | ||
formValue.httpUrl!, | ||
)!; | ||
const queryString = this.queryParamsMapper.getFullQueryString( | ||
formValue.httpUrl!, | ||
formValue.httpQueryParams ?? [], | ||
); | ||
|
||
const authFields = getAuthFields(formValue); | ||
|
||
return { | ||
type: 'HTTP_DATA', | ||
httpData: { | ||
method: formValue.httpMethod, | ||
baseUrl, | ||
queryString: queryString ?? undefined, | ||
authHeaderName: authFields.authHeaderName ?? undefined, | ||
authHeaderValue: { | ||
secretName: authFields.authHeaderSecretName ?? undefined, | ||
rawValue: authFields.authHeaderValue ?? undefined, | ||
}, | ||
headers: this.buildHttpHeaders(formValue.httpHeaders ?? []), | ||
enableMethodParameterization: formValue.httpProxyMethod, | ||
enablePathParameterization: formValue.httpProxyPath, | ||
enableQueryParameterization: formValue.httpProxyQueryParams, | ||
enableBodyParameterization: formValue.httpProxyBody, | ||
}, | ||
}; | ||
} | ||
|
||
private buildOnRequestDataSourceLegacy( | ||
formValue: AssetDatasourceFormValue, | ||
): UiDataSource { | ||
return { | ||
type: 'ON_REQUEST', | ||
onRequest: { | ||
contactEmail: formValue.contactEmail!!, | ||
contactPreferredEmailSubject: formValue.contactPreferredEmailSubject!!, | ||
}, | ||
}; | ||
} | ||
|
||
private buildHttpHeaders( | ||
headers: HttpDatasourceHeaderFormValue[], | ||
): Record<string, string> { | ||
return Object.fromEntries( | ||
headers | ||
.map((header) => [ | ||
header.headerName?.trim() || '', | ||
header.headerValue?.trim() || '', | ||
]) | ||
.filter((a) => a[0] && a[1]), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {UiAssetCreateRequest, UiAssetEditRequest} from '@sovity.de/edc-client'; | ||
import {AssetEditorDialogFormValue} from '../../routes/connector-ui/asset-page/asset-edit-dialog/form/model/asset-editor-dialog-form-model'; | ||
import {toGmtZeroHourDate} from '../utils/date-utils'; | ||
import {AssetDataSourceMapperLegacy} from './asset-data-source-mapper-legacy'; | ||
import {AssetRequestCommonMetadata} from './asset-request-common-metadata'; | ||
|
||
@Injectable() | ||
export class AssetRequestBuilderLegacy { | ||
constructor(private assetDataSourceMapper: AssetDataSourceMapperLegacy) {} | ||
|
||
buildAssetCreateRequestLegacy( | ||
formValue: AssetEditorDialogFormValue, | ||
): UiAssetCreateRequest { | ||
const id = formValue.metadata?.id!; | ||
const metadata = this.buildAssetRequestCommonMetadataLegacy(formValue); | ||
const dataSource = this.assetDataSourceMapper.buildDataSourceLegacy( | ||
formValue.datasource!, | ||
); | ||
return { | ||
id, | ||
...metadata, | ||
dataSource, | ||
}; | ||
} | ||
|
||
buildAssetEditRequestLegacy( | ||
formValue: AssetEditorDialogFormValue, | ||
): UiAssetEditRequest { | ||
const metadata = this.buildAssetRequestCommonMetadataLegacy(formValue); | ||
const dataSourceOrNull = | ||
this.assetDataSourceMapper.buildDataSourceOrNullLegacy( | ||
formValue.datasource!, | ||
); | ||
return { | ||
...metadata, | ||
dataSourceOverrideOrNull: dataSourceOrNull ?? undefined, | ||
}; | ||
} | ||
|
||
buildAssetRequestCommonMetadataLegacy( | ||
formValue: AssetEditorDialogFormValue, | ||
): AssetRequestCommonMetadata { | ||
const title = formValue.metadata?.title!; | ||
const version = formValue.metadata?.version; | ||
const description = formValue.metadata?.description; | ||
const language = formValue.metadata?.language?.id; | ||
const keywords = formValue.metadata?.keywords; | ||
const licenseUrl = formValue.metadata?.standardLicense; | ||
const publisherHomepage = formValue.metadata?.publisher; | ||
const mediaType = formValue.metadata?.contentType; | ||
const landingPageUrl = formValue.metadata?.endpointDocumentation; | ||
|
||
const dataCategory = formValue.advanced?.dataCategory?.id; | ||
const dataSubcategory = formValue.advanced?.dataSubcategory?.id; | ||
const transportMode = formValue.advanced?.transportMode?.id; | ||
const geoReferenceMethod = formValue.advanced?.geoReferenceMethod; | ||
const dataModel = formValue.advanced?.dataModel; | ||
|
||
const sovereignLegalName = formValue.advanced?.sovereignLegalName; | ||
const geoLocation = formValue.advanced?.geoLocation; | ||
const nutsLocations = formValue.advanced?.nutsLocations; | ||
const dataSampleUrls = formValue.advanced?.dataSampleUrls; | ||
const referenceFileUrls = formValue.advanced?.referenceFileUrls; | ||
const referenceFilesDescription = | ||
formValue.advanced?.referenceFilesDescription; | ||
const conditionsForUse = formValue.advanced?.conditionsForUse; | ||
const dataUpdateFrequency = formValue.advanced?.dataUpdateFrequency; | ||
let temporalCoverageFrom = | ||
formValue.advanced?.temporalCoverage?.from || undefined; | ||
let temporalCoverageToInclusive = | ||
formValue.advanced?.temporalCoverage?.toInclusive || undefined; | ||
temporalCoverageFrom = temporalCoverageFrom | ||
? toGmtZeroHourDate(temporalCoverageFrom) | ||
: undefined; | ||
temporalCoverageToInclusive = temporalCoverageToInclusive | ||
? toGmtZeroHourDate(temporalCoverageToInclusive) | ||
: undefined; | ||
|
||
return { | ||
title, | ||
language, | ||
description, | ||
publisherHomepage, | ||
licenseUrl, | ||
version, | ||
keywords, | ||
mediaType, | ||
landingPageUrl, | ||
dataCategory, | ||
dataSubcategory, | ||
dataModel, | ||
geoReferenceMethod, | ||
transportMode, | ||
sovereignLegalName, | ||
geoLocation, | ||
nutsLocations, | ||
dataSampleUrls, | ||
referenceFileUrls, | ||
referenceFilesDescription, | ||
conditionsForUse, | ||
dataUpdateFrequency, | ||
temporalCoverageFrom, | ||
temporalCoverageToInclusive, | ||
customJsonAsString: undefined, | ||
customJsonLdAsString: undefined, | ||
privateCustomJsonAsString: undefined, | ||
privateCustomJsonLdAsString: undefined, | ||
}; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/app/routes/connector-ui/asset-page/asset-edit-dialog/asset-edit-dialog-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {AssetEditorDialogFormValue} from './form/model/asset-editor-dialog-form-model'; | ||
|
||
export interface AssetEditDialogData { | ||
initialFormValue: AssetEditorDialogFormValue; | ||
} |
1 change: 1 addition & 0 deletions
1
src/app/routes/connector-ui/asset-page/asset-edit-dialog/asset-edit-dialog-mode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type AssetEditDialogMode = 'CREATE' | 'EDIT'; |
13 changes: 13 additions & 0 deletions
13
src/app/routes/connector-ui/asset-page/asset-edit-dialog/asset-edit-dialog-result.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {UiAssetMapped} from '../../../../core/services/models/ui-asset-mapped'; | ||
|
||
export interface AssetEditDialogResult { | ||
/** | ||
* Updated asset list for the asset page | ||
*/ | ||
refreshedList: UiAssetMapped[]; | ||
|
||
/** | ||
* The updated / created asset | ||
*/ | ||
asset: UiAssetMapped; | ||
} |
Oops, something went wrong.