workflow-4-node
Version:
Workflow 4 Node is a .NET Workflow Foundation like framework for Node.js. The goal is to reach feature equivalence and beyond.
45 lines (35 loc) • 1.26 kB
JavaScript
;
let Activity = require("./activity");
let util = require("util");
let errors = require("../common/errors");
function ResumeBookmark() {
Activity.call(this);
this.bookmarkName = "";
this.reason = Activity.states.complete;
this.mustExists = true;
}
ResumeBookmark.validReasons = [Activity.states.complete, Activity.states.fail, Activity.states.cancel];
util.inherits(ResumeBookmark, Activity);
ResumeBookmark.prototype.run = function (callContext, args) {
let bookmarkName = this.bookmarkName;
let reason = this.reason;
if (!bookmarkName) {
callContext.fail(new errors.ValidationError("Bookmark name expected."));
}
if (ResumeBookmark.validReasons.indexOf(reason) === -1) {
callContext.fail(new errors.ValidationError("Reason value '" + reason + "' is not valid."));
}
let result = false;
if (this.mustExists) {
callContext.resumeBookmark(bookmarkName, reason, args);
result = true;
}
else {
if (callContext.executionContext.isBookmarkExists(bookmarkName)) {
callContext.resumeBookmark(bookmarkName, reason, args);
result = true;
}
}
callContext.complete(result);
};
module.exports = ResumeBookmark;