Search in sources :

Example 16 with BlankNode

use of org.apache.clerezza.commons.rdf.BlankNode in project stanbol by apache.

the class MultipartRequestTest method getDummyRdfMetadata.

/**
     * @param contentItemId
     * @param rdfContentType
     * @return
     */
private String getDummyRdfMetadata(final IRI contentItemId, String rdfContentType) {
    Graph metadata = new SimpleGraph();
    metadata.add(new TripleImpl(new BlankNode(), Properties.ENHANCER_EXTRACTED_FROM, contentItemId));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    serializer.serialize(out, metadata, rdfContentType);
    String rdfContent = new String(out.toByteArray(), UTF8);
    return rdfContent;
}
Also used : SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Graph(org.apache.clerezza.commons.rdf.Graph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) BlankNode(org.apache.clerezza.commons.rdf.BlankNode) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 17 with BlankNode

use of org.apache.clerezza.commons.rdf.BlankNode in project stanbol by apache.

the class ExecutionMetadataHelper method createChainExecutionNode.

public static BlankNodeOrIRI createChainExecutionNode(Graph graph, BlankNodeOrIRI executionPlan, IRI ciUri, boolean defaultChain) {
    BlankNodeOrIRI node = new BlankNode();
    graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION));
    graph.add(new TripleImpl(node, RDF_TYPE, CHAIN_EXECUTION));
    graph.add(new TripleImpl(node, ENHANCES, ciUri));
    graph.add(new TripleImpl(ciUri, ENHANCED_BY, node));
    graph.add(new TripleImpl(node, STATUS, STATUS_SCHEDULED));
    graph.add(new TripleImpl(node, EXECUTION_PLAN, executionPlan));
    graph.add(new TripleImpl(node, IS_DEFAULT_CHAIN, lf.createTypedLiteral(defaultChain)));
    return node;
}
Also used : BlankNode(org.apache.clerezza.commons.rdf.BlankNode) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Example 18 with BlankNode

use of org.apache.clerezza.commons.rdf.BlankNode in project stanbol by apache.

the class ExecutionPlanHelper method writeExecutionNode.

/**
     * Writes all triples for an ep:ExecutionNode to the parsed {@link Graph}.
     * An {@link BlankNode} is use for representing the execution node resource.
     * @param graph the graph to write the triples. MUST NOT be empty
     * @param epNode the BlankNodeOrIRI representing the ep:ExecutionPlan
     * @param engineName the name of the engine. MUST NOT be <code>null</code> nor empty
     * @param optional if the execution of this node is optional or required
     * @param dependsOn other nodes that MUST BE executed before this one. Parse 
     * <code>null</code> or an empty set if none.
     * @param enhProps the EnhancementProperties for this ExecutionNode or
     * <code>null</code> if none
     * @return the resource representing the added ep:ExecutionNode.
     * @since 0.12.1
     */
public static BlankNodeOrIRI writeExecutionNode(Graph graph, BlankNodeOrIRI epNode, String engineName, boolean optional, Set<BlankNodeOrIRI> dependsOn, Map<String, Object> enhProps) {
    if (graph == null) {
        throw new IllegalArgumentException("The parsed Graph MUST NOT be NULL!");
    }
    if (engineName == null || engineName.isEmpty()) {
        throw new IllegalArgumentException("The parsed Engine name MUST NOT be NULL nor empty!");
    }
    if (epNode == null) {
        throw new IllegalArgumentException("The ep:ExecutionPlan instance MUST NOT be NULL!");
    }
    BlankNodeOrIRI node = new BlankNode();
    graph.add(new TripleImpl(epNode, HAS_EXECUTION_NODE, node));
    graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION_NODE));
    graph.add(new TripleImpl(node, ENGINE, new PlainLiteralImpl(engineName)));
    if (dependsOn != null) {
        for (BlankNodeOrIRI dependend : dependsOn) {
            if (dependend != null) {
                graph.add(new TripleImpl(node, DEPENDS_ON, dependend));
            }
        }
    }
    graph.add(new TripleImpl(node, OPTIONAL, lf.createTypedLiteral(optional)));
    writeEnhancementProperties(graph, node, engineName, enhProps);
    return node;
}
Also used : PlainLiteralImpl(org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl) BlankNode(org.apache.clerezza.commons.rdf.BlankNode) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Aggregations

BlankNode (org.apache.clerezza.commons.rdf.BlankNode)18 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)11 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)10 Graph (org.apache.clerezza.commons.rdf.Graph)6 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)6 IRI (org.apache.clerezza.commons.rdf.IRI)5 Triple (org.apache.clerezza.commons.rdf.Triple)5 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)5 HashMap (java.util.HashMap)4 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)4 GraphNode (org.apache.clerezza.rdf.utils.GraphNode)3 Statement (org.ontoware.rdf2go.model.Statement)2 BlankNode (org.ontoware.rdf2go.model.node.BlankNode)2 RDFDataset (com.github.jsonldjava.core.RDFDataset)1 BufferedWriter (java.io.BufferedWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1