/** * Returns the activity with the given ID, or null if not found. */ public Activity findActivity(String activityId) { if (activities == null || activityId == null) { return null; } for (Activity activity : activities) { if (activityId.equals(activity.getId())) { return activity; } } return null; }
/** * Returns the activity with the given ID, or null if not found. */ public Activity findActivity(String activityId) { if (activities == null || activityId == null) { return null; } for (Activity activity : activities) { if (activityId.equals(activity.getId())) { return activity; } } return null; }
workflow.getActivities().stream().map(activity -> activity.getId()).collect(Collectors.toSet());
workflow.getActivities().stream().map(activity -> activity.getId()).collect(Collectors.toSet());
activityIds.add(activity.getId());
public static String getIdText(Object object) { if (object instanceof Activity) { return ((Activity)object).getId(); } else if (object instanceof Transition) { return ((Transition)object).getId(); } else if (object instanceof Variable) { return ((Variable)object).getId(); } else if (object instanceof ExecutableWorkflow) { WorkflowId workflowId = ((ExecutableWorkflow)object).getId(); return workflowId!=null ? workflowId.getInternal() : null; } return null; }
public void parse(Activity activity, Scope parentScope, ScopeImpl parentScopeImpl, WorkflowParser parser) { super.parse(activity, parentScopeImpl, parser); this.id = activity.getId(); this.activity = activity; if (id==null) { parser.addError("Activity has no id"); } else if ("".equals(id)) { parser.addError("Activity has a empty string as id", id); } else if (id.contains(".")) { parser.addError("Activity '%s' has a dot in the id", id); } else if (parser.activityIds.contains(id)) { parser.addError("Duplicate activity id '%s'", id); } else { parser.activityIds.add(id); } ActivityTypeService activityTypeService = parser.getConfiguration(ActivityTypeService.class); this.activityType = activityTypeService.instantiateActivityType(activity); // some activity types need to validate incoming and outgoing transitions, // that's why they are NOT parsed here, but after the transitions. if (this.activityType==null) { parser.addError("Activity '%s' has no activityType configured", id); } }
public void testWorkflow() { ExecutableWorkflow workflow = new ExecutableWorkflow() .id(new WorkflowId(workflowId())) .name("Software release") .description("Regular software production release process.") .sourceWorkflowId(workflowId()) .variable("v", TextType.INSTANCE) .activity("s", new StartEvent()) .activity("task", new NoneTask()) .transition(new Transition().fromId("s").toId("task")); workflow = serialize(workflow); assertEquals(workflowId(), workflow.getId().getInternal()); assertEquals("Software release", workflow.getName()); assertEquals("Regular software production release process.", workflow.getDescription()); assertEquals(workflowId(), workflow.getSourceWorkflowId()); assertEquals(StartEvent.class, workflow.getActivities().get(0).getClass()); assertEquals("s", workflow.getActivities().get(0).getId()); }
@Test public void testActivity() { Activity activity = new NoneTask() .id("verifyRequirements") .defaultTransitionId("continue") .multiInstance(new MultiInstance() .valuesExpression("reviewers") .variable("reviewer", TextType.INSTANCE)); activity = serializeActivity(activity); assertEquals("verifyRequirements", activity.getId()); assertEquals("continue", activity.getDefaultTransitionId()); assertNotNull(activity.getMultiInstance()); assertEquals("reviewer", activity.getMultiInstance().getVariable().getId()); assertEquals("reviewers", activity.getMultiInstance().getValues().get(0).getExpression()); }