Search in sources :

Example 1 with Options

use of org.qi4j.api.value.ValueSerializer.Options in project qi4j-sdk by Qi4j.

the class EntityStateSerializer method serializeProperty.

private void serializeProperty(PropertyDescriptor persistentProperty, Object property, Resource subject, Graph graph, boolean includeNonQueryable) {
    if (!(includeNonQueryable || persistentProperty.queryable())) {
        // Skip non-queryable
        return;
    }
    ValueType valueType = persistentProperty.valueType();
    final ValueFactory valueFactory = graph.getValueFactory();
    String propertyURI = persistentProperty.qualifiedName().toURI();
    URI predicate = valueFactory.createURI(propertyURI);
    String baseURI = propertyURI.substring(0, propertyURI.indexOf('#')) + "/";
    if (valueType instanceof ValueCompositeType) {
        serializeValueComposite(subject, predicate, (ValueComposite) property, valueType, graph, baseURI, includeNonQueryable);
    } else {
        String stringProperty = valueSerializer.serialize(new Options().withoutTypeInfo(), property);
        final Literal object = valueFactory.createLiteral(stringProperty);
        graph.add(subject, predicate, object);
    }
}
Also used : Options(org.qi4j.api.value.ValueSerializer.Options) ValueType(org.qi4j.api.type.ValueType) Literal(org.openrdf.model.Literal) ValueFactory(org.openrdf.model.ValueFactory) URI(org.openrdf.model.URI) ValueCompositeType(org.qi4j.api.type.ValueCompositeType)

Aggregations

Literal (org.openrdf.model.Literal)1 URI (org.openrdf.model.URI)1 ValueFactory (org.openrdf.model.ValueFactory)1 ValueCompositeType (org.qi4j.api.type.ValueCompositeType)1 ValueType (org.qi4j.api.type.ValueType)1 Options (org.qi4j.api.value.ValueSerializer.Options)1