Search in sources :

Example 16 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class XQueryBaseComponent method validateAction.

@Override
protected boolean validateAction() {
    boolean result = false;
    IActionDefinition actionDefinition = getActionDefinition();
    if (actionDefinition instanceof XQueryAction) {
        XQueryAction xQueryAction = (XQueryAction) actionDefinition;
        if ((xQueryAction.getSourceXml() == ActionInputConstant.NULL_INPUT) && (xQueryAction.getXmlDocument() == null)) {
            error(Messages.getInstance().getString("XQueryBaseComponent.ERROR_0008_SOURCE_NOT_DEFINED", // $NON-NLS-1$
            getActionName()));
        } else if (xQueryAction.getQuery() == ActionInputConstant.NULL_INPUT) {
            error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", // $NON-NLS-1$
            getActionName()));
        } else if ((xQueryAction.getOutputPreparedStatement() == null) && (xQueryAction.getOutputResultSet() == null)) {
            error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", // $NON-NLS-1$
            getActionName()));
        } else {
            result = true;
        }
    } else if (actionDefinition instanceof XQueryConnectionAction) {
        XQueryConnectionAction xQueryConnectionAction = (XQueryConnectionAction) actionDefinition;
        if (xQueryConnectionAction.getOutputConnection() == null) {
            error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", // $NON-NLS-1$
            getActionName()));
        } else {
            result = true;
        }
    } else {
        error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
        actionDefinition.getElement().asXML()));
    }
    return result;
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) XQueryConnectionAction(org.pentaho.actionsequence.dom.actions.XQueryConnectionAction) XQueryAction(org.pentaho.actionsequence.dom.actions.XQueryAction)

Example 17 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class UtilityComponent method validateAction.

@Override
protected boolean validateAction() {
    boolean result = true;
    IActionDefinition actionDefinition = getActionDefinition();
    if (actionDefinition instanceof CopyParamAction) {
        result = validateCopyAction((CopyParamAction) actionDefinition);
    } else if (actionDefinition instanceof FormatMsgAction) {
        result = validateFormatAction((FormatMsgAction) actionDefinition);
    } else if (actionDefinition instanceof PrintMapValsAction) {
        result = validateGetMapValuesAction((PrintMapValsAction) actionDefinition);
    } else if (actionDefinition instanceof PrintParamAction) {
        result = validatePrintParamAction((PrintParamAction) actionDefinition);
    } else {
        // This component allows multiple actions to be defined in a single action definition.
        // While this is no longer supported by the design studio, it needs to be supported here
        // for backwards compatibility with older action sequence documents.
        result = validateAction(actionDefinition);
    }
    return result;
}
Also used : PrintMapValsAction(org.pentaho.actionsequence.dom.actions.PrintMapValsAction) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) PrintParamAction(org.pentaho.actionsequence.dom.actions.PrintParamAction) FormatMsgAction(org.pentaho.actionsequence.dom.actions.FormatMsgAction) CopyParamAction(org.pentaho.actionsequence.dom.actions.CopyParamAction)

Example 18 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class ActionExecutionExceptionTest method testCustomizedConstructors.

@Test
public void testCustomizedConstructors() {
    IActionDefinition actionDef = Mockito.mock(IActionDefinition.class);
    try {
        Constructor<ActionExecutionException> constructor = ActionExecutionException.class.getDeclaredConstructor(String.class, Throwable.class, String.class, String.class, String.class, IActionDefinition.class);
        constructor.setAccessible(true);
        constructor.newInstance("msg", new Exception("cause"), "sessionName", "instanceId", "actionSequenceName", actionDef);
    } catch (Exception e) {
        fail(ActionExecutionException.class.getSimpleName() + " Does not have a constructor with String, Throwable, String, String, String, IActionDefinition ");
    }
    try {
        Constructor<ActionExecutionException> constructor = ActionExecutionException.class.getDeclaredConstructor(String.class, String.class, String.class, String.class, IActionDefinition.class);
        constructor.setAccessible(true);
        constructor.newInstance("msg", "sessionName", "instanceId", "actionSequenceName", actionDef);
    } catch (Exception e) {
        fail(ActionExecutionException.class.getSimpleName() + " Does not have a constructor with String, String, String, String, IActionDefinition ");
    }
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) Test(org.junit.Test)

Example 19 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class UnresolvedParameterExceptionTest method testUnresolvedParameterExceptionStringThrowableStringStringStringIActionDefinition.

@Test
public void testUnresolvedParameterExceptionStringThrowableStringStringStringIActionDefinition() {
    IActionDefinition actionDef = Mockito.mock(IActionDefinition.class);
    try {
        Constructor<UnresolvedParameterException> constructor = UnresolvedParameterException.class.getDeclaredConstructor(String.class, String.class, String.class, String.class, IActionDefinition.class);
        constructor.setAccessible(true);
        constructor.newInstance("msg", "sessionName", "instanceId", "actionSequenceName", actionDef);
    } catch (Exception e) {
        fail(UnresolvedParameterException.class.getSimpleName() + " Does not have a constructor with String, String, String, String, IActionDefinition ");
    }
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) Test(org.junit.Test)

Aggregations

IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)19 Test (org.junit.Test)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 List (java.util.List)3 IActionInput (org.pentaho.actionsequence.dom.IActionInput)3 AbstractRelationalDbAction (org.pentaho.actionsequence.dom.actions.AbstractRelationalDbAction)3 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)3 ArrayList (java.util.ArrayList)2 IActionIfStatement (org.pentaho.actionsequence.dom.IActionIfStatement)2 IActionLoop (org.pentaho.actionsequence.dom.IActionLoop)2 CopyParamAction (org.pentaho.actionsequence.dom.actions.CopyParamAction)2 FormatMsgAction (org.pentaho.actionsequence.dom.actions.FormatMsgAction)2 PrintMapValsAction (org.pentaho.actionsequence.dom.actions.PrintMapValsAction)2 PrintParamAction (org.pentaho.actionsequence.dom.actions.PrintParamAction)2 SqlConnectionAction (org.pentaho.actionsequence.dom.actions.SqlConnectionAction)2 XQueryAction (org.pentaho.actionsequence.dom.actions.XQueryAction)2 XQueryConnectionAction (org.pentaho.actionsequence.dom.actions.XQueryConnectionAction)2