Java Code Examples for org.openrdf.model.vocabulary.RDFS#LABEL

The following examples show how to use org.openrdf.model.vocabulary.RDFS#LABEL . 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: TestBigdataSailRemoteRepository.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test of insert and retrieval of a large literal.
 */
public void test_INSERT_veryLargeLiteral() throws Exception {

    final Graph g = new LinkedHashModel();
    
    final URI s = new URIImpl("http://www.bigdata.com/");
    final URI p = RDFS.LABEL;
    final Literal o = getVeryLargeLiteral();
    final Statement stmt = new StatementImpl(s, p, o);
    g.add(stmt);
    
    // Load the resource into the KB.
    assertEquals(
            1L,
            doInsertByBody("POST", RDFFormat.RDFXML, g, null/* defaultContext */));

    // Read back the data into a graph.
    final Graph g2;
    {
        final String queryStr = "DESCRIBE <" + s.stringValue() + ">";
        final GraphQuery query = cxn.prepareGraphQuery(QueryLanguage.SPARQL, queryStr);
        g2 = asGraph(query.evaluate());
        
    }
    
    assertEquals(1, g2.size());
    
    assertTrue(g2.match(s, p, o).hasNext());
    
}
 
Example 2
Source File: BigdataRDFFactory.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct an instance with a simple Sesame ValueFactoryImpl.
 */
private BigdataRDFFactory() {
	super(new ValueFactoryImpl(), 
	        GRAPH_NAMESPACE, VERTEX_NAMESPACE, EDGE_NAMESPACE,
	        RDF.TYPE, VERTEX, EDGE, RDFS.LABEL);
}
 
Example 3
Source File: TestStatementBuffer.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
     * Test verifies detection of duplicate terms and their automatic
     * replacement with a canonicalizing term.
     */
    public void test_handleStatement_distinctTerm() {

        final int capacity = 5;

        final AbstractTripleStore store = getStore();

        try {

			final StatementBuffer<Statement> buffer = new StatementBuffer<Statement>(
					store, capacity);

//            assertTrue(buffer.distinct);

            /*
             * add a statement.
             */

            final URI s1 = new URIImpl("http://www.foo.org");
            final URI p1 = RDF.TYPE;
            final URI o1 = RDFS.RESOURCE;
            final URI c1 = null; // no context.

            buffer.handleStatement(s1, p1, o1, c1, StatementEnum.Explicit);

            assertEquals(8, buffer.numURIs);
            assertEquals(0, buffer.numLiterals);
            assertEquals(0, buffer.numBNodes);
            assertEquals(1, buffer.numStmts);

            /*
             * add another statement.
             */

            final URI s2 = new URIImpl("http://www.foo.org"); // duplicate term!
            final URI p2 = RDFS.LABEL;
            final Literal o2 = new LiteralImpl("test lit.");
            final URI c2 = null;

            buffer.handleStatement(s2, p2, o2, c2, StatementEnum.Explicit);

            assertEquals(9, buffer.numURIs); // only 4 since one is duplicate.
            assertEquals(1, buffer.numLiterals);
            assertEquals(0, buffer.numBNodes);
            assertEquals(2, buffer.numStmts);

            /*
             * add a duplicate statement.
             */

            final URI s3 = new URIImpl("http://www.foo.org"); // duplicate term
            final URI p3 = RDFS.LABEL;                        // duplicate term
            final Literal o3 = new LiteralImpl("test lit.");  // duplicate term
            final URI c3 = null;

            buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit);

            assertEquals(9, buffer.numURIs);
            assertEquals(1, buffer.numLiterals);
            assertEquals(0, buffer.numBNodes);
            assertEquals(3, buffer.numStmts);

            /*
             * add a duplicate statement using the _same_ term objects.
             */

            buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit);

            assertEquals(9, buffer.numURIs);
            assertEquals(1, buffer.numLiterals);
            assertEquals(0, buffer.numBNodes);
            assertEquals(4, buffer.numStmts);
            
            buffer.flush();

        } finally {

            store.__tearDownUnitTest();

        }

    }
 
Example 4
Source File: DefaultBlueprintsValueFactory.java    From database with GNU General Public License v2.0 3 votes vote down vote up
/**
    * {@inheritDoc}
    */
@Override
public URI toPropertyURI(final String property) {
	
	try {

	    if (property.equals("label")) {
	     
	        /*
	         * Label is a reserved property for edge labels, we use
	         * rdfs:label for that.
	         */
	        return RDFS.LABEL;
	        
	    } else {
		
	        return vf.createURI(GRAPH_NAMESPACE, URLEncoder.encode(property, "UTF-8"));
	        
	    }
			
	} catch (UnsupportedEncodingException e) {
		
		throw new RuntimeException(e);
		
	}
	
}
 
Example 5
Source File: TestStatementBuffer.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
* Test verifies interpretation of triples by the {@link StatementBuffer} by
* validating how the triples written onto the statement buffer are loaded
* into the {@link AbstractTripleStore}.
*/
  public void test_statementBuffer() {

      final int capacity = 5;

final Properties properties = new Properties(getProperties());

// turn off entailments.
properties.setProperty(AbstractTripleStore.Options.AXIOMS_CLASS,
		NoAxioms.class.getName());

      final AbstractTripleStore store = getStore(properties);

      try {
      	
      		// store is empty.
      		assertEquals(0,store.getStatementCount());

      		final BigdataValueFactory vf = store.getValueFactory();
      	
	final StatementBuffer<Statement> buffer = new StatementBuffer<Statement>(
			store, capacity);

          /*
           * add a statement.
           */

          final URI s1 = new URIImpl("http://www.foo.org");
          final URI p1 = RDF.TYPE;
          final URI o1 = RDFS.RESOURCE;
          final URI c1 = null; // no context.

          buffer.add(vf.createStatement(s1, p1, o1, c1, StatementEnum.Explicit));

          /*
           * add another statement.
           */

          final URI s2 = new URIImpl("http://www.foo.org"); // duplicate term!
          final URI p2 = RDFS.LABEL;
          final Literal o2 = new LiteralImpl("test lit.");
          final URI c2 = null;

          buffer.add(vf.createStatement(s2, p2, o2, c2, StatementEnum.Explicit));

          /*
           * add a duplicate statement.
           */

          final URI s3 = new URIImpl("http://www.foo.org"); // duplicate term
          final URI p3 = RDFS.LABEL;                        // duplicate term
          final Literal o3 = new LiteralImpl("test lit.");  // duplicate term
          final URI c3 = null;

          buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit);

          // store is still empty (statements are buffered).
          assertEquals(0,store.getStatementCount());

          // flush the buffer.
	buffer.flush();

	// the statements are now in the store.
	assertEquals(2, store.getStatementCount());

	assertTrue(store.hasStatement(s1, p1, o1));
	assertTrue(store.hasStatement(s2, p2, o2));
	assertFalse(store.hasStatement(s1, p2, o1));

      } finally {

          store.__tearDownUnitTest();

      }

  }