-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'v1.7.0' of http://10.73.97.24/oecloud.io/oe-workflow into …
…release PI 12 Release
- Loading branch information
Showing
4 changed files
with
59 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |