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


Java ResourceFactory类代码示例

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


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

示例1: getJenaModel

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
private Model getJenaModel(@NonNull org.eclipse.rdf4j.model.Model model) {
  Model jenaModel = ModelFactory.createDefaultModel();
  java.util.Iterator<org.eclipse.rdf4j.model.Statement> iterator = model.iterator();

  while (iterator.hasNext()) {
    org.eclipse.rdf4j.model.Statement rdf4jStatement = iterator.next();

    // create resource / subject
    Resource resource = rdf4jResourceToJenaResource(jenaModel, rdf4jStatement.getSubject());
    // create property / predicate
    Property property =
        rdf4jPropertyToJenaProperty(jenaModel, (SimpleIRI) rdf4jStatement.getPredicate());
    // create rdfnode / object
    RDFNode node = rdf4jValueToJenaRdfNode(jenaModel, rdf4jStatement.getObject());

    Statement statement = ResourceFactory.createStatement(resource, property, node);
    jenaModel.add(statement);
  }
  return jenaModel;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:ShaclValidator.java

示例2: getTypedContent

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
public Literal getTypedContent(String con) {
	try {

		return ResourceFactory.createTypedLiteral(Double.valueOf(con));
		// return "\"" + Double.valueOf(con) + "\"^^xsd:double";
	} catch (java.lang.NumberFormatException e) {
		try {
			return ResourceFactory.createTypedLiteral(Float.valueOf(con));
			// return "\"" + Float.valueOf(con) + "\"^^xsd:float";
		} catch (Exception e2) {
			return ResourceFactory.createTypedLiteral(String.valueOf(con));
			// return "\"" + con + "\"^^xsd:string";
		}
	}

}
 
开发者ID:iotoasis,项目名称:SDA,代码行数:17,代码来源:OneM2MContentInstanceMapper.java

示例3: toRDFNode

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
public static RDFNode toRDFNode(String value) {
  if (isURI(value)) {
    return ResourceFactory.createResource(value);
  } else if (NumberUtils.isNumber(value)) {
    if (value.contains(".")) {
      return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDdouble);
    }
    if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
      return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDboolean);
    } else {
      return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDinteger);
    }
  } else {
    return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDstring);
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:17,代码来源:ResourceUtils.java

示例4: addProperties

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
public void addProperties(List<UDTValue> properties) {
  if (properties != null && !properties.isEmpty()) {
    for (UDTValue value : properties) {
      Property property = ResourceFactory.createProperty(value.getString("property"));
      RDFNode propertyValue;
      if (value.isNull("datatype")) {
        propertyValue = ResourceFactory.createResource(value.getString("value"));
      } else {
        propertyValue = ResourceFactory.createTypedLiteral(value.getString("value"),
            TypeMapper.getInstance().getSafeTypeByName(value.getString("datatype")));
      }

      addProperty(property, propertyValue);
    }
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:17,代码来源:CommandResult.java

示例5: toRDF

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
public Model toRDF() {
  Model model = ModelFactory.createDefaultModel();
  Resource observation = ResourceFactory.createResource();
  Resource obsResult = ResourceFactory.createResource();
  Resource obsValue = ResourceFactory.createResource();
  Resource sensor = ResourceFactory.createResource(
      SENSOR_URI_TEMPLATE.replace("${SYSTEM_ID}", systemId).replace("${SENSOR_ID}", sensorId));

  model.add(observation, RDF.type, SSN.Observaton)
      .add(observation, SSN.observedProperty, property).add(observation, SSN.observedBy, sensor)
      .add(observation, SSN.observationResultTime,
          ResourceFactory.createTypedLiteral(eventTime.toString(), XSDDatatype.XSDdateTime));

  if (featureOfInterest != null) {
    model.add(observation, SSN.featureOfInterest, featureOfInterest);
  }

  model.add(observation, SSN.observationResult, obsResult)
      .add(obsResult, RDF.type, SSN.SensorOutput).add(obsResult, SSN.isProducedBy, sensor)
      .add(obsResult, SSN.hasValue, obsValue);

  model.add(obsValue, RDF.type, QUDT.QuantityValue).add(obsValue, QUDT.quantityValue,
      toLiteral(value));

  return model;
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:27,代码来源:Observation.java

示例6: testToRDF1

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Test
public void testToRDF1() {
  Observation observation = new Observation("123123", "123123-humidity",
      "2016-03-31T16:39:57+01:00",
      "http://qudt.org/vocab/quantity#ThermodynamicTemperature",
      null, "3.4");

  Model model = observation.toRDF();

  model.write(System.out, RDFLanguages.strLangTurtle);

  assertTrue(model.contains(
      null,
      SSN.observationResultTime,
      ResourceFactory.createTypedLiteral("2016-03-31T16:39:57+01:00",
          XSDDatatype.XSDdateTime)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:ObservationTest.java

示例7: testToRDF2

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Test
public void testToRDF2() {
  Observation observation = new Observation("123123", "123123-humidity",
      "2016-03-31T16:39:57+01:00",
      "http://qudt.org/vocab/quantity#ThermodynamicTemperature",
      null, "3.4");

  Model model = observation.toRDF();

  model.write(System.out, RDFLanguages.strLangTurtle);

  assertTrue(model.contains(
      null,
      SSN.observationResultTime,
      ResourceFactory.createTypedLiteral("2016-03-31T16:39:57+01:00",
          XSDDatatype.XSDdateTime)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:ObservationTest.java

示例8: addSupportedCommands

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
private Observable<Model> addSupportedCommands(Model model, Resource system, Resource process) {
  return metadata.describe(QUERY_DESCRIBE_COMMANDS.replace(VAR_PROCESS_URI, process.getURI()))
      .map((Model rs) -> {
        Resource operation = ResourceFactory.createResource();
        rs.add(process, Hydra.supportedOperation, operation)
            .add(operation, RDF.type, Hydra.Operation)
            .add(operation, Hydra.method, "POST")
            .add(operation, Hydra.returns, SEMIOT.CommandResult);

        ResIterator commandIter = rs.listSubjectsWithProperty(RDF.type, SEMIOT.Command);
        while (commandIter.hasNext()) {
          Resource command = commandIter.next();
          rs.add(operation, Hydra.expects, command)
              .add(command, SEMIOT.forProcess, process)
              .add(command, DUL.associatedWith, system);
        }

        model.add(rs);
        return model;
      });
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:22,代码来源:ProcessResource.java

示例9: listResourcesWithProperty

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Test
public void listResourcesWithProperty() {
  Model model = ModelFactory.createDefaultModel();
  RDFDataMgr.read(model, this.getClass().getResourceAsStream(PATH_PREFIX + "system.ttl"),
      RDFLanguages.TURTLE);

  List<Resource> actual = RDFUtils.listResourcesWithProperty(
      model, RDF.type, SSN.System, Proto.Individual);

  List<Resource> expected = new ArrayList<>();
  expected.add(ResourceFactory.createResource("http://localhost/systems/3503522021"));

  assertEquals(expected, actual);

  assertEquals(0, RDFUtils.listResourcesWithProperty(
      model, RDF.type, OWL.Class).size());
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:18,代码来源:RDFUtilsTest.java

示例10: collectTestCases

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
private static void collectTestCases(File folder, List<TestCase> testCases) throws Exception {
	for(File f : folder.listFiles()) {
		if(f.isDirectory()) {
			collectTestCases(f, testCases);
		}
		else if(f.isFile() && f.getName().endsWith(".ttl")) {
			Model testModel = JenaUtil.createDefaultModel();
			InputStream is = new FileInputStream(f);
			testModel.read(is, "urn:dummy", FileUtils.langTurtle);
			testModel.add(SHACLSystemModel.getSHACLModel());
			Resource ontology = testModel.listStatements(null, OWL.imports, ResourceFactory.createResource(DASH.BASE_URI)).next().getSubject();
			for(TestCaseType type : TestCaseTypes.getTypes()) {
				testCases.addAll(type.getTestCases(testModel, ontology));
			}
		}
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:18,代码来源:TestDASHTestCases.java

示例11: createTyped

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
public static final RDFNode createTyped(String value, Resource valueType)
   {
if (value == null) throw new IllegalArgumentException("Param value cannot be null");

       // without value type, return default xsd:string value
       if (valueType == null) return ResourceFactory.createTypedLiteral(value, XSDDatatype.XSDstring);

       // if value type is from XSD namespace, value is treated as typed literal with XSD datatype
       if (valueType.getNameSpace().equals(XSD.getURI()))
       {
           RDFDatatype dataType = NodeFactory.getType(valueType.getURI());
           return ResourceFactory.createTypedLiteral(value, dataType);
       }
       // otherwise, value is treated as URI resource
       else
           return ResourceFactory.createResource(value);
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:18,代码来源:RDFNodeFactory.java

示例12: toResponse

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Override
   public Response toResponse(QueryParseException ex)
   {
       return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
               getResponseBuilder(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,
                       ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                   getModel(), getVariants()).
               status(Response.Status.INTERNAL_SERVER_ERROR).
               build();

       /*
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
               entity(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,
                       ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                   getModel()).
	build();
       */
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:19,代码来源:QueryParseExceptionMapper.java

示例13: toResponse

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Override
public Response toResponse(QueryExceptionHTTP ex)
{        
    if (ex.getResponseCode() > 0)
        return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
            getResponseBuilder(toResource(ex, Response.Status.fromStatusCode(ex.getResponseCode()),
                    ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                getModel(), getVariants()).
            status(ex.getResponseCode()).
            build();
    else
        return com.atomgraph.core.model.impl.Response.fromRequest(getRequest()).
            getResponseBuilder(toResource(ex, Response.Status.INTERNAL_SERVER_ERROR,
                    ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#InternalServerError")).
                getModel(), getVariants()).
            status(Response.Status.INTERNAL_SERVER_ERROR).
            build();
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:19,代码来源:QueryExceptionHTTPMapper.java

示例14: doExecute

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
@Override
public Response doExecute() {
    String graphURI = target + "?annotation=" + parameters.getFirst(Parameters.ANNOTATION);
    RegisterItem item = store.getItem(target, false);
    if (item == null) {
        throw new NotFoundException();
    }
    store.storeGraph(graphURI, getPayload());
    item.getRoot().addProperty(RegistryVocab.annotation, ResourceFactory.createResource(graphURI));
    store.update(item, false);
    store.commit();
    
    // notify event
    Message message = new Message(this);
    message.setMessage( payload );
    notify(message);
    
    try {
        return Response.created(new URI(graphURI)).build();
    } catch (URISyntaxException e) {
        throw new EpiException(e);
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:24,代码来源:CommandAnnotate.java

示例15: addMembership

import org.apache.jena.rdf.model.ResourceFactory; //导入依赖的package包/类
protected void addMembership(Model model, List<Resource> entities) {
    // Membership relations
    Resource predicateR = null;
    boolean isInverse = false;
    predicateR = getMembershipPredicate();
    if (predicateR == null) {
        predicateR = getInvMembershipPredicate();
        if (predicateR != null) {
            isInverse = true;
        } else {
            predicateR = RDFS.member;
        }
    }
    Property predicate = ResourceFactory.createProperty( predicateR.getURI() );

    Resource reg = model.getResource(root.getURI());
    for (Resource entity : entities) {
        if (isInverse) {
            entity.inModel(model).addProperty(predicate, reg);
        } else {
            reg.addProperty(predicate, entity);
        }
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:25,代码来源:Register.java


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