diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java index 6a6b0ded1..cecbbdbfd 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java @@ -911,6 +911,9 @@ private ItemCollection lookupDefinition(final BPMNModel model) { * @return */ private Activity lookupTaskElementByID(final BPMNModel model, int taskID) { + if (model == null) { + return null; + } Set activities = model.findAllActivities(); // filter the imixs activity with the corresponding id for (Activity activity : activities) { diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/bpmn/BPMNUtil.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/bpmn/BPMNUtil.java index 97e0155ac..4eb99dcca 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/bpmn/BPMNUtil.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/bpmn/BPMNUtil.java @@ -121,10 +121,12 @@ private BPMNUtil() { * @return */ public static String getVersion(BPMNModel model) { - List valueList = getItemValueList(model, model.getDefinitions(), "txtworkflowmodelversion", - null); - if (valueList != null && valueList.size() > 0) { - return valueList.get(0); + if (model != null) { + List valueList = getItemValueList(model, model.getDefinitions(), "txtworkflowmodelversion", + null); + if (valueList != null && valueList.size() > 0) { + return valueList.get(0); + } } return null; } diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/WorkflowScheduler.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/WorkflowScheduler.java index 42d002572..9e91eded1 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/WorkflowScheduler.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/WorkflowScheduler.java @@ -373,22 +373,22 @@ public ItemCollection run(ItemCollection configItemCollection) throws SchedulerE // processWorkListByEvent(version, taskID, EventID, Group) BPMNModel model = modelService.getModelManager().getModel(version); - - // find all tasks - Set activities = model.findAllActivities(); - for (Activity task : activities) { - if (BPMNUtil.isImixsTaskElement(task)) { - - ItemCollection taskEntity = BPMNEntityBuilder.build(task); - int taskID = taskEntity.getItemValueInteger(BPMNUtil.TASK_ITEM_TASKID); - // iterate through all scheduled events - List events = modelService.getModelManager().findEventsByTask(model, - taskID); - for (ItemCollection eventEntity : events) { - // test if this is a scheduled event... - if (eventEntity.getItemValueBoolean(BPMNUtil.EVENT_ITEM_TIMER_ACTIVE)) { - // eventID = eventEntity.getItemValueInteger(BPMNUtil.EVENT_ITEM_EVENTID); - processWorkListByEvent(model, taskEntity, eventEntity, configItemCollection); + if (model != null) { + // find all tasks + Set activities = model.findAllActivities(); + for (Activity task : activities) { + if (BPMNUtil.isImixsTaskElement(task)) { + ItemCollection taskEntity = BPMNEntityBuilder.build(task); + int taskID = taskEntity.getItemValueInteger(BPMNUtil.TASK_ITEM_TASKID); + // iterate through all scheduled events + List events = modelService.getModelManager().findEventsByTask(model, + taskID); + for (ItemCollection eventEntity : events) { + // test if this is a scheduled event... + if (eventEntity.getItemValueBoolean(BPMNUtil.EVENT_ITEM_TIMER_ACTIVE)) { + // eventID = eventEntity.getItemValueInteger(BPMNUtil.EVENT_ITEM_EVENTID); + processWorkListByEvent(model, taskEntity, eventEntity, configItemCollection); + } } } } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java index 58720a08d..52b140944 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java @@ -180,7 +180,7 @@ public String getModelXML() { StringBuffer sb = new StringBuffer(); sb.append(""); try { - col = modelService.getVersions(); + col = modelService.getModelManager().getVersions(); for (String aversion : col) { sb.append("" + aversion + ""); @@ -200,7 +200,7 @@ public Response findAllTasks(@PathParam("version") String version, @QueryParam(" try { BPMNModel model; - model = modelService.getModel(version); + model = modelService.getModelManager().getModel(version); // find all tasks Set activities = model.findAllActivities(); @@ -229,7 +229,7 @@ public Response findAllTasks(@PathParam("version") String version, @QueryParam(" public Response getModelFile(@PathParam("version") String version, @Context UriInfo uriInfo) { try { // lookup model - BPMNModel model = modelService.getModel(version); + BPMNModel model = modelService.getModelManager().getModel(version); if (model != null) { StreamingOutput stream = output -> { try { @@ -328,7 +328,7 @@ public Response findTasksByGroup(@PathParam("version") String version, @PathPara @QueryParam("items") String items, @QueryParam("format") String format) { List result = new ArrayList<>(); try { - BPMNModel model = modelService.getModel(version); + BPMNModel model = modelService.getModelManager().getModel(version); BPMNProcess process = model.findProcessByName(group); process.init(); Set tasks = process.getActivities(); @@ -442,7 +442,7 @@ public void putModelByVersion(@PathParam("version") final String _modelVersion, // delete old model if a modelversion is available if (!"".equals(sModelVersion)) - modelService.removeModel(sModelVersion); + modelService.getModelManager().removeModel(sModelVersion); // save new entities into database and update modelversion..... for (int i = 0; i < ecol.getDocument().length; i++) { @@ -515,7 +515,7 @@ public void postModel(XMLDataCollection ecol) { * @throws ModelException */ private String modelVersionTableToString(String rootContext) throws ModelException { - List modelVersionList = modelService.getVersions(); + List modelVersionList = modelService.getModelManager().getVersions(); StringBuffer buffer = new StringBuffer(); for (String modelVersion : modelVersionList) {