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


Java ValueFactory.createIRI方法代码示例

本文整理汇总了Java中org.eclipse.rdf4j.model.ValueFactory.createIRI方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactory.createIRI方法的具体用法?Java ValueFactory.createIRI怎么用?Java ValueFactory.createIRI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.rdf4j.model.ValueFactory的用法示例。


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

示例1: loadResources_ThrowException_WithUnknownParameterMapper

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void loadResources_ThrowException_WithUnknownParameterMapper() {
  // Assert
  thrown.expect(ConfigurationException.class);

  // Arrange
  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  final IRI unknownParameterMapper =
      valueFactory.createIRI("http://dotwebstack.org/def/elmo", "UnknownParameterMapper");

  when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
      ImmutableList.of(
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, RDF.TYPE,
              unknownParameterMapper),
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, ELMO.SOURCE_PROP,
              HTTP.REQUEST_URI),
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, ELMO.TARGET_PROP,
              DBEERPEDIA.SUBJECT_PARAMETER))));

  // Act
  parameterMapperResourceProvider.loadResources();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:ParameterMapperResourceProviderTest.java

示例2: loadTriples

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
public void loadTriples() throws RepositoryException {
    ValueFactory vf = SimpleValueFactory.getInstance();
    IRI graph = vf.createIRI("urn:test");
    int docSize = 100000;

    conn.configureWriteCache(750,750,600); // customise write cache (initDelay interval, delayCache interval, cache size)

    conn.begin();
    Set<Statement> bulkInsert = new HashSet();
    for (int term = 0; term < docSize; term++) {
        bulkInsert.add(vf.createStatement
                (vf.createIRI("urn:subject:" + term),
                        vf.createIRI("urn:predicate:" + term),
                        vf.createIRI("urn:object:" + term)));
    }
    conn.add(bulkInsert, graph);
    conn.commit();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:19,代码来源:Example4_Load_Triples.java

示例3: verifyStatementPresence

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private void verifyStatementPresence(Collection<Statement> statements, URI contextUri) throws Exception {
    final EntityManager em = emf.createEntityManager();
    final Repository repo = em.unwrap(Repository.class);
    try (final RepositoryConnection connection = repo.getConnection()) {
        final ValueFactory vf = connection.getValueFactory();
        final org.eclipse.rdf4j.model.IRI context = vf.createIRI(contextUri.toString());
        for (Statement s : statements) {
            final RepositoryResult rr = connection
                    .getStatements(s.getSubject(), s.getPredicate(), s.getObject(), false, context);
            assertTrue(rr.hasNext());
            rr.close();
        }
    } finally {
        em.close();
    }
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:17,代码来源:OccurrenceReportFormGenDaoTest.java

示例4: buildOntoMetaData

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private <ONTORES> void buildOntoMetaData(Model model, Resource root, ValueFactory factory,
		OntoContainer<ONTORES> onto, int number) {
	
	IRI ontologyResource = factory.createIRI(ALIGN_NS + onto.getURI());
	
	if (number == 1) {			
		model.add(root, ONTO1_PROPERTY, ontologyResource);			
	} else {
		model.add(root, ONTO2_PROPERTY, ontologyResource);
	}
	
	model.add(ontologyResource, RDF.TYPE, ONTOLOGY_TYPE);
	model.add(ontologyResource, LOCATION_PROPERTY,factory.createLiteral(onto.getURI().toString()));
	model.add(ontologyResource, FORMALISM_PROPERTY,factory.createLiteral(onto.getFormalism()));
	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:17,代码来源:EuzenatRDFImpl.java

示例5: buildNoMapNode

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private <ONTORES> void buildNoMapNode(OntoContainer<ONTORES> onto,
		NoMappingPossible<ONTORES> noMap, int number, Model model, ValueFactory factory,
		Resource alignmentRoot) {
	
	// ordre d'insertion des proprietes necessaires pour avoir une "belle"
	// ecriture dans le fichier RDF/XML
	
	// on créé le noeud correspondant a la Cell		
	BNode cellNode = factory.createBNode();
	// on relie l'objet "Alignement" a ce noeud par la propriete "nomap"
	model.add(alignmentRoot,NOMAP_PROPERTY,cellNode);
	// on donne le type de l'objet "Cell"
	model.add(cellNode, RDF.TYPE, CELL_TYPE);		
	
	IRI res1 = factory.createIRI(onto.getURI(noMap.getConcept())
			.toString());
	if (number == 1)
		model.add(cellNode,ENTITY1_PROPERTY,res1);
	else
		model.add(cellNode,ENTITY2_PROPERTY,res1);
	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:23,代码来源:EuzenatRDFImpl.java

示例6: testEvaluate

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testEvaluate() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:18,代码来源:HBaseSailTest.java

示例7: testEvaluateWithContext

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testEvaluateWithContext() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    IRI context = vf.createIRI("http://whatever/context/");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj, context);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o from named <http://whatever/context/> where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertFalse(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HBaseSailTest.java

示例8: testTruncateTable

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testTruncateTable() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value expl = vf.createLiteral("explicit");
    for (KeyValue kv : HalyardTableUtils.toKeyValues(subj, pred, expl, null, false, System.currentTimeMillis())) {
            table.put(new Put(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(), kv.getTimestamp()).add(kv));
    }
    table.flushCommits();
    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, expl, null))) {
        assertNotNull(rs.next());
    }
    table = HalyardTableUtils.truncateTable(table);
    try (ResultScanner rs = table.getScanner(HalyardTableUtils.scan(subj, pred, expl, null))) {
        assertNull(rs.next());
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HalyardTableUtilsTest.java

示例9: initTestData

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
public static GeneratedData initTestData(Repository repository) throws RepositoryException {
    final RepositoryConnection connection = repository.getConnection();
    connection.begin();
    final ValueFactory vf = connection.getValueFactory();

    final GeneratedData data = new GeneratedData();
    int classCount = randomPositiveInt(10);
    for (int i = 0; i < classCount; i++) {
        final String cls = "http://krizik.felk.cvut.cz/ontologies/jopa/entities#OWLClass" + RAND.nextInt();
        data.classes.add(cls);
        int individualCount = randomPositiveInt(20);
        for (int j = 0; j < individualCount; j++) {
            final String ind = cls + "_instance-" + RAND.nextInt();
            data.individuals.add(ind);
            final IRI indUri = vf.createIRI(ind);
            generatePropertiesWithValues(indUri, data, connection);
            connection.add(indUri, RDF.TYPE, vf.createIRI(cls));
            data.addValue(ind, Assertion.createClassAssertion(false), java.net.URI.create(cls));
        }
    }

    connection.commit();
    connection.close();
    return data;
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:26,代码来源:Generator.java

示例10: testAsRDFTermOverloads

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testAsRDFTermOverloads() {
    final RDF4J rdf4J = new RDF4J();

    final ValueFactory valueFactory = SimpleValueFactory.getInstance();

    final Value bNode = valueFactory.createBNode("b1");
    final Value iri = valueFactory.createIRI("http://ex.org");
    final Value literal = valueFactory.createLiteral("b1");

    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((BNode) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((IRI) iri));
    assertEquals(rdf4J.asRDFTerm(literal), rdf4J.asRDFTerm((Literal) literal));
    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((Resource) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((Resource) iri));
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:17,代码来源:RDF4JMethodOverloadsTest.java

示例11: setUp

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    testDir = tempDir.newFolder("schema-generator-test").toPath();

    ValueFactory vf = SimpleValueFactory.getInstance();

    String ns = "http://example.com/ns/ontology#";
    testOntologyUri = vf.createIRI(ns);
    testProperty1 = vf.createIRI(ns, "property1");
    testProperty2 = vf.createIRI(ns, "property_2");
    testProperty3 = vf.createIRI(ns, "property-3");
    testProperty4 = vf.createIRI(ns, "propertyLocalised4");
    testProperty1Description = vf.createLiteral("property 1 description");
    testProperty2Description = vf.createLiteral("property 2 description");
    testProperty3Description = vf.createLiteral("property 3 description");
    testProperty4DescriptionEn = vf.createLiteral("property 4 description english", "en");
    testProperty4DescriptionFr = vf.createLiteral("Description de la propriété français", "fr");

    Model testOntology = new LinkedHashModel();
    testOntology.add(testOntologyUri, RDF.TYPE, OWL.ONTOLOGY);
    testOntology.add(testProperty1, RDF.TYPE, OWL.DATATYPEPROPERTY);
    testOntology.add(testProperty2, RDF.TYPE, OWL.OBJECTPROPERTY);
    testOntology.add(testProperty3, RDF.TYPE, OWL.ANNOTATIONPROPERTY);
    testOntology.add(testProperty4, RDF.TYPE, OWL.ANNOTATIONPROPERTY);
    testOntology.add(testProperty1, DCTERMS.DESCRIPTION, testProperty1Description);
    testOntology.add(testProperty2, RDFS.COMMENT, testProperty2Description);
    testOntology.add(testProperty3, SKOS.DEFINITION, testProperty3Description);
    testOntology.add(testProperty4, SKOS.PREF_LABEL, testProperty4DescriptionEn);
    testOntology.add(testProperty4, SKOS.PREF_LABEL, testProperty4DescriptionFr);
    String fileName = "test." + format.getDefaultFileExtension();
    inputPath = testDir.resolve(fileName);
    try (final OutputStream outputStream = Files.newOutputStream(inputPath)) {
        Rio.write(testOntology, outputStream, format);
    }
}
 
开发者ID:ansell,项目名称:rdf4j-schema-generator,代码行数:36,代码来源:SchemaGeneratorTest.java

示例12: mapper_builtWithLogicalSourceResolvers_shouldUseTheCorrectResolver

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void mapper_builtWithLogicalSourceResolvers_shouldUseTheCorrectResolver() throws IOException {
	ValueFactory f = SimpleValueFactory.getInstance();
	IRI expectedIRI = f.createIRI("http://this.iri/isUsed");
	Iterable<String> expectedSourceData = Collections.singletonList("expected");
	LogicalSourceResolver.SourceIterator<String> expectedSourceIterator = (a, b) -> expectedSourceData;
	LogicalSourceResolver.ExpressionEvaluatorFactory<String> expectedFactory = a -> null;
	LogicalSourceResolver<String> expectedResolver = new LogicalSourceResolverContainer<>(
			expectedSourceIterator, expectedFactory);

	IRI unusedIRI = f.createIRI("http://this.iri/isNotUsed");
	LogicalSourceResolver<String> unusedResolver = new LogicalSourceResolverContainer<>(null, null);

	SourceResolver sourceResolver = mock(SourceResolver.class);
	String input = "foo";
	when(sourceResolver.apply(any())).thenReturn(Optional.of(input));

	RmlMapper mapper = RmlMapper.newBuilder()
			.sourceResolver(sourceResolver)
			.setLogicalSourceResolver(expectedIRI, expectedResolver)
			.setLogicalSourceResolver(unusedIRI, unusedResolver)
			.build();

	TriplesMap logicalSourceMap = mock(TriplesMap.class);
	when(logicalSourceMap.getLogicalSource())
			.thenReturn(new LogicalSourceImpl(null, null, expectedIRI));

	TriplesMapperComponents<?> components = mapper.getTriplesMapperComponents(logicalSourceMap);

	Assert.assertSame(expectedFactory, components.getExpressionEvaluatorFactory());
	Assert.assertSame(expectedSourceData, components.getIterator().get());

}
 
开发者ID:carml,项目名称:carml,代码行数:34,代码来源:RmlMapperTest.java

示例13: mapper_usedWithUnknownReferenceFormulation_shouldThrowException

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void mapper_usedWithUnknownReferenceFormulation_shouldThrowException() throws IOException {
	ValueFactory f = SimpleValueFactory.getInstance();
	IRI unusedIRI = f.createIRI("http://this.iri/isNotUsed");
	LogicalSourceResolver<?> unusedResolver = new LogicalSourceResolverContainer<>(null, null);

	SourceResolver sourceResolver = mock(SourceResolver.class);
	String input = "foo";
	when(sourceResolver.apply(any())).thenReturn(Optional.of(input));

	RmlMapper mapper = RmlMapper.newBuilder()
			.sourceResolver(sourceResolver)
			.setLogicalSourceResolver(unusedIRI, unusedResolver)
			.build();

	IRI unsupportedRefFormulation = f.createIRI("http://this.iri/isNotSupported");

	TriplesMap logicalSourceMap = mock(TriplesMap.class);
	when(logicalSourceMap.getLogicalSource())
			.thenReturn(new LogicalSourceImpl(null, null, unsupportedRefFormulation));


	exception.expect(RuntimeException.class);
	exception.expectMessage(startsWith("Unsupported reference formulation"));
	exception.expectMessage(contains(unsupportedRefFormulation.toString()));

	mapper.getTriplesMapperComponents(logicalSourceMap);
}
 
开发者ID:carml,项目名称:carml,代码行数:29,代码来源:RmlMapperTest.java

示例14: getSubjects

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Apply the subject filter and returns the filtered subjects.
 * 
 * @param property property with subject filter
 * @param graphEntityContext context of the entity
 * @return non empty set when no results could be found.
 * @throws IllegalStateException If the property does not have the
 *         {@link OpenApiSpecificationExtensions#SUBJECT_FILTER} vendor extension defined. Please
 *         call {@link #hasSubjectFilterVendorExtension(Property)} before calling this method.
 */
protected final Set<Resource> getSubjects(@NonNull Property property,
    @NonNull GraphEntityContext graphEntityContext) {
  if (!hasSubjectFilterVendorExtension(property)) {
    throw new IllegalStateException(String.format(
        "Vendor extension '%s' not defined, "
            + "please call hasSubjectFilterVendorExtension() before calling this method",
        OpenApiSpecificationExtensions.SUBJECT_FILTER));
  }

  Map subjectFilter =
      (Map) property.getVendorExtensions().get(OpenApiSpecificationExtensions.SUBJECT_FILTER);

  String predicate =
      (String) subjectFilter.get(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE);
  String object =
      (String) subjectFilter.get(OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT);

  if (predicate == null || object == null) {
    throw new SchemaMapperRuntimeException(
        "Subject filter cannot work without missing predicate or object.");
  }

  ValueFactory vf = SimpleValueFactory.getInstance();

  final IRI predicateIri = vf.createIRI(predicate);
  final IRI objectIri = vf.createIRI(object);
  Model filteredModel = graphEntityContext.getModel().filter(null, predicateIri, objectIri);

  return filteredModel.subjects();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:41,代码来源:AbstractSubjectFilterSchemaMapper.java

示例15: merge

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Merge the value given as argument into the value factory given as argument.
 */
@SuppressWarnings("unchecked")
private <T extends Value> T merge(T value, @NonNull ValueFactory vf) {
  if (value instanceof IRI) {
    return (T) vf.createIRI(value.stringValue());
  } else if (value instanceof BNode) {
    return (T) vf.createBNode(((BNode) value).getID());
  } else {
    return value;
  }
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:14,代码来源:AbstractRdf4jBackend.java


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