Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for VSUM “views” (NeoJoin configurations) by introducing new view entities and associations to metamodels, wiring them into VSUM sync/history flows, and extending persistence + DTOs accordingly.
Changes:
- Added
VsumView/VsumViewMetaModeldomain model, repositories, services, and DB migration for storing NeoJoin-backed views and their metamodel links. - Extended VSUM sync changes handling (
applySyncChanges) to diff/create/delete views based on incomingviewRequests. - Updated history representation to include views; added tests for the new view services.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/test/java/tools/vitruv/methodologist/vsum/service/VsumViewServiceTest.java | Adds unit tests for creating/deleting views via VsumViewService. |
| app/src/test/java/tools/vitruv/methodologist/vsum/service/VsumViewMetaModelServiceTest.java | Adds unit tests for creating/deleting view–metamodel associations. |
| app/src/test/java/tools/vitruv/methodologist/vsum/service/VsumServiceTest.java | Updates VSUM service test wiring for new view dependencies. |
| app/src/main/resources/db/migration/V8__VIEW_TYPE.sql | Introduces vsum_view and vsum_view_meta_model tables and FKs. |
| app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumViewService.java | New service for persisting/removing VsumView entities. |
| app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumViewMetaModelService.java | New service for persisting/removing VsumViewMetaModel join rows. |
| app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java | Extends sync changes logic to normalize/diff/apply view operations. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumViewRepository.java | Adds repository methods for VSUM-scoped view CRUD. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumViewMetaModelRepository.java | Adds repository methods for per-view join querying/deletion. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumHistoryRepository.java | Uses an entity graph to eagerly load view associations for history loads. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/MetaModelRepository.java | Removes unused user-id-based metamodel queries. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/VsumViewMetaModel.java | New JPA entity for view–metamodel associations. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/VsumView.java | New JPA entity representing a NeoJoin-backed VSUM view. |
| app/src/main/java/tools/vitruv/methodologist/vsum/model/Vsum.java | Adds views collection to the VSUM aggregate. |
| app/src/main/java/tools/vitruv/methodologist/vsum/mapper/VsumHistoryMapper.java | Maps domain views into history representation DTOs. |
| app/src/main/java/tools/vitruv/methodologist/vsum/controller/dto/request/VsumSyncChangesPutRequest.java | Adds viewRequests to the sync-changes request payload. |
| app/src/main/java/tools/vitruv/methodologist/vsum/controller/dto/request/ViewRequest.java | New request DTO for view sync operations. |
| app/src/main/java/tools/vitruv/methodologist/vsum/VsumRepresentation.java | Extends persisted history snapshot representation with views. |
| app/src/main/java/tools/vitruv/methodologist/user/service/UserService.java | Disables OTP email sending by commenting out mail dispatch. |
| app/src/main/java/tools/vitruv/methodologist/messages/Error.java | Adds VIEW_FILE_ID_NOT_FOUND_ERROR. |
| app/src/main/java/tools/vitruv/methodologist/general/FileEnumType.java | Adds NEO_JOIN file type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| */ | ||
| public void sendOtp(String to, String toName, String otp, int ttlMinutes) { | ||
| mailService.sendOtpMail(to, toName, otp, ttlMinutes); | ||
| // mailService.sendOtpMail(to, toName, otp, ttlMinutes); |
Comment on lines
+684
to
+768
| @@ -723,14 +728,14 @@ public Vsum applySyncChanges( | |||
| Set<Long> toAddVsumMetaModelIds = new HashSet<>(desiredMetaModelIds); | |||
| toAddVsumMetaModelIds.removeAll(existingVsumMetaModelIds); | |||
|
|
|||
| Set<String> toAddMetaModelRelation = new HashSet<>(desiredMetaModelRelationPairs); | |||
| toAddMetaModelRelation.removeAll(existingMetaModelRelationPairs); | |||
| ViewSyncPlan viewSyncPlan = buildViewSyncPlan(vsum, desiredViewRequests); | |||
|
|
|||
| boolean hasAnyChanges = | |||
| !toRemoveMetaModelRelation.isEmpty() | |||
| || !toRemoveVsumMetaModelIds.isEmpty() | |||
| || !toAddVsumMetaModelIds.isEmpty() | |||
| || !toAddMetaModelRelation.isEmpty(); | |||
| || !toAddMetaModelRelation.isEmpty() | |||
| || viewSyncPlan.hasChanges(); | |||
|
|
|||
| if (createHistory && hasAnyChanges) { | |||
| vsumHistoryService.create(vsum, user); | |||
| @@ -759,6 +764,8 @@ public Vsum applySyncChanges( | |||
| } | |||
| } | |||
|
|
|||
| applyViewSyncPlan(vsum, viewSyncPlan); | |||
|
|
|||
Comment on lines
+57
to
+59
|
|
||
| return (List<VsumViewMetaModel>) vsumViewMetaModelRepository.saveAll(entities); | ||
| } |
Comment on lines
+855
to
+860
| private ViewSyncPlan buildViewSyncPlan(Vsum vsum, List<ViewRequest> desiredViewRequests) { | ||
| List<VsumView> existingViews = vsumViewRepository.findAllByVsum(vsum); | ||
|
|
||
| Map<String, VsumView> existingByKey = new HashMap<>(); | ||
| for (VsumView existingView : existingViews) { | ||
| existingByKey.put(toViewKey(existingView), existingView); |
Comment on lines
42
to
47
| vsum.getVsumMetaModels().stream() | ||
| .map(metaModel -> metaModel.getMetaModel().getSource().getId()) | ||
| .collect(Collectors.toSet())) | ||
| .metaModelsRealation(toMetaModelsRelation(vsum.getMetaModelRelations())) | ||
| .views(toView(vsum.getViews())) | ||
| .build(); |
| ( | ||
| id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, | ||
| vsum_view_id BIGINT NOT NULL, | ||
| meta_model_id BIGINT NOT NULL, |
Comment on lines
+66
to
+72
| @Transactional | ||
| public void delete(Vsum vsum, VsumView vsumView) { | ||
| vsumViewRepository.delete(vsumView); | ||
|
|
||
| if (vsum.getViews() != null) { | ||
| vsum.getViews().remove(vsumView); | ||
| } |
Comment on lines
+44
to
+48
| public List<VsumViewMetaModel> create(VsumView vsumView, Set<Long> metaModelIds) { | ||
| List<VsumMetaModel> vsumMetaModels = | ||
| vsumMetaModelRepository.findAllByVsumAndMetaModel_source_idIn( | ||
| vsumView.getVsum(), metaModelIds); | ||
|
|
Comment on lines
+81
to
+86
| public void deleteByVsum(Vsum vsum) { | ||
| vsumViewRepository.deleteAllByVsum(vsum); | ||
|
|
||
| if (vsum.getViews() != null) { | ||
| vsum.getViews().clear(); | ||
| } |
| .map( | ||
| vsumViewMetaModel -> | ||
| vsumViewMetaModel.getMetaModel().getSource().getId()) | ||
| .toList()) |
Contributor
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@ma-mirzaei I've opened a new pull request, #224, to work on those changes. Once the pull request is ready, I'll request review from you. |
…e, revert views, null handling, and add unique constraint Co-authored-by: ma-mirzaei <93537795+ma-mirzaei@users.noreply.github.com>
Co-authored-by: ma-mirzaei <93537795+ma-mirzaei@users.noreply.github.com>
Fix view sync correctness, cascade delete, N+1 queries, and revert path for VSUM views
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces support for VSUM "views" (NeoJoin configurations) that allow associating multiple metamodels with a NeoJoin file. The changes add new entities, repositories, DTOs, and mapping logic to handle views within the VSUM domain, and update service and controller layers to process view-related requests. Additionally, some minor improvements and cleanups are included.
VSUM Views (NeoJoin) Feature
VsumViewandVsumViewMetaModelto model VSUM views and their associations with metamodels. These entities allow a VSUM to have multiple views, each backed by a NeoJoin file and linked to a set of metamodels. (app/src/main/java/tools/vitruv/methodologist/vsum/model/VsumView.java[1]app/src/main/java/tools/vitruv/methodologist/vsum/model/VsumViewMetaModel.java[2]VsumViewRepositoryandVsumViewMetaModelRepositoryfor managing views and their associations. These provide CRUD operations and custom queries for views and their linked metamodels. (app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumViewRepository.java[1]app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumViewMetaModelRepository.java[2]Vsum) to include a set of views, and updated history repository queries to eagerly load view associations. (app/src/main/java/tools/vitruv/methodologist/vsum/model/Vsum.java[1]app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/VsumHistoryRepository.java[2]VsumHistoryMapperto convert domain views to DTOs for history representation, including meta model IDs and file storage references. (app/src/main/java/tools/vitruv/methodologist/vsum/mapper/VsumHistoryMapper.java[1] [2]ViewRequestDTO and updated sync changes request to support view operations. (app/src/main/java/tools/vitruv/methodologist/vsum/controller/dto/request/ViewRequest.java[1]app/src/main/java/tools/vitruv/methodologist/vsum/controller/dto/request/VsumSyncChangesPutRequest.java[2]Service and Controller Layer Updates
VsumServiceto process view-related sync changes, including normalization and handling of view requests alongside metamodel relations. (app/src/main/java/tools/vitruv/methodologist/vsum/service/VsumService.java[1] [2] [3] [4]Enum and Error Handling Improvements
NEO_JOINtoFileEnumTypeto represent NeoJoin files in the system. (app/src/main/java/tools/vitruv/methodologist/general/FileEnumType.javaapp/src/main/java/tools/vitruv/methodologist/general/FileEnumType.javaL10-R11)app/src/main/java/tools/vitruv/methodologist/messages/Error.javaapp/src/main/java/tools/vitruv/methodologist/messages/Error.javaR10)Cleanup and Minor Changes
MetaModelRepositoryfor finding metamodels by user ID. (app/src/main/java/tools/vitruv/methodologist/vsum/model/repository/MetaModelRepository.javaapp/src/main/java/tools/vitruv/methodologist/vsum/model/repository/MetaModelRepository.javaL57-L72)UserService(possibly for testing or future update). (app/src/main/java/tools/vitruv/methodologist/user/service/UserService.javaapp/src/main/java/tools/vitruv/methodologist/user/service/UserService.javaL250-R250)References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]