本文整理汇总了Java中org.apache.jena.rdf.model.ResIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java ResIterator.next方法的具体用法?Java ResIterator.next怎么用?Java ResIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.rdf.model.ResIterator
的用法示例。
在下文中一共展示了ResIterator.next方法的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: 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);
}
示例8: 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));
}
}
示例9: 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;
}
示例10: 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;
}
示例11: createBenchmarkBean
import org.apache.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Creates a {@link BenchmarkBean} from the given RDF model by searching for
* an instance of {@link HOBBIT#Benchmark}. If such an instance can be
* found, the label and description of this resource are derived. Otherwise,
* <code>null</code> is returned.
*
* @param model
* the RDF model containing the benchmark model
* @return a {@link BenchmarkBean} or <code>null</code> if there is no
* benchmark inside the given model
*/
public static BenchmarkBean createBenchmarkBean(Model model) {
// Get the benchmark node
ResIterator resourceIterator = model.listSubjectsWithProperty(RDF.type, HOBBIT.Benchmark);
if (!resourceIterator.hasNext()) {
LOGGER.error("Benchmark model does not have a Benchmark. Returning null.");
return null;
}
Resource benchmarkResource = resourceIterator.next();
if (resourceIterator.hasNext()) {
LOGGER.warn(
"Benchmark model defines more than one Benchmark. Only the first will be used while all others are ignored.");
}
return createBenchmarkBean(model, benchmarkResource);
}
示例12: createParamValueBeans
import org.apache.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
private static void createParamValueBeans(Model model, Resource taskResource, ResIterator parameterIterator,
Map<String, ConfigurationParamValueBean> parameters) {
Resource parameter;
Property paraProp;
String parameterUri;
while (parameterIterator.hasNext()) {
parameter = parameterIterator.next();
parameterUri = parameter.getURI();
paraProp = model.getProperty(parameterUri);
if (model.contains(taskResource, paraProp) && !parameters.containsKey(parameterUri)) {
ConfigurationParamValueBean paramBean = new ConfigurationParamValueBean();
paramBean.setId(parameterUri);
paramBean.setValue(RdfHelper.getStringValue(model, taskResource, paraProp));
paramBean.setName(RdfHelper.getLabel(model, paraProp));
if (paramBean.getName() == null) {
paramBean.setName(parameter.getURI());
LOGGER.info("The benchmark parameter {} does not have a label.", parameter.getURI());
}
paramBean.setDescription(RdfHelper.getDescription(model, paraProp));
if (paramBean.getDescription() == null) {
LOGGER.info("The benchmark parameter {} does not have a description.", parameter.getURI());
}
NodeIterator nodeIterator = model.listObjectsOfProperty(parameter, RDFS.range);
RDFNode node;
if (nodeIterator.hasNext()) {
node = nodeIterator.next();
if (node.isResource()) {
Resource typeResource = node.asResource();
paramBean.setRange(typeResource.getURI());
// If this is an XSD resource
if (XSD.getURI().equals(typeResource.getNameSpace())) {
paramBean.setDatatype(parseXsdType(typeResource));
}
}
}
parameters.put(parameterUri, paramBean);
}
}
}
示例13: populate
import org.apache.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
/**
* Populate lookup table (name to URI).
* @param model
*
* @return
*/
public void populate(Model model) {
ResIterator list = model.listResourcesWithProperty(RDF.type, OWL.Class);
while(list.hasNext()) {
Resource r = list.next();
this.put(r.getLocalName(), r);
}
logger.info("Classes map = " + this);
}
示例14: build
import org.apache.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public Model build(Model model)
{
if (model == null) throw new IllegalArgumentException("Model cannot be null");
Map<Resource, String> resourceURIMap = new HashMap<>();
ResIterator resIt = model.listSubjects();
try
{
while (resIt.hasNext())
{
Resource resource = resIt.next();
if (resource.isAnon())
{
URI uri = build(resource);
if (uri != null) resourceURIMap.put(resource, uri.toString());
}
}
}
finally
{
resIt.close();
}
Iterator<Map.Entry<Resource, String>> entryIt = resourceURIMap.entrySet().iterator();
while (entryIt.hasNext())
{
Map.Entry<Resource, String> entry = entryIt.next();
ResourceUtils.renameResource(entry.getKey(), entry.getValue());
}
return model;
}
示例15: ConferenceEvent
import org.apache.jena.rdf.model.ResIterator; //导入方法依赖的package包/类
public ConferenceEvent(Model model) {
ResIterator resIt = model.listResourcesWithProperty(RDF.type, SWC.ConferenceEvent);
//ResIterator resIt = model.listResourcesWithProperty(RDF.type, SWC.WorkshopEvent);
if(resIt.hasNext()){
resource = resIt.next();
}
}