当前位置: 首页>>代码示例>>Java>>正文


Java FOAF类代码示例

本文整理汇总了Java中org.openrdf.model.vocabulary.FOAF的典型用法代码示例。如果您正苦于以下问题:Java FOAF类的具体用法?Java FOAF怎么用?Java FOAF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FOAF类属于org.openrdf.model.vocabulary包,在下文中一共展示了FOAF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUser

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
private static User getUser( Resource id, RepositoryConnection rc )
		throws RepositoryException {

	LinkedHashModel model = new LinkedHashModel( Iterations.asList(
			rc.getStatements( id, null, null, false ) ) );
	org.openrdf.model.Model namer = model.filter( id, FOAF.ACCOUNT, null );
	RemoteUserImpl user = new RemoteUserImpl( namer.objectString() );
	model.removeAll( namer );

	for ( Statement stmt : model ) {
		URI pred = stmt.getPredicate();
		String val = stmt.getObject().stringValue();

		for ( Map.Entry<UserProperty, URI> en : PROPMAP.entrySet() ) {
			if ( en.getValue().equals( pred ) ) {
				user.setProperty( en.getKey(), val );
			}
		}
	}

	return user;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:23,代码来源:UserMapper.java

示例2: getId

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
private static Resource getId( User t, RepositoryConnection rc )
		throws RepositoryException {
	List<Statement> stmts = Iterations.asList( rc.getStatements( null, RDF.TYPE,
			FOAF.PERSON, false ) );
	Resource idToRemove = null;
	for ( Statement s : stmts ) {
		Resource sbj = s.getSubject();
		List<Statement> individuals
				= Iterations.asList( rc.getStatements( sbj, FOAF.ACCOUNT, null, false ) );
		for ( Statement ind : individuals ) {
			if ( ind.getObject().stringValue().equals( t.getUsername() ) ) {
				idToRemove = sbj;
			}
		}
	}

	return idToRemove;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:19,代码来源:UserMapper.java

示例3: getCreateStatements

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
private static Collection<Statement> getCreateStatements( Resource id, User t,
		ValueFactory vf ) {
	List<Statement> stmts = new ArrayList<>();
	stmts.add( new StatementImpl( id, RDF.TYPE, FOAF.PERSON ) );
	stmts.add( new StatementImpl( id, FOAF.ACCOUNT, vf.createLiteral( t.getUsername() ) ) );

	for ( Map.Entry<UserProperty, URI> en : PROPMAP.entrySet() ) {
		UserProperty prop = en.getKey();

		String str = t.getProperty( prop );
		if ( !str.trim().isEmpty() ) {
			stmts.add( new StatementImpl( id, en.getValue(), vf.createLiteral( str ) ) );
		}
	}

	return stmts;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:UserMapper.java

示例4: testSingleStatementPattern

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testSingleStatementPattern() throws Exception {
    // Insert data
    insert(OWL.THING, RDF.TYPE, OWL.CLASS);
    insert(FOAF.PERSON, RDF.TYPE, OWL.CLASS, 1);
    insert(FOAF.PERSON, RDFS.SUBCLASSOF, OWL.THING);
    insert(VF.createURI("urn:Alice"), RDF.TYPE, FOAF.PERSON);
    dao.flush();
    // Define query and expected results
    final String query = "SELECT * WHERE {\n"
            + "  ?individual a ?type .\n"
            + "}";
    List<String> varNames = Arrays.asList("individual", "type");
    Multiset<BindingSet> expectedSolutions = HashMultiset.create();
    expectedSolutions.add(new ListBindingSet(varNames, OWL.THING, OWL.CLASS));
    expectedSolutions.add(new ListBindingSet(varNames, FOAF.PERSON, OWL.CLASS));
    expectedSolutions.add(new ListBindingSet(varNames, VF.createURI("urn:Alice"), FOAF.PERSON));
    // Execute pipeline and verify results
    testPipelineQuery(query, expectedSolutions);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:PipelineQueryIT.java

示例5: testSelectQuery

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testSelectQuery() throws Exception {
    String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
            + "SELECT * WHERE {\n"
            + "  ?x a foaf:Person .\n"
            + "  ?y a foaf:Person .\n"
            + "  ?x foaf:knows ?y .\n"
            + "}";
    ParsedQuery query = new SPARQLParser().parseQuery(text, null);
    AntecedentVisitor visitor = new AntecedentVisitor();
    query.getTupleExpr().visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(
            new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
            new StatementPattern(new Var("y"), c(RDF.TYPE), c(FOAF.PERSON)),
            new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y")));
    Assert.assertEquals(expected, visitor.getAntecedents());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:AntecedentVisitorTest.java

示例6: testConstructQuery

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testConstructQuery() throws Exception {
    String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
            + "CONSTRUCT {\n"
            + "  ?y foaf:knows ?x .\n"
            + "  ?y <urn:knows> ?x .\n"
            + "  ?x <urn:knows> ?y .\n"
            + "} WHERE {\n"
            + "  ?x a foaf:Person .\n"
            + "  ?y a foaf:Person .\n"
            + "  ?x foaf:knows ?y .\n"
            + "}";
    ParsedQuery query = new SPARQLParser().parseQuery(text, null);
    AntecedentVisitor visitor = new AntecedentVisitor();
    query.getTupleExpr().visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(
            new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
            new StatementPattern(new Var("y"), c(RDF.TYPE), c(FOAF.PERSON)),
            new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y")));
    Assert.assertEquals(expected, visitor.getAntecedents());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:AntecedentVisitorTest.java

示例7: testComplexQuery

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testComplexQuery() throws Exception {
    String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
            + "PREFIX ex: <" + EX + ">\n"
            + "SELECT * WHERE {\n"
            + "  { ?x a foaf:Person } UNION {\n"
            + "    GRAPH ex:Graph1 { ?y a foaf:Person }\n"
            + "  } .\n"
            + "  GRAPH ex:Graph2 {\n"
            + "    ?x foaf:knows ?y .\n"
            + "  }\n ."
            + "  OPTIONAL { ?x foaf:mbox ?m } .\n"
            + "  FILTER (?x != ?y) .\n"
            + "}";
    ParsedQuery query = new SPARQLParser().parseQuery(text, null);
    AntecedentVisitor visitor = new AntecedentVisitor();
    query.getTupleExpr().visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(
            new StatementPattern(Scope.NAMED_CONTEXTS, new Var("y"), c(RDF.TYPE), c(FOAF.PERSON), c(G1)),
            new StatementPattern(new Var("x"), c(RDF.TYPE), c(FOAF.PERSON)),
            new StatementPattern(Scope.NAMED_CONTEXTS, new Var("x"), c(FOAF.KNOWS), new Var("y"), c(G2)),
            new StatementPattern(new Var("x"), c(FOAF.MBOX), new Var("m")));
    Assert.assertEquals(expected, visitor.getAntecedents());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:AntecedentVisitorTest.java

示例8: testBNodeQuery

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testBNodeQuery() throws Exception {
    String text = "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n"
            + "SELECT * WHERE {\n"
            + "  ?x a [ rdfs:subClassOf foaf:Person ] .\n"
            + "  ?x foaf:knows ?y .\n"
            + "}";
    ParsedQuery query = new SPARQLParser().parseQuery(text, null);
    AntecedentVisitor visitor = new AntecedentVisitor();
    query.getTupleExpr().visit(visitor);
    Set<StatementPattern> actual = visitor.getAntecedents();
    Assert.assertEquals(3, actual.size());
    StatementPattern knows = new StatementPattern(new Var("x"), c(FOAF.KNOWS), new Var("y"));
    Assert.assertTrue(actual.remove(knows));
    Assert.assertTrue(actual.removeIf(sp -> {
        return sp.getSubjectVar().equals(new Var("x"))
                && RDF.TYPE.equals(sp.getPredicateVar().getValue())
                && sp.getObjectVar().getValue() == null;
    }));
    Assert.assertTrue(actual.removeIf(sp -> {
        return sp.getSubjectVar().getValue() == null
                && RDFS.SUBCLASSOF.equals(sp.getPredicateVar().getValue())
                && FOAF.PERSON.equals(sp.getObjectVar().getValue());
    }));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:AntecedentVisitorTest.java

示例9: testGeneralConsequent

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testGeneralConsequent() throws Exception {
    String text = "CONSTRUCT {\n"
            + "  ?x ?p2 ?y"
            + "} WHERE {\n"
            + "  ?x ?p1 ?y .\n"
            + "  ?p1 rdfs:subPropertyOf ?p2 .\n"
            + "}";
    ParsedGraphQuery query = (ParsedGraphQuery) PARSER.parseQuery(text, null);
    SpinConstructRule rule = new SpinConstructRule(OWL.THING, RL_PRP_SPO1, query);
    Multiset<StatementPattern> expectedAntecedents = HashMultiset.create(Arrays.asList(
            new StatementPattern(new Var("p1"), ac(RDFS.SUBPROPERTYOF), new Var("p2")),
            new StatementPattern(new Var("x"), new Var("p1"), new Var("y"))));
    Multiset<StatementPattern> expectedConsequents = HashMultiset.create(Arrays.asList(
            new StatementPattern(new Var("subject"), new Var("predicate"), new Var("object"))));
    Assert.assertEquals(expectedAntecedents, HashMultiset.create(rule.getAntecedentPatterns()));
    Assert.assertEquals(expectedConsequents, HashMultiset.create(rule.getConsequentPatterns()));
    Assert.assertFalse(rule.hasAnonymousConsequent());
    // Basic pattern matches
    Assert.assertTrue(rule.canConclude(new StatementPattern(new Var("a"), new Var("b"), new Var("c"))));
    // Narrower patterns match (constants in place of variables)
    Assert.assertTrue(rule.canConclude(new StatementPattern(new Var("x"), c(RDFS.SUBPROPERTYOF), c(OWL.THING))));
    Assert.assertTrue(rule.canConclude(new StatementPattern(c(OWL.NOTHING), new Var("prop"), c(OWL.THING))));
    Assert.assertTrue(rule.canConclude(new StatementPattern(c(FOAF.PERSON), c(RDFS.SUBCLASSOF), new Var("x"))));
    Assert.assertTrue(rule.canConclude(new StatementPattern(c(OWL.NOTHING), c(RDFS.SUBCLASSOF), c(FOAF.PERSON))));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:SpinConstructRuleTest.java

示例10: testConcreteSP

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testConcreteSP() {
    Extension extension = new Extension(new SingletonSet(),
            new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"),
            new ExtensionElem(new ValueConstant(RDF.TYPE), "y"),
            new ExtensionElem(new ValueConstant(OWL.CLASS), "z"));
    Projection projection = new Projection(extension, new ProjectionElemList(
            new ProjectionElem("x", "subject"),
            new ProjectionElem("y", "predicate"),
            new ProjectionElem("z", "object")));
    ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
    projection.visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(
            new StatementPattern(s(FOAF.PERSON), p(RDF.TYPE), o(OWL.CLASS)));
    Assert.assertEquals(expected, visitor.getConsequents());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:ConstructConsequentVisitorTest.java

示例11: getURIWithManagedId

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Identifiers for managed URI must be be directly served by the dictionary, without involving the decoratee.
 * 
 * @throws Exception never otherwise the test fails.
 */
@Test
public void getURIWithManagedId() throws Exception {
	final URI managedUri = buildResource(FOAF.NAMESPACE + System.currentTimeMillis());

	final String n3 = NTriplesUtil.toNTriplesString(managedUri);

	when(_dummyIndex.getQuick(any(byte[].class))).thenReturn(n3);
	when(_dummyIndex.get(n3)).thenReturn(ValueDictionaryBase.NOT_SET);

	byte[] id = _cut.getID(managedUri, _isPredicate);

	final Value value = _cut.getValue(id, _isPredicate);
	assertEquals(managedUri, value);

	verify(_decoratee, times(0)).getValue(id, _isPredicate);
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:22,代码来源:KnownURIsDictionaryTest.java

示例12: removeManagedURI

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Tests remove() method with managed URI.
 * 
 * @throws Exception never otherwise the test fails.
 */
@Test
public void removeManagedURI() throws Exception {
	final String[] managedNamespaces = {
			FOAF.NAMESPACE,
			RDFS.NAMESPACE,
			OWL.NAMESPACE };

	for (final String managedNamespace : managedNamespaces) {
		assertTrue(_cut.contains(managedNamespace));

		final Value uri = buildResource(managedNamespace + randomString());
		final String n3 = NTriplesUtil.toNTriplesString(uri);

		_cut.removeValue(uri, _isPredicate);
		verify(_dummyIndex).remove(n3);

		reset(_dummyIndex);
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:25,代码来源:KnownURIsDictionaryTest.java

示例13: generateModel

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
static Model generateModel(RepositoryResult<Statement> statements) {

		Model model = null;
		try {
			model = Iterations.addAll(statements, new LinkedHashModel());
		} catch (RepositoryException e) {
			e.printStackTrace();
		}

		model.setNamespace("rdf", RDF.NAMESPACE);
		model.setNamespace("rdfs", RDFS.NAMESPACE);
		model.setNamespace("foaf", FOAF.NAMESPACE);
		model.setNamespace("schema", schema);
		model.setNamespace("dbpedia", dbpedia);
		model.setNamespace("dc", dublin);
		return model;
	}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:18,代码来源:Homework.java

示例14: SaveRdf

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
/**
 * Saves as RDF the graph created.
 *
 * @throws RepositoryException
 * @throws RDFHandlerException
 * @throws IOException
 */
private void SaveRdf() throws RepositoryException, RDFHandlerException, IOException {
    RepositoryResult statements = src.getStatements(null, null, null, true);

    Model model = new LinkedHashModel();

    java.util.ArrayList arr = new java.util.ArrayList();
    while (statements.hasNext()) {
        arr.add(statements.next());
    }
    model.addAll(arr);

    model.setNamespace("rdf", RDF.NAMESPACE);
    model.setNamespace("rdfs", RDFS.NAMESPACE);
    model.setNamespace("xsd", XMLSchema.NAMESPACE);
    model.setNamespace("foaf", FOAF.NAMESPACE);
    model.setNamespace("ex", "");

    Rio.write(model, new java.io.FileWriter(new java.io.File(outputFileName),false), RDFFormat.TURTLE);
    
    CloseAllConnections();
}
 
开发者ID:ale003,项目名称:testGraphDbs,代码行数:29,代码来源:GenerateRdf.java

示例15: testParsing

import org.openrdf.model.vocabulary.FOAF; //导入依赖的package包/类
@Test
public void testParsing() throws ParseException {
    List<PatchLine> patchLines = parser.parsePatch();

    Iterator<PatchLine> it = patchLines.iterator();

    Assert.assertTrue(it.hasNext());
    checkPatchLine(it.next(), PatchLine.Operator.DELETE, bob, FOAF.NAME, lcBob);

    Assert.assertTrue(it.hasNext());
    checkPatchLine(it.next(), PatchLine.Operator.ADD, bob, FOAF.NAME, ucBob);

    Assert.assertTrue(it.hasNext());
    checkPatchLine(it.next(), PatchLine.Operator.ADD, null, FOAF.KNOWS, alice);

    Assert.assertTrue(it.hasNext());
    checkPatchLine(it.next(), PatchLine.Operator.DELETE, null, null, charlie);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:19,代码来源:RdfPatchParserImplTest.java


注:本文中的org.openrdf.model.vocabulary.FOAF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。