當前位置: 首頁>>代碼示例>>Java>>正文


Java RDFNode.isResource方法代碼示例

本文整理匯總了Java中org.apache.jena.rdf.model.RDFNode.isResource方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFNode.isResource方法的具體用法?Java RDFNode.isResource怎麽用?Java RDFNode.isResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.jena.rdf.model.RDFNode的用法示例。


在下文中一共展示了RDFNode.isResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProperties

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private static List<Pair<String, String>> getProperties(String uri) {
    List<Pair<String, String>> results = new ArrayList<>();
    String sparqlQuery = "select ?r ?y where {<" + uri + "> ?r ?y}";
    //System.out.println(sparqlQuery);
    QueryExecution e = QueryExecutionFactory.sparqlService(ENDPOINT, sparqlQuery);
    ResultSet rs = e.execSelect();
    while (rs.hasNext()) {
        QuerySolution nextSolution = rs.nextSolution();
        RDFNode ynode = nextSolution.get("y");
        if (ynode.isResource()) {
            results.add(Pair.of(nextSolution.getResource("r").getURI(), nextSolution.getResource("y").getURI()));
        } else {
            results.add(Pair.of(nextSolution.getResource("r").getURI(), nextSolution.getLiteral("y").getString().replaceAll("\\n+", " ")));
        }
    }
    e.close();
    return results;
}
 
開發者ID:swapUniba,項目名稱:lodrecsys_eswc2017tutorial,代碼行數:19,代碼來源:DownloadLodProperties.java

示例2: listSystemBeans

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public static List<SystemBean> listSystemBeans(Model model, Resource involvingResource) {
    List<SystemBean> systems = new ArrayList<>();
    if (model == null) {
        return systems;
    }
    // iterate over all systems
    NodeIterator systemIterator = model.listObjectsOfProperty(involvingResource, HOBBIT.involvesSystemInstance);
    RDFNode node;
    while (systemIterator.hasNext()) {
        node = systemIterator.next();
        if (node.isResource()) {
            systems.add(getSystemBean(model, node.asResource()));
        }
    }

    return systems;
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:18,代碼來源:RdfModelHelper.java

示例3: createParamValueBeans

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private static void createParamValueBeans(Model model, Resource taskResource, NodeIterator parameterIterator,
        Map<String, ConfigurationParamValueBean> parameters) {
    RDFNode node;
    Resource parameter;
    Property paraProp;
    String parameterUri;
    while (parameterIterator.hasNext()) {
        node = parameterIterator.next();
        if (node.isResource()) {
            parameter = node.asResource();
            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));
                parameters.put(parameterUri, paramBean);
            }
        }
    }
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:22,代碼來源:RdfModelHelper.java

示例4: filterBinaryReferences

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
 * Filter out the binary resource references from the model
 * @param uri the URI for the resource
 * @param model the RDF Model of the resource
 * @return the RDF model with no binary references
 * @throws FcrepoOperationFailedException
 * @throws IOException
 */
private void filterBinaryReferences(final URI uri, final Model model) throws IOException,
        FcrepoOperationFailedException {

    final List<Statement> removeList = new ArrayList<>();
    for (final StmtIterator it = model.listStatements(); it.hasNext();) {
        final Statement s = it.nextStatement();

        final RDFNode obj = s.getObject();
        if (obj.isResource() && obj.toString().startsWith(repositoryRoot.toString())
                && !s.getPredicate().toString().equals(REPOSITORY_NAMESPACE + "hasTransactionProvider")) {
            try (final FcrepoResponse resp = client().head(URI.create(obj.toString())).disableRedirects()
                    .perform()) {
                checkValidResponse(resp, URI.create(obj.toString()), config.getUsername());
                final List<URI> linkHeaders = resp.getLinkHeaders("type");
                if (linkHeaders.contains(binaryURI)) {
                    removeList.add(s);
                }
            }
        }
    }

    model.remove(removeList);
}
 
開發者ID:fcrepo4-labs,項目名稱:fcrepo-import-export,代碼行數:32,代碼來源:Exporter.java

