本文整理汇总了Java中net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback类的典型用法代码示例。如果您正苦于以下问题:Java AsynchronousActivityCallback类的具体用法?Java AsynchronousActivityCallback怎么用?Java AsynchronousActivityCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsynchronousActivityCallback类属于net.sf.taverna.t2.workflowmodel.processor.activity包,在下文中一共展示了AsynchronousActivityCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerOutputs
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
/**
* Registers the outputs.
*
* @param callback callback of the activity
* @param op results
* @return a map of output port names and output references
*/
private Map<String, T2Reference> registerOutputs(final AsynchronousActivityCallback callback,
final TransientOperation<Boolean, Boolean> op) {
logger.debug("Registering outputs");
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
Map<String, T2Reference> outputs = new HashMap<String, T2Reference>();
// Result
Boolean result = op.getAggregatedResult();
T2Reference ref = referenceService.register(result.toString(), 0, true, context);
outputs.put(OUT, ref);
return outputs;
}
示例2: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
executeQa(new PaeQa(), images[0], images[1], callback);
}
});
}
示例3: readImages
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
/**
* Reads the input images from the provided inputs.
*
* @param inputs the inputs of the activity
* @param callback callback
* @return an array with IN_IMAGE_1 and IN_IMAGE_2 in this order or null if
* one of the images could not be read
*/
protected BufferedImage[] readImages(final Map<String, T2Reference> inputs,
final AsynchronousActivityCallback callback) {
BufferedImage[] images = new BufferedImage[2];
// Wrap image 1
logger.info("Loading image on port " + IN_IMAGE_1);
images[0] = wrapInputImage(callback, inputs.get(IN_IMAGE_1));
if (null == images[0]) {
logger.warn("Could not read image on port " + IN_IMAGE_1);
callback.fail("Equals: Could not read image on port " + IN_IMAGE_1);
return null;
}
// Wrap image 2
logger.info("Loading image on port " + IN_IMAGE_2);
images[1] = wrapInputImage(callback, inputs.get(IN_IMAGE_2));
if (null == images[1]) {
logger.warn("Could not read image on port " + IN_IMAGE_2);
callback.fail("Equals: Could not read image on port " + IN_IMAGE_2);
return null;
}
return images;
}
示例4: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
executeQa(new AeQa(), images[0], images[1], callback);
}
});
}
示例5: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
executeQa(new MaeQa(), images[0], images[1], callback);
}
});
}
示例6: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
SsimQa ssimQa = new SsimQa();
if (getConfiguration().getTargetSize() > 0) {
ssimQa.targetSize(getConfiguration().getTargetSize());
}
if (!getConfiguration().isDoThreaded()) {
ssimQa.numThreads(0);
} else {
ssimQa.numThreads(getConfiguration().getThreadPoolSize());
}
executeQa(new SsimQa(), images[0], images[1], callback);
}
});
}
示例7: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
executeQa(new MseQa(), images[0], images[1], callback);
}
});
}
示例8: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Read images
BufferedImage[] images = readImages(inputs, callback);
if (images == null) {
return;
}
// Process images
Map<String, T2Reference> outputs = null;
if (images[0].getWidth() != images[1].getWidth() || images[0].getHeight() != images[1].getHeight()) {
logger.debug("Images have different size");
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
outputs = new HashMap<String, T2Reference>();
T2Reference aggregatedRef = referenceService.register(false, 0, true, context);
outputs.put(OUT, aggregatedRef);
} else {
EqualQa equalQa = new EqualQa();
TransientOperation<Boolean, Boolean> op = equalQa.evaluate(images[0], images[1]);
outputs = registerOutputs(callback, op);
}
// Return results
callback.receiveResult(outputs, new int[0]);
}
});
}
示例9: registerOutputs
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
/**
* Registers the outputs.
*
* @param callback callback of the activity
* @param op results
* @return a map of output port names and output references
*/
protected Map<String, T2Reference> registerOutputs(final AsynchronousActivityCallback callback,
final TransientOperation<Float, StaticColor> op, final String aggregatedName, final String channelsName,
final String channelNamesName) {
logger.debug("Registering outputs");
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
Map<String, T2Reference> outputs = new HashMap<String, T2Reference>();
// Aggregated result
Float aggregatedResult = op.getAggregatedResult();
T2Reference aggregatedRef = referenceService.register(aggregatedResult.toString(), 0, true, context);
outputs.put(aggregatedName, aggregatedRef);
// Channels
StaticColor result = op.getResult();
float[] resultValues = result.getChannelValues();
T2Reference channelsRef = referenceService.register(resultValues, 1, true, context);
outputs.put(channelsName, channelsRef);
String[] resultDescriptions = result.getChannelDescription();
T2Reference channelDescriptionRef = referenceService.register(resultDescriptions, 1, true, context);
outputs.put(channelNamesName, channelDescriptionRef);
return outputs;
}
示例10: executeQa
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
/**
* Executes the provided QA on the provided images and registeres the results in the callback.
*
* @param qa the QA to execute
* @param image1 the left image to process
* @param image2 the right image to process
* @param callback the callback to use
*/
protected void executeQa(final Qa<Float, StaticColor> qa, final BufferedImage image1, final BufferedImage image2, final AsynchronousActivityCallback callback) {
try {
// Evaluate
TransientOperation<Float, StaticColor> op = qa.evaluate(image1, image2);
Map<String, T2Reference> outputs = registerOutputs(callback, op, outAggregated, outChannels,
outChannelNames);
// Return results
callback.receiveResult(outputs, new int[0]);
} catch (PreprocessingException e) {
logger.info("Image size does not match");
callback.fail("Image size does not match");
}
}
示例11: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
// Don't execute service directly now, request to be run ask to be run
// from thread pool and return asynchronously
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
// Resolve inputs
String fits1 = (String) referenceService.renderIdentifier(inputs.get(IN_FITS_1), String.class, context);
String fits2 = (String) referenceService.renderIdentifier(inputs.get(IN_FITS_2), String.class, context);
if (logger.isInfoEnabled()) {
logger.info("Image paths: " + fits1 + ", " + fits2);
}
// Evaluate FITS
JavaFITSEvaluator evaluator = new JavaFITSEvaluator();
HashMap<MeasurementInfoUri, Value> results = new HashMap<MeasurementInfoUri, Value>();
try {
results = evaluator.evaluate(fits1, fits2, measurementInfoUris);
} catch (EvaluatorException e) {
logger.error("Error evaluating " + IN_FITS_2 + " and " + IN_FITS_2, e);
callback
.fail("JavaImageEvalutatorActivity: Error evaluating " + IN_FITS_2 + " and " + IN_FITS_2, e);
return;
}
// Register outputs
Map<String, T2Reference> outputs = registerOutputs(callback, results);
// Return map of output data, with empty index array as this is
// the only and final result (this index parameter is used if
// pipelining output)
callback.receiveResult(outputs, new int[0]);
}
});
}
示例12: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
// Don't execute service directly now, request to be run ask to be run
// from thread pool and return asynchronously
callback.requestRun(new Runnable() {
public void run() {
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
// Resolve inputs
String firstInput = (String) referenceService.renderIdentifier(inputs.get(IN_FIRST_INPUT),
String.class, context);
// Support our configuration-dependendent input
boolean optionalPorts = configBean.getExampleString().equals("specialCase");
List<byte[]> special = null;
// We'll also allow IN_EXTRA_DATA to be optionally not provided
if (optionalPorts && inputs.containsKey(IN_EXTRA_DATA)) {
// Resolve as a list of byte[]
special = (List<byte[]>) referenceService.renderIdentifier(inputs.get(IN_EXTRA_DATA), byte[].class,
context);
}
// TODO: Do the actual service invocation
// try {
// results = this.service.invoke(firstInput, special)
// } catch (ServiceException ex) {
// callback.fail("Could not invoke RAWverna service " +
// configBean.getExampleUri(),
// ex);
// // Make sure we don't call callback.receiveResult later
// return;
// }
// Register outputs
Map<String, T2Reference> outputs = new HashMap<String, T2Reference>();
String simpleValue = "simple";
T2Reference simpleRef = referenceService.register(simpleValue, 0, true, context);
outputs.put(OUT_SIMPLE_OUTPUT, simpleRef);
// For list outputs, only need to register the top level list
List<String> moreValues = new ArrayList<String>();
moreValues.add("Value 1");
moreValues.add("Value 2");
T2Reference moreRef = referenceService.register(moreValues, 1, true, context);
outputs.put(OUT_MORE_OUTPUTS, moreRef);
if (optionalPorts) {
// Populate our optional output port
// NOTE: Need to return output values for all defined output
// ports
String report = "Everything OK";
outputs.put(OUT_REPORT, referenceService.register(report, 0, true, context));
}
// return map of output data, with empty index array as this is
// the only and final result (this index parameter is used if
// pipelining output)
callback.receiveResult(outputs, new int[0]);
}
});
}
示例13: executeAsynch
import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; //导入依赖的package包/类
@Override
public void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback) {
// Don't execute service directly now, request to be run
// from thread pool and return asynchronously
callback.requestRun(new Runnable() {
public void run() {
logger.info("Activity started");
// Get context and reference service
InvocationContext context = callback.getContext();
ReferenceService referenceService = context.getReferenceService();
// Wrap image 1
logger.info("Loading image on port " + IN_IMAGE_1);
BufferedImage image1 = wrapInputImage(callback, inputs.get(IN_IMAGE_1));
if (null == image1) {
callback.fail("JavaImageEvalutatorActivity: 2 Could not read image on port " + IN_IMAGE_1);
logger.error("Could not read image on port " + IN_IMAGE_1);
return;
}
// Wrap image 2
logger.info("Loading image on port " + IN_IMAGE_2);
BufferedImage image2 = wrapInputImage(callback, inputs.get(IN_IMAGE_2));
if (null == image2) {
callback.fail("JavaImageEvalutatorActivity: 2 Could not read image on port " + IN_IMAGE_2);
logger.error("Could not read image on port " + IN_IMAGE_2);
return;
}
// Evaluate Images
JavaImageComparisonEvaluator evaluator = new JavaImageComparisonEvaluator();
HashMap<MeasurementInfoUri, Value> results = new HashMap<MeasurementInfoUri, Value>();
try {
logger.info("Evaluating images");
results = evaluator.evaluate(image1, image2, measurementInfoUris);
} catch (EvaluatorException e) {
logger.error("Error evaluating " + IN_IMAGE_1 + " and " + IN_IMAGE_2, e);
callback.fail("JavaImageEvalutatorActivity: Error evaluating " + IN_IMAGE_1 + " and " + IN_IMAGE_2,
e);
return;
}
// Register outputs
Map<String, T2Reference> outputs = registerOutputs(callback, results);
// Return map of output data, with empty index array as this is
// the only and final result (this index parameter is used if
// pipelining output)
callback.receiveResult(outputs, new int[0]);
}
});
}