-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Copy paste of classes (RDFA-381) #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
816ce63
Added feature to copy classes
kiph-soptim 784e4b0
Merge remote-tracking branch 'origin/main' into feature/RDFA-381-Copy…
kiph-soptim 7a5bc1c
fixed missing constructor arguments
kiph-soptim 4ad63b6
format
kiph-soptim 7a80654
format
kiph-soptim 0ead7c4
format
kiph-soptim 91aa558
format
kiph-soptim 28ad92e
added test and refactoring
kiph-soptim f169a67
open pasted class automatically
kiph-soptim 25578ae
format
kiph-soptim 96a2fae
various improvements and fixes
kiph-soptim 4d36a14
added a Test for the GetPackageUseCase
kiph-soptim 6a1130b
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim e70af04
moved copyClass from svelteFlowWrapper.svelte to SvelteFlowClassConte…
kiph-soptim e3d8eb6
small fix
kiph-soptim 690ce97
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim de8878a
fix: show diagram class context menu in read only mode
spah-soptim 740fb96
enabled copy in read only datasets
kiph-soptim 3565612
added option to copy association with the class
kiph-soptim 4727bdb
fix
kiph-soptim da5a696
Merge remote-tracking branch 'origin/main' into feature/RDFA-381-Copy…
kiph-soptim b1410ba
copying a class now only creates one commit on the graph
kiph-soptim 11cd68c
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim 65c4dfb
fixed bugs
kiph-soptim 54a5f11
format
kiph-soptim 4d7ba1c
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim 28cc388
removed unused variables
kiph-soptim 7ecd05a
removed unused variables
kiph-soptim 9dc0410
bug fixes and tests
kiph-soptim 8c2f925
format
kiph-soptim 8e47ecf
bug fixes
kiph-soptim 13bae89
format
kiph-soptim 1d8d20b
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim 3ccb232
readability
kiph-soptim f6f0202
fixed tests
kiph-soptim 54dd4b6
format
kiph-soptim 26e7aec
bug fixes
kiph-soptim 44499cd
bug fixes
kiph-soptim 2927fab
bug fixes
kiph-soptim 18d054a
bug fixes and keyboard shortcuts
kiph-soptim 2d62684
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim b34e9dd
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim 7aa5dc7
format
kiph-soptim 4d017ee
resolved merge bugs
kiph-soptim a9669c6
bug fixes
kiph-soptim ee63dc7
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim a47853e
format
kiph-soptim af39512
fixed pasting into default package
kiph-soptim 9e052b4
fixed alternate keyboard inputs
kiph-soptim 4b3a4ca
Merge branch 'main' into feature/RDFA-381-Copy-Paste-of-classes
kiph-soptim 1ca03cc
format
kiph-soptim 790192e
added toast notification for pasting a class
kiph-soptim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
...org/rdfarchitect/api/controller/datasets/graphs/classes/copy/CopyClassRESTController.java
This file contains hidden or 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,112 @@ | ||
| /* | ||
| * Copyright (c) 2024-2026 SOPTIM AG | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package org.rdfarchitect.api.controller.datasets.graphs.classes.copy; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import org.rdfarchitect.api.dto.CopyClassRequestDTO; | ||
| import org.rdfarchitect.api.dto.CopyClassResponseDTO; | ||
| import org.rdfarchitect.database.GraphIdentifier; | ||
| import org.rdfarchitect.services.ExpandURIUseCase; | ||
| import org.rdfarchitect.services.update.classes.CopyClassUseCase; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestHeader; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @RestController | ||
| @RequestMapping("api/datasets/{datasetName}/graphs/{graphURI}/classes/{classUUID}/copy") | ||
| @RequiredArgsConstructor | ||
| public class CopyClassRESTController { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(CopyClassRESTController.class); | ||
|
|
||
| private final ExpandURIUseCase expandURIUseCase; | ||
| private final CopyClassUseCase copyClassUseCase; | ||
|
|
||
| @Operation( | ||
| summary = "copy a class", | ||
| description = "Create a copy of a class in the specified graph") | ||
| @PostMapping | ||
| public CopyClassResponseDTO copyClass( | ||
| @Parameter(description = "The name/url of the inquirer.") | ||
| @RequestHeader( | ||
| value = HttpHeaders.ORIGIN, | ||
| required = false, | ||
| defaultValue = "unknown") | ||
| String originURL, | ||
| @Parameter(description = "The literal name of the dataset.") @PathVariable | ||
| String datasetName, | ||
| @Parameter( | ||
| description = | ||
| "The url encoded uri of the graph, or \"default\" to access the default graph.") | ||
| @PathVariable | ||
| String graphURI, | ||
| @Parameter(description = "The uuid of the class.") @PathVariable String classUUID, | ||
| @io.swagger.v3.oas.annotations.parameters.RequestBody( | ||
| required = true, | ||
| description = | ||
| "Contains the information of the target where the class should be copied to. Also includes if the class should be copied only abstract or " | ||
| + "fully.") | ||
| @RequestBody | ||
| CopyClassRequestDTO copyClassRequest) { | ||
| logger.info( | ||
| "Received POST request: \"/api/datasets/{{}}/graphs/{{}}/classes/{{}}/copy\" from \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| classUUID, | ||
| originURL); | ||
|
|
||
| var extendedGraphURI = expandURIUseCase.expandUri(datasetName, graphURI); | ||
| var graphIdentifier = new GraphIdentifier(datasetName, extendedGraphURI); | ||
|
|
||
| var targetExtendedGraphURI = | ||
| expandURIUseCase.expandUri( | ||
| copyClassRequest.getTargetDatasetName(), | ||
| copyClassRequest.getTargetGraphURI()); | ||
| var targetGraphIdentifier = | ||
| new GraphIdentifier( | ||
| copyClassRequest.getTargetDatasetName(), targetExtendedGraphURI); | ||
|
|
||
| var response = | ||
| copyClassUseCase.copyClass( | ||
| graphIdentifier, | ||
| UUID.fromString(classUUID), | ||
| targetGraphIdentifier, | ||
| copyClassRequest); | ||
|
|
||
| logger.info( | ||
| "Sending response to POST request: \"/api/datasets/{{}}/graphs/{{}}/classes/{{}}/copy\" to \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| classUUID, | ||
| originURL); | ||
|
|
||
| return response; | ||
| } | ||
| } |
This file contains hidden or 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
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/org/rdfarchitect/api/dto/CopyClassRequestDTO.java
This file contains hidden or 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,33 @@ | ||
| /* | ||
| * Copyright (c) 2024-2026 SOPTIM AG | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package org.rdfarchitect.api.dto; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import org.rdfarchitect.api.dto.packages.PackageDTO; | ||
|
|
||
| @Data | ||
| public class CopyClassRequestDTO { | ||
|
|
||
| String targetDatasetName; | ||
| String targetGraphURI; | ||
| PackageDTO targetPackage; | ||
| boolean copyAsAbstract; | ||
| boolean copyAttributes; | ||
| boolean copyAssociations; | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
backend/src/main/java/org/rdfarchitect/api/dto/CopyClassResponseDTO.java
This file contains hidden or 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,29 @@ | ||
| /* | ||
| * Copyright (c) 2024-2026 SOPTIM AG | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package org.rdfarchitect.api.dto; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| @AllArgsConstructor | ||
| public class CopyClassResponseDTO { | ||
|
|
||
| String uuid; | ||
| String name; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.