本文整理汇总了Java中org.apache.jena.rdf.model.ResIterator类的典型用法代码示例。如果您正苦于以下问题:Java ResIterator类的具体用法?Java ResIterator怎么用?Java ResIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResIterator类属于org.apache.jena.rdf.model包,在下文中一共展示了ResIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResources
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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;
}
示例2: getBenchmarkUri
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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();
}
示例3: getBenchmarkUri
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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();
}
示例4: listOptions
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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;
}
}
示例5: listChallenges
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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;
}
示例6: listChallengeTasks
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
public static List<ChallengeTaskBean> listChallengeTasks(Model model, Resource challengeResource) {
List<ChallengeTaskBean> challengeTasks = new ArrayList<>();
if (model == null) {
return challengeTasks;
}
// iterate over all tasks
ResIterator taskIterator = model.listResourcesWithProperty(HOBBIT.isTaskOf, challengeResource);
Resource taskResource;
while (taskIterator.hasNext()) {
taskResource = taskIterator.next();
ChallengeTaskBean task = getChallengeTask(model, taskResource);
if (task != null) {
challengeTasks.add(task);
}
}
return challengeTasks;
}
示例7: addSupportedCommands
import org.apache.jena.rdf.model.ResIterator; //导入依赖的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;
});
}
示例8: process
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
@Override
public Model process(Model model)
{
if (getRequest().getMethod().equalsIgnoreCase("POST"))
{
ResIterator it = model.listSubjects();
try
{
while (it.hasNext())
{
Resource resource = it.next();
process(resource); // add dh:slug to documents before skolemization
}
}
finally
{
it.close();
}
return skolemize(getOntology(), getUriInfo().getBaseUriBuilder(), getUriInfo().getAbsolutePathBuilder(),
super.process(model));
}
return super.process(model);
}
示例9: removeOrphans
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
void removeOrphans(OntModel ont, Resource type) {
boolean b = true;
// removing orphans may create orphans
while (b) {
b = false;
// orphaned classes
for (ResIterator classes = ont.listSubjectsWithProperty(RDF.type,type); classes.hasNext(); ) {
Resource c = classes.nextResource();
if (c.isAnon()) {
// an orphan is anonymous and has no referee other than itself
Resource r = null;
Statement s = null;
for (StmtIterator si = ont.listStatements(null,null,c); si.hasNext(); ) {
s = si.nextStatement();
r = s.getSubject();
if (!r.equals(c)) break;
}
if (r==null || r.equals(c)) {
b = true;
c.removeProperties();
}
}
}
}
}
示例10: checkConsistency
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
public boolean checkConsistency(Resource cls, Model model) {
Model temp = ModelFactory.createDefaultModel();
temp.add(this.model);
if (infModel==null) infModel = ModelFactory.createInfModel(reasoner,this.model);
// merge the models eg. optimization of infModel.add(model);
// if the class is anonymous add it separately
Map<RDFNode,RDFNode> visited = new HashMap<RDFNode,RDFNode>();
if (cls!=null && cls.isAnon()) mergeDescription(infModel.createResource(), cls, false, visited);
mergeModel(model,false,visited);
boolean valid = infModel.validate().isValid();
if (!valid) {
// restore the old state
this.model.removeAll().add(temp);
infModel.rebind();
}
else {
// mark known classes as OK
Resource ok = infModel.getResource(Gloze.OK);
for (ResIterator ri = this.model.listSubjectsWithProperty(RDF.type, OWL.Class); ri.hasNext(); )
ri.nextResource().addProperty(RDF.type, ok);
}
return valid;
}
示例11: testBNodeSubmitter
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
@Test
public void testBNodeSubmitter() {
addEntry("file:test/reg1.ttl", ROOT_REGISTER);
Register parent = store.getCurrentVersion(REG1).asRegister();
String base = NameUtils.ensureLastSlash(REG1);
Model m = ModelFactory.createDefaultModel();
m.read("file:test/red-submitter-test.ttl", base, FileUtils.langTurtle);
Calendar now = Calendar.getInstance();
for (ResIterator i = m.listResourcesWithProperty(RDF.type, RegistryVocab.RegisterItem); i.hasNext();) {
RegisterItem item = RegisterItem.fromRIRequest(i.next(), REG1, true, now);
store.addToRegister(parent, item);
}
RegisterItem ri = store.getItem(REG1 + "/_red", true);
List<Statement> submitters = ri.getRoot().listProperties(RegistryVocab.submitter).toList();
assertEquals(1, submitters.size());
ri.getEntity().addProperty(RDFS.comment, "Updated");
store.update(ri, true);
ri = store.getItem(REG1 + "/_red", true);
submitters = ri.getRoot().listProperties(RegistryVocab.submitter).toList();
assertEquals(1, submitters.size());
}
示例12: addDeref
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
/**
* Adds a dereferencing resource for every subject that is available in the
* given model.
*
* @param resources
* the list of crawleable resources this server is using
* @param model
* the model from which the subjects and the data that will be
* returned when they are dereferenced is collected
*/
protected void addDeref(List<CrawleableResource> resources, Model model) {
ResIterator iterator = model.listSubjects();
Resource subject;
Model resourceModel;
while (iterator.hasNext()) {
subject = iterator.next();
resourceModel = ModelFactory.createDefaultModel();
resourceModel.add(model.listStatements(subject, null, (RDFNode) null));
resources.add(new StringResource(resourceModel, subject.getURI(), Lang.N3));
}
}
示例13: getResource
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
protected Resource getResource(Model model, Resource resourceType) throws Exception {
Objects.requireNonNull(model, "The given RDF model is null");
// find benchmark subject
Resource benchmark = null;
ResIterator subjects = model.listSubjectsWithProperty(RDF.type, resourceType);
if (subjects.hasNext()) {
benchmark = subjects.next();
}
// check if benchmark was actually found
Objects.requireNonNull(model, "Benchmark not found!");
return benchmark;
}
示例14: getChallengeTasksFromUri
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
private List<ExperimentConfiguration> getChallengeTasksFromUri(String challengeUri) {
Model model = getChallengeFromUri(challengeUri);
if (model == null) {
LOGGER.error("Couldn't get model for challenge {} . Aborting.", challengeUri);
return null;
}
Resource challengeResource = model.getResource(challengeUri);
Calendar executionDate = RdfHelper.getDateValue(model, challengeResource, HOBBIT.executionDate);
ResIterator taskIterator = model.listSubjectsWithProperty(HOBBIT.isTaskOf, challengeResource);
List<ExperimentConfiguration> experiments = new ArrayList<>();
while (taskIterator.hasNext()) {
Resource challengeTask = taskIterator.next();
String challengeTaskUri = challengeTask.getURI();
// get benchmark information
String benchmarkUri = RdfHelper.getStringValue(model, challengeTask, HOBBIT.involvesBenchmark);
String experimentId, systemUri, serializedBenchParams;
// iterate participating system instances
NodeIterator systemInstanceIterator = model.listObjectsOfProperty(challengeTask,
HOBBIT.involvesSystemInstance);
RDFNode sysInstance;
while (systemInstanceIterator.hasNext()) {
sysInstance = systemInstanceIterator.next();
if (sysInstance.isURIResource()) {
systemUri = sysInstance.asResource().getURI();
experimentId = generateExperimentId();
serializedBenchParams = RabbitMQUtils
.writeModel2String(createExpModelForChallengeTask(model, challengeTaskUri, systemUri));
experiments.add(new ExperimentConfiguration(experimentId, benchmarkUri, serializedBenchParams,
systemUri, challengeUri, challengeTaskUri, executionDate));
} else {
LOGGER.error("Couldn't get the benchmark for challenge task \"{}\". This task will be ignored.",
challengeTaskUri);
}
}
}
return experiments;
}
示例15: getSerializedSystemParams
import org.apache.jena.rdf.model.ResIterator; //导入依赖的package包/类
protected static String getSerializedSystemParams(ExperimentConfiguration config, ImageManager imageManager) {
Model systemModel = imageManager.getSystemModel(config.systemUri);
Model benchmarkModel = imageManager.getBenchmarkModel(config.benchmarkUri);;
// Check the benchmark model for parameters that should be forwarded to the
// system
// if(benchmarkModel.contains(null, RDF.type, HOBBIT.ForwardedParameter)) {
if (benchmarkModel.contains(null, RDF.type, HOBBIT.ForwardedParameter)) {
Model benchParams = RabbitMQUtils.readModel(config.serializedBenchParams);
Property parameter;
NodeIterator objIterator;
Resource system = systemModel.getResource(config.systemUri);
Resource experiment = benchParams.getResource(Constants.NEW_EXPERIMENT_URI);
// Get an iterator for all these parameters
ResIterator iterator = benchmarkModel.listResourcesWithProperty(RDF.type, HOBBIT.ForwardedParameter);
while (iterator.hasNext()) {
// Get the parameter
parameter = benchmarkModel.getProperty(iterator.next().getURI());
// Get its value
objIterator = benchParams.listObjectsOfProperty(experiment, parameter);
// If there is a value, add it to the system model
while (objIterator.hasNext()) {
systemModel.add(system, parameter, objIterator.next());
}
}
}
return RabbitMQUtils.writeModel2String(systemModel);
}