可以利用Bonita的ProcessBuilder来创建一个bar文件,然后发布到数据库中,从而实现不使用BOS来创建工作流。
ProcessBuilder processBuilder = ProcessBuilder.createProcess("Test_Process", "1.0");
processBuilder.addDescription("This is build by program.");
processBuilder.addLabel("Test Process");
// Participant Def
processBuilder.addHuman("Step1Role");
processBuilder.addDescription("Step1Role Desc");
processBuilder.addLabel("Step1Role");
processBuilder.addHuman("Step2Role");
processBuilder.addDescription("Step2Role Desc");
processBuilder.addLabel("Step2Role");
// Activity Def
// Start
processBuilder.addSystemTask("BonitaInit");
processBuilder.addDescription("Start");
processBuilder.addLabel("BonitaInit");
processBuilder.addJoinType(JoinType.AND);
processBuilder.addHumanTask("Step1", "Step1Role");
processBuilder.addDescription("Step1 Desc");
processBuilder.addLabel("Step1");
processBuilder.addJoinType(JoinType.AND);
processBuilder.addHumanTask("Step2", "Step2Role");
processBuilder.addDescription("Step2 Desc");
processBuilder.addLabel("Step2");
processBuilder.addJoinType(JoinType.AND);
// End
processBuilder.addSystemTask("BonitaEnd");
processBuilder.addDescription("End");
processBuilder.addLabel("BonitaEnd");
processBuilder.addJoinType(JoinType.XOR);
// transition Def
processBuilder.addTransition("Start_Step1", "BonitaInit", "Step1");
processBuilder.addDescription("Start to Step1");
processBuilder.addLabel("Start_step1");
processBuilder.addTransition("Step1_Step2", "Step1", "Step2");
processBuilder.addDescription("Step1 to Step2");
processBuilder.addLabel("Step1_Step2");
processBuilder.addTransition("Step2_END", "Step2", "BonitaEnd");
processBuilder.addDescription("Step2 to End");
processBuilder.addLabel("Step2_END");
ProcessDefinition processDef = processBuilder.done();
try {
File filebar = new File("E:/bonita/bonita_application/Test_Process.bar");
filebar.createNewFile();
BusinessArchive bar = BusinessArchiveFactory.getBusinessArchive(processDef);
BusinessArchiveFactory.generateBusinessArchiveFile(filebar, bar);
bar = BusinessArchiveFactory.getBusinessArchive(filebar);
AccessorUtil.getManagementAPI().deleteAllProcesses();
final BusinessArchive businessArchive = BusinessArchiveFactory.getBusinessArchive("E:/bonita /bonita_application/Test_Process.bar");
AccessorUtil.getManagementAPI().deploy(businessArchive);
} catch (IOException e) {
e.printStackTrace();
assertTrue(false);
} catch (ClassNotFoundException e) {
e.printStackTrace();
assertTrue(false);
} catch (BonitaDeployException e) {
e.printStackTrace();
assertTrue(false);
}
但有个问题,就是Bonita的task节点的ID必须遵循Java变量的命名规约。