Skip to content

Commit

Permalink
fix: remove dead Code
Browse files Browse the repository at this point in the history
  • Loading branch information
SaadEGI committed Sep 21, 2023
1 parent b5d8e9c commit 445bf9f
Showing 1 changed file with 2 additions and 73 deletions.
75 changes: 2 additions & 73 deletions src/app/core/services/asset-property-mapper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {Inject, Injectable} from '@angular/core';
import {Injectable} from '@angular/core';
import {UiAsset} from '@sovity.de/edc-client';
import {AssetEditorDialogFormValue} from '../../routes/connector-ui/asset-page/asset-create-dialog/asset-editor-dialog-form-model';
import {ActiveFeatureSet} from '../config/active-feature-set';
import {APP_CONFIG, AppConfig} from '../config/app-config';
import {removeNullValues} from '../utils/record-utils';
import {trimmedOrNull} from '../utils/string-utils';
import {AssetProperties} from './asset-properties';
import {AdditionalAssetProperty, Asset} from './models/asset';

Expand All @@ -15,11 +10,6 @@ import {AdditionalAssetProperty, Asset} from './models/asset';
providedIn: 'root',
})
export class AssetPropertyMapper {
constructor(
@Inject(APP_CONFIG) private config: AppConfig,
private activeFeatureSet: ActiveFeatureSet,
) {}

buildUiAssetfromprops(props: Record<string, string>): UiAsset {
return {
assetId: props[AssetProperties.id] ?? '',
Expand Down Expand Up @@ -91,14 +81,13 @@ export class AssetPropertyMapper {
];

for (let propName of propertiesToConvert) {
const propValue = asset[propName as AssetKey];
const propValue = asset[propName];
if (propValue) {
for (let key in propValue) {
result.push({key: key, value: propValue[key]});
}
}
}

return result;
}

Expand All @@ -122,70 +111,10 @@ export class AssetPropertyMapper {
return result;
}

buildProperties(
formValue: AssetEditorDialogFormValue,
): Record<string, string> {
const {metadata, advanced, datasource} = formValue;
const props: Record<string, string | null> = {};
props[AssetProperties.id] = trimmedOrNull(metadata?.id);
props[AssetProperties.name] = trimmedOrNull(metadata?.name);
props[AssetProperties.version] = trimmedOrNull(metadata?.version);
props[AssetProperties.curatorOrganizationName] = trimmedOrNull(
this.config.curatorOrganizationName,
);
props[AssetProperties.keywords] = trimmedOrNull(
metadata?.keywords?.join(', '),
);
props[AssetProperties.contentType] = trimmedOrNull(metadata?.contentType);
props[AssetProperties.description] = trimmedOrNull(metadata?.description);
props[AssetProperties.language] = metadata?.language?.id ?? null;

props[AssetProperties.publisher] = trimmedOrNull(metadata?.publisher);
props[AssetProperties.standardLicense] = trimmedOrNull(
metadata?.standardLicense,
);
props[AssetProperties.endpointDocumentation] = trimmedOrNull(
metadata?.endpointDocumentation,
);

if (this.activeFeatureSet.hasMdsFields()) {
props[AssetProperties.dataCategory] = advanced?.dataCategory?.id ?? null;
props[AssetProperties.dataSubcategory] =
advanced?.dataSubcategory?.id ?? null;
props[AssetProperties.dataModel] = trimmedOrNull(advanced?.dataModel);
props[AssetProperties.geoReferenceMethod] = trimmedOrNull(
advanced?.geoReferenceMethod,
);
props[AssetProperties.transportMode] =
advanced?.transportMode?.id ?? null;
}

if (datasource?.dataAddressType === 'Http') {
props[AssetProperties.httpProxyMethod] = this._encodeBoolean(
datasource?.httpProxyMethod,
);
props[AssetProperties.httpProxyPath] = this._encodeBoolean(
datasource?.httpProxyPath,
);
props[AssetProperties.httpProxyQueryParams] = this._encodeBoolean(
datasource?.httpProxyQueryParams,
);
props[AssetProperties.httpProxyBody] = this._encodeBoolean(
datasource?.httpProxyBody,
);
}

return removeNullValues(props);
}

private _parseBooleanFromString(value: string | null): boolean | undefined {
if (!value) {
return undefined;
}
return value === 'true';
}

private _encodeBoolean(value?: boolean | null): string {
return value ? 'true' : 'false';
}
}

0 comments on commit 445bf9f

Please sign in to comment.