예제 #1
0
  public EndpointResponse removeWorkflowClass(RemoveWorkflowClassRequest request) {
    try {
      workflowClassDao.remove(request.getWorkflowClassId());
      return EndpointHelper.createResponse(EndpointResponse.class, request);

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(EndpointResponse.class, request, e);
    }
  }
예제 #2
0
  public CreateWorkflowClassResponse createWorkflowClass(CreateWorkflowClassRequest request) {
    try {
      CreateWorkflowClassResponse response =
          EndpointHelper.createResponse(CreateWorkflowClassResponse.class, request);
      response.setWorkflowClass(workflowClassDao.add(request.getWorkflowClass()));
      return response;

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(CreateWorkflowClassResponse.class, request, e);
    }
  }
예제 #3
0
  public ListWorkflowClassesResponse listWorkflowClasses(ListWorkflowClassesRequest request) {
    try {
      ListWorkflowClassesResponse r =
          EndpointHelper.createResponse(ListWorkflowClassesResponse.class, request);
      r.setWorkflowClasses(workflowClassDao.findAll()); // todo more criteria
      return r;

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(ListWorkflowsResponse.class, request, e);
    }
  }
예제 #4
0
  public FindWorkflowClassResponse findWorkflowClass(FindWorkflowClassRequest request) {
    try {
      FindWorkflowClassResponse r =
          EndpointHelper.createResponse(FindWorkflowClassResponse.class, request);
      r.setWorkflowClass(workflowClassDao.get(request.getWorkflowClassId()));
      return r;

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(FindWorkflowClassResponse.class, request, e);
    }
  }
예제 #5
0
  public StartWorkflowResponse startWorkflow(StartWorkflowRequest request) {

    String workflowClassId = workflowClassDao.findByName(request.getWorkflowClass()).get_id();

    Workflow wf = workflowEngine.createNewWorkflow(workflowClassId, request.getAttributes());

    Event e = new Event();
    e.setEventType(WorkflowEventType.INITIATE_WORKFLOW);
    e.setWorkflowId(wf.get_id());
    e.setAttributes(request.getAttributes()); // todo should the attributes be in event as well?
    workflowEngine.submitEvent(e);
    log.info("New workflow initiated: " + wf);
    StartWorkflowResponse response = new StartWorkflowResponse();
    response.setWorkflowId(wf.get_id());
    response.setStatus(EndpointResponseStatus.OK);
    return response;
  }