-
Notifications
You must be signed in to change notification settings - Fork 21
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
1 parent
c8323d1
commit 4dc22cb
Showing
10 changed files
with
362 additions
and
12 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
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
88 changes: 88 additions & 0 deletions
88
...mmon-api/src/main/java/de/sovity/edc/ext/wrapper/api/common/model/UiAssetEditRequest.java
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,88 @@ | ||
/* | ||
* Copyright (c) 2022 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.wrapper.api.common.model; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Schema(description = "Data for editing an asset.") | ||
public class UiAssetEditRequest { | ||
@Schema(description = "Asset Title", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String title; | ||
|
||
@Schema(description = "Asset Language", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String language; | ||
|
||
@Schema(description = "Asset Description", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String description; | ||
|
||
@Schema(description = "Asset Homepage", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String publisherHomepage; | ||
|
||
@Schema(description = "License URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String licenseUrl; | ||
|
||
@Schema(description = "Version", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String version; | ||
|
||
@Schema(description = "Asset Keywords", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private List<String> keywords; | ||
|
||
@Schema(description = "Asset MediaType", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String mediaType; | ||
|
||
@Schema(description = "Landing Page URL", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String landingPageUrl; | ||
|
||
@Schema(description = "Data Category", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String dataCategory; | ||
|
||
@Schema(description = "Data Subcategory", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String dataSubcategory; | ||
|
||
@Schema(description = "Data Model", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String dataModel; | ||
|
||
@Schema(description = "Geo-Reference Method", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String geoReferenceMethod; | ||
|
||
@Schema(description = "Transport Mode", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private String transportMode; | ||
|
||
@Schema(description = "Data Address", requiredMode = Schema.RequiredMode.REQUIRED) | ||
private Map<String, String> dataAddressProperties; | ||
|
||
@Schema(description = "Custom Asset Properties (that are strings)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private Map<String, String> additionalProperties; | ||
|
||
@Schema(description = "Custom Asset Properties (that are not strings but other JSON values)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private Map<String, String> additionalJsonProperties; | ||
|
||
@Schema(description = "Private Asset Properties (that are strings)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private Map<String, String> privateProperties; | ||
|
||
@Schema(description = "Private Asset Properties (that are not strings but other JSON values)", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private Map<String, String> privateJsonProperties; | ||
} |
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
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
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
86 changes: 86 additions & 0 deletions
86
...pper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/asset/AssetUpdater.java
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,86 @@ | ||
/* | ||
* Copyright (c) 2022 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.wrapper.api.ui.pages.asset; | ||
|
||
import de.sovity.edc.ext.wrapper.api.common.mappers.AssetMapper; | ||
import de.sovity.edc.ext.wrapper.api.common.model.UiAssetCreateRequest; | ||
import de.sovity.edc.ext.wrapper.api.common.model.UiAssetEditRequest; | ||
import de.sovity.edc.ext.wrapper.api.ui.pages.dashboard.services.SelfDescriptionService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.eclipse.edc.spi.types.domain.asset.Asset; | ||
|
||
@RequiredArgsConstructor | ||
public class AssetUpdater { | ||
private final AssetMapper assetMapper; | ||
private final AssetIdValidator assetIdValidator; | ||
private final SelfDescriptionService selfDescriptionService; | ||
|
||
/** | ||
* Creates an {@link Asset} from a {@link UiAssetCreateRequest}. | ||
* | ||
* @param request {@link UiAssetCreateRequest} | ||
* @return {@link Asset} | ||
*/ | ||
public Asset createAsset(UiAssetCreateRequest request) { | ||
assetIdValidator.assertValid(request.getId()); | ||
var organizationName = selfDescriptionService.getCuratorName(); | ||
return assetMapper.buildAsset(request, organizationName); | ||
} | ||
|
||
/** | ||
* Returns an edited copy of an {@link Asset} updated with a {@link UiAssetEditRequest} | ||
* | ||
* @param asset {@link Asset} (immutable) | ||
* @param request {@link UiAssetEditRequest} | ||
* @return copy of {@link Asset} | ||
*/ | ||
public Asset editAsset(Asset asset, UiAssetEditRequest request) { | ||
var createRequest = buildCreateRequest(asset.getId(), request); | ||
var tmpAsset = createAsset(createRequest); | ||
|
||
return asset.toBuilder() | ||
.dataAddress(tmpAsset.getDataAddress()) | ||
.properties(tmpAsset.getProperties()) | ||
.privateProperties(tmpAsset.getPrivateProperties()) | ||
.build(); | ||
} | ||
|
||
|
||
private UiAssetCreateRequest buildCreateRequest(String id, UiAssetEditRequest editRequest) { | ||
var createRequest = new UiAssetCreateRequest(); | ||
createRequest.setId(id); | ||
createRequest.setAdditionalJsonProperties(editRequest.getAdditionalJsonProperties()); | ||
createRequest.setAdditionalProperties(editRequest.getAdditionalProperties()); | ||
createRequest.setDataAddressProperties(editRequest.getDataAddressProperties()); | ||
createRequest.setDataCategory(editRequest.getDataCategory()); | ||
createRequest.setDataModel(editRequest.getDataModel()); | ||
createRequest.setDataSubcategory(editRequest.getDataSubcategory()); | ||
createRequest.setDescription(editRequest.getDescription()); | ||
createRequest.setGeoReferenceMethod(editRequest.getGeoReferenceMethod()); | ||
createRequest.setKeywords(editRequest.getKeywords()); | ||
createRequest.setLandingPageUrl(editRequest.getLandingPageUrl()); | ||
createRequest.setLanguage(editRequest.getLanguage()); | ||
createRequest.setLicenseUrl(editRequest.getLicenseUrl()); | ||
createRequest.setMediaType(editRequest.getMediaType()); | ||
createRequest.setPrivateJsonProperties(editRequest.getPrivateJsonProperties()); | ||
createRequest.setPrivateProperties(editRequest.getPrivateProperties()); | ||
createRequest.setPublisherHomepage(editRequest.getPublisherHomepage()); | ||
createRequest.setTitle(editRequest.getTitle()); | ||
createRequest.setTransportMode(editRequest.getTransportMode()); | ||
createRequest.setVersion(editRequest.getVersion()); | ||
return createRequest; | ||
} | ||
|
||
} |
Oops, something went wrong.