public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor ) { Graph graph = new GraphImpl(); ValueFactory values = graph.getValueFactory(); URI entityTypeUri = values.createURI( Classes.toURI( entityDescriptor.types().findFirst().orElse( null ) ) ); graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS ); graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS ); graph.add( entityTypeUri, PolygeneEntityType.TYPE, values.createLiteral( entityDescriptor.types().findFirst().get().toString() ) ); graph.add( entityTypeUri, PolygeneEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) ); serializeMixinTypes( entityDescriptor, graph, entityTypeUri ); serializePropertyTypes( entityDescriptor, graph, entityTypeUri ); serializeAssociationTypes( entityDescriptor, graph, entityTypeUri ); serializeManyAssociationTypes( entityDescriptor, graph, entityTypeUri ); return graph; }
private void indexEntityType( final EntityDescriptor entityType, final RepositoryConnection connection ) throws RepositoryException { if( entityType.queryable() ) { String uri = Classes.toURI(entityType.types().findFirst().orElse(null)); final URI compositeURI = getValueFactory().createURI( uri ); // remove composite type if already present connection.clear( compositeURI ); Iterable<Statement> statements = typeSerializer.serialize( entityType ); connection.add( statements, compositeURI ); } }
private void indexEntityType( final EntityDescriptor entityType, final RepositoryConnection connection ) throws RepositoryException { if( entityType.queryable() ) { String uri = Classes.toURI(entityType.types().findFirst().orElse(null)); final URI compositeURI = getValueFactory().createURI( uri ); // remove composite type if already present connection.clear( compositeURI ); Iterable<Statement> statements = typeSerializer.serialize( entityType ); connection.add( statements, compositeURI ); } }
@Test public void testEntityTypeSerializer() throws RDFHandlerException { EntityDescriptor entityDescriptor = module.entityDescriptor(TestEntity.class.getName()); Iterable<Statement> graph = serializer.serialize( entityDescriptor ); String[] prefixes = new String[]{ "rdf", "dc", " vc", "polygene" }; String[] namespaces = new String[]{ Rdfs.RDF, DcRdf.NAMESPACE, "http://www.w3.org/2001/vcard-rdf/3.0#", PolygeneEntityType.NAMESPACE }; new RdfXmlSerializer().serialize( graph, new PrintWriter( System.out ), prefixes, namespaces ); }