Skip to content

Commit

Permalink
Fixed bamm migration for Literal Datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
ysrbo committed Aug 9, 2023
1 parent a10d67c commit 08177ec
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.jena.graph.NodeFactory;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.ResourceFactory;
import org.apache.jena.rdf.model.Statement;
import org.eclipse.esmf.aspectmodel.vocabulary.Namespace;
import org.eclipse.esmf.samm.KnownVersion;
Expand Down Expand Up @@ -78,6 +82,19 @@ protected Optional<String> rewriteUri( final String oldUri, final Map<String, St
return Optional.of( result );
}

@Override
protected RDFNode updateRdfNode( final RDFNode rdfNode, final Map<String, String> oldToNewNamespaces ) {
RDFNode result = super.updateRdfNode( rdfNode, oldToNewNamespaces );
if ( result instanceof Literal literal ) {
result = Optional.ofNullable( literal.getDatatypeURI() )
.flatMap( type -> rewriteUri( type, oldToNewNamespaces ) )
.map( NodeFactory::getType )
.<RDFNode> map( type -> ResourceFactory.createTypedLiteral( literal.getString(), type ) )
.orElse( result );
}
return result;
}

@Override
public Model migrate( final Model sourceModel ) {
final Map<String, String> targetPrefixes = Namespace.createPrefixMap( getTargetKnownVersion() );
Expand Down

0 comments on commit 08177ec

Please sign in to comment.