Search in sources :

Example 81 with PlainLiteralImpl

use of org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl 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)

Example 82 with PlainLiteralImpl

use of org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl in project stanbol by apache.

the class ExecutionMetadataHelper method setExecutionFaild.

/**
     * Set the parsed execution node to failed.
     * @param graph
     * @param execution
     * @param message An message describing why the execution failed
     */
public static void setExecutionFaild(Graph graph, BlankNodeOrIRI execution, String message) {
    Literal dateTime = lf.createTypedLiteral(new Date());
    setStatus(graph, execution, STATUS_FAILED);
    graph.add(new TripleImpl(execution, COMPLETED, dateTime));
    if (message != null) {
        graph.add(new TripleImpl(execution, STATUS_MESSAGE, new PlainLiteralImpl(message)));
    } else {
        throw new IllegalArgumentException("For faild Execution a STATUS message is required!");
    }
}
Also used : PlainLiteralImpl(org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl) Literal(org.apache.clerezza.commons.rdf.Literal) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) Date(java.util.Date)

Aggregations

PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)82 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)69 IRI (org.apache.clerezza.commons.rdf.IRI)58 Graph (org.apache.clerezza.commons.rdf.Graph)34 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)20 Language (org.apache.clerezza.commons.rdf.Language)19 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)18 Literal (org.apache.clerezza.commons.rdf.Literal)16 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)16 IOException (java.io.IOException)14 HashMap (java.util.HashMap)13 Triple (org.apache.clerezza.commons.rdf.Triple)12 StringSource (org.apache.stanbol.enhancer.servicesapi.impl.StringSource)12 ArrayList (java.util.ArrayList)11 Blob (org.apache.stanbol.enhancer.servicesapi.Blob)11 LiteralFactory (org.apache.clerezza.rdf.core.LiteralFactory)10 ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)10 Test (org.junit.Test)10 HashSet (java.util.HashSet)8 SOAPException (javax.xml.soap.SOAPException)6