-
Notifications
You must be signed in to change notification settings - Fork 3
feature: Show references on delete and allow selective deleting (RDFA-136) #82
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
Open
rema-soptim
wants to merge
31
commits into
main
Choose a base branch
from
feature/RDFA-136-show-references-on-delete
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
6dc469a
Created first structure
rema-soptim 2e89607
improved structure for deleteRelations response and started on implem…
rema-soptim 0ddd2a9
added needed context for displaying data correctly
rema-soptim 448e3bf
implemented frontend ui for selecting delete dependencies
rema-soptim a2ad272
added first impl for actual deletion.
rema-soptim 3ea8e49
started fixing bugs
rema-soptim 07f2170
started fixing bugs
rema-soptim 9606a38
check before rebase
rema-soptim a8b4604
fixed bug, where associations to external classes caused the classedi…
rema-soptim 261ca62
fixed more bugs, where resources were not deleted properly
rema-soptim 484c234
structures some code
rema-soptim 2f81e90
added tabs component
rema-soptim bd0b34f
Added:
rema-soptim e823eb9
Added: deleterequest for ontologies in header menu
rema-soptim 9420b9e
Added another class delete dialog to the new in diagram context menu
rema-soptim 3ad5054
backend lint
rema-soptim 53a5a14
removed comments
rema-soptim 7c01460
renamed variable
rema-soptim 4b66d01
removed repeating checks for resource type
rema-soptim 3f01c90
refactored code into util classes, for future reusability
rema-soptim c00203b
Potential fix for pull request finding 'Missing Override annotation'
rema-soptim 48c7cbb
Potential fix for pull request finding 'Missing Override annotation'
rema-soptim 02c0eb1
Potential fix for pull request finding 'Exposing internal representat…
rema-soptim 2309805
rebase fixes
rema-soptim 19caee3
rebase fixes
rema-soptim 9ce6572
more rebase fixes
rema-soptim c62c430
fixed backend lint issues
rema-soptim ba6806c
fixed backend lint issues
rema-soptim 5c5c4c9
backend lint
rema-soptim 123b148
rebase bugs
rema-soptim b6c7c04
fixed bugs found in test:
rema-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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
...d/src/main/java/org/rdfarchitect/api/controller/datasets/graphs/DeleteRESTController.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,147 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import org.rdfarchitect.api.dto.delete.ResourceDeleteRequest; | ||
| import org.rdfarchitect.api.dto.delete.relations.AffectedResource; | ||
| import org.rdfarchitect.database.GraphIdentifier; | ||
| import org.rdfarchitect.services.ExpandURIUseCase; | ||
| import org.rdfarchitect.services.delete.DeleteResourcesUseCase; | ||
| import org.rdfarchitect.services.delete.FindDeleteDependenciesUseCase; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| 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.List; | ||
| import java.util.UUID; | ||
|
|
||
| @RestController | ||
| @RequestMapping("api/datasets/{datasetName}/graphs/{graphURI}") | ||
| @RequiredArgsConstructor | ||
| public class DeleteRESTController { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(DeleteRESTController.class); | ||
|
|
||
| private final ExpandURIUseCase expandURIUseCase; | ||
| private final FindDeleteDependenciesUseCase findDeleteDependenciesUseCase; | ||
| private final DeleteResourcesUseCase deleteResourcesUseCase; | ||
|
|
||
| @Operation( | ||
| summary = "Get deletion impact", | ||
| description = | ||
| "Returns a tree of affected resources for deleting the resource with the given UUID.", | ||
| tags = {"graph"}, | ||
| responses = {@ApiResponse(responseCode = "200")}) | ||
| @GetMapping("/uuid/{uuid}/deletion-impact") | ||
| public AffectedResource getDeletionImpact( | ||
| @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 url encoded iri identifier of the cim resource.") | ||
| @PathVariable | ||
| String uuid) { | ||
| logger.info( | ||
| "Received GET request: \"/api/datasets/{{}}/graphs/{{}}/uuid/{{}/deletion-impact\" from \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| uuid, | ||
| originURL); | ||
|
|
||
| var extendedGraphURI = expandURIUseCase.expandUri(datasetName, graphURI); | ||
|
|
||
| var resultObj = | ||
| findDeleteDependenciesUseCase.getDeleteDependencies( | ||
| new GraphIdentifier(datasetName, extendedGraphURI), UUID.fromString(uuid)); | ||
|
|
||
| logger.info( | ||
| "Sending response to GET request: \"/api/datasets/{{}}/graphs/{{}}/uuid/{{}/deletion-impact\" from \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| uuid, | ||
| originURL); | ||
| return resultObj; | ||
| } | ||
|
|
||
| @Operation( | ||
| summary = "Delete resources", | ||
| description = | ||
| "Processes a list of delete requests, each specifying a resource UUID and the desired action.", | ||
| tags = {"graph"}, | ||
| responses = {@ApiResponse(responseCode = "200")}) | ||
| @PostMapping("/delete-requests") | ||
| public String deleteResources( | ||
| @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 = | ||
| "A list of resource delete requests, each containing the uuid of the resource to delete and the type of deletion") | ||
| @RequestBody | ||
| List<ResourceDeleteRequest> deleteRequests) { | ||
| logger.info( | ||
| "Received POST request: \"/api/datasets/{{}}/graphs/{{}}/delete\" from \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| originURL); | ||
|
|
||
| var extendedGraphURI = expandURIUseCase.expandUri(datasetName, graphURI); | ||
|
|
||
| deleteResourcesUseCase.executeDeleteRequests( | ||
| new GraphIdentifier(datasetName, extendedGraphURI), deleteRequests); | ||
|
|
||
| logger.info( | ||
| "Sending response to POST request: \"/api/datasets/{{}}/graphs/{{}}/delete\" from \"{}\".", | ||
| datasetName, | ||
| graphURI, | ||
| originURL); | ||
| return "success"; | ||
| } | ||
| } |
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
41 changes: 41 additions & 0 deletions
41
backend/src/main/java/org/rdfarchitect/api/dto/delete/DeleteAction.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,41 @@ | ||
| /* | ||
| * 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.delete; | ||
|
|
||
| public enum DeleteAction { | ||
|
|
||
| /** Delete the affected resource entirely. Applicable to all resource types. */ | ||
| DELETE, | ||
|
|
||
| /** | ||
| * Keep the affected resource as-is, even though it references a deleted resource. E.g. a class | ||
| * that extends a deleted class — keep the class but accept that the parent reference becomes | ||
| * invalid. | ||
| */ | ||
| KEEP, | ||
|
|
||
| /** | ||
| * Remove the {@code cims:belongsToCategory} triple from a class whose package is being deleted. | ||
| */ | ||
| REMOVE_PACKAGE_REFERENCE, | ||
|
|
||
| /** | ||
| * Remove the {@code rdfs:subClassOf} triple from a class whose parent class is being deleted. | ||
| */ | ||
| REMOVE_SUBCLASS_REFERENCE; | ||
| } |
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/org/rdfarchitect/api/dto/delete/ResourceDeleteRequest.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,30 @@ | ||
| /* | ||
| * 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.delete; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Data | ||
| public class ResourceDeleteRequest { | ||
|
|
||
| private UUID uuid; | ||
|
|
||
| private DeleteAction action; | ||
| } |
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/org/rdfarchitect/api/dto/delete/ResourceIdentifier.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,31 @@ | ||
| /* | ||
| * 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.delete; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.experimental.Accessors; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Data | ||
| @Accessors(chain = true) | ||
| public class ResourceIdentifier { | ||
| private UUID uuid; | ||
| private String label; | ||
| private String namespace; | ||
| } |
45 changes: 45 additions & 0 deletions
45
backend/src/main/java/org/rdfarchitect/api/dto/delete/relations/AffectedAssociation.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,45 @@ | ||
| /* | ||
| * 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.delete.relations; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.experimental.Accessors; | ||
|
|
||
| import org.rdfarchitect.api.dto.delete.ResourceIdentifier; | ||
| import org.rdfarchitect.models.cim.relations.model.CIMResourceTypeIdentifyingUtils; | ||
|
|
||
| @Data | ||
| @Accessors(chain = true) | ||
| @EqualsAndHashCode(callSuper = true) | ||
|
rema-soptim marked this conversation as resolved.
Dismissed
|
||
| @NoArgsConstructor | ||
| public class AffectedAssociation extends AffectedOwnedResource { | ||
|
|
||
| private ResourceIdentifier target; | ||
|
|
||
| public AffectedAssociation( | ||
| ResourceIdentifier resourceIdentifier, | ||
| CIMResourceTypeIdentifyingUtils.CimResourceType type, | ||
| AffectedResourceReason reason, | ||
| ResourceIdentifier domain, | ||
| ResourceIdentifier target) { | ||
| super(resourceIdentifier, type, reason, domain); | ||
| this.target = target; | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
backend/src/main/java/org/rdfarchitect/api/dto/delete/relations/AffectedOwnedResource.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,44 @@ | ||
| /* | ||
| * 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.delete.relations; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.experimental.Accessors; | ||
|
|
||
| import org.rdfarchitect.api.dto.delete.ResourceIdentifier; | ||
| import org.rdfarchitect.models.cim.relations.model.CIMResourceTypeIdentifyingUtils; | ||
|
|
||
| @Data | ||
| @Accessors(chain = true) | ||
| @EqualsAndHashCode(callSuper = true) | ||
|
rema-soptim marked this conversation as resolved.
Dismissed
|
||
| @NoArgsConstructor | ||
| public class AffectedOwnedResource extends AffectedResource { | ||
|
|
||
| private ResourceIdentifier domain; | ||
|
|
||
| public AffectedOwnedResource( | ||
| ResourceIdentifier resourceIdentifier, | ||
| CIMResourceTypeIdentifyingUtils.CimResourceType type, | ||
| AffectedResourceReason reason, | ||
| ResourceIdentifier domain) { | ||
| super(resourceIdentifier, type, reason); | ||
| this.domain = domain; | ||
| } | ||
| } | ||
Oops, something went wrong.
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.