本文整理汇总了Java中org.eclipse.rdf4j.model.IRI类的典型用法代码示例。如果您正苦于以下问题:Java IRI类的具体用法?Java IRI怎么用?Java IRI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IRI类属于org.eclipse.rdf4j.model包,在下文中一共展示了IRI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStatementsByObject
import org.eclipse.rdf4j.model.IRI; //导入依赖的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;
}
示例2: getStatementsBySubject
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
private CloseableIteration<? extends Statement, SailException> getStatementsBySubject(
final Resource subject,
final IRI predicate,
final Value object,
final Resource... contexts) {
CloseableIteration<? extends Statement, SailException> iter = getSubjectStatements(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;
}
示例3: map
import org.eclipse.rdf4j.model.IRI; //导入依赖的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));
}
示例4: loadRedirection_IgnoreSecondRedirection_WhenAddedTwice
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void loadRedirection_IgnoreSecondRedirection_WhenAddedTwice() {
// Arrange
stage = new Stage.Builder(DBEERPEDIA.BREWERIES, site).basePath(
DBEERPEDIA.BASE_PATH.stringValue()).build();
Redirection redirection = new Redirection.Builder(DBEERPEDIA.ID2DOC_REDIRECTION, stage,
DBEERPEDIA.ID2DOC_URL_PATTERN.stringValue(),
DBEERPEDIA.ID2DOC_TARGET_URL.stringValue()).build();
Map<IRI, Redirection> redirectionMap = new HashMap<>();
redirectionMap.put(redirection.getIdentifier(), redirection);
Redirection sameSecondRedirection = new Redirection.Builder(DBEERPEDIA.ID2DOC_DUMMY_REDIRECTION,
stage, DBEERPEDIA.ID2DOC_URL_PATTERN.stringValue(),
DBEERPEDIA.ID2DOC_TARGET_URL.stringValue()).build();
redirectionMap.put(sameSecondRedirection.getIdentifier(), sameSecondRedirection);
when(redirectionResourceProvider.getAll()).thenReturn(redirectionMap);
// Act
ldRedirectionRequestMapper.loadRedirections(httpConfiguration);
// Assert
assertThat(httpConfiguration.getResources(), hasSize(1));
}
示例5: setUp
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Before
public void setUp() {
site = new Site.Builder(DBEERPEDIA.BREWERIES).domain(DBEERPEDIA.DOMAIN.stringValue()).build();
stage = new Stage.Builder(DBEERPEDIA.BREWERIES, site).basePath(
DBEERPEDIA.BASE_PATH.stringValue()).build();
Redirection redirection = new Redirection.Builder(DBEERPEDIA.ID2DOC_REDIRECTION, stage,
DBEERPEDIA.ID2DOC_URL_PATTERN.stringValue(),
DBEERPEDIA.ID2DOC_TARGET_URL.stringValue()).build();
Map<IRI, Redirection> redirectionMap = new HashMap<>();
redirectionMap.put(redirection.getIdentifier(), redirection);
when(redirectionResourceProvider.getAll()).thenReturn(redirectionMap);
ldRedirectionRequestMapper = new LdRedirectionRequestMapper(redirectionResourceProvider);
httpConfiguration = new HttpConfiguration(ImmutableList.of());
}
示例6: map_withPredicateMappers_callsEachPredicateMapper
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void map_withPredicateMappers_callsEachPredicateMapper() throws Exception {
SimpleValueFactory f = SimpleValueFactory.getInstance();
IRI subjectIRI = f.createIRI("http://foo.bar/subjectIRI");
Set<PredicateMapper> predicateMappers = ImmutableSet.of(
mock(PredicateMapper.class),
mock(PredicateMapper.class),
mock(PredicateMapper.class),
mock(PredicateMapper.class)
);
Model model = new ModelBuilder().build();
EvaluateExpression evaluator = null;
PredicateObjectMapper testSubject = new PredicateObjectMapper(ImmutableSet.of(), predicateMappers);
testSubject.map(model, evaluator, subjectIRI, ImmutableSet.of());
predicateMappers.forEach(mapper -> verify(mapper).map(model, evaluator, subjectIRI));
}
示例7: loadResources_GetResources_WithValidData
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void loadResources_GetResources_WithValidData() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(
valueFactory.createStatement(DBEERPEDIA.BACKEND, RDF.TYPE, ELMO.SPARQL_BACKEND),
valueFactory.createStatement(DBEERPEDIA.BACKEND, ELMO.ENDPOINT, DBEERPEDIA.ENDPOINT))));
when(backendFactory.create(any(Model.class), eq(DBEERPEDIA.BACKEND))).thenReturn(backend);
when(backendFactory.supports(any(IRI.class))).thenReturn(true);
// Act
backendResourceProvider.loadResources();
// Assert
assertThat(backendResourceProvider.getAll().entrySet(), hasSize(1));
assertThat(backendResourceProvider.get(DBEERPEDIA.BACKEND), equalTo(backend));
}
示例8: expander_givenShorthandWithContext_ShouldHaveContextOnExpandedStatements
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void expander_givenShorthandWithContext_ShouldHaveContextOnExpandedStatements() {
IRI context = VF.createIRI(NS + "someContext");
Statement toExpand = VF.createStatement(TM, Rr.subject, SM, context);
Model expanded = expandAndTestShorthandStatement(toExpand, Rr.subjectMap);
int nrOfstatementsWithContext =
(int) expanded
.stream()
.filter(st -> st.getContext() != null)
.count();
assertThat(nrOfstatementsWithContext, is(2));
assertThat(expanded.contexts().size(), is(1));
assertThat(expanded.contexts(), hasItem(context));
}
示例9: addStatementInternal
import org.eclipse.rdf4j.model.IRI; //导入依赖的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);
}
}
示例10: decide
import org.eclipse.rdf4j.model.IRI; //导入依赖的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);
}
示例11: create
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Override
public ParameterDefinition create(@NonNull Model model, @NonNull IRI id) {
String name = Models.objectLiteral(model.filter(id, ELMO.NAME_PROP, null)).orElseThrow(
() -> new ConfigurationException(
String.format("No <%s> property found for <%s> of type <%s>", ELMO.NAME_PROP, id,
ELMO.TERM_FILTER))).stringValue();
Set<Value> objects = model.filter(id, ELMO.SHAPE_PROP, null).objects();
Optional<PropertyShape> propertyShapeOptional = Optional.empty();
if (objects.iterator().hasNext()) {
Set<Value> iriShapeTypes =
model.filter((Resource) objects.iterator().next(), SHACL.DATATYPE, null).objects();
propertyShapeOptional = supportedShapes.stream().filter(
propertyShape -> iriShapeTypes.iterator().next().stringValue().equals(
propertyShape.getDataType().stringValue())).findFirst();
}
return new TermParameterDefinition(id, name, propertyShapeOptional);
}
示例12: handle_ReturnsNonNullValue_ForRequiredParameter
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void handle_ReturnsNonNullValue_ForRequiredParameter() {
// Arrange
Map<String, String> parameterValues =
ImmutableMap.of(DBEERPEDIA.NAME_PARAMETER_VALUE_STRING, "http://iri");
// Act
IRI result = requiredParameter.handle(parameterValues);
// Assert
assertThat(result, is(SimpleValueFactory.getInstance().createIRI("http://iri")));
}
示例13: handle_RejectsNullValue_ForRequiredParameter
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@Test
public void handle_RejectsNullValue_ForRequiredParameter() {
// Assert
thrown.expect(BackendException.class);
thrown.expectMessage(
String.format("No value found for required parameter '%s'. Supplied parameterValues:",
DBEERPEDIA.NAME_PARAMETER_ID));
// Act
IRI handle = requiredParameter.handle(ImmutableMap.of());
assertThat(handle, is("x"));
}
示例14: getTriplesMapperComponents
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
TriplesMapperComponents<?> getTriplesMapperComponents(TriplesMap triplesMap) {
LogicalSource logicalSource = triplesMap.getLogicalSource();
IRI referenceFormulation = logicalSource.getReferenceFormulation();
if (!logicalSourceResolvers.containsKey(referenceFormulation)) {
throw new RuntimeException(String.format("Unsupported reference formulation %s", referenceFormulation));
}
return new TriplesMapperComponents<>(
logicalSourceResolvers.get(referenceFormulation),
sourceResolver.apply(logicalSource.getSource()),
logicalSource.getIterator()
);
}
示例15: getObjectGenerator
import org.eclipse.rdf4j.model.IRI; //导入依赖的package包/类
@SuppressWarnings("unchecked")
TermGenerator<Value> getObjectGenerator(ObjectMap map) {
return (TermGenerator<Value>) getGenerator(
map,
ImmutableSet.of(TermType.IRI, TermType.BLANK_NODE, TermType.LITERAL),
ImmutableSet.of(IRI.class, Literal.class)
);
}