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


Java RDFS类代码示例

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


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

示例1: writeTo_JsonLdFormat_ForQueryResult

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void writeTo_JsonLdFormat_ForQueryResult() throws Exception {
  // Arrange
  final JsonLdGraphEntityWriter writer = new JsonLdGraphEntityWriter();
  Model model =
      new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDF.TYPE, DBEERPEDIA.BACKEND).add(
          RDFS.LABEL, DBEERPEDIA.BREWERIES_LABEL).build();

  when(graphEntity.getQueryResult()).thenReturn(graphQueryResult);
  when(graphQueryResult.hasNext()).thenReturn(true, true, true, false);
  when(graphQueryResult.next()).thenReturn(model.stream().findFirst().get(),
      model.stream().skip(1).toArray(Statement[]::new));

  // Act
  writer.writeTo(graphEntity, null, null, null, null, null, outputStream);

  // Assert
  verify(outputStream).write(byteCaptor.capture(), anyInt(), anyInt());
  String result = new String(byteCaptor.getValue());
  assertThat(result, containsString(
      "[{\"@id\":\"http://dbeerpedia.org#Breweries\",\"@type\":[\"http://dbeerpedia.org#Backend\"]"));
  assertThat(result, containsString(
      "http://www.w3.org/2000/01/rdf-schema#label\":[{\"@value\":\"Beer breweries in The Netherlands\"}]}]"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:JsonLdGraphEntityWriterTest.java

示例2: writeTo_TurtleFormat_ForQueryResult

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void writeTo_TurtleFormat_ForQueryResult() throws IOException {
  // Arrange
  final TurtleGraphEntityWriter writer = new TurtleGraphEntityWriter();
  Model model =
      new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDF.TYPE, DBEERPEDIA.BACKEND).add(
          RDFS.LABEL, DBEERPEDIA.BREWERIES_LABEL).build();

  when(graphEntity.getQueryResult()).thenReturn(graphQueryResult);
  when(graphQueryResult.hasNext()).thenReturn(true, true, true, false);
  when(graphQueryResult.next()).thenReturn(model.stream().findFirst().get(),
      model.stream().skip(1).toArray(Statement[]::new));

  // Act
  writer.writeTo(graphEntity, null, null, null, null, null, outputStream);

  // Assert
  verify(outputStream).write(byteCaptor.capture(), anyInt(), anyInt());
  String result = new String(byteCaptor.getValue());
  assertThat(result,
      containsString("<http://dbeerpedia.org#Breweries> a <http://dbeerpedia.org#Backend> ;"));
  assertThat(result, containsString(
      "<http://www.w3.org/2000/01/rdf-schema#label> \"Beer breweries in The Netherlands\""));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:TupleGraphEntityWriterTest.java

示例3: getResultWithMediaType

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
private String getResultWithMediaType(MediaType mediaType) {
  // Arrange
  Model model = new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDFS.LABEL,
      DBEERPEDIA.BREWERIES_LABEL).build();
  SparqlHttpStub.returnGraph(model);

  // Act
  Response response = target.path("/dbp/ld/v1/graph-breweries").request().accept(mediaType).get();

  // Assert
  assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
  assertThat(response.getMediaType(), equalTo(mediaType));
  assertThat(response.getLength(), greaterThan(0));

  return response.readEntity(String.class);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:GraphContentNegotiationIntegrationTest.java

示例4: get_GetBreweryCollection_ThroughLdApi

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void get_GetBreweryCollection_ThroughLdApi() {
  // Arrange
  Model model = new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDFS.LABEL,
      DBEERPEDIA.BREWERIES_LABEL).build();
  SparqlHttpStub.returnGraph(model);
  MediaType mediaType = MediaType.valueOf("text/turtle");

  // Act
  Response response = target.path("/dbp/ld/v1/graph-breweries").request().accept(mediaType).get();

  // Assert
  assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
  assertThat(response.getMediaType(), equalTo(mediaType));
  assertThat(response.getLength(), greaterThan(0));
  assertThat(response.readEntity(String.class),
      containsString(DBEERPEDIA.BREWERIES_LABEL.stringValue()));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:LdIntegrationTest.java

示例5: get_GetCorrectHead_ThroughLdApi

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void get_GetCorrectHead_ThroughLdApi() {
  // Arrange
  Model model = new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDFS.LABEL,
      DBEERPEDIA.BREWERIES_LABEL).build();
  SparqlHttpStub.returnGraph(model);

  // Act
  Response response =
      target.path("/dbp/ld/v1/graph-breweries").request("application/ld+json").head();

  // Assert
  assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
  assertThat(response.getMediaType(), equalTo(MediaType.valueOf("application/ld+json")));
  assertThat(response.getLength(), greaterThan(0));
  assertThat(response.readEntity(String.class), isEmptyString());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:LdIntegrationTest.java

示例6: get_GetDocResource_ThroughLdApi

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void get_GetDocResource_ThroughLdApi() {
  // Arrange
  Model model = new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDFS.LABEL,
      DBEERPEDIA.BREWERIES_LABEL).build();
  SparqlHttpStub.returnGraph(model);
  MediaType mediaType = MediaType.valueOf("text/turtle");

  // Act
  Response response = target.path("/dbp/ld/v1/doc/breweries").request().accept(mediaType).get();

  // Assert
  assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
  assertThat(response.getMediaType(), equalTo(mediaType));
  assertThat(response.getLength(), greaterThan(0));
  assertThat(response.readEntity(String.class),
      containsString(DBEERPEDIA.BREWERIES_LABEL.stringValue()));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:LdIntegrationTest.java

示例7: createResource

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Override
protected InformationProduct createResource(Model model, IRI identifier) {
  IRI backendIRI =
      Models.objectIRI(model.filter(identifier, ELMO.BACKEND_PROP, null)).orElseThrow(
          () -> new ConfigurationException(
              String.format("No <%s> statement has been found for information product <%s>.",
                  ELMO.BACKEND_PROP, identifier)));
  Set<IRI> requiredParameterIds =
      Models.objectIRIs(model.filter(identifier, ELMO.REQUIRED_PARAMETER_PROP, null));
  Set<IRI> optionalParameterIds =
      Models.objectIRIs(model.filter(identifier, ELMO.OPTIONAL_PARAMETER_PROP, null));

  String label = getObjectString(model, identifier, RDFS.LABEL).orElse(null);

  return create(backendIRI, requiredParameterIds, optionalParameterIds, identifier, label, model);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:InformationProductResourceProvider.java

示例8: addPropertyValue

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
/**
 * Adds a property value (a triple describing the Resource).
 *
 * @param tripleDF the triple display format
 * @throws RMapWebException the RMap web exception
 */
public void addPropertyValue(TripleDisplayFormat tripleDF) throws RMapWebException {
	if (tripleDF!=null) {
		
		//these predicates should be first in the list. Property Values list is ordered alphabetically.
		String[] bubbleToTop = {DC.TITLE.toString(),DCTERMS.TITLE.toString(),FOAF.NAME.toString(),
								RDFS.LABEL.toString(), RDFS.SEEALSO.toString(), DC.IDENTIFIER.toString(),
								DCTERMS.IDENTIFIER.toString(), SKOS.PREF_LABEL.toString()};
		
		String listKey;
		String predicate= tripleDF.getPredicate().toString();
		//if it's a title, name or label, bubble to top of list.
		if (Arrays.asList(bubbleToTop).contains(predicate)){
			listKey = tripleDF.getSubjectDisplay()+"______a" + tripleDF.getPredicateDisplay()+tripleDF.getObjectDisplay();	
		} else {
			listKey = tripleDF.getSubjectDisplay()+tripleDF.getPredicateDisplay()+tripleDF.getObjectDisplay();	
		}
		
		this.propertyValues.put(listKey, tripleDF);
	} else {
		throw new RMapWebException(ErrorCode.ER_RESOURCE_PROPERTY_VALUE_NULL);
	}
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:29,代码来源:ResourceDescription.java

示例9: propagateToHandler

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
private static void propagateToHandler(List<Statement> statements,
        RDFHandler handler)
        throws RDFHandlerException, RepositoryException {
    handler.startRDF();
    handler.handleNamespace(RDF.PREFIX, RDF.NAMESPACE);
    handler.handleNamespace(RDFS.PREFIX, RDFS.NAMESPACE);
    handler.handleNamespace(DCAT.PREFIX, DCAT.NAMESPACE);
    handler.handleNamespace(XMLSchema.PREFIX, XMLSchema.NAMESPACE);
    handler.handleNamespace(OWL.PREFIX, OWL.NAMESPACE);
    handler.handleNamespace(DCTERMS.PREFIX, DCTERMS.NAMESPACE);
    handler.handleNamespace(FDP.PREFIX, FDP.NAMESPACE);
    handler.handleNamespace(R3D.PREFIX, R3D.NAMESPACE);
    handler.handleNamespace("lang",
            "http://id.loc.gov/vocabulary/iso639-1/");
    for (Statement st : statements) {
        handler.handleStatement(st);
    }
    handler.endRDF();
}
 
开发者ID:DTL-FAIRData,项目名称:fairmetadata4j,代码行数:20,代码来源:MetadataUtils.java

示例10: loadsStringLiteralWithCorrectLanguageTagWhenItIsSpecifiedInAssertionOfUnspecifiedProperty

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void loadsStringLiteralWithCorrectLanguageTagWhenItIsSpecifiedInAssertionOfUnspecifiedProperty() throws
                                                                                                        Exception {
    final String individual = generatedData.individuals.get(Generator.randomIndex(generatedData.individuals));
    persistLanguageTaggedStrings(individual);

    connector.begin();
    final AxiomDescriptor descriptor = new AxiomDescriptor(NamedResource.create(individual));
    final Assertion assertion =
            Assertion.createPropertyAssertion(URI.create(RDFS.LABEL.stringValue()), "cs", false);
    descriptor.addAssertion(assertion);
    final Collection<Axiom<?>> axioms = axiomLoader.loadAxioms(descriptor);
    assertEquals(1, axioms.size());
    final Axiom<?> ax = axioms.iterator().next();
    assertEquals("b", ax.getValue().getValue());
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:17,代码来源:AxiomLoaderTest.java

示例11: loadsStringLiteralWithAllLanguagesWhenLanguageTagIsExplicitlySetToNull

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void loadsStringLiteralWithAllLanguagesWhenLanguageTagIsExplicitlySetToNull() throws Exception {
    final String individual = generatedData.individuals.get(Generator.randomIndex(generatedData.individuals));
    persistLanguageTaggedStrings(individual);

    connector.begin();
    final AxiomDescriptor descriptor = new AxiomDescriptor(NamedResource.create(individual));
    final Assertion assertion =
            Assertion.createDataPropertyAssertion(URI.create(RDFS.LABEL.stringValue()), null, false);
    descriptor.addAssertion(assertion);
    final Collection<Axiom<?>> axioms = axiomLoader.loadAxioms(descriptor);
    assertEquals(2, axioms.size());
    final Set<String> values = axioms.stream().map(ax -> ax.getValue().stringValue()).collect(Collectors.toSet());
    assertTrue(values.contains("a"));
    assertTrue(values.contains("b"));
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:17,代码来源:AxiomLoaderTest.java

示例12: addAxiomStatements

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
protected void addAxiomStatements() throws SailException {

        addInferredStatement(VOID.DATASET, RDF.TYPE, RDFS.CLASS);
        addInferredStatement(VOID.LINKSET, RDFS.SUBCLASSOF, VOID.DATASET);

        addInferredStatement(VOID.SUBSET, RDF.TYPE, RDF.PROPERTY);
        addInferredStatement(VOID.SUBSET, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.SUBSET, RDFS.RANGE, VOID.DATASET);
        addInferredStatement(VOID.PROPERTYPARTITION, RDFS.SUBPROPERTYOF, VOID.SUBSET);
        addInferredStatement(VOID.CLASSPARTITION, RDFS.SUBPROPERTYOF, VOID.SUBSET);

        addInferredStatement(VOID.SPARQLENDPOINT, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.TRIPLES, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.ENTITIES, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.CLASSES, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.DISTINCTOBJECTS, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.DISTINCTSUBJECTS, RDFS.DOMAIN, VOID.DATASET);

        addInferredStatement(VOID.URIREGEXPATTERN, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.PROPERTY, RDFS.DOMAIN, VOID.DATASET);
        addInferredStatement(VOID.CLASS, RDFS.RANGE, RDF.PROPERTY);
    }
 
开发者ID:semagrow,项目名称:semagrow,代码行数:23,代码来源:VOIDInferencerConnection.java

示例13: writeTo_TriGFormat_ForQueryResult

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void writeTo_TriGFormat_ForQueryResult() throws IOException {
  // Arrange
  final TriGGraphEntityWriter writer = new TriGGraphEntityWriter();
  Model model =
      new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDF.TYPE, DBEERPEDIA.BACKEND).add(
          RDFS.LABEL, DBEERPEDIA.BREWERIES_LABEL).build();

  when(graphEntity.getQueryResult()).thenReturn(graphQueryResult);
  when(graphQueryResult.hasNext()).thenReturn(true, true, true, false);
  when(graphQueryResult.next()).thenReturn(model.stream().findFirst().get(),
      model.stream().skip(1).toArray(Statement[]::new));

  // Act
  writer.writeTo(graphEntity, null, null, null, null, null, outputStream);

  // Assert
  // 2 times? feels like weird behaviour of the TriG parser
  verify(outputStream, times(2)).write(byteCaptor.capture(), anyInt(), anyInt());
  List<byte[]> values = byteCaptor.getAllValues();
  String result1 = new String(values.get(0));
  String result2 = new String(values.get(1));

  assertThat(result1,
      containsString("<http://dbeerpedia.org#Breweries> a <http://dbeerpedia.org#Backend> ;"));
  assertThat(result1, containsString(
      "<http://www.w3.org/2000/01/rdf-schema#label> \"Beer breweries in The Netherlands\""));

  assertThat(result2,
      containsString("<http://dbeerpedia.org#Breweries> a <http://dbeerpedia.org#Backend> ;"));
  assertThat(result2, containsString(
      "<http://www.w3.org/2000/01/rdf-schema#label> \"Beer breweries in The Netherlands\""));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:34,代码来源:TriGGraphEntityWriterTest.java

示例14: writeTo_RdfXmlFormat_ForQueryResult

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
@Test
public void writeTo_RdfXmlFormat_ForQueryResult() throws IOException {
  // Arrange
  final RdfXmlGraphEntityWriter writer = new RdfXmlGraphEntityWriter();
  Model model =
      new ModelBuilder().subject(DBEERPEDIA.BREWERIES).add(RDF.TYPE, DBEERPEDIA.BACKEND).add(
          RDFS.LABEL, DBEERPEDIA.BREWERIES_LABEL).build();

  when(graphEntity.getQueryResult()).thenReturn(graphQueryResult);
  when(graphQueryResult.hasNext()).thenReturn(true, true, true, false);
  when(graphQueryResult.next()).thenReturn(model.stream().findFirst().get(),
      model.stream().skip(1).toArray(Statement[]::new));

  // Act
  writer.writeTo(graphEntity, null, null, null, null, null, outputStream);

  // Assert
  verify(outputStream).write(byteCaptor.capture(), anyInt(), anyInt());
  String result = new String(byteCaptor.getValue());
  assertThat(result, containsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
  assertThat(result,
      containsString("<rdf:Description rdf:about=\"http://dbeerpedia.org#Breweries\">"));
  assertThat(result,
      containsString("<rdf:type rdf:resource=\"http://dbeerpedia.org#Backend\"/>"));
  assertThat(result, containsString(
      "<label xmlns=\"http://www.w3.org/2000/01/rdf-schema#\">Beer breweries in The Netherlands</label>"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:28,代码来源:RdfXmlGraphEntityWriterTest.java

示例15: assertModel

import org.eclipse.rdf4j.model.vocabulary.RDFS; //导入依赖的package包/类
private void assertModel(Model model) {
  assertThat(model.subjects(), hasSize(1));
  assertThat(model.subjects().stream().findFirst().get(), equalTo(DBEERPEDIA.BREWERIES));
  assertThat(model.predicates(), hasSize(1));
  assertThat(model.predicates().stream().findFirst().get(), equalTo(RDFS.LABEL));
  assertThat(model.objects(), hasSize(1));
  assertThat(model.objects().stream().findFirst().get(), equalTo(DBEERPEDIA.BREWERIES_LABEL));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:9,代码来源:GraphContentNegotiationIntegrationTest.java


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