MCPcopy Index your code
hub / github.com/totaljs/framework / controller_json_workflow

Function controller_json_workflow

index.js:19391–19456  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

19389
19390// Default action for workflow routing
19391function controller_json_workflow(id) {
19392 var self = this;
19393 var w = self.route.workflow;
19394
19395 self.id = self.route.paramidindex === -1 ? id : self.req.split[self.route.paramidindex];
19396
19397 CONF.logger && (self.req.$logger = []);
19398
19399 if (w instanceof Object) {
19400
19401 if (!w.type) {
19402
19403 // IS IT AN OPERATION?
19404 if (!self.route.schema.length) {
19405 OPERATION(w.id, self.body, w.view ? self.callback(w.view) : self.callback(), self);
19406 return;
19407 }
19408
19409 var schema = self.route.isDYNAMICSCHEMA ? framework_builders.findschema(self.req.$schemaname || (self.route.schema[0] + '/' + self.params[self.route.schema[1]])) : GETSCHEMA(self.route.schema[0], self.route.schema[1]);
19410 if (!schema) {
19411 var err = 'Schema "{0}" not found.'.format(getSchemaName(self.route.schema, self.route.isDYNAMICSCHEMA ? self.params : null));
19412 if (self.route.isDYNAMICSCHEMA)
19413 self.throw404(err);
19414 else
19415 self.throw500(err);
19416 return;
19417 }
19418
19419 if (schema.meta[w.id] !== undefined) {
19420 w.type = '$' + w.id;
19421 } else if (schema.meta['workflow#' + w.id] !== undefined) {
19422 w.type = '$workflow';
19423 w.name = w.id;
19424 } else if (schema.meta['transform#' + w.id] !== undefined) {
19425 w.type = '$transform';
19426 w.name = w.id;
19427 } else if (schema.meta['operation#' + w.id] !== undefined) {
19428 w.type = '$operation';
19429 w.name = w.id;
19430 } else if (schema.meta['hook#' + w.id] !== undefined) {
19431 w.type = '$hook';
19432 w.name = w.id;
19433 }
19434 }
19435
19436 if (w.name)
19437 self[w.type](w.name, self.callback(w.view));
19438 else {
19439
19440 if (w.type)
19441 self[w.type](self.callback(w.view));
19442 else {
19443 var err = 'Schema "{0}" does not contain "{1}" operation.'.format(schema.name, w.id);
19444 if (self.route.isDYNAMICSCHEMA)
19445 self.throw404(err);
19446 else
19447 self.throw500(err);
19448 }

Callers

nothing calls this directly

Calls 1

getSchemaNameFunction · 0.85

Tested by

no test coverage detected