• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Resource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: map

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
void map(Model model, EvaluateExpression evaluate, Resource subject, Set<IRI> subjectGraphs) {

		Resource[] contexts = Stream
				.concat(
					subjectGraphs.stream(),
					graphGenerators.stream()
							.map(g -> g.apply(evaluate))
							.filter(Optional::isPresent)
							.map(Optional::get)
				)
				.distinct()
				.toArray(Resource[]::new);
		
		predicateMappers.forEach(p -> p.map(model, evaluate, subject, contexts));
		
	}
 
开发者ID:carml,项目名称:carml,代码行数:17,代码来源:PredicateObjectMapper.java


示例2: testUpdateQueryWithPermsFromConnectionDefaults

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Test
public void testUpdateQueryWithPermsFromConnectionDefaults()
        throws Exception {

    GraphPermissions gp = conn.getDefaultGraphPerms();
    Assert.assertEquals(0,gp.size());
    GraphManager gmgr = adminClient.newGraphManager();
    conn.setDefaultGraphPerms(gmgr.permission("app-user", Capability.READ));


    Resource context = conn.getValueFactory().createIRI("http://marklogic.com/test/graph/permstest");

    String defGraphQuery = "INSERT DATA { GRAPH <http://marklogic.com/test/graph/permstest> { <http://marklogic.com/test> <pp1> <oo1> } }";
    String checkQuery = "ASK WHERE {  GRAPH <http://marklogic.com/test/graph/permstest> {<http://marklogic.com/test> <pp1> <oo1> }}";
    MarkLogicUpdateQuery updateQuery = conn.prepareUpdate(QueryLanguage.SPARQL, defGraphQuery);
    updateQuery.execute();

    BooleanQuery booleanQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL, checkQuery);
    boolean results = booleanQuery.evaluate();
    Assert.assertEquals(true, results);

    conn.clear(context);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:24,代码来源:MarkLogicGraphPermsTest.java


示例3: expandStatements

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private void expandStatements(Model model, Statement statement) {
	IRI p = statement.getPredicate();
	
	// add statements that are NOT shortcut properties
	// as-is to the result model
	if (!shortcutPredicates.contains(p)) {
		model.add(statement);
		return;
	}
	
	// 'p' is a shortcut predicate
	Resource context = statement.getContext();
	BNode bNode = f.createBNode();
	// TODO verify that 'context' works properly, even if it is null
	model.add(statement.getSubject(), getExpandedPredicate(p), bNode, context);
	model.add(bNode, constant, statement.getObject(), context);
}
 
开发者ID:carml,项目名称:carml,代码行数:18,代码来源:RmlConstantShorthandExpander.java


示例4: expandAndTestShorthandStatement

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private Model expandAndTestShorthandStatement(Statement toExpand, IRI expandedPredicate) {
	model.add(toExpand);
	Model expanded = SHORTHAND_EXPANDER.apply(model);
	assertThat(expanded.size(), is(2));
	
	Statement firstStatement = 
		Iterators.getOnlyElement(
			expanded
				.filter(null, expandedPredicate, null)
				.iterator()
		); 
	assertThat(firstStatement.getSubject(), is(toExpand.getSubject()));
	assertThat(firstStatement.getObject(), instanceOf(BNode.class));
	
	Statement otherSt = 
		Iterators.getOnlyElement(
			expanded
				.filter((Resource)firstStatement.getObject(), null, null)
				.iterator()
		);
	assertThat(otherSt.getPredicate(), is(Rr.constant));
	assertThat(otherSt.getObject(), is(toExpand.getObject()));
	
	return expanded;
}
 
开发者ID:carml,项目名称:carml,代码行数:26,代码来源:RmlConstantShorthandExpanderTest.java


示例5: load

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
public static <T> Set<T> load(
	Function<Model, Set<Resource>> resourceSelector, 
	Class<T> clazz,
	Model model,
	UnaryOperator<Model> modelAdapter,
	Consumer<MappingCache> populateCache,
	Consumer<Mapper> configureMapper
) {
	
	requireNonNull(resourceSelector, RESOURCE_SELECTOR_MSG);
	requireNonNull(clazz, CLASS_MSG);
	requireNonNull(model, MODEL_MSG);
	requireNonNull(modelAdapter, MODEL_ADAPTER_MSG);
	requireNonNull(populateCache, POPULATE_CACHE_MSG);
	
	MapperImpl mapper = new MapperImpl();
	populateCache.accept(mapper);
	configureMapper.accept(mapper);
	
	Set<Resource> resources = resourceSelector.apply(model);
	
	return resources
		.stream()
		.<T> map(r -> mapper.map(modelAdapter.apply(model), r, clazz))
		.collect(ImmutableCollectors.toImmutableSet());
}
 
