本文整理汇总了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);
}
示例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));
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}