Skip to content

Commit

Permalink
Merge tag 'v1.7.0' of http://10.73.97.24/oecloud.io/oe-workflow into …
Browse files Browse the repository at this point in the history
…release

PI 12 Release
  • Loading branch information
vamsee committed Jan 14, 2019
2 parents 5216ddb + f287bfe commit 5d62a98
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 93 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oe-workflow",
"version": "1.6.0",
"version": "1.7.0",
"main": "server/server.js",
"scripts": {
"lint": "./node_modules/.bin/eslint .",
Expand Down
46 changes: 0 additions & 46 deletions server/boot/03-01-attach-workflow.js

This file was deleted.

46 changes: 0 additions & 46 deletions server/boot/03-02-attach-workflow.js

This file was deleted.

58 changes: 58 additions & 0 deletions server/boot/03-attach-workflow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
*
* ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
* Bangalore, India. All Rights Reserved.
*
*/
/**
* Boot Script for attaching workflow on boot for version 2
* @author Mandeep Gill(mandeep6ill), Prem Sai(premsai-ch)
*/
var logger = require('oe-logger');
var log = logger('attach-workflow.boot');
var applyMakerCheckerMixin1 = require('../../common/mixins/maker-checker-mixin.js');

var applyMakerCheckerMixin2 = require('../../common/mixins/maker-checker-mixin-v2.js');
var globalMessaging = require('oe-cloud/lib/common/global-messaging');
module.exports = function attachWorkFlows(app) {
var WorkflowMapping = app.models.WorkflowMapping;
var options = {
ctx: {},
ignoreAutoScope: true,
fetchAllScopes: true
};

WorkflowMapping.find({
where: {
'engineType': 'oe-workflow'
}
}, options, function fetchWM(err, result) {
if (err) {
log.error(options, err);
} else {
var WorkflowMaps = result;
WorkflowMaps.forEach(function iterateWM(mapping) {
newMappingHandler(mapping, options);
});
}
});


function newMappingHandler(mapping, options) {
var actualModelName = mapping.actualModelName;
var Model = app.models[actualModelName];
if (mapping.version === 'v1') {
applyMakerCheckerMixin1(Model);
} else {
applyMakerCheckerMixin2(Model);
}
}
function workflowMappingAfterSave(ctx, next) {
let data = ctx.data || ctx.instance;
globalMessaging.publish('workflowMappingAfterSave', {version: data.version, actualModelName: data.actualModelName, modelName: data.modelName}, ctx.options);
next();
}

WorkflowMapping.observe('after save', workflowMappingAfterSave);
globalMessaging.subscribe('workflowMappingAfterSave', newMappingHandler);
};

0 comments on commit 5d62a98

Please sign in to comment.