开发者ID:carml,项目名称:carml,代码行数:27,代码来源:RdfObjectLoader.java


示例6: decide

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Override
public Type decide(Model model, Resource resource) {
	
	List<IRI> rdfTypes =
		model.filter(resource, RDF.TYPE, null).objects().stream()
			.map(v -> (IRI) v)
			.collect(Collectors.toList());
	
	// TODO what if multiple rdf:types? probably choose the only 1 that's known/registered. what if multiple of those?
	if (rdfTypes.size() > 1)
		throw new RuntimeException("multiple rdf:type triples found for resource [" + resource + "]; can't handle that yet");
	
	// if no rdf:type, use property type (or its registered implementation) as target type
	if (rdfTypes.isEmpty()) {
		if(propertyTypeDecider.isPresent()) {
			return propertyTypeDecider.get().decide(model, resource);
		} else {
			throw new RuntimeException(String.format("No decidable type found for %s. Register decidable type on rdf mapper.", resource));
		}
	}
	
	IRI rdfType = rdfTypes.get(0);
	return mapper.getDecidableType(rdfType);
}
 
开发者ID:carml,项目名称:carml,代码行数:25,代码来源:TypeFromTripleTypeDecider.java


示例7: mapGraphValue

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Override
public Object mapGraphValue(@NonNull ArrayProperty property,
    @NonNull GraphEntityContext graphEntityContext, @NonNull ValueContext valueContext,
    @NonNull SchemaMapperAdapter schemaMapperAdapter) {
  ImmutableList.Builder<Object> builder = ImmutableList.builder();

  if (hasSubjectFilterVendorExtension(property)) {
    Set<Resource> subjects = getSubjects(property, graphEntityContext);

    subjects.forEach(subject -> {
      ValueContext subjectContext = valueContext.toBuilder().value(subject).build();

      builder.add(schemaMapperAdapter.mapGraphValue(property.getItems(), graphEntityContext,
          subjectContext, schemaMapperAdapter));
    });
  } else if (valueContext.getValue() != null) {
    if (property.getVendorExtensions().containsKey(OpenApiSpecificationExtensions.LDPATH)) {
      queryAndValidate(property, graphEntityContext, valueContext, schemaMapperAdapter, builder);
    } else {
      throw new SchemaMapperRuntimeException(String.format(
          "ArrayProperty must have a '%s' attribute", OpenApiSpecificationExtensions.LDPATH));
    }
  }

  return builder.build();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:27,代码来源:ArraySchemaMapper.java


示例8: filterSubjects_ReturnsResults_WhenFilterDoesMatch

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Test
public void filterSubjects_ReturnsResults_WhenFilterDoesMatch() {
  // Arrange
  Model model = new ModelBuilder().add("http://www.test.nl#subj", "http://www.test.nl#is",
      SimpleValueFactory.getInstance().createIRI("http://www.test.nl#obj1")).add(
          "http://www.test.nl#subj2", "http://www.test.nl#is",
          SimpleValueFactory.getInstance().createIRI("http://www.test.nl#obj1")).build();
  when(graphEntityContextMock.getModel()).thenReturn(model);

  Map<String, Object> vendorExtensions =
      Maps.newHashMap(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
          Maps.newHashMap(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
              "http://www.test.nl#is", OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
              "http://www.test.nl#obj1"))));
  when(propertyMock.getVendorExtensions()).thenReturn(vendorExtensions);
  // Act
  Set<Resource> results = mapper.getSubjects(propertyMock, graphEntityContextMock);
  // Assert
  assertThat(results, hasSize(is(2)));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:AbstractSubjectFilterSchemaMapperTest.java