示例5: getDisplayName

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public static String getDisplayName(RDFNode node) {
	if (node == null)
		return "unknown";
	else if (node.isAnon())
		return "anon";
	else if (node.isLiteral())
		return node.asLiteral().getLexicalForm();
	else if (node.isResource()) {
		Resource resource = node.asResource();
		if (resource instanceof OntResource) {
			String label = ((OntResource) resource).getLabel(null);
			if (label != null)
				return label;
		}
		String localName = resource.getLocalName();
		if ((localName != null) && !localName.isEmpty())
			return localName;
		return resource.toString();
	} else
		return "unknown";
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-component,代碼行數:22,代碼來源:SemanticAnnotationUtils.java

示例6: getNodeValue

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private static String getNodeValue(RDFNode node) {
	if (node.isLiteral()) {
		Literal lit = node.asLiteral();
		return lit.getLexicalForm();
	}
	if (node.isResource()) {
		Resource res = node.asResource();
		return res.getURI();
	}
	throw new RuntimeException("RDF node " + node + " is neither a literal nor a resource!");
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:12,代碼來源:RDFProjector.java

示例7: getAllEdges

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
@Override
public Set<Statement> getAllEdges(RDFNode sourceVertex, RDFNode targetVertex) {
    Set<Statement> result = sourceVertex.isResource()
            ? model.listStatements(sourceVertex.asResource(), predicate, targetVertex).toSet()
            : Collections.emptySet()
            ;

    return result;
    //return model.find(sourceVertex, predicate, targetVertex).toSet();
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:11,代碼來源:PseudoGraphJenaModel.java

示例8: containsVertex

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
@Override
public boolean containsVertex(RDFNode v) {
    boolean result =
            (v != null && v.isResource() && model.contains(v.asResource(), null, (RDFNode)null)) ||
            model.contains(null, null, v);
    return result;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:8,代碼來源:PseudoGraphJenaModel.java

示例9: removeVertex

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
@Override
public boolean removeVertex(RDFNode v) {
    if(v.isResource()) {
        model.remove(v.asResource(), predicate, (RDFNode)null);
    }

    model.remove(null, predicate, v);
    return true;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:10,代碼來源:PseudoGraphJenaModel.java

示例10: parseBenchmarkParameters

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
 * Retrieves benchmark parameters of the given benchmark from the given RDF
 * model and adds them to the given {@link BenchmarkBean}.
 *
 * @param model
 *            the RDF model containing the benchmark parameters
 * @param benchmark
 *            the {@link Resource} representing the benchmark
 * @param benchmarkBean
 *            the {@link BenchmarkBean} to which the parameters should be
 *            added
 */
public static void parseBenchmarkParameters(Model model, Resource benchmark, BenchmarkBean benchmarkBean) {
    NodeIterator nodeIterator = model.listObjectsOfProperty(benchmark, HOBBIT.hasParameter);
    RDFNode node;
    if (nodeIterator.hasNext()) {
        benchmarkBean.setConfigurationParams(new ArrayList<>());
        benchmarkBean.setConfigurationParamNames(new ArrayList<>());
    }
    while (nodeIterator.hasNext()) {
        node = nodeIterator.next();
        if (node.isResource()) {
            parseBenchmarkParameter(model, node.asResource(), benchmarkBean);
        }
    }
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:27,代碼來源:RdfModelHelper.java

示例11: getChallengeTask

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public static ChallengeTaskBean getChallengeTask(Model model, Resource taskResource) {
    if (model == null) {
        return null;
    }
    ChallengeTaskBean task = new ChallengeTaskBean();
    task.setName(RdfHelper.getLabel(model, taskResource));
    task.setDescription(RdfHelper.getDescription(model, taskResource));
    Resource benchmarkResource = RdfHelper.getObjectResource(model, taskResource, HOBBIT.involvesBenchmark);
    if (benchmarkResource != null) {
        task.setBenchmark(createBenchmarkBean(model, benchmarkResource));
        task.getBenchmark().setSystems(listSystemBeans(model, taskResource));
    }
    task.setConfigurationParams(createParamValueBeans(model, taskResource, benchmarkResource));
    task.setId(taskResource.getURI());

    List<String> rankingKPIs = new ArrayList<>();
    Resource rankingKPIsSequence = RdfHelper.getObjectResource(model, taskResource, HOBBIT.rankingKPIs);
    if (rankingKPIsSequence != null) {
        SeqImpl sequence = new SeqImpl(rankingKPIsSequence, (ModelCom) model);
        NodeIterator sequenceIterator = sequence.iterator();
        while (sequenceIterator.hasNext()) {
            RDFNode node = sequenceIterator.next();
            if (node.isResource()) {
                rankingKPIs.add(node.asResource().toString());
            }
        }
    }
    task.setRankingKPIs(rankingKPIs);

    return task;
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:32,代碼來源:RdfModelHelper.java

示例12: listObjectProperties

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private Set<Individual> listObjectProperties(OntResource ontResource,
		ObjectProperty prop) {
	LinkedHashSet<Individual> results = new LinkedHashSet<>();
	try (ClosableIterable<RDFNode> props = iterate(ontResource
			.listPropertyValues(prop))) {
		for (RDFNode node : props) {
			if (!node.isResource() || !node.canAs(Individual.class))
				continue;
			results.add(node.as(Individual.class));
		}
	}
	return results;
}
 
開發者ID:apache,項目名稱:incubator-taverna-language,代碼行數:14,代碼來源:RDFToManifest.java

示例13: containsEdge

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
@Override
public boolean containsEdge(RDFNode sourceVertex, RDFNode targetVertex) {
    // TODO Not sure if contains works with RDFNode.ANY - may have to use !.find().toSet().isEmpyt()
    boolean result = sourceVertex != null && sourceVertex.isResource() && model.contains(sourceVertex.asResource(), predicate, targetVertex);
    return result;
}
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:7,代碼來源:PseudoGraphJenaModel.java

示例14: createEdgePalette

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
protected ColourPalette createEdgePalette(Model model) {
    RDFNode node;
    Resource resource1, resource2;
    StmtIterator sIterator = model.listStatements(null, RDFS.subPropertyOf, (RDFNode) null);
    Statement statement;
    HierarchyNode hNode1, hNode2;
    // Iterate over the class hierarchy triples
    while (sIterator.hasNext()) {
        statement = sIterator.next();
        resource1 = statement.getSubject();
        node = statement.getObject();
        if (node.isResource()) {
            resource2 = node.asResource();
            if (properties.containsKey(resource1)) {
                hNode1 = properties.get(resource1);
            } else {
                // this property is not known, add it
                hNode1 = new HierarchyNode();
                properties.put(resource1, hNode1);
            }
            if (properties.containsKey(resource2)) {
                hNode2 = properties.get(resource2);
            } else {
                // this property is not known, add it
                hNode2 = new HierarchyNode();
                properties.put(resource2, hNode2);
            }
            // add the hierarchy information
            // if there is no list of child nodes
            if (hNode1.childNodes == null) {
                hNode1.childNodes = new Resource[] { resource2 };
            } else {
                hNode1.childNodes = Arrays.copyOf(hNode1.childNodes, hNode1.childNodes.length + 1);
                hNode1.childNodes[hNode1.childNodes.length - 1] = resource2;
            }
            // if there is no list of parent nodes
            if (hNode2.parentNodes == null) {
                hNode2.parentNodes = new Resource[] { resource1 };
            } else {
                hNode2.parentNodes = Arrays.copyOf(hNode2.parentNodes, hNode2.parentNodes.length + 1);
                hNode2.parentNodes[hNode2.parentNodes.length - 1] = resource1;
            }
        }
    }

    // All properties have been collected
    // The colours can be defined
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            edgePalette.addColour(((Resource) ((Object[]) properties.keys)[i]).getURI());
        }
    }

    // The hierarchy can be used to create colour mixtures that contain the
    // hierarchy
    // Search for all root nodes that have child nodes
    for (int i = 0; i < properties.allocated.length; ++i) {
        if (properties.allocated[i]) {
            hNode1 = (HierarchyNode) ((Object[]) properties.values)[i];
            if ((hNode1.childNodes != null) && (hNode1.parentNodes == null)) {
                mixColours((Resource) ((Object[]) properties.keys)[i], hNode1, properties, edgePalette);
            }
        }
    }

    return edgePalette;
}
 
開發者ID:dice-group,項目名稱:Lemming,代碼行數:68,代碼來源:GraphCreator.java

示例15: parseBenchmarkParameter

import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
 * Parses the given parameter from the given RDFmodel and adds it to the
 * given {@link BenchmarkBean}.
 *
 * @param model
 *            the RDF model containing the parameter
 * @param parameter
 *            the {@link Resource} representing the parameter
 * @param benchmarkBean
 *            the {@link BenchmarkBean} to which the parameter should be
 *            added
 */
public static void parseBenchmarkParameter(Model model, Resource parameter, BenchmarkBean benchmarkBean) {
    // If this parameter can be configured
    if (model.contains(parameter, RDF.type, HOBBIT.ConfigurableParameter)) {
        ConfigurationParamBean configParam = new ConfigurationParamBean();
        configParam.setId(parameter.getURI());
        configParam.setName(RdfHelper.getLabel(model, parameter));
        if (configParam.getName() == null) {
            configParam.setName(parameter.getURI());
            LOGGER.warn("The benchmark parameter {} does not have a label.", parameter.getURI());
        }
        configParam.setDescription(RdfHelper.getDescription(model, parameter));
        if (configParam.getDescription() == null) {
            LOGGER.warn("The benchmark parameter {} does not have a description.", parameter.getURI());
        }
        configParam.setDefaultValue(RdfHelper.getStringValue(model, parameter, HOBBIT.defaultValue));
        configParam.setFeature(model.contains(parameter, RDF.type, HOBBIT.FeatureParameter));

        NodeIterator nodeIterator = model.listObjectsOfProperty(parameter, RDFS.range);
        RDFNode node;
        if (nodeIterator.hasNext()) {
            node = nodeIterator.next();
            if (node.isResource()) {
                Resource typeResource = node.asResource();
                configParam.setRange(typeResource.getURI());
                // If this is an XSD resource
                if (XSD.getURI().equals(typeResource.getNameSpace())) {
                    configParam.setDatatype(parseXsdType(typeResource));
                } else if (model.contains(typeResource, RDF.type, RDFS.Class)
                        || model.contains(typeResource, RDF.type, OWL.Class)) {
                    // Maybe this parameter has a set of predefined enum
                    // values
                    configParam.setOptions(listOptions(model, typeResource));
                }
            }
        }
        // If the datatype couldn't be found and there is no list of options
        if ((configParam.getDatatype() == null) && (configParam.getOptions() == null)) {
            configParam.setDatatype(Datatype.STRING);
            LOGGER.warn("Couldn't find datatype of parameter {}. Using String as default.", parameter.getURI());

        }
        benchmarkBean.getConfigurationParamNames().add(configParam.getName());
        benchmarkBean.getConfigurationParams().add(configParam);
    }
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:58,代碼來源:RdfModelHelper.java


注:本文中的org.apache.jena.rdf.model.RDFNode.isResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。