Java Code Examples for org.openrdf.model.ValueFactory#createBNode()

The following examples show how to use org.openrdf.model.ValueFactory#createBNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OwlNormalizer.java    From anno4j with Apache License 2.0 5 votes vote down vote up
private void hasValueFromList() {
	ValueFactory vf = getValueFactory();
	for (Statement st : ds.match(null, OWL.HASVALUE, null)) {
		Resource res = st.getSubject();
		Value obj = st.getObject();
		if (obj instanceof Resource) {
			BNode node = vf.createBNode();
			ds.add(res, OWL.ALLVALUESFROM, node);
			ds.add(node, RDF.TYPE, OWL.CLASS);
			BNode list = vf.createBNode();
			ds.add(node, OWL.ONEOF, list);
			ds.add(list, RDF.TYPE, RDF.LIST);
			ds.add(list, RDF.FIRST, obj);
			ds.add(list, RDF.REST, RDF.NIL);
			for (Value type : ds.match(obj, RDF.TYPE, null).objects()) {
				ds.add(node, RDFS.SUBCLASSOF, type);
			}
			for (Value prop : ds.match(res, OWL.ONPROPERTY, null).objects()) {
				for (Value range : ds.match(prop, RDFS.RANGE, null).objects()) {
					ds.add(node, RDFS.SUBCLASSOF, range);
				}
				for (Resource cls : ds.match(null, RDFS.SUBCLASSOF, res).subjects()) {
					for (Value sup : findSuperClasses(cls)) {
						if (!sup.equals(res) && !ds.match(sup, OWL.ONPROPERTY, prop).isEmpty()) {
							for (Value from : ds.match(sup, OWL.ALLVALUESFROM, null).objects()) {
								ds.add(node, RDFS.SUBCLASSOF, from);
							}
						}
					}
				}
			}
		}
	}
}
 
Example 2
Source File: CustomSesameDataset.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
/**
 * BNode factory
 * 
 * @return
 */
public BNode bnode() {
	try {
		RepositoryConnection con = currentRepository.getConnection();
		try {
			ValueFactory vf = con.getValueFactory();
			return vf.createBNode();
		} finally {
			con.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
Example 3
Source File: EntityStateSerializer.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
private void serializeValueComposite( Resource subject, URI predicate,
                                      ValueComposite value,
                                      ValueType valueType,
                                      Graph graph,
                                      String baseUri,
                                      boolean includeNonQueryable
)
{
    final ValueFactory valueFactory = graph.getValueFactory();
    BNode collection = valueFactory.createBNode();
    graph.add( subject, predicate, collection );

    ( (ValueCompositeType) valueType ).properties().forEach(
        persistentProperty ->
        {
            Object propertyValue
                = PolygeneAPI.FUNCTION_COMPOSITE_INSTANCE_OF
                .apply( value )
                .state()
                .propertyFor( persistentProperty.accessor() )
                .get();

            if( propertyValue != null )
            {
                ValueType type = persistentProperty
                    .valueType();
                if( type instanceof ValueCompositeType )
                {
                    URI pred = valueFactory.createURI( baseUri,
                                                       persistentProperty
                                                           .qualifiedName()
                                                           .name() );
                    serializeValueComposite( collection, pred,
                                             (ValueComposite) propertyValue,
                                             type, graph,
                                             baseUri
                                             + persistentProperty
                                                 .qualifiedName()
                                                 .name() + "/",
                                             includeNonQueryable );
                }
                else
                {
                    serializeProperty( persistentProperty,
                                       propertyValue,
                                       collection, graph,
                                       includeNonQueryable );
                }
            }
        } );
}
 
Example 4
Source File: AbstractBNodeIV.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public V asValue(final LexiconRelation lex) {

V bnode = getValueCache();

if (bnode == null) {

	final ValueFactory f = lex.getValueFactory();
	
	bnode = (V) f.createBNode(stringValue());
	
	bnode.setIV(this);
	
	setValue(bnode);

}
	
return bnode;

  }