示例9: getStatementsByObject

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private CloseableIteration<? extends Statement, SailException> getStatementsByObject(
        final Resource subject,
        final IRI predicate,
        final Value object,
        final Resource... contexts) {
    CloseableIteration<? extends Statement, SailException> iter = getObjectStatements(object);
    if (null != subject) {
        iter = addSubjectFilter(iter, subject);
    }
    if (null != predicate) {
        iter = addPredicateFilter(iter, predicate);
    }
    if (contexts.length > 0) {
        iter = addContextFilter(iter, contexts);
    }
    return iter;
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:18,代码来源:DataStore.java


示例10: getStatementsWithFullScan

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private CloseableIteration<? extends Statement, SailException> getStatementsWithFullScan(
        final Resource subject,
        final IRI predicate,
        final Value object,
        final Resource... contexts) {
    CloseableIteration<? extends Statement, SailException> iter = getAllStatements();
    if (null != subject) {
        iter = addSubjectFilter(iter, subject);
    }
    if (null != object) {
        iter = addObjectFilter(iter, object);
    }
    if (null != predicate) {
        iter = addPredicateFilter(iter, predicate);
    }
    if (contexts.length > 0) {
        iter = addContextFilter(iter, contexts);
    }
    return iter;
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:21,代码来源:DataStore.java


示例11: addStatementInternal

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Override
public void addStatementInternal(
        final Resource subject,
        final IRI predicate,
        final Value object,
        final Resource... contexts) throws SailException {
    Vertex subjectVertex = dataStore.getOrCreateVertexByValue(subject);
    Vertex objectVertex = dataStore.getOrCreateVertexByValue(object);
    Resource[] addContexts = 0 == contexts.length
            ? DEFAULT_CONTEXT
            : contexts;
    String label = predicate.stringValue();
    for (Resource context : addContexts) {
        String contextValue = null == context ? null : context.stringValue();
        if (dataStore.getUniqueStatements()
                && dataStore.edgeExists(subjectVertex, objectVertex, label, contextValue)) {
            continue;
        }

        dataStore.addStatementInternal(subjectVertex, objectVertex, label, contextValue);
     }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:23,代码来源:GraphSailConnection.java


示例12: testNullContext

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Test
public void testNullContext() throws Exception {
    IRI uriA = sail.getValueFactory().createIRI("http://example.org/test/nullContext#a");
    IRI uriB = sail.getValueFactory().createIRI("http://example.org/test/nullContext#b");
    IRI uriC = sail.getValueFactory().createIRI("http://example.org/test/nullContext#c");

    try (SailConnection sc = getConnection()) {
        long count = countStatements(sc, uriA, null, null, false);
        assertEquals(0, count);
        sc.addStatement(uriA, uriB, uriC);
        Statement statement = sc.getStatements(uriA, uriB, uriC, false, new Resource[]{null}).next();
        Resource context = statement.getContext();
        assertNull(context);
        sc.removeStatements(uriA, null, null);
        assertFalse(sc.getStatements(uriA, uriB, uriC, false, new Resource[]{null}).hasNext());
    }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:18,代码来源:SailTest.java


示例13: performAdd

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
/**
 * Executes merge of triples from File
 *
 * @param file
 * @param baseURI
 * @param dataFormat
 * @param tx
 * @param contexts
 * @throws RDFParseException
 */
// performAdd
// as we use mergeGraphs, baseURI is always file.toURI
public void performAdd(File file, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException {
    try {
        graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType());
        if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) {
            graphManager.mergeGraphs(new FileHandle(file),tx);
        } else {
            if (contexts.length>0) {
                for (int i = 0; i < contexts.length; i++) {
                    if(Util.notNull(contexts[i])){
                        graphManager.mergeAs(contexts[i].toString(), new FileHandle(file), getGraphPerms(),tx);
                    }else{
                        graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file), getGraphPerms(), tx);
                    }
                }
            } else {
                graphManager.mergeAs(DEFAULT_GRAPH_URI, new FileHandle(file), getGraphPerms(),tx);
            }
        }
    } catch (FailedRequestException e) {
        logger.error(e.getLocalizedMessage());
        throw new RDFParseException("Request to MarkLogic server failed, check file and format.");
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:36,代码来源:MarkLogicClientImpl.java


示例14: performRemove

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
/**
 * Executes DELETE of single triple.
 *
 * @param baseURI
 * @param subject
 * @param predicate
 * @param object
 * @param tx
 * @param contexts
 * @throws MarkLogicRdf4jException
 */
public void performRemove(String baseURI, Resource subject, IRI predicate, Value object, Transaction tx, Resource... contexts) throws MarkLogicRdf4jException {
    StringBuilder sb = new StringBuilder();
    String[] contextArgs = null;
    if(contexts.length>0)
    {	if (Util.notNull(baseURI))sb.append("BASE <" + baseURI + ">\n");
        contextArgs = new String[contexts.length];
        for (int i = 0; i < contexts.length; i++) {
            if(Util.notNull(contexts[i])){
                contextArgs[i] = contexts[i].stringValue();
            }
            else{
            	contextArgs[i] = DEFAULT_GRAPH_URI;
            }
        }
    }
    sb.append("DELETE WHERE { GRAPH ?ctx { ?s ?p ?o .}}");
    SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(sb.toString());
    if(Util.notNull(contextArgs)) qdef.setUsingNamedGraphUris(contextArgs);
    if(Util.notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}
    if(Util.notNull(subject)) qdef.withBinding("s", subject.stringValue());
    if(Util.notNull(predicate)) qdef.withBinding("p", predicate.stringValue());
    if(Util.notNull(object)) bindObject(qdef, "o", object);
    sparqlManager.executeUpdate(qdef, tx);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:36,代码来源:MarkLogicClientImpl.java


示例15: ParentTriplesMapper

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
ParentTriplesMapper(
	TermGenerator<Resource> subjectGenerator,
	TriplesMapperComponents<T>  trMapperComponents
) {
	this(
		subjectGenerator, 
		trMapperComponents.getIterator(), 
		trMapperComponents.getExpressionEvaluatorFactory()
	);
}
 
开发者ID:carml,项目名称:carml,代码行数:11,代码来源:ParentTriplesMapper.java


示例16: testAddingIfClosed

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@Test
public void testAddingIfClosed() throws Exception {
    File inputFile = new File("src/test/resources/testdata/default-graph-1.ttl");
    String baseURI = "http://example.org/example1/";
    Resource context1 = conn.getValueFactory().createIRI("http://marklogic.com/test/context1");
    exception.expect(RepositoryException.class);
    conn.close();
    conn.add(inputFile, baseURI, RDFFormat.TURTLE, context1);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:10,代码来源:MarkLogicExceptionsTest.java


示例17: getSubjectGenerator

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
TermGenerator<Resource> getSubjectGenerator(SubjectMap map) {
	return (TermGenerator<Resource>) getGenerator(
		map,
		ImmutableSet.of(TermType.BLANK_NODE, TermType.IRI),
		ImmutableSet.of(IRI.class)
	);
}
 
开发者ID:carml,项目名称:carml,代码行数:9,代码来源:TermGeneratorCreator.java


示例18: mapExecution

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private Object mapExecution(Resource execution, Model model) {
	IRI functionIri = getFunctionIRI(execution, model);
	ExecuteFunction function =
			mapper.getFunction(functionIri)
				.orElseThrow(() -> new RuntimeException(
					"no function registered for function IRI [" + functionIri + "]"));

	return function.execute(model, execution);
}
 
开发者ID:carml,项目名称:carml,代码行数:10,代码来源:TermGeneratorCreator.java


示例19: getFunctionIRI

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private IRI getFunctionIRI(Resource execution, Model model) {
	return Models.objectIRI(
			model.filter(execution, Rdf.Fno.executes, null)
		)
		.orElseThrow(() -> new RuntimeException(
			"function execution does not have fno:executes value"));
}
 
开发者ID:carml,项目名称:carml,代码行数:8,代码来源:TermGeneratorCreator.java


示例20: mapPredicate

import org.eclipse.rdf4j.model.Resource; //导入依赖的package包/类
private void mapPredicate(IRI predicate, Model model, EvaluateExpression evaluate, Resource subject, Resource... contexts) {
	Consumer<Value> addObjectTriple =
			o -> model.add(subject, predicate, o, contexts);
		
	objectGenerators.stream()
		.map(g -> g.apply(evaluate))
		.filter(Optional::isPresent)
		.map(Optional::get)
		.forEach(addObjectTriple);
	
	refObjectMappers.stream()
		.flatMap(r -> r.map(evaluate).stream())
		.forEach(addObjectTriple);
}
 
开发者ID:carml,项目名称:carml,代码行数:15,代码来源:PredicateMapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyAccessorUtils类代码示例发布时间:2022-05-21
下一篇:
Java IPage类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap