-
Notifications
You must be signed in to change notification settings - Fork 10
Miscellanea
Marco Brandizi edited this page Feb 4, 2023
·
6 revisions
Every PG node created by rdf2pg tools must have at least a default label, to which further labels can be added. There a default value for such label, 'Resource', which can be changed via the configuration property defaultNodeLabel
:
<beans...>
...
<bean id = "defaultNodeLabel" class = "java.lang.String">
<constructor-arg value = "ItemNode" />
</bean>
...
</beans>
Labels, relation types and node/relation property names can be converted from URIs or literals. We have a simple default converter that does that. You can define your own converter and configure it via Spring, by using the beans named nodeLabelIdConverter
, relationIdConverter
, propertyIdConverter
. For instance:
<beans...>
<!--
Must be a class implementing java.util.function.Function<String, String>, which takes a IRI and returns an identifier.
If your class needs config values, either in the constructor or via bean setters, you can use the usual Spring syntax to pass them.
-->
<bean id = "nodeLabelIdConverter" class = "my.package.MyCustomIdConverter" />
</beans>
An example of how a new converter might be:
public class DefaultIri2IdConverter implements Function<String, String>
{
@Override
public String apply ( String iri )
{
String prefix = IRIUtils.prefix ( iri );
String id = IRIUtils.lastFragment ( iri ); // possibly the whole IRI
return prefix == null ? id : prefix + ":" + id; // i.e., a CURIE
}
}