use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.
the class EnhancementEngineHelper method getChainExecutionProperties.
/**
* Getter for the {@link Chain} scoped (chain and chain-engine scoped) properties
* for the parsed enhancement engine and content item.
* @param engine the enhancement engine
* @param ci the content item
* @return the chain scoped enhancement properties. This will not include any
* request scoped properties.
* @since 0.12.1 (<a href="https://issues.apache.org/jira/browse/STANBOL-1361">STANBOL-1361</a>)
*/
public static Map<String, Object> getChainExecutionProperties(EnhancementEngine engine, ContentItem ci) {
if (engine == null) {
throw new IllegalArgumentException("The parsed EnhancementEngine MUST NOT be NULL");
}
if (ci == null) {
throw new IllegalArgumentException("The parsed ContentItem MUST NOT be NULL");
}
Map<String, Object> chainExProps = new HashMap<String, Object>();
Map<String, Object> engineExProps = new HashMap<String, Object>();
ci.getLock().readLock().lock();
try {
Graph em = ExecutionMetadataHelper.getExecutionMetadata(ci);
// (1.a) retrieve EnhancementProperties from the ep:ExecutionPlan
log.debug("> extract EnhancementProperties form the ExecutionPlan");
BlankNodeOrIRI executionPlanNode = ExecutionMetadataHelper.getExecutionPlanNode(em, ExecutionMetadataHelper.getChainExecution(em, ci.getUri()));
extractEnhancementProperties(chainExProps, em, executionPlanNode, "Chain Execution");
// (1.b) retrieve Enhancement Properties from the ep:ExectutionNode
// for the parsed EnhancementEngine
log.debug("> extract EnhancementProperties form the ExecutionNode of Engine {}", engine.getName());
Iterator<Triple> engineExecutions = em.filter(null, ExecutionPlan.ENGINE, new PlainLiteralImpl(engine.getName()));
// there are multiple we will merge the properties of those
while (engineExecutions.hasNext()) {
BlankNodeOrIRI engineExecution = engineExecutions.next().getSubject();
if (em.contains(new TripleImpl(executionPlanNode, ExecutionPlan.HAS_EXECUTION_NODE, engineExecution))) {
extractEnhancementProperties(engineExProps, em, engineExecution, "Engine Execution");
}
// else engine execution of a different execution plan
}
} catch (NoSuchPartException e) {
// no execution metadata are present
log.debug(" - no ExecutionMetadata are present ...");
} finally {
ci.getLock().readLock().unlock();
}
// finally merge the chain-engine scoped properties into the chain scoped properties
chainExProps.putAll(engineExProps);
return chainExProps;
}
use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.
the class EnhancementEngineHelper method createTextEnhancement.
/**
* Create a new instance with the types enhancer:Enhancement and
* enhancer:TextAnnotation in the parsed graph along with default properties
* (dc:creator, dc:created and enhancer:extracted-form) and return
* the IRI of the extraction so that engines can further add.
*
* @param metadata the graph
* @param engine the engine
* @param contentItemId the id
*
* @return the URI of the new enhancement instance
*/
public static IRI createTextEnhancement(Graph metadata, EnhancementEngine engine, IRI contentItemId) {
IRI enhancement = createEnhancement(metadata, engine, contentItemId);
// add the Text Annotation Type
metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_TEXTANNOTATION));
return enhancement;
}
use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.
the class ExecutionPlanHelper method createExecutionPlan.
/**
* Creates an ExecutionPlan for the parsed chainName in the parsed ImmutableGraph
* @param graph the graph
* @param chainName the chain name
* @param enhProps the map with the enhancement properties defined for the
* chain or <code>null</code> if none
* @return the node representing the ex:ExecutionPlan
* @since 0.12.1
*/
public static BlankNodeOrIRI createExecutionPlan(Graph graph, String chainName, Map<String, Object> enhProps) {
if (graph == null) {
throw new IllegalArgumentException("The parsed Graph MUST NOT be NULL!");
}
if (chainName == null || chainName.isEmpty()) {
throw new IllegalArgumentException("The parsed Chain name MUST NOT be NULL nor empty!");
}
BlankNodeOrIRI node = new BlankNode();
graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION_PLAN));
graph.add(new TripleImpl(node, CHAIN, new PlainLiteralImpl(chainName)));
writeEnhancementProperties(graph, node, null, enhProps);
return node;
}
use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.
the class ExecutionMetadataHelper method setExecutionSkipped.
/**
* Sets an execution node to skipped. This sets both the start and the completed
* time to the current time.
* @param graph
* @param execution
* @param message An optional message why this execution was skipped
*/
public static void setExecutionSkipped(Graph graph, BlankNodeOrIRI execution, String message) {
Literal dateTime = lf.createTypedLiteral(new Date());
setStatus(graph, execution, STATUS_SKIPPED);
graph.add(new TripleImpl(execution, STARTED, dateTime));
graph.add(new TripleImpl(execution, COMPLETED, dateTime));
if (message != null) {
graph.add(new TripleImpl(execution, STATUS_MESSAGE, new PlainLiteralImpl(message)));
}
}
use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.
the class GraphMultiplexer method updateSessionRegistration.
private void updateSessionRegistration(Session session) {
final IRI sesur = getIRIforSession(session);
// If this method was called after a session rebuild, the following will have little to no effect.
synchronized (meta) {
// The only essential triple to add is typing
meta.add(new TripleImpl(sesur, RDF.type, SESSION_URIREF));
}
log.debug("Ontology collector information triples added for session \"{}\".", sesur);
}
Aggregations