Skip to content

Commit 3525061

Browse files
authored
Merge pull request #352 from bci-oss/bugfix/esmf-fix-validation-issues
Fix validation issues after update to esmf.
2 parents f91c545 + c18bffc commit 3525061

File tree

2 files changed

+27
-4
lines changed
  • core
    • esmf-aspect-meta-model-resolver
    • esmf-aspect-meta-model-version-migrator/src/main/java/org/eclipse/esmf/aspectmodel/versionupdate/migrator

2 files changed

+27
-4
lines changed

core/esmf-aspect-meta-model-resolver/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<packaging>jar</packaging>
3030

3131
<properties>
32-
<samm-revision>https://raw.githubusercontent.com/eclipse-esmf/esmf-semantic-aspect-meta-model/34468bf</samm-revision>
32+
<samm-revision>
33+
https://raw.githubusercontent.com/eclipse-esmf/esmf-semantic-aspect-meta-model/bf9196547384bf072095cc8300d45ca7117a3211/esmf-semantic-aspect-meta-model
34+
</samm-revision>
3335
</properties>
3436

3537
<dependencies>
@@ -144,8 +146,6 @@
144146

145147
<!-- Download updated meta model shape files -->
146148
<!-- This refers to the state of the shape files after merging of https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/pull/176 -->
147-
<!-- TODO: Enable this section once https://github.com/eclipse-esmf/esmf-semantic-aspect-meta-model/pull/186 has been merged -->
148-
<!--
149149
<plugin>
150150
<groupId>com.googlecode.maven-download-plugin</groupId>
151151
<artifactId>download-maven-plugin</artifactId>
@@ -221,7 +221,6 @@
221221
</execution>
222222
</executions>
223223
</plugin>
224-
-->
225224

226225
</plugins>
227226
</build>

core/esmf-aspect-meta-model-version-migrator/src/main/java/org/eclipse/esmf/aspectmodel/versionupdate/migrator/BammUriRewriter.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313

1414
package org.eclipse.esmf.aspectmodel.versionupdate.migrator;
1515

16+
import java.util.ArrayList;
17+
import java.util.List;
1618
import java.util.Map;
1719
import java.util.Optional;
1820
import java.util.stream.Collectors;
1921

2022
import org.apache.jena.rdf.model.Model;
23+
import org.apache.jena.rdf.model.Statement;
24+
import org.eclipse.esmf.aspectmodel.vocabulary.Namespace;
2125
import org.eclipse.esmf.samm.KnownVersion;
2226

2327
/**
@@ -67,4 +71,24 @@ protected Optional<String> rewriteUri( final String oldUri, final Map<String, St
6771
result = result.replace( "urn:bamm:", "urn:samm:" );
6872
return Optional.of( result );
6973
}
74+
75+
@Override
76+
public Model migrate( final Model sourceModel ) {
77+
final Map<String, String> targetPrefixes = Namespace.createPrefixMap( getTargetKnownVersion() );
78+
final Map<String, String> oldToNewNamespaces = buildReplacementPrefixMap( sourceModel, targetPrefixes );
79+
80+
final List<Statement> remappedStatements = new ArrayList<>();
81+
82+
// it is important to do the remapping "in situ" (in the same model), because otherwise the position information would be lost.
83+
sourceModel.listStatements().forEach( statement ->
84+
remappedStatements.add( sourceModel.createStatement( updateResource( statement.getSubject(), oldToNewNamespaces ),
85+
updateProperty( statement.getPredicate(), oldToNewNamespaces ),
86+
updateRdfNode( statement.getObject(), oldToNewNamespaces ) ) )
87+
);
88+
89+
sourceModel.removeAll();
90+
remappedStatements.forEach( sourceModel::add );
91+
sourceModel.setNsPrefixes( buildPrefixMap( sourceModel, targetPrefixes, oldToNewNamespaces ) );
92+
return sourceModel;
93+
}
7094
}

0 commit comments

Comments
 (0)