Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
issue #597
  • Loading branch information
rsoika committed Sep 4, 2024
1 parent 05105b8 commit 0c6fe51
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -47,7 +45,6 @@
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.bpmn.BPMNUtil;
import org.imixs.workflow.engine.ModelService;
import org.imixs.workflow.engine.SetupService;
import org.imixs.workflow.engine.WorkflowService;
import org.imixs.workflow.exceptions.AccessDeniedException;
import org.imixs.workflow.exceptions.ModelException;
Expand Down Expand Up @@ -91,11 +88,6 @@ public class ModelController implements Serializable {
@EJB
protected WorkflowService workflowService;

@EJB
protected SetupService setupService;

private Map<String, ItemCollection> modelEntityCache = new HashMap<String, ItemCollection>();

private static Logger logger = Logger.getLogger(ModelController.class.getName());

/**
Expand Down Expand Up @@ -128,8 +120,9 @@ public List<String> getGroups(String version) {
* The worflowGroup list is used to assign a workflow Group to a core process.
*
* @return list of workflow groups
* @throws ModelException
*/
public List<String> getWorkflowGroups() {
public List<String> getWorkflowGroups() throws ModelException {
List<String> result = new ArrayList<>();
for (BPMNModel model : modelService.getModelManager().getAllModels()) {
String version = BPMNUtil.getVersion(model);
Expand All @@ -155,8 +148,9 @@ public List<String> getWorkflowGroups() {
*
* @param group
* @return
* @throws ModelException
*/
public String getVersionByGroup(String group) {
public String getVersionByGroup(String group) throws ModelException {
return modelService.getModelManager().findVersionByGroup(group);
}

Expand Down Expand Up @@ -188,20 +182,22 @@ public List<ItemCollection> findAllStartTasksByGroup(String version, String grou
try {
BPMNModel model = modelService.getModelManager().getModel(version);
return modelService.getModelManager().findStartTasks(model, group);
} catch (ModelException | BPMNModelException e) {
logger.severe("Failed to find Start Tasks for '" + group + "' : " + e.getMessage());
} catch (ModelException e) {
logger.severe(
"Failed to find start tasks for workflow group '" + group + "' : " + e.getMessage());
}

return result;
}

/**
* returns all model versions. Used by the Model View
* Returns a sorted set of all model versions.
* <p>
* Used by the Model View.
*
* @return
*/
public List<String> getVersions() {
return modelService.getModelManager().getVersions();
public Set<String> getVersions() {
return modelService.getModelEntityStore().keySet();
}

/**
Expand Down Expand Up @@ -242,7 +238,6 @@ public void doUploadModel(ActionEvent event)
BPMNModel model;
try {
model = BPMNModelFactory.read(inputStream);

modelService.saveModel(model);
continue;
} catch (BPMNModelException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,20 @@ public void lookupWorkflowGroups() {
if (version.startsWith("system-")) {
continue;
}
Set<String> groups = modelService.getModelManager().findAllGroupsByModel(model);
for (String groupName : groups) {
if (workflowGroups.contains(groupName))
continue;
if (groupName.contains("~"))
continue;
workflowGroups.add(groupName);
Set<String> groups;
try {
groups = modelService.getModelManager().findAllGroupsByModel(model);
for (String groupName : groups) {
if (workflowGroups.contains(groupName))
continue;
if (groupName.contains("~"))
continue;
workflowGroups.add(groupName);
}
} catch (ModelException e) {
logger.warning("Invalid Model Object found - version=" + version);
}

}
Collections.sort(workflowGroups);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.imixs.workflow.engine.ModelService;
import org.imixs.workflow.engine.index.SchemaService;
import org.imixs.workflow.exceptions.InvalidAccessException;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.faces.data.ViewController;
import org.imixs.workflow.faces.util.LoginController;
Expand Down Expand Up @@ -197,9 +198,12 @@ public void init() {
} catch (NumberFormatException nfe) {
// try to find the task based on the name of the given task....

String version = modelService.getModelManager().findVersionByGroup(workflowgroup);
// BPMNModel model=modelService.getModelManager().
// modelService.getModelManager().task
try {
String version = modelService.getModelManager().findVersionByGroup(workflowgroup);
} catch (ModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// Model model = modelController.getModelByGroup(workflowgroup);
List<ItemCollection> tasks = modelController.findAllTasksByGroup(workflowgroup); // model.findTasksByGroup(workflowgroup);
Expand Down

0 comments on commit 0c6fe51

Please sign in to comment.