Skip to content

Fix: Pattern link edge labels swapped in model-transformation diagrams#13

Draft
amirrza777 wants to merge 1 commit into
mde-optimiser:mainfrom
amirrza777:amir/fixes-and-features
Draft

Fix: Pattern link edge labels swapped in model-transformation diagrams#13
amirrza777 wants to merge 1 commit into
mde-optimiser:mainfrom
amirrza777:amir/fixes-and-features

Conversation

@amirrza777

@amirrza777 amirrza777 commented Jul 3, 2026

Copy link
Copy Markdown

Closes #11
Related to #12

Changes

Bug fix — edge label swap (#11)

  • Fixed swapped .end() values in addPatternLinkLabels in modelTransformationGModelFactory.ts
  • Source property label now correctly tagged "source", target property label tagged "target"

Feature — CSV model import (#12)

  • Added CsvModelInference in the metamodel module: infers a metamodel and model from a CSV file (type detection: int, double, boolean, enum, string; one class per file, one property per column, one instance per row)
  • Added CsvImportService and CsvImportRoutes in the backend: POST /api/projects/{projectId}/csv-import accepts a CSV file and writes the resulting .metamodel and .model files into the project
  • Added unit tests for the inference logic (all passing)

Status

  • Edge label fix applied and compiles cleanly
  • CSV inference logic implemented and unit tested
  • Backend endpoint wired into auth/permission system
  • End-to-end testing in running app (in progress)

@amirrza777 amirrza777 marked this pull request as draft July 3, 2026 12:08
@szschaler szschaler requested a review from Copilot July 3, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a diagram rendering bug where pattern link edge end labels were assigned to the wrong end, and adds an initial CSV import pipeline that infers a metamodel/model pair from CSV text and exposes it via a backend endpoint.

Changes:

  • Corrected addPatternLinkLabels end-tagging so source/target edge labels attach to the correct edge end.
  • Added CsvModelInference (metamodel module) plus unit tests for CSV parsing and type inference.
  • Added backend CSV import service + route, wiring it into DI and adding the metamodel module dependency; adjusted workbench Docker build memory.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
platform/metamodel/src/test/kotlin/com/mdeo/metamodel/csv/CsvModelInferenceTest.kt Adds unit tests covering CSV parsing, type inference, optionality, enums, and header sanitization.
platform/metamodel/src/test/kotlin/com/mdeo/metamodel/csv/CsvModelInferenceManualRun.kt Adds a manual-run test harness for printing inferred metamodel/model from a CSV file.
platform/metamodel/src/main/kotlin/com/mdeo/metamodel/csv/CsvModelInference.kt Implements CSV parsing + inference to produce MetamodelData and ModelData.
platform/common/src/main/kotlin/com/mdeo/common/model/ApiResult.kt Adds an error code for CSV import failures.
platform/backend/src/main/kotlin/com/mdeo/backend/service/InjectedServices.kt Extends injected services with csvImportService.
platform/backend/src/main/kotlin/com/mdeo/backend/service/CsvImportService.kt Implements backend CSV→(metamodel, model) import and writes results into project files.
platform/backend/src/main/kotlin/com/mdeo/backend/routes/CsvImportRoutes.kt Exposes POST /api/projects/{projectId}/csv-import with permission checks.
platform/backend/src/main/kotlin/com/mdeo/backend/Application.kt Registers CsvImportService and routes in the backend module wiring.
platform/backend/build.gradle.kts Adds :metamodel dependency to backend for CSV inference usage.
infra/docker/workbench/Dockerfile Increases Node heap during workbench build to reduce build-time OOM.
app/packages/language-model-transformation/src/features/diagram-server/modelTransformationGModelFactory.ts Swaps pattern link end label .end(...) values to fix swapped/missing labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +11
@Test
fun `print inferred metamodel and model for a real csv file`() {
Comment on lines +59 to +64
val properties = mutableListOf<PropertyData>()
val enums = mutableListOf<EnumData>()

header.forEachIndexed { colIndex, rawColumnName ->
val propertyName = sanitizePropertyName(rawColumnName, fallback = "column${colIndex + 1}")
val values = columns[colIndex]
Comment on lines +141 to +146
val distinctValues = nonBlankValues.distinct()
val isRepeated = distinctValues.size < nonBlankValues.size
if (distinctValues.size <= enumMaxDistinct && isRepeated) {
val enumName = propertyName.replaceFirstChar(Char::uppercaseChar) + "Enum"
return ColumnType.Enum(enumName, distinctValues.map { sanitizeEnumEntry(it) })
}
Comment on lines +31 to +33
val normalizedBasePath = basePath.trim().trim('/')
val metamodelPath = "$normalizedBasePath.metamodel"
val modelPath = "$normalizedBasePath.model"
@szschaler

Copy link
Copy Markdown
Member

Many thanks, @amirrza777. I notice that this PR also includes some files related to CSV import, which is unrelated to the issue that the PR aims to fix. Could you separate these out to make for a cleaner PR?

@szschaler

Copy link
Copy Markdown
Member

I just noticed that this seems to be intentional. I would recommend ensuring that each PR maps to exactly one issue that it solves rather than trying to solve multiple issues in one PR. That makes reviewing PRs much easier.

@szschaler szschaler added the bug Something isn't working label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Edge labels missing or swapped in model-transformation diagrams

3 participants