本文整理汇总了Java中org.eclipse.rdf4j.model.vocabulary.RDF类的典型用法代码示例。如果您正苦于以下问题:Java RDF类的具体用法?Java RDF怎么用?Java RDF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RDF类属于org.eclipse.rdf4j.model.vocabulary包,在下文中一共展示了RDF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapSubject
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
private Resource mapSubject(Resource subject, Model model, EvaluateExpression evaluate) {
// use graphs when generating statements later
Set<IRI> graphs = graphGenerators.stream()
.map(g -> g.apply(evaluate))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(ImmutableCollectors.toImmutableSet());
Resource[] contexts = new Resource[graphs.size()];
graphs.toArray(contexts);
// generate rdf:type triples from classes
classes.forEach(c -> model.add(subject, RDF.TYPE, c, contexts));
predicateObjectMappers.forEach(p -> p.map(model, evaluate, subject, graphs));
return subject;
}
示例2: map_withClasses_appliesEveryClassToGeneratedSubject
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void map_withClasses_appliesEveryClassToGeneratedSubject() throws Exception {
EvaluateExpression evaluator = null;
SimpleValueFactory f = SimpleValueFactory.getInstance();
IRI subjectIRI = f.createIRI("http://foo.bar/subjectIRI");
when(subjectGenerator.apply(evaluator))
.thenReturn(Optional.of(subjectIRI));
Set<IRI> expectedClasses =
ImmutableSet.of(
f.createIRI("http://www.none.invalid/foo"),
f.createIRI("http://www.none.invalid/bar"),
f.createIRI("http://www.none.invalid/baz")
);
Model model = new ModelBuilder().build();
SubjectMapper s = new SubjectMapper(subjectGenerator, ImmutableSet.of(), expectedClasses, ImmutableSet.of());
s.map(model, evaluator);
expectedClasses.forEach(iri -> Assert.assertTrue(model.contains(subjectIRI, RDF.TYPE, iri)));
}
示例3: decide
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的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);
}
示例4: ldPathQuery_ReturnsResult_ForQuery
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void ldPathQuery_ReturnsResult_ForQuery() {
// Arrange
when(entityContextMock.getLdPathNamespaces()).thenReturn(
ImmutableMap.of("beer", "http://dbeerpedia.org#"));
Model model = new ModelBuilder().subject(DBEERPEDIA.BROUWTOREN).add(RDF.TYPE,
DBEERPEDIA.BREWERY_TYPE).add(DBEERPEDIA.NAME, DBEERPEDIA.BROUWTOREN_NAME).subject(
DBEERPEDIA.MAXIMUS).add(RDF.TYPE, DBEERPEDIA.BREWERY_TYPE).add(DBEERPEDIA.NAME,
DBEERPEDIA.MAXIMUS_NAME).build();
when(entityContextMock.getModel()).thenReturn(model);
LdPathExecutor executor = new LdPathExecutor(entityContextMock);
// Act
Collection<Value> result = executor.ldPathQuery(DBEERPEDIA.BROUWTOREN, "beer:Name");
// Assert
assertThat(result, contains(DBEERPEDIA.BROUWTOREN_NAME));
}
示例5: mapGraphValue_ReturnsNull_WhenSubjectFilterYieldsNoResultAndPropertyIsOptional
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void mapGraphValue_ReturnsNull_WhenSubjectFilterYieldsNoResultAndPropertyIsOptional() {
// Arrange
response.setVendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
RDF.TYPE.stringValue(), OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
DBEERPEDIA.BREWERY_TYPE.stringValue())));
objectProperty.setVendorExtensions(
ImmutableMap.of(OpenApiSpecificationExtensions.LDPATH, DBEERPEDIA.NAME.stringValue()));
objectProperty.setProperties(
ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), new StringProperty()));
Model model = new ModelBuilder().build();
when(contextMock.getModel()).thenReturn(model);
// Act
Object result = schemaMapperAdapter.mapGraphValue(new ResponseProperty(response), contextMock,
ValueContext.builder().value(null).build(), schemaMapperAdapter);
// Assert
assertThat(result, nullValue());
}
示例6: mapGraphValue_ThrowsException_WhenSubjectFilterYieldsNoResultAndPropertyIsRequired
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void mapGraphValue_ThrowsException_WhenSubjectFilterYieldsNoResultAndPropertyIsRequired() {
// Assert
expectedException.expect(SchemaMapperRuntimeException.class);
expectedException.expectMessage(
"Subject filter for a required object property yielded no result");
// Arrange
response.setVendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
RDF.TYPE.stringValue(), OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
DBEERPEDIA.BREWERY_TYPE.stringValue())));
objectProperty.setVendorExtensions(
ImmutableMap.of(OpenApiSpecificationExtensions.LDPATH, DBEERPEDIA.NAME.stringValue()));
objectProperty.setProperties(
ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), new StringProperty()));
objectProperty.setRequired(true);
Model model = new ModelBuilder().build();
when(contextMock.getModel()).thenReturn(model);
// Act
schemaMapperAdapter.mapGraphValue(new ResponseProperty(response), contextMock,
ValueContext.builder().value(null).build(), schemaMapperAdapter);
}
示例7: mapGraphValue_ReturnsNull_WhenSubjectFilterYieldsNoResultAndPropertyIsOptional
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void mapGraphValue_ReturnsNull_WhenSubjectFilterYieldsNoResultAndPropertyIsOptional() {
// Arrange
property.setVendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
RDF.TYPE.stringValue(), OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
DBEERPEDIA.BREWERY_TYPE.stringValue()),
OpenApiSpecificationExtensions.LDPATH, DBEERPEDIA.NAME.stringValue()));
property.setProperties(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), new StringProperty()));
Model model = new ModelBuilder().build();
when(contextMock.getModel()).thenReturn(model);
// Act
Object result = schemaMapperAdapter.mapGraphValue(property, contextMock,
ValueContext.builder().value(null).build(), schemaMapperAdapter);
// Assert
assertThat(result, nullValue());
}
示例8: mapGraphValue_ThrowsException_WhenSubjectFilterYieldsNoResultAndPropertyIsRequired
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void mapGraphValue_ThrowsException_WhenSubjectFilterYieldsNoResultAndPropertyIsRequired() {
// Assert
expectedException.expect(SchemaMapperRuntimeException.class);
expectedException.expectMessage(
"Subject filter for a required object property yielded no result");
// Arrange
property.setVendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
RDF.TYPE.stringValue(), OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
DBEERPEDIA.BREWERY_TYPE.stringValue()),
OpenApiSpecificationExtensions.LDPATH, DBEERPEDIA.NAME.stringValue()));
property.setProperties(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), new StringProperty()));
property.setRequired(true);
Model model = new ModelBuilder().build();
when(contextMock.getModel()).thenReturn(model);
// Act
schemaMapperAdapter.mapGraphValue(property, contextMock,
ValueContext.builder().value(null).build(), schemaMapperAdapter);
}
示例9: mapGraphValue_ThrowsException_WhenSubjectFilterYieldsMultipleResults
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void mapGraphValue_ThrowsException_WhenSubjectFilterYieldsMultipleResults() {
// Assert
expectedException.expect(SchemaMapperRuntimeException.class);
expectedException.expectMessage("More entrypoint subjects found. Only one is required");
// Arrange
property.setVendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
RDF.TYPE.stringValue(), OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
DBEERPEDIA.BREWERY_TYPE.stringValue()),
OpenApiSpecificationExtensions.LDPATH, DBEERPEDIA.NAME.stringValue()));
property.setProperties(ImmutableMap.of(DBEERPEDIA.NAME.stringValue(), new StringProperty()));
property.setRequired(true);
Model model = new ModelBuilder().subject(DBEERPEDIA.BROUWTOREN).add(RDF.TYPE,
DBEERPEDIA.BREWERY_TYPE).add(DBEERPEDIA.NAME, DBEERPEDIA.BROUWTOREN_NAME).subject(
DBEERPEDIA.MAXIMUS).add(RDF.TYPE, DBEERPEDIA.BREWERY_TYPE).add(DBEERPEDIA.NAME,
DBEERPEDIA.MAXIMUS_NAME).build();
when(contextMock.getModel()).thenReturn(model);
// Act
schemaMapperAdapter.mapGraphValue(property, contextMock,
ValueContext.builder().value(null).build(), schemaMapperAdapter);
}
示例10: loadResources_LoadsSite_WithValidData
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_LoadsSite_WithValidData() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(
valueFactory.createStatement(DBEERPEDIA.SITE, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE, ELMO.DOMAIN, DBEERPEDIA.DOMAIN,
DBEERPEDIA.SYSTEM_GRAPH_IRI))));
// Act
siteResourceProvider.loadResources();
// Assert
assertThat(siteResourceProvider.getAll().entrySet(), hasSize(1));
assertThat(siteResourceProvider.get(DBEERPEDIA.SITE), is(not(nullValue())));
}
示例11: loadResources_LoadsSeveralSite_WithValidData
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_LoadsSeveralSite_WithValidData() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(valueFactory.createStatement(DBEERPEDIA.SITE, RDF.TYPE, ELMO.SITE),
valueFactory.createStatement(DBEERPEDIA.SITE, ELMO.DOMAIN, DBEERPEDIA.DOMAIN,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE_NL, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE_NL, ELMO.DOMAIN, DBEERPEDIA.DOMAIN_NL,
DBEERPEDIA.SYSTEM_GRAPH_IRI))));
// Act
siteResourceProvider.loadResources();
// Assert
assertThat(siteResourceProvider.getAll().entrySet(), hasSize(2));
}
示例12: loadResources_ThrowsException_WithSitesWithSimularDomain
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_ThrowsException_WithSitesWithSimularDomain() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(
valueFactory.createStatement(DBEERPEDIA.SITE, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE, ELMO.DOMAIN, DBEERPEDIA.DOMAIN,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE_NL, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE_NL, ELMO.DOMAIN, DBEERPEDIA.DOMAIN,
DBEERPEDIA.SYSTEM_GRAPH_IRI))));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(
String.format("Domain <%s> found for multiple sites.", DBEERPEDIA.DOMAIN.stringValue()));
// Act
siteResourceProvider.loadResources();
}
示例13: loadResources_ThrowsException_WithMultipleCatchAllDomains
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_ThrowsException_WithMultipleCatchAllDomains() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(
valueFactory.createStatement(DBEERPEDIA.SITE, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI),
valueFactory.createStatement(DBEERPEDIA.SITE_NL, RDF.TYPE, ELMO.SITE,
DBEERPEDIA.SYSTEM_GRAPH_IRI))));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(String.format("Catch all domain found for multiple sites"));
// Act
siteResourceProvider.loadResources();
}
示例14: loadResources_LoadStage_WithValidData
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_LoadStage_WithValidData() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(valueFactory.createStatement(DBEERPEDIA.STAGE, RDF.TYPE, ELMO.STAGE),
valueFactory.createStatement(DBEERPEDIA.STAGE, ELMO.SITE_PROP, DBEERPEDIA.SITE),
valueFactory.createStatement(DBEERPEDIA.STAGE, ELMO.BASE_PATH, DBEERPEDIA.BASE_PATH))));
// Act
stageResourceProvider.loadResources();
// Assert
assertThat(stageResourceProvider.getAll().entrySet(), hasSize(1));
Stage stage = stageResourceProvider.get(DBEERPEDIA.STAGE);
assertThat(stage, is(not(nullValue())));
assertThat(stage.getSite(), equalTo(site));
assertThat(stage.getBasePath(), equalTo(DBEERPEDIA.BASE_PATH.stringValue()));
}
示例15: loadResources_LoadMultipleStages_WithValidData
import org.eclipse.rdf4j.model.vocabulary.RDF; //导入依赖的package包/类
@Test
public void loadResources_LoadMultipleStages_WithValidData() {
// Arrange
when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(valueFactory.createStatement(DBEERPEDIA.STAGE, RDF.TYPE, ELMO.STAGE),
valueFactory.createStatement(DBEERPEDIA.STAGE, ELMO.SITE_PROP, DBEERPEDIA.SITE),
valueFactory.createStatement(DBEERPEDIA.STAGE, ELMO.BASE_PATH, DBEERPEDIA.BASE_PATH),
valueFactory.createStatement(DBEERPEDIA.SECOND_STAGE, RDF.TYPE, ELMO.STAGE),
valueFactory.createStatement(DBEERPEDIA.SECOND_STAGE, ELMO.SITE_PROP,
DBEERPEDIA.SITE))));
// Act
stageResourceProvider.loadResources();
// Assert
assertThat(stageResourceProvider.getAll().entrySet(), hasSize(2));
}