Skip to content

221 add view type neojoin files#223

Draft
ma-mirzaei wants to merge 12 commits intodevelopfrom
221-add-view-type-neojoin-files
Draft

221 add view type neojoin files#223
ma-mirzaei wants to merge 12 commits intodevelopfrom
221-add-view-type-neojoin-files

Conversation

@ma-mirzaei
Copy link
Copy Markdown
Contributor

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

  • Added new entities VsumView and VsumViewMetaModel to 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]
  • Created repositories VsumViewRepository and VsumViewMetaModelRepository for 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]
  • Extended the VSUM domain model (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]
  • Added mapping logic in VsumHistoryMapper to 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]
  • Introduced ViewRequest DTO 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

  • Updated VsumService to 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

Cleanup and Minor Changes


References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / VsumViewMetaModel domain 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 incoming viewRequests.
  • 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())
@ma-mirzaei
Copy link
Copy Markdown
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI commented Mar 18, 2026

@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.

Copilot AI and others added 4 commits March 18, 2026 15:14
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants