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


Java ResIterator类代码示例

本文整理汇总了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;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:23,代码来源:ImageManagerImpl.java

示例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();
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:17,代码来源:ImageManagerImpl.java

示例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();
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:17,代码来源:FileBasedImageManager.java

示例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;
    }
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:29,代码来源:RdfModelHelper.java

示例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;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:19,代码来源:RdfModelHelper.java

示例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;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:19,代码来源:RdfModelHelper.java

示例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;
      });
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:22,代码来源:ProcessResource.java

示例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);
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:26,代码来源:SkolemizingModelProvider.java

示例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();
				}
			}
		}
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:26,代码来源:schema.java

示例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;
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:26,代码来源:Context.java

示例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());
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:27,代码来源:TestStoreImpl.java

示例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));
    }
}
 
开发者ID:dice-group,项目名称:Squirrel,代码行数:22,代码来源:SimpleHttpServerComponent.java

示例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;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:16,代码来源:ImageManagerImpl.java

示例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;
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:38,代码来源:PlatformController.java

示例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);
}
 
开发者ID:hobbit-project,项目名称:platform,代码行数:28,代码来源:ExperimentManager.java


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