Fix: Pattern link edge labels swapped in model-transformation diagrams#13
Fix: Pattern link edge labels swapped in model-transformation diagrams#13amirrza777 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
addPatternLinkLabelsend-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.
| @Test | ||
| fun `print inferred metamodel and model for a real csv file`() { |
| val properties = mutableListOf<PropertyData>() | ||
| val enums = mutableListOf<EnumData>() | ||
|
|
||
| header.forEachIndexed { colIndex, rawColumnName -> | ||
| val propertyName = sanitizePropertyName(rawColumnName, fallback = "column${colIndex + 1}") | ||
| val values = columns[colIndex] |
| 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) }) | ||
| } |
| val normalizedBasePath = basePath.trim().trim('/') | ||
| val metamodelPath = "$normalizedBasePath.metamodel" | ||
| val modelPath = "$normalizedBasePath.model" |
|
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? |
|
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. |
Closes #11
Related to #12
Changes
Bug fix — edge label swap (#11)
.end()values inaddPatternLinkLabelsinmodelTransformationGModelFactory.ts"source", target property label tagged"target"Feature — CSV model import (#12)
CsvModelInferencein themetamodelmodule: 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)CsvImportServiceandCsvImportRoutesin the backend:POST /api/projects/{projectId}/csv-importaccepts a CSV file and writes the resulting.metamodeland.modelfiles into the projectStatus