예제 #1
0
  @SuppressWarnings("rawtypes")
  protected static IRuntimeContext executeInternal(
      RepositoryFile file,
      IParameterProvider requestParams,
      HttpServletRequest httpServletRequest,
      IOutputHandler outputHandler,
      Map<String, IParameterProvider> parameterProviders,
      IPentahoSession userSession,
      boolean forcePrompt,
      List messages)
      throws Exception {
    String processId = XactionUtil.class.getName();
    String instanceId = httpServletRequest.getParameter("instance-id"); // $NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, userSession);
    ISystemSettings systemSettings = PentahoSystem.getSystemSettings();

    if (solutionEngine == null) {
      throw new ObjectFactoryException("No Solution Engine");
    }

    boolean instanceEnds =
        "true"
            .equalsIgnoreCase(
                requestParams.getStringParameter(
                    "instanceends", "true")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String parameterXsl =
        systemSettings.getSystemSetting(
            "default-parameter-xsl", "DefaultParameterForm.xsl"); // $NON-NLS-1$ //$NON-NLS-2$

    solutionEngine.setLoggingLevel(2);
    solutionEngine.init(userSession);
    solutionEngine.setForcePrompt(forcePrompt);
    if (parameterXsl != null) {
      solutionEngine.setParameterXsl(parameterXsl);
    }
    return solutionEngine.execute(
        file.getPath(),
        processId,
        false,
        instanceEnds,
        instanceId,
        false,
        parameterProviders,
        outputHandler,
        null,
        urlFactory,
        messages);
  }
  public IRuntimeContext handleActionRequest(final int timeout, final int timeoutType) {

    // Get the solution engine
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setCreateFeedbackParameterCallback(createFeedbackParameterCallback);
    if (solutionEngine == null) {
      Logger.error(
          this,
          Messages.getInstance()
              .getErrorString("BaseRequestHandler.ERROR_0001_NO_SOLUTION_ENGINE")); // $NON-NLS-1$
      return null;
    }
    solutionEngine.setLoggingLevel(ILogger.DEBUG);
    solutionEngine.init(session);
    solutionEngine.setForcePrompt(forcePrompt);
    if (parameterXsl != null) {
      solutionEngine.setParameterXsl(parameterXsl);
    }

    dispose();
    runtime =
        solutionEngine.execute(
            actionPath,
            processId,
            false,
            instanceEnds,
            instanceId,
            true,
            parameterProviders,
            outputHandler,
            this,
            urlFactory,
            messages);

    // need to wait until this is complete
    // TODO

    // if this times out check the timeoutType before cancelling or
    // returning and leaving the component running

    return runtime;
  }
  protected IPentahoResultSet getActionData() {
    // create an instance of the solution engine to execute the specified
    // action

    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, getSession());
    solutionEngine.setLoggingLevel(ILogger.DEBUG);
    solutionEngine.init(getSession());

    HashMap parameterProviders = getParameterProviders();

    OutputStream outputStream = null;
    SimpleOutputHandler outputHandler = null;
    outputHandler = new SimpleOutputHandler(outputStream, false);

    ArrayList messages = new ArrayList();
    String processId = this.getClass().getName();

    String actionSeqPath = ActionInfo.buildSolutionPath(solution, actionPath, actionName);

    context =
        solutionEngine.execute(
            actionSeqPath,
            processId,
            false,
            true,
            instanceId,
            false,
            parameterProviders,
            outputHandler,
            null,
            urlFactory,
            messages);

    if (actionOutput != null) {
      if (context.getOutputNames().contains(actionOutput)) {
        IActionParameter output = context.getOutputParameter(actionOutput);
        IPentahoResultSet results = output.getValueAsResultSet();
        if (results != null) {
          results = results.memoryCopy();
        }
        return results;
      } else {
        // this is an error
        return null;
      }
    } else {
      // return the first list that we find...
      Iterator it = context.getOutputNames().iterator();
      while (it.hasNext()) {
        IActionParameter output = (IActionParameter) it.next();
        if (output.getType().equalsIgnoreCase(IActionParameter.TYPE_RESULT_SET)) {
          IPentahoResultSet results = output.getValueAsResultSet();
          if (results != null) {
            results = results.memoryCopy();
          }
          return results;
        }
      }
    }
    return null;
  }
  /**
   * Gets a IPentahoResultSet from the action output
   *
   * @return IPentahoResultSet
   */
  public IPentahoResultSet getActionData() {
    // create an instance of the solution engine to execute the specified
    // action

    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, getSession());
    solutionEngine.setLoggingLevel(ILogger.DEBUG);
    solutionEngine.init(getSession());

    HashMap parameterProviders = getParameterProviders();

    OutputStream outputStream = null;
    SimpleOutputHandler outputHandler = null;
    outputHandler = new SimpleOutputHandler(outputStream, false);

    ArrayList messages = new ArrayList();
    String processId = this.getClass().getName();
    context =
        solutionEngine.execute(
            actionPath,
            processId,
            false,
            true,
            instanceId,
            false, //$NON-NLS-1$ //$NON-NLS-2$
            parameterProviders,
            outputHandler,
            null,
            urlFactory,
            messages);

    if (context == null) {
      // this went badly wrong
      return null;
    }

    if (actionOutput != null) {
      if (context.getOutputNames().contains(actionOutput)) {
        IActionParameter output = context.getOutputParameter(actionOutput);
        IPentahoResultSet results = output.getValueAsResultSet();
        if (results != null) {
          results = results.memoryCopy();
        }
        return results;
      } else {
        // this is an error
        return null;
      }
    } else {
      for (Object objAp : context.getOutputNames()) {
        IActionParameter output = (IActionParameter) objAp;
        if (output.getType().equalsIgnoreCase(IActionParameter.TYPE_RESULT_SET)) {
          IPentahoResultSet results = output.getValueAsResultSet();
          if (results != null) {
            results = results.memoryCopy();
          }
          return results;
        }
      }
    }
    return null;
  }