use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class EnhancementJob method setCompleted.
/**
* Sets the state of the parsed executionNode to completed. This also validates if the new state
* confirms to the ExectionPlan (e.g. if all nodes the parsed node depends on are also marked as
* completed).
*
* @param execution
* the exection to be marked as running
* @throws IllegalArgumentException
* if <code>null</code> is parsed as execution node
* @throws IllegalStateException
* if the parsed execution node can not be marked as completed because some of its
* depended nodes are not yet marked as completed.
*/
public void setCompleted(BlankNodeOrIRI execution) {
if (execution == null) {
throw new IllegalArgumentException("The parsed em:Execution instance MUST NOT be NULL!");
}
writeLock.lock();
BlankNodeOrIRI executionNode = getExecutionNode(execution);
log.trace("++ w: {}: {}", "setCompleted", getEngine(executionPlan, executionNode));
try {
log.trace(">> w: {}: {}", "setCompleted", getEngine(executionPlan, executionNode));
setNodeCompleted(executionNode);
setExecutionCompleted(executionMetadata, execution, null);
} finally {
log.trace("<< w: {}: {}", "setCompleted", getEngine(executionPlan, executionNode));
writeLock.unlock();
}
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class EnhancementJob method checkExecutable.
/**
* updated the {@link #executable} and also checks for {@link #finished}<p>
* Assumed to be called within a write lock!
*/
private void checkExecutable() {
Set<BlankNodeOrIRI> executeableNodes = ExecutionPlanHelper.getExecutable(executionPlan, completed);
//a Chain finishes if no engine is running and no more nodes are executable
if (!ExecutionMetadata.STATUS_FAILED.equals(getReference(executionMetadata, chainExecutionNode, STATUS))) {
executeableNodes.removeAll(running);
if (log.isDebugEnabled()) {
Collection<String> engines = new ArrayList<String>(executeableNodes.size());
for (BlankNodeOrIRI node : executeableNodes) {
engines.add(getEngine(executionPlan, node));
}
log.trace("MARK {} as executeable", engines);
}
//we need to get the em:Executables for the ep:ExecutionNodes ...
if (executeableNodes.isEmpty()) {
this.executable = Collections.emptySet();
} else if (executeableNodes.size() == 1) {
this.executable = Collections.singleton(getExecution(executeableNodes.iterator().next()));
} else {
Set<BlankNodeOrIRI> executable = new HashSet<BlankNodeOrIRI>(executeableNodes.size());
for (BlankNodeOrIRI exeutableNode : executeableNodes) {
executable.add(getExecution(exeutableNode));
}
this.executable = Collections.unmodifiableSet(executable);
}
} else {
//do not mark engines as executeable if chain already failed
this.executable = Collections.emptySet();
}
if (isFinished() && !isFailed()) {
//mark the execution process as completed
setExecutionCompleted(executionMetadata, chainExecutionNode, null);
}
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class GenericEnhancerUiResource method getExecutionNodes.
/**
* Getter for the executionNodes
*
* @return
*/
public Set<ExecutionNode> getExecutionNodes() {
if (_executionNodes == null) {
ImmutableGraph ep;
try {
ep = chain.getExecutionPlan();
} catch (ChainException e) {
ep = null;
}
if (ep != null) {
_executionNodes = new LinkedHashSet<ExecutionNode>();
Set<BlankNodeOrIRI> processed = new HashSet<BlankNodeOrIRI>();
Set<BlankNodeOrIRI> next;
do {
next = ExecutionPlanHelper.getExecutable(ep, processed);
for (BlankNodeOrIRI node : next) {
_executionNodes.add(new ExecutionNode(ep, node));
}
processed.addAll(next);
} while (!next.isEmpty());
}
}
return _executionNodes;
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class TikaEngineTest method testMp4.
/**
* Tests mappings for the Mp4 metadata extraction capabilities added to
* Tika 1.1 (STANBOL-627)
* @throws EngineException
* @throws IOException
* @throws ParseException
*/
@Test
public void testMp4() throws EngineException, IOException, ParseException {
log.info(">>> testMp4 <<<");
ContentItem ci = createContentItem("testMP4.m4a", "audio/mp4");
assertFalse(engine.canEnhance(ci) == CANNOT_ENHANCE);
engine.computeEnhancements(ci);
Entry<IRI, Blob> contentPart = ContentItemHelper.getBlob(ci, singleton("text/plain"));
assertNotNull(contentPart);
Blob plainTextBlob = contentPart.getValue();
assertNotNull(plainTextBlob);
assertContentRegexp(plainTextBlob, "Test Title", "Test Artist", "Test Album");
//validate XHTML results
contentPart = ContentItemHelper.getBlob(ci, singleton("application/xhtml+xml"));
assertNotNull(contentPart);
Blob xhtmlBlob = contentPart.getValue();
assertNotNull(xhtmlBlob);
//Test AudioTrack metadata
BlankNodeOrIRI audioTrack = verifyBlankNodeOrIRI(ci, new IRI(NamespaceEnum.media + "hasTrack"));
//types
verifyValues(ci, audioTrack, RDF.type, new IRI(NamespaceEnum.media + "MediaFragment"), new IRI(NamespaceEnum.media + "Track"), new IRI(NamespaceEnum.media + "AudioTrack"));
//properties
verifyValue(ci, audioTrack, new IRI(NamespaceEnum.media + "hasFormat"), XSD.string, "Stereo");
verifyValue(ci, audioTrack, new IRI(NamespaceEnum.media + "samplingRate"), XSD.int_, "44100");
verifyValue(ci, audioTrack, new IRI(NamespaceEnum.media + "hasCompression"), XSD.string, "M4A");
}
use of org.apache.clerezza.commons.rdf.BlankNodeOrIRI in project stanbol by apache.
the class TikaEngineTest method verifyBlankNodeOrIRI.
private static BlankNodeOrIRI verifyBlankNodeOrIRI(ContentItem ci, IRI subject, IRI property) {
Iterator<Triple> it = ci.getMetadata().filter(subject, property, null);
assertTrue(it.hasNext());
RDFTerm r = it.next().getObject();
assertFalse(it.hasNext());
assertTrue(r instanceof BlankNodeOrIRI);
return (BlankNodeOrIRI) r;
}
Aggregations