Skip to content

Commit 57a5a5d

Browse files
committed
[1322] Make file extension check case-insensitive on textual import
Bug: #1322 Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
1 parent 548cb1d commit 57a5a5d

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ At the moment SysON only supports KerML and SysML, and does not support the defi
7373
All existing SysON _DiagramDescriptions_ (i.g. _General View_, _Interconnection View_...) have been updated to reflect the fact that they now be associated to `ViewUsages`.
7474
- https://github.com/eclipse-syson/syson/issues/1310[#1310] [metamodel] Remove derived flag for `ViewUsage#exposedElement` feature.
7575
- https://github.com/eclipse-syson/syson/issues/1314[#1314] [diagrams] Update `ViewUsage#exposedElement` when manipulating any SysMLv2 diagram (_General View_, _Interconnection View_, ...).
76-
76+
- https://github.com/eclipse-syson/syson/issues/1322[#1322] [import] Make file extension check case-insensitive on textual import (i.e. allows to import .SYSML, .SysML, .KERML...)
7777

7878
=== New features
7979

backend/application/syson-application/src/test/resources/scripts/initialize-test-data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fi
1717

1818
echo "Cleaning syson-db & importing ./${1}"
1919
# Remove winpty if you are not calling the script from git bash
20-
psql -U dbuser -d syson-db --host "localhost" --port "5433" -f ./cleanup.sql -f ./${1}
20+
winpty psql -U dbuser -d syson-db --host "localhost" --port "5433" -f ./cleanup.sql -f ./${1}
2121
echo "Done"
2222

2323
exit 0

backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/upload/SysMLExternalResourceLoaderService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -64,7 +64,7 @@ public boolean canHandle(InputStream inputStream, URI resourceURI, ResourceSet r
6464
canHandle = false;
6565
}
6666
if (canHandle) {
67-
canHandle = resourceURI != null && (resourceURI.toString().endsWith(".sysml") || resourceURI.toString().endsWith(".kerml"));
67+
canHandle = resourceURI != null && (resourceURI.toString().toLowerCase().endsWith(".sysml") || resourceURI.toString().toLowerCase().endsWith(".kerml"));
6868
}
6969
return canHandle;
7070
}

backend/application/syson-sysml-import/src/test/java/org/eclipse/syson/sysml/SysMLExternalResourceLoaderServiceTests.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 Obeo.
2+
* Copyright (c) 2024, 2025 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -29,15 +29,32 @@
2929
*/
3030
public class SysMLExternalResourceLoaderServiceTests {
3131

32+
private static final String PACKAGE_P1 = "package p1;";
33+
3234
@Test
3335
public void testCandHandle() {
3436
// Incorrect content
3537
assertFalse(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream("{}".getBytes()), URI.createFileURI("/test/model.sysml"), new ResourceSetImpl()));
3638
// Incorrect extension
37-
assertFalse(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream("package p1;".getBytes()), URI.createFileURI("/test/model.sysml2"),
39+
assertFalse(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.sysml2"),
40+
new ResourceSetImpl()));
41+
// Valid file
42+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.sysml"),
43+
new ResourceSetImpl()));
44+
// Valid file
45+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.kerml"),
46+
new ResourceSetImpl()));
47+
// Valid file
48+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.SYSML"),
49+
new ResourceSetImpl()));
50+
// Valid file
51+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.KERML"),
52+
new ResourceSetImpl()));
53+
// Valid file
54+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.SysML"),
3855
new ResourceSetImpl()));
3956
// Valid file
40-
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream("package p1;".getBytes()), URI.createFileURI("/test/model.sysml"),
57+
assertTrue(new SysMLExternalResourceLoaderService(new SysmlToAst(null)).canHandle(new ByteArrayInputStream(PACKAGE_P1.getBytes()), URI.createFileURI("/test/model.KerML"),
4158
new ResourceSetImpl()));
4259
}
4360

doc/content/modules/user-manual/pages/release-notes/2025.6.0.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ image:StateTransitionsCmpOnStates.png[State Transition Compartment on StateUsage
247247

248248
- The `ViewUsage#exposedElement` feature is no longer derived in the metamodel.
249249
- The `ViewUsage#exposedElement` feature is now updated to reflect the contents of the diagram (_General View_, _Interconnection View_...) on which it is associated.
250+
- Make file extension check case-insensitive on textual import (i.e. allows to import .SYSML, .SysML, .KERML...)
250251

251252
== Dependency update
252253

0 commit comments

Comments
 (0)