예제 #1
0
  public WorkflowExecutionWizard(
      final IFile workflowFile, WorkflowDescription workflowDescription) {
    serviceRegistryAccess = ServiceRegistry.createPublisherAccessFor(this);
    workflowExecutionService = serviceRegistryAccess.getService(WorkflowExecutionService.class);
    Activator.getInstance().registerUndisposedWorkflowShutdownListener();

    this.inputTabEnabled =
        serviceRegistryAccess
            .getService(ConfigurationService.class)
            .getConfigurationSegment("general")
            .getBoolean(ComponentConstants.CONFIG_KEY_ENABLE_INPUT_TAB, false);

    this.wfFile = workflowFile;

    this.disabledWorkflowNodes =
        WorkflowExecutionUtils.getDisabledWorkflowNodes(workflowDescription);
    this.disabledConnections =
        workflowDescription.removeWorkflowNodesAndRelatedConnections(disabledWorkflowNodes);
    this.wfDescription = workflowDescription;

    nodeIdConfigHelper = new NodeIdentifierConfigurationHelper();
    // cache the local instance for later use
    this.localNodeId = serviceRegistryAccess.getService(PlatformService.class).getLocalNodeId();

    wfDescription.setName(
        WorkflowExecutionUtils.generateDefaultNameforExecutingWorkflow(
            workflowFile.getName(), wfDescription));
    wfDescription.setFileName(workflowFile.getName());

    // set the title of the wizard dialog
    setWindowTitle(Messages.workflowExecutionWizardTitle);
    // display a progress monitor
    setNeedsProgressMonitor(true);

    ColorPalette.getInstance().loadColors();
    serviceRegistryAccess.registerService(DistributedComponentKnowledgeListener.class, this);
  }
예제 #2
0
  @Override
  public boolean performFinish() {

    grabDataFromWorkflowPage();

    if (!performValidations()) {
      return false;
    }

    if (!validateWorkflowAndPlaceholders() && !requestConfirmationForValidationErrorsWarnings()) {
      // keeps the execute dialog open
      return false;
    }

    WorkflowExecutionUtils.setNodeIdentifiersToTransientInCaseOfLocalOnes(
        wfDescription, localNodeId);
    saveWorkflow();

    grabDataFromPlaceholdersPage();

    Job job =
        new Job(Messages.workflowExecutionWizardTitle) {

          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              monitor.beginTask(Messages.settingUpWorkflow, 2);
              monitor.worked(1);
              executeWorkflowInBackground();
              monitor.worked(1);
              return Status.OK_STATUS;
            } finally {
              monitor.done();
            }
          };
        };
    job.setUser(true);
    job.schedule();

    return true;
  }
예제 #3
0
  private void executeWorkflowInBackground() {

    DistributedComponentKnowledge compKnowledge =
        serviceRegistryAccess
            .getService(DistributedComponentKnowledgeService.class)
            .getCurrentComponentKnowledge();

    try {
      WorkflowExecutionUtils.replaceNullNodeIdentifiersWithActualNodeIdentifier(
          wfDescription, localNodeId, compKnowledge);
    } catch (WorkflowExecutionException e) {
      handleWorkflowExecutionError(e);
      return;
    }

    String name = wfDescription.getName();
    if (name == null) {
      name = Messages.bind(Messages.defaultWorkflowName, wfFile.getName().toString());
    }

    WorkflowExecutionContextBuilder wfExeCtxBuilder =
        new WorkflowExecutionContextBuilder(wfDescription);
    wfExeCtxBuilder.setInstanceName(name);
    wfExeCtxBuilder.setNodeIdentifierStartedExecution(localNodeId);
    if (wfDescription.getAdditionalInformation() != null
        && !wfDescription.getAdditionalInformation().isEmpty()) {
      wfExeCtxBuilder.setAdditionalInformationProvidedAtStart(
          wfDescription.getAdditionalInformation());
    }
    WorkflowExecutionContext wfExecutionContext = wfExeCtxBuilder.build();

    final WorkflowExecutionInformation wfExeInfo;
    try {
      wfExeInfo = workflowExecutionService.executeWorkflowAsync(wfExecutionContext);
    } catch (WorkflowExecutionException | RemoteOperationException e) {
      handleWorkflowExecutionError(e);
      return;
    }

    // before starting the workflow, ensure that the console model is initialized
    // so that no console output gets lost; this is lazily initialized here
    // so the application startup is not slowed down
    try {
      serviceRegistryAccess
          .getService(ConsoleRowModelService.class)
          .ensureConsoleCaptureIsInitialized();
    } catch (InterruptedException e) {
      LOG.error(
          "Failed initialize workflow console capturing for workflow: " + wfDescription.getName(),
          e);
    }

    if (inputTabEnabled) {
      InputModel.ensureInputCaptureIsInitialized();
    }

    WorkflowExecutionUtils.removeDisabledWorkflowNodesWithoutNotify(
        wfExeInfo.getWorkflowDescription());
    Display.getDefault()
        .asyncExec(
            new Runnable() {

              @Override
              public void run() {
                new OpenReadOnlyWorkflowRunEditorAction(wfExeInfo).run();
              }
            });
  }