本文整理了Java中org.opencastproject.workflow.api.WorkflowInstance
类的一些代码示例,展示了WorkflowInstance
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkflowInstance
类的具体详情如下:
包路径:org.opencastproject.workflow.api.WorkflowInstance
类名称:WorkflowInstance
[英]An single instance of a running, paused, or stopped workflow. WorkflowInstance objects are snapshots in time for a particular workflow. They are not thread-safe, and will not be updated by other threads.
[中]正在运行、暂停或停止的工作流的单个实例。WorkflowInstance对象是特定工作流的实时快照。它们不是线程安全的,不会被其他线程更新。
代码示例来源:origin: opencast/opencast
/**
* Gets a notification message with placeholders and substitute them with corresponding meta-data of workflowInstance.
* The resulting String is transformed to a Json-String
*
* @param s The notification message to transform to Json-String
* @param workflowInstance The workflowInstance which getting metadata from
* @return JSON-String containing the information of the workflowInstance
*/
private String makeJson(String s, WorkflowInstance workflowInstance) {
s = s.replace("%t", checkIfNull(workflowInstance.getTitle(), "Title"));
s = s.replace("%i", String.valueOf(workflowInstance.getId()));
s = s.replace("%s", String.valueOf(workflowInstance.getState()));
s = s.replace("%o", String.valueOf(workflowInstance.getCurrentOperation().getId()));
s = s.replace("%I", checkIfNull(workflowInstance.getMediaPackage().getIdentifier(), "Mediapackage-ID"));
s = s.replace("%T", checkIfNull(workflowInstance.getMediaPackage().getTitle(), "Mediapackage-Title"));
s = s.replace("%c", checkIfNull(workflowInstance.getMediaPackage().getContributors(), "Contributors"));
s = s.replace("%C", checkIfNull(workflowInstance.getMediaPackage().getCreators(), "Creators"));
s = s.replace("%D", checkIfNull(workflowInstance.getMediaPackage().getDate(), "Date"));
s = s.replace("%d", checkIfNull(workflowInstance.getMediaPackage().getDuration(), "Duration"));
s = s.replace("%l", checkIfNull(workflowInstance.getMediaPackage().getLanguage(), "Language"));
s = s.replace("%L", checkIfNull(workflowInstance.getMediaPackage().getLicense(), "License"));
s = s.replace("%S", checkIfNull(workflowInstance.getMediaPackage().getSeriesTitle(), "Series-Title"));
JsonObject json = new JsonObject();
json.addProperty("text", s);
return gson.toJson(json);
}
代码示例来源:origin: opencast/opencast
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowListener#stateChanged(org.opencastproject.workflow.api.WorkflowInstance)
*/
@Override
public void stateChanged(WorkflowInstance workflow) {
synchronized (this) {
if (!workflowInstanceIds.isEmpty() && !workflowInstanceIds.contains(workflow.getId()))
return;
WorkflowState currentState = workflow.getState();
if (!notifyStates.isEmpty() && !notifyStates.containsKey(currentState))
return;
if (notifyStates.containsKey(currentState)) {
notifyStates.get(currentState).incrementAndGet();
}
total.incrementAndGet();
logger.debug("Workflow {} state updated to {}", workflow.getId(), workflow.getState());
notifyAll();
}
}
代码示例来源:origin: opencast/opencast
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
logger.info("Start waveform workflow operation for mediapackage {}", mediaPackage);
String sourceFlavorProperty = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(SOURCE_FLAVOR_PROPERTY));
String sourceTagsProperty = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(SOURCE_TAGS_PROPERTY));
if (StringUtils.isEmpty(sourceFlavorProperty) && StringUtils.isEmpty(sourceTagsProperty)) {
throw new WorkflowOperationException(
String targetFlavorProperty = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(TARGET_FLAVOR_PROPERTY));
if (targetFlavorProperty == null) {
throw new WorkflowOperationException(String.format("Required property %s not set", TARGET_FLAVOR_PROPERTY));
String targetTagsProperty = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(TARGET_TAGS_PROPERTY));
StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(PIXELS_PER_MINUTE_PROPERTY)),
DEFAULT_PIXELS_PER_MINUTE
);
StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(MIN_WIDTH_PROPERTY)),
DEFAULT_MIN_WIDTH
);
StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(MAX_WIDTH_PROPERTY)),
DEFAULT_MAX_WIDTH
);
StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(HEIGHT_PROPERTY)),
DEFAULT_HEIGHT
);
代码示例来源:origin: opencast/opencast
public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context)
throws WorkflowOperationException {
WorkflowOperationInstance operation = workflowInstance.getCurrentOperation();
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
String filename = String.format("workflow-%d-%d-mediapackage-%s.json", workflowInstance.getId(),
operation.getId(), mediaPackage.getIdentifier());
saveOrLog(MediaPackageParser.getAsJSON(mediaPackage), directory, filename);
String filename = String.format("workflow-%d-%d-mediapackage-%s.xml", workflowInstance.getId(),
operation.getId(), mediaPackage.getIdentifier());
saveOrLog(MediaPackageParser.getAsXml(mediaPackage), directory, filename);
String filename = String.format("workflow-%d-%d.xml", workflowInstance.getId(), operation.getId());
try {
saveOrLog(WorkflowParser.toXml(workflowInstance), directory, filename);
代码示例来源:origin: opencast/opencast
/**
* Get an optional configuration key. Values are returned trimmed.
*/
protected Opt<String> getOptConfig(WorkflowInstance wi, String key) {
return getOptConfig(wi.getCurrentOperation(), key);
}
代码示例来源:origin: opencast/opencast
public WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context)
throws WorkflowOperationException {
logger.debug("Running HTTP notification workflow operation on workflow {}", workflowInstance.getId());
int maxRetry = DEFAULT_MAX_RETRY;
int timeout = DEFAULT_TIMEOUT;
return createResult(workflowInstance.getMediaPackage(), Action.CONTINUE);
代码示例来源:origin: opencast/opencast
/**
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof WorkflowInstance) {
WorkflowInstance other = (WorkflowInstance) obj;
return id == other.getId();
}
return false;
}
代码示例来源:origin: opencast/opencast
@Override
public IncidentTree getIncidentsOfJob(long jobId, boolean cascade) throws NotFoundException, IncidentServiceException {
List<Incident> incidents = getIncidentsOfJob(jobId);
List<IncidentTree> childIncidents = new ArrayList<IncidentTree>();
try {
Job job = getServiceRegistry().getJob(jobId);
if (cascade && !"START_WORKFLOW".equals(job.getOperation())) {
childIncidents = getChildIncidents(jobId);
} else if (cascade && "START_WORKFLOW".equals(job.getOperation())) {
for (WorkflowOperationInstance operation : getWorkflowService().getWorkflowById(jobId).getOperations()) {
if (operation.getState().equals(OperationState.INSTANTIATED))
continue;
IncidentTree operationResult = getIncidentsOfJob(operation.getId(), true);
if (hasIncidents(Collections.list(operationResult)))
childIncidents.add(operationResult);
}
}
return new IncidentTreeImpl(incidents, childIncidents);
} catch (NotFoundException ignore) {
// Workflow deleted
return new IncidentTreeImpl(incidents, childIncidents);
} catch (Exception e) {
logger.error("Error loading child jobs of {}: {}", jobId);
throw new IncidentServiceException(e);
}
}
代码示例来源:origin: opencast/opencast
public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context)
throws WorkflowOperationException {
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
WorkflowOperationInstance operation = workflowInstance.getCurrentOperation();
代码示例来源:origin: opencast/opencast
/**
* Get a mandatory configuration key. Values are returned trimmed.
*
* @throws WorkflowOperationException
* if the configuration key is either missing or empty
*/
protected String getConfig(WorkflowInstance wi, String key) throws WorkflowOperationException {
return getConfig(wi.getCurrentOperation(), key);
}
代码示例来源:origin: opencast/opencast
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowService#update(org.opencastproject.workflow.api.WorkflowInstance)
*/
@Override
public void update(WorkflowInstance workflowInstance) throws WorkflowDatabaseException {
HttpPost post = new HttpPost("/update");
try {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("workflow", WorkflowParser.toXml(workflowInstance)));
post.setEntity(new UrlEncodedFormEntity(params));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Unable to assemble a remote workflow service request", e);
} catch (Exception e) {
throw new IllegalStateException("unable to serialize workflow instance to xml");
}
HttpResponse response = getResponse(post, SC_NO_CONTENT);
try {
if (response != null) {
logger.info("Workflow '{}' updated", workflowInstance);
return;
}
} finally {
closeConnection(response);
}
throw new WorkflowDatabaseException("Unable to update workflow instance " + workflowInstance.getId());
}
代码示例来源:origin: opencast/opencast
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
logger.info("Start timeline previews workflow operation for mediapackage {}", mediaPackage.getIdentifier().compact());
workflowInstance.getCurrentOperation().getConfiguration(SOURCE_FLAVOR_PROPERTY));
String sourceTagsProperty = StringUtils.trimToNull(
workflowInstance.getCurrentOperation().getConfiguration(SOURCE_TAGS_PROPERTY));
if (StringUtils.isEmpty(sourceFlavorProperty) && StringUtils.isEmpty(sourceTagsProperty)) {
throw new WorkflowOperationException(String.format("Required property %s or %s not set",
workflowInstance.getCurrentOperation().getConfiguration(TARGET_FLAVOR_PROPERTY));
if (targetFlavorProperty == null) {
throw new WorkflowOperationException(String.format("Required property %s not set", TARGET_FLAVOR_PROPERTY));
workflowInstance.getCurrentOperation().getConfiguration(TARGET_TAGS_PROPERTY));
workflowInstance.getCurrentOperation().getConfiguration(IMAGE_SIZE_PROPERTY));
int imageSize;
if (imageSizeArg != null) {
代码示例来源:origin: opencast/opencast
/**
* Get a configuration key. Values are returned trimmed.
*
* @param w
* WorkflowInstance with current operation
* @param key
* Configuration key to check for
* @param defaultValue
* Value to return if key does not exists
*/
protected String getConfig(WorkflowInstance w, String key, String defaultValue) {
for (final String cfg : getOptConfig(w.getCurrentOperation(), key)) {
return cfg;
}
return defaultValue;
}
代码示例来源:origin: opencast/opencast
public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context)
throws WorkflowOperationException {
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
WorkflowOperationInstance operation = workflowInstance.getCurrentOperation();
代码示例来源:origin: opencast/opencast
/**
* Get a configuration option.
*
* @deprecated use {@link #getConfig(WorkflowInstance, String)} or {@link #getOptConfig(org.opencastproject.workflow.api.WorkflowInstance, String)}
*/
protected Option<String> getCfg(WorkflowInstance wi, String key) {
return option(wi.getCurrentOperation().getConfiguration(key));
}
代码示例来源:origin: opencast/opencast
@Override
public WorkflowOperationResult start(WorkflowInstance wi, JobContext ctx) throws WorkflowOperationException {
final WorkflowOperationInstance woi = wi.getCurrentOperation();
final int code = option(woi.getConfiguration(OPT_CODE)).bind(Strings.toInt).getOrElse(1);
final Severity severity = option(woi.getConfiguration(OPT_SEVERITY)).bind(parseEnum(Severity.FAILURE)).getOrElse(Severity.INFO);
final List<Tuple<String, String>> details = Arrays.stream(ArrayUtils.nullToEmpty(
StringUtils.split(woi.getConfiguration(OPT_DETAILS), ";")))
.map((opt) -> opt.split("="))
.filter((t) -> t.length == 2)
.map((x) -> Tuple.tuple(x[0], x[1]))
.collect(Collectors.toList());
final Map<String, String> params = Arrays.stream(ArrayUtils.nullToEmpty(
StringUtils.split(woi.getConfiguration(OPT_PARAMS), ";")))
.map((opt) -> opt.split("="))
.filter((t) -> t.length == 2)
.collect(Collectors.toMap(x -> x[0], x -> x[1]));
log.info("Create nop job");
final Job job = nopService.nop();
log.info("Log a dummy incident with code %d", code);
serviceRegistry.incident().record(job, severity, code, params, details);
if (!waitForStatus(job).isSuccess()) {
throw new WorkflowOperationException("Job did not complete successfully");
} else {
return createResult(WorkflowOperationResult.Action.CONTINUE);
}
}
内容来源于网络,如有侵权,请联系作者删除!