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


Java RDF类代码示例

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


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

示例1: createConcept

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
public Concept createConcept(URI uri, Label prefLabel, URI[] classURIs, UUID uuid) throws ModelException {
	Resource conceptURIResource = resourceFromURI(model, uri);

	if (resourceInUse(conceptURIResource)) throw new ModelException("Attempting to create concept with URI - '%s'. This URI is already in use.", uri.toString());
	
	if ((classURIs == null) || (classURIs.length == 0)) {
		conceptURIResource.addProperty(RDF.type, SKOS.Concept);
	} else {
		for (URI classURI: classURIs) {
			conceptURIResource.addProperty(RDF.type, resourceFromURI(model, classURI));
		}
	}
	
	conceptURIResource.addLiteral(SEM.guid, (uuid == null ? Utils.generateGuid(uri.toString()) : uuid.toString()));
		
	URI labelURI = getLabelURI(model, conceptURIResource, SKOS.prefLabel, prefLabel);
	Resource labelURIResource = resourceFromURI(model, labelURI);
	model.add(conceptURIResource, SKOSXL.prefLabel, labelURIResource);
	model.add(labelURIResource, SKOSXL.literalForm, getAsLiteral(model, prefLabel));
	model.add(labelURIResource, RDF.type, SKOSXL.Label);
	return new Concept(model, conceptURIResource);
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:23,代码来源:SemaphoreModel.java

示例2: testLocalDiff

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
@Test
public void testLocalDiff() throws Exception {
  Model firstModel = ModelFactory.createDefaultModel();
  firstModel.read("Playpen2.ttl", "TTL");

  Model secondModel = ModelFactory.createDefaultModel();
  secondModel.add(firstModel);
  Resource res1 = secondModel.createResource(resIri1);
  res1.addProperty(RDF.type, SKOS.Concept);

  client.setCurrentModel(firstModel);
  client.setPendingModel(secondModel);
  assertEquals(firstModel, client.getCurrentModel());
  assertEquals(secondModel, client.getPendingModel());

  RDFDifference diff = client.getBatchDiff();

  assertTrue(diff.getInLeftOnly().size() == 0);
  assertTrue(diff.getInRightOnly().size() == 1);

  assertFalse(diff.getInLeftOnly().containsResource(res1));
  assertFalse(diff.getInLeftOnly().contains(res1, RDF.type, SKOS.Concept));

  assertTrue(diff.getInRightOnly().containsResource(res1));
  assertTrue(diff.getInRightOnly().contains(res1, RDF.type, SKOS.Concept));
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:27,代码来源:OEBatchClientTests.java

示例3: GraphCreator

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
public GraphCreator() {
    // Initialize the classes
    classes = new ObjectObjectOpenHashMap<Resource, HierarchyNode>();
    classes.put(RDFS.Class, new HierarchyNode());
    classes.put(OWL.Class, new HierarchyNode());
    classes.put(RDF.Property, new HierarchyNode());
    vertexPalette = new InMemoryPalette();
    vertexPalette.addColour(RDFS.Class.getURI());
    vertexPalette.setColour(OWL.Class.getURI(), vertexPalette.getColour(RDFS.Class.getURI()));
    vertexPalette.addColour(RDF.Property.getURI());
    // Initialize the properties
    properties = new ObjectObjectOpenHashMap<Resource, HierarchyNode>();
    properties.put(RDF.type, new HierarchyNode());
    edgePalette = new InMemoryPalette();
    edgePalette.addColour(RDF.type.getURI());
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:17,代码来源:GraphCreator.java

示例4: getResources

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
protected List<Resource> getResources(Model model, Resource resourceType) throws Exception {
    Objects.requireNonNull(model, "The given RDF model is null");

    List<Resource> results = new ArrayList<>();

    // find benchmark subject
    Resource res = null;
    ResIterator subjects = model.listSubjectsWithProperty(RDF.type, resourceType);
    while (subjects.hasNext()) {
        res = subjects.next();
        if (res != null) {
            results.add(res);
        }
    }

    // check if benchmark was actually found
    if (results.size() == 0) {
        throw new Exception("No resources found!");
    }

    return results;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:23,代码来源:ImageManagerImpl.java

示例5: getBenchmarkUri

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
protected String getBenchmarkUri(Model model) {
    // find benchmark subject
    Resource benchmark = null;
    ResIterator subjects = model.listSubjectsWithProperty(RDF.type, HOBBIT.Benchmark);
    if (subjects.hasNext()) {
        benchmark = subjects.next();
    }

    // check if benchmark was actually found
    if (benchmark == null) {
        return null;
    }

    // set URI
    return benchmark.getURI();
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:17,代码来源:ImageManagerImpl.java

示例6: getBenchmarkUri

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
protected static String getBenchmarkUri(Model model) {
    // find benchmark subject
    Resource benchmark = null;
    ResIterator subjects = model.listSubjectsWithProperty(RDF.type, HOBBIT.Benchmark);
    if (subjects.hasNext()) {
        benchmark = subjects.next();
    }

    // check if benchmark was actually found
    if (benchmark == null) {
        return null;
    }

    // set URI
    return benchmark.getURI();
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:17,代码来源:FileBasedImageManager.java

示例7: modelToBenchmarkMetaData

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
@Override
public BenchmarkMetaData modelToBenchmarkMetaData(Model model) throws Exception {
    BenchmarkMetaData result = new BenchmarkMetaData();

    // find benchmark subject
    List<Resource> benchmarks = RdfHelper.getSubjectResources(model, RDF.type, HOBBIT.Benchmark);
    if (benchmarks.size() == 0) {
        return null;
    }
    Resource benchmark = benchmarks.get(0);
    // set URI
    result.benchmarkUri = benchmark.getURI();
    // find name
    result.benchmarkName = getName(model, benchmark);
    // find description
    result.benchmarkDescription = getDescription(model, benchmark);
    // find APIs
    result.implementedApis = getAPIs(model, benchmark, true);
    // find used images
    result.usedImages = getUsedImages(model, benchmark);

    return result;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:24,代码来源:FileBasedImageManager.java

示例8: createBenchmarkBean

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
/**
 * Creates a {@link BenchmarkBean} from the given RDF model by collecting
 * all benchmark-relevant information found for the given benchmark
 * {@link Resource}.
 *
 * @param model
 *            the RDF model containing the benchmark model
 * @param benchmarkResource
 *            the {@link Resource} representing the benchmark
 * @return a {@link BenchmarkBean} containing the found information
 */
public static <T extends BenchmarkBean> T createBenchmarkBean(Model model, Resource benchmarkResource, T bean) {
    String label = RdfHelper.getLabel(model, benchmarkResource);
    if (label == null) {
        label = benchmarkResource.getURI();
        LOGGER.info("Benchmark {} model does not have a label.", label);
    }
    String description = RdfHelper.getDescription(model, benchmarkResource);
    if (description == null) {
        LOGGER.info("Benchmark {} model does not have a description.", benchmarkResource.getURI());
    }

    bean.setId(benchmarkResource.getURI());
    bean.setName(label);
    bean.setDescription(description);
    parseBenchmarkParameters(model, benchmarkResource, bean);

    Map<String, KeyPerformanceIndicatorBean> kpiMap = new HashMap<>();
    createKPIBeans(model, benchmarkResource, model.listResourcesWithProperty(RDF.type, HOBBIT.KPI), kpiMap);
    bean.setKpis(new ArrayList<>(kpiMap.values()));
    return bean;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:33,代码来源:RdfModelHelper.java

示例9: listOptions

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
/**
 * Derives a list of options that are connected to the given parameter
 * resource via owl:oneOf predicates or <code>null</code> if no such
 * resource could be found.
 *
 * @param model
 *            the RDF model containing the options
 * @param typeResource
 *            the typ resource for which the options are possible values
 * @return a list of options or <code>null</code> if no option could be
 *         found
 */
public static List<SelectOptionBean> listOptions(Model model, Resource typeResource) {
    ResIterator iterator = model.listSubjectsWithProperty(RDF.type, typeResource);
    Resource option;
    String optionLabel;
    List<SelectOptionBean> options = new ArrayList<>();
    while (iterator.hasNext()) {
        option = iterator.next();
        optionLabel = RdfHelper.getLabel(model, option);
        options.add(new SelectOptionBean(optionLabel != null ? optionLabel : option.getURI(), option.getURI()));
    }
    if (options.size() > 0) {
        return options;
    } else {
        return null;
    }
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:29,代码来源:RdfModelHelper.java

示例10: listChallenges

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
public static List<ChallengeBean> listChallenges(Model model) {
    List<ChallengeBean> challengeBeans = new ArrayList<>();
    if (model == null) {
        return challengeBeans;
    }
    // iterate over all challenges
    ResIterator challengeIterator = model.listResourcesWithProperty(RDF.type, HOBBIT.Challenge);
    Resource challengeResource;
    while (challengeIterator.hasNext()) {
        challengeResource = challengeIterator.next();
        ChallengeBean challenge = getChallengeBean(model, challengeResource);
        if (challenge != null) {
            challengeBeans.add(challenge);
        }
    }

    return challengeBeans;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:19,代码来源:RdfModelHelper.java

示例11: createParamValueBeans

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
/**
 * Extracts configuration parameters of the given challenge task from the
 * given model.
 * 
 * @param model
 *            the model containing the triples
 * @param taskResource
 *            the challenge task resource
 * @param benchResource
 *            the benchmark resource which might have hobbit:hasParameter
 *            triples. It is ignored if it is set to <code>null</code>
 * @return a list of configuration parameters
 */
public static List<ConfigurationParamValueBean> createParamValueBeans(Model model, Resource taskResource,
        Resource benchResource) {
    if ((model == null) || (taskResource == null)) {
        return new ArrayList<>(0);
    }
    Map<String, ConfigurationParamValueBean> parameters = new HashMap<String, ConfigurationParamValueBean>();
    createParamValueBeans(model, taskResource,
            model.listResourcesWithProperty(RDF.type, HOBBIT.ConfigurableParameter), parameters);
    createParamValueBeans(model, taskResource, model.listResourcesWithProperty(RDF.type, HOBBIT.Parameter),
            parameters);
    if (benchResource != null) {
        createParamValueBeans(model, taskResource, model.listObjectsOfProperty(benchResource, HOBBIT.hasParameter),
                parameters);
    }
    return new ArrayList<>(parameters.values());
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:30,代码来源:RdfModelHelper.java

示例12: createExperimentBean

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
public static ExperimentBean createExperimentBean(Model model, Resource experiment) {
    if (model == null) {
        return null;
    }
    ExperimentBean bean = new ExperimentBean();
    bean.setId(experiment.getURI().substring(Constants.EXPERIMENT_URI_NS.length()));
    Resource benchmarkResource = RdfHelper.getObjectResource(model, experiment, HOBBIT.involvesBenchmark);
    if (benchmarkResource != null) {
        bean.setBenchmark(createConfiguredBenchmarkBean(model, benchmarkResource, experiment));
    }
    Resource systemResource = RdfHelper.getObjectResource(model, experiment, HOBBIT.involvesSystemInstance);
    if (systemResource != null) {
        bean.setSystem(getSystemBean(model, systemResource));
    }
    Resource challengeTask = RdfHelper.getObjectResource(model, experiment, HOBBIT.isPartOf);
    if (challengeTask != null) {
        bean.setChallengeTask(getChallengeTask(model, challengeTask));
    }
    Map<String, KeyPerformanceIndicatorBean> kpis = new HashMap<String, KeyPerformanceIndicatorBean>();
    createKPIBeans(model, experiment, model.listResourcesWithProperty(RDF.type, HOBBIT.KPI), kpis);
    bean.setKpis(new ArrayList<>(kpis.values()));

    bean.setError(getErrorMessage(RdfHelper.getObjectResource(model, experiment, HOBBIT.terminatedWithError)));

    return bean;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:27,代码来源:RdfModelHelper.java

示例13: addBenchmark

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
/**
 * Adds the given benchmark to the given model and returns the created
 * {@link Resource} of the benchmark. Note that the list of systems (
 * {@link BenchmarkBean#systems}) is not added to the model.
 *
 * @param benchmark
 *            the bean containing the information about the benchmark that
 *            should be added
 * @param model
 *            the RDF model to which the benchmark should be added
 * @return the {@link Resource} representing the newly created benchmark
 */
public static Resource addBenchmark(BenchmarkBean benchmark, Model model) {
    Resource benchmarkResource = model.getResource(benchmark.getId());
    model.add(benchmarkResource, RDF.type, HOBBIT.Benchmark);
    if ((benchmark.getName() != null) && (!benchmark.getName().equals(benchmark.getId()))) {
        model.add(benchmarkResource, RDFS.label, benchmark.getName(), "en");
    }
    if ((benchmark.getDescription() != null) && (!benchmark.getDescription().equals(benchmark.getId()))) {
        model.add(benchmarkResource, RDFS.comment, benchmark.getDescription(), "en");
    }
    if (benchmark.getConfigurationParams() != null) {
        Resource paramResource;
        for (ConfigurationParamBean parameter : benchmark.getConfigurationParams()) {
            paramResource = addParameter(parameter, model);
            model.add(benchmarkResource, HOBBIT.hasParameter, paramResource);
        }
    }
    if (benchmark.getKpis() != null){
        Resource kpiResource;
        for (KeyPerformanceIndicatorBean kpi : benchmark.getKpis()) {
            kpiResource = addKpi(kpi, model);
            model.add(benchmarkResource, HOBBIT.measuresKPI, kpiResource);
        }
    }
    return benchmarkResource;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:38,代码来源:RdfModelCreationHelper.java

示例14: addKpi

import org.apache.jena.vocabulary.RDF; //导入依赖的package包/类
private static Resource addKpi(KeyPerformanceIndicatorBean kpi, Model model) {
    Resource kpiResource = model.getResource(kpi.getId());
    model.add(kpiResource, RDF.type, HOBBIT.KPI);
    if ((kpi.getName() != null) && (!kpi.getName().equals(kpi.getId()))) {
        model.add(kpiResource, RDFS.label, kpi.getName(), "en");
    }
    if ((kpi.getDescription() != null) && (!kpi.getDescription().equals(kpi.getId()))) {
        model.add(kpiResource, RDFS.comment, kpi.getDescription(), "en");
    }
    if (kpi.getDatatype() != null) {
        XSDDatatype datatype = datatypeToXsd(kpi.getDatatype());
        if (datatype != null) {
            model.add(kpiResource, RDFS.range, model.getResource(datatype.getURI()));
        }
    } if (kpi.getRanking() != null) {
        model.add(kpiResource, HOBBIT.ranking, model.getResource(kpi.getRanking()));
    }
    return kpiResource;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:20,代码来源:RdfModelCreationHelper.java

示例15: toRDF

import org.apache.jena.vocabulary.RDF; //导入依赖的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


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