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


Java ResourceFactory.createResource方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: items

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
@Parameterized.Parameters(name= "{index}")
public static Collection<Object[]> items() {

    List<String> sparqlSampleQueries = Arrays.asList(
            "select ?s where{?s ?p ?o }",
            "select ?s where { ?this ?p ?o ; ?p2 ?o}"
    );

    Resource p = ResourceFactory.createResource("http://example.com#ex");
    List<ShapeTarget> targets = Arrays.stream(ShapeTargetType.values())
            .filter( sct -> !sct.equals(ShapeTargetType.ValueShapeTarget))
            .map(scType -> ShapeTargetCore.create(scType, p))
            .collect(Collectors.toList());

    Collection<Object[]> parameters = new ArrayList<>();
    sparqlSampleQueries
            .forEach( sparql -> targets
                    .forEach(target ->
                            parameters.add(new Object[] {sparql, target})));
    return parameters;
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:22,代码来源:TestCaseWithTargetTest.java

示例6: testDelegation

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
@Test
public void testDelegation() {
    DelegationRecord dr = new DelegationRecord("/def/bw", BW_TEST_ENDPOINT, Type.DELEGATE);
    dr.setObject( ResourceFactory.createResource("http://environment.data.gov.uk/id/bathing-water/") );
    dr.setPredicate( ResourceFactory.createResource("http://reference.data.gov.uk/def/reference/uriSet") );

    List<Resource> members = dr.listMembers();
    assertTrue(members.size() > 300);

    Resource bw1 = ResourceFactory.createResource("http://environment.data.gov.uk/id/bathing-water/ukc1101-06000");
    Model m = dr.describeMember( bw1 );
    assertEquals("Seaton Carew North", RDFUtil.getStringValue(bw1.inModel(m), RDFS.label));

    m = ModelFactory.createDefaultModel();
    dr.fetchMembers(m, Util.listWindow(members, 5, 2) );
    assertEquals(2, m.listSubjects().toList().size());
    assertTrue( m.contains( members.get(5), RDF.type, (RDFNode)null ) );
    assertTrue( m.contains( members.get(6), RDF.type, (RDFNode)null ) );
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:20,代码来源:TestDelegationRecord.java

示例7: main

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public static void main(String args[]){
		InstanceSplitModifier sM=new InstanceSplitModifier();
		Resource s = ResourceFactory.createResource("medo.test");
		RDFNode o= ResourceFactory.createTypedLiteral("Medo koko dodo");
		Statement stmt = ResourceFactory.createStatement(s, RDFS.label, o);
		sM.setPartsCount(3);
		List<Property> sP = new ArrayList<Property>();
//		sP.add(ResourceFactory.createProperty("Name1"));
//		sP.add(ResourceFactory.createProperty("Name2"));
//		sP.add(ResourceFactory.createProperty("Name3"));
		sM.setSplitProperties(sP);
		System.out.println(sP);
		System.out.println(sM.split(stmt));
		
		System.out.println(o);
		System.out.println(o.asNode().getLiteral().getLexicalForm());

	}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:19,代码来源:InstanceSplitModifier.java

示例8: addParameters

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public void addParameters(List<UDTValue> parameters) {
  if (parameters != null && !parameters.isEmpty()) {
    for (UDTValue value : parameters) {
      Resource parameter = ResourceFactory.createResource(value.getString("for_parameter"));
      RDFNode parameterValue = ResourceFactory.createTypedLiteral(value.getString("value"),
          TypeMapper.getInstance().getSafeTypeByName(value.getString("datatype")));

      addParameter(parameter, parameterValue);
    }
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:12,代码来源:CommandResult.java

示例9: toRDF

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public Model toRDF() {
  Model model = ModelFactory.createDefaultModel();
  Resource commandResult = ResourceFactory.createResource();
  Resource command = ResourceFactory.createResource();
  Resource system = ResourceFactory.createResource(SYSTEMS_URI_PREFIX + systemId);
  Resource process = ResourceFactory.createResource(system.getURI()
      + "/" + PROCESSES_PATH_URI + "/" + processId);

  model.add(commandResult, RDF.type, SEMIOT.CommandResult)
      .add(commandResult, SEMIOT.isResultOf, command)
      .add(commandResult, DUL.hasEventTime,
          eventTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME))
      .add(commandResult, DUL.hasParticipant, system);

  model.add(command, RDF.type, SEMIOT.Command)
      .add(command, RDF.type, ResourceFactory.createResource(type))
      .add(command, DUL.associatedWith, system)
      .add(command, SEMIOT.forProcess, process);

  for (Resource parameter : parameters.keySet()) {
    Resource parameterResource = ResourceFactory.createResource();
    model.add(command, DUL.hasParameter, parameterResource)
        .add(parameterResource, SEMIOT.forParameter, parameter)
        .add(parameterResource, DUL.hasParameterDataValue, parameters.get(parameter));
  }

  for (CommandProperty property : properties) {
    model.add(command, property.property, property.value);
  }

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

示例10: Observation

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public Observation(@NotNull String systemId, @NotNull String sensorId, @NotNull String eventTime,
    @NotNull String property, String featureOfInterest, @NotNull String value) {
  this.systemId = systemId;
  this.sensorId = sensorId;
  this.eventTime = ZonedDateTime.parse(eventTime, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
  this.property = ResourceFactory.createResource(property);
  if (featureOfInterest != null) {
    this.featureOfInterest = ResourceFactory.createResource(featureOfInterest);
  } else {
    this.featureOfInterest = null;
  }
  this.value = value;
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:14,代码来源:Observation.java

示例11: createResourceFromClass

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public static final Resource createResourceFromClass(String rootURL, String className) {
  StringBuilder builder = new StringBuilder(rootURL)
      .append("/doc#")
      .append(className);

  return ResourceFactory.createResource(builder.toString());
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:8,代码来源:ResourceUtils.java

示例12: defineResourceIndividual

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private List<Resource> defineResourceIndividual(Model model, String rootURL,
    String collectionName, ResultSet rs, Resource... classes) {
  List<Resource> resultPrototypes = new ArrayList<>();
  final Resource apiDocResource = model.listResourcesWithProperty(
      RDF.type, Hydra.ApiDocumentation).next();
  final Resource collection = ResourceFactory.createResource(rootURL + "/doc#" + collectionName);

  //Find the restriction on hydra:member of the given collection
  ResultSet results = query.select(model, QUERY_COLLECTION_MEMBER
      .replace(VAR_COLLECTION_URI, collection.getURI()));
  Resource restriction = null;
  if (results.hasNext()) {
    restriction = results.next().getResource(VAR_URI);
  }

  while (rs.hasNext()) {
    final Resource prototype = rs.next().getResource(VAR_PROTOTYPE);
    resultPrototypes.add(prototype);
    final Resource prototypeResource = ResourceUtils.createResourceFromClass(
        rootURL, prototype.getLocalName());

    //Define in hydra:supportedClass
    model.add(apiDocResource, Hydra.supportedClass, prototypeResource);
    model.add(prototypeResource, RDF.type, Hydra.Class);
    model.add(prototypeResource, RDF.type, Proto.Individual);
    for (Resource clazz : classes) {
      model.add(prototypeResource, RDF.type, clazz);
    }
    model.add(prototypeResource, Proto.hasPrototype, prototype);

    //Define in the given collection
    if (restriction != null) {
      model.add(restriction, SHACL.clazz, prototypeResource);
    }
  }

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

示例13: write

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
@Override
public void write(AMapping mapping, String outputFile, String format) throws IOException {
    Property p = ResourceFactory.createProperty(mapping.getPredicate());
    for (String source : mapping.getMap().keySet()) {
        for (String target : mapping.getMap().get(source).keySet()) {
            Resource s = ResourceFactory.createResource(source);
            Resource o = ResourceFactory.createResource(target);
            mappingModel.add(s, p, o);
        }
    }
    writeModel(mappingModel, format, outputFile);
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:13,代码来源:RDFMappingWriter.java

示例14: createResource

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Resource createResource(Model m, String p) {
    if (p.contains(":")) {
        String pPrefix = p.substring(0, p.indexOf(":"));
        if (!m.getNsPrefixMap().containsKey(pPrefix)) {
            logger.error("Undefined prefix " + pPrefix);
        }
        String pPrefixUri = m.getNsPrefixMap().get(pPrefix);
        p = p.replace(":", "").replace(pPrefix, pPrefixUri);
    }
    return ResourceFactory.createResource(p);
}
 
开发者ID:dice-group,项目名称:LIMES,代码行数:12,代码来源:RDFConfigurationWriter.java

示例15: entityLookup

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Response entityLookup() {
    Model result = ModelFactory.createDefaultModel();
    String uri = parameters.getFirst(ENTITY_LOOKUP);
    Status statusFilter = Status.forString(parameters.getFirst(STATUS), Status.Any);
    for (EntityInfo entityInfo : store.listEntityOccurences(uri)) {
        if (entityInfo.getStatus().isA(statusFilter)) {
            if (entityInfo.getRegisterURI().startsWith(target)) {
                if (withMetadata) {
                    RegisterItem ri = store.getItem(entityInfo.getItemURI(), true);
                    result.add( ri.getRoot().getModel() );
                    result.add( ri.getEntity().getModel() );
                } else {
                    Description d = store.getCurrentVersion(entityInfo.getEntityURI());
                    result.add(d.getRoot().getModel());
                }
            }
        }
    }

    // Check for contained delegation points
    Resource entity = ResourceFactory.createResource(uri);
    for (DelegationRecord delegation : registry.getForwarder().listDelegations(path)) {
        Model member = delegation.describeMember(entity);
        if (member != null) {
            result.add( member );
            if (withMetadata && member.contains(entity, RDF.type, (RDFNode)null)) {
                // Add pseudo RegisterItem so we know which register it was in
                Resource entityRef = result.createResource().addProperty(RegistryVocab.entity, entity);
                Resource registerRef = result.createResource(delegation.getLocation())
                        .addProperty(RDF.type, RegistryVocab.Register)
                        .addProperty(RDF.type, RegistryVocab.DelegatedRegister);
                result.createResource()
                    .addProperty(RegistryVocab.definition, entityRef)
                    .addProperty(RegistryVocab.register, registerRef);
            }
        }
    }
    return returnModel(result, target);
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:40,代码来源:CommandRead.java


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