diff --git a/index.js b/index.js index fa3cc1e..b35115d 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const path = require('path'); const { sleep } = require('./util'); const { getAllWorkflows } = require('./workflow'); +const { getAllProcesses } = require('./process'); require(path.join(process.cwd(),"..","server","dist","database.js")); @@ -10,10 +11,35 @@ require(path.join(process.cwd(),"..","server","dist","database.js")); console.log("initilizing begin.."); - const workflows = await getAllWorkflows(); + const workflows = await getAllWorkflows({ + id:{ + [Op.gt] : 0 + } + }); if(workflows.length==0) throw "There is not any workflow"; - + const allWorkflowInfo = {}; + + workflowsFor: + for await(const workflow of workflows){ + + if(+workflow.id < 0) continue; + + const processes = await getAllProcesses(workflow); + + if(processes.length == 0){ + allWorkflowInfo[workflow.id] = { + isValid:false, + root:{ + valid: 0, + invalid: 0, + subFlowList: [] + }, + subFlow:{} + } + continue workflowsFor; + } + } console.timeEnd("WorkflowTester") console.log("DONE"); diff --git a/process.js b/process.js new file mode 100644 index 0000000..f1bde3f --- /dev/null +++ b/process.js @@ -0,0 +1,25 @@ +const getAllProcesses = async (workflow,query = {}) => { + const processes = await bpmsDB.bpms_process.findAll({ + where: { + workflowId: workflow.id, + subFlowId: null, + ...query + // type:{ + // [Op.in]:[0,1] + // } + }, + order: [ + ['id', 'ASC'] + ], + attributes: [ + "id", "pid", "link", "type", "name", "conditions", "subFlowPid", "subFlowId" + ], + raw: true + }); + return processes; +} + +module.exports = { + getAllProcesses, + +} \ No newline at end of file