Search in sources :

Example 1 with ActionSequenceParameterMgr

use of org.pentaho.platform.engine.services.actionsequence.ActionSequenceParameterMgr in project pentaho-platform by pentaho.

the class SQLDdlComponent method getActionDefinition.

@Override
public IActionDefinition getActionDefinition() {
    IActionDefinition generic = super.getActionDefinition();
    ActionSequenceParameterMgr paramMgr = new ActionSequenceParameterMgr(getRuntimeContext(), getSession());
    SqlDataAction action = new SqlDataAction(generic.getElement(), paramMgr);
    return action;
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) SqlDataAction(org.pentaho.actionsequence.dom.actions.SqlDataAction) ActionSequenceParameterMgr(org.pentaho.platform.engine.services.actionsequence.ActionSequenceParameterMgr)

Example 2 with ActionSequenceParameterMgr

use of org.pentaho.platform.engine.services.actionsequence.ActionSequenceParameterMgr in project pentaho-platform by pentaho.

the class RuntimeContext method resolveComponent.

protected IComponent resolveComponent(final ISolutionActionDefinition actionDefinition, final String currentInstanceId, final String currentProcessId, final IPentahoSession currentSession) throws ClassNotFoundException, PluginBeanException, InstantiationException, IllegalAccessException {
    // try to create an instance of the component class specified in the
    // action document
    String componentAlias = actionDefinition.getComponentName().trim();
    String componentClassName = RuntimeContext.getComponentClassName(componentAlias, this);
    Element componentDefinition = (Element) actionDefinition.getComponentSection();
    setCurrentComponent(componentClassName);
    setCurrentActionDef(actionDefinition);
    IComponent component = null;
    Class componentClass = null;
    Object componentTmp = null;
    // Explicitly using the short name instead of the fully layed out class name
    if ((pluginManager != null) && (pluginManager.isBeanRegistered(componentAlias))) {
        if (RuntimeContext.debug) {
            // $NON-NLS-1$ //$NON-NLS-2$
            this.debug("Component alias " + componentAlias + " will be resolved by the plugin manager.");
        }
        componentTmp = pluginManager.getBean(componentAlias);
        if (RuntimeContext.debug) {
            // $NON-NLS-1$
            this.debug("Component found in a plugin, class is: " + componentTmp.getClass().getName());
        }
    }
    if (RuntimeContext.debug) {
        // $NON-NLS-1$ //$NON-NLS-2$
        this.debug("Component alias " + componentAlias + " will be resolved by the platform");
    }
    // Ok - the plugin didn't load - try the old route
    if (componentTmp == null) {
        componentClass = Class.forName(componentClassName);
        componentTmp = componentClass.newInstance();
    }
    if (componentTmp instanceof IComponent) {
        component = (IComponent) componentTmp;
    } else if (componentTmp instanceof IAction) {
        component = new ActionDelegate(componentTmp);
    } else {
        // Try this out...
        PojoComponent pc = new PojoComponent();
        pc.setPojo(componentTmp);
        component = pc;
    }
    component.setInstanceId(currentInstanceId);
    component.setActionName(getActionName());
    component.setProcessId(currentProcessId);
    // to the dom nodes.
    if (component instanceof IParameterResolver) {
        component.setActionDefinition(ActionFactory.getActionDefinition((Element) actionDefinition.getNode(), new ActionSequenceParameterMgr(this, currentSession, (IParameterResolver) component)));
    } else {
        component.setActionDefinition(ActionFactory.getActionDefinition((Element) actionDefinition.getNode(), new ActionSequenceParameterMgr(this, currentSession)));
    }
    // create a map of the top level component definition nodes and their text
    Map<String, String> componentDefinitionMap = new HashMap<String, String>();
    List elements = componentDefinition.elements();
    Element element;
    String name;
    String value;
    String customXsl = null;
    for (int idx = 0; idx < elements.size(); idx++) {
        element = (Element) elements.get(idx);
        name = element.getName();
        value = element.getText();
        // see if we have a target window for the output
        if ("target".equals(name)) {
            // $NON-NLS-1$
            setParameterTarget(value);
        } else if ("xsl".equals(name)) {
            // $NON-NLS-1$
            // setParameterXsl(value);
            customXsl = value;
        }
        componentDefinitionMap.put(element.getName(), element.getText());
    }
    if (customXsl != null) {
        setParameterXsl(customXsl);
    }
    component.setComponentDefinitionMap(componentDefinitionMap);
    component.setComponentDefinition(componentDefinition);
    component.setRuntimeContext(this);
    component.setSession(currentSession);
    component.setLoggingLevel(getLoggingLevel());
    component.setMessages(getMessages());
    return component;
}
Also used : IAction(org.pentaho.platform.api.action.IAction) HashMap(java.util.HashMap) IComponent(org.pentaho.platform.api.engine.IComponent) IRuntimeElement(org.pentaho.platform.api.repository.IRuntimeElement) Element(org.dom4j.Element) ActionDelegate(org.pentaho.platform.engine.services.solution.ActionDelegate) IParameterResolver(org.pentaho.platform.api.engine.IParameterResolver) List(java.util.List) ArrayList(java.util.ArrayList) ActionSequenceParameterMgr(org.pentaho.platform.engine.services.actionsequence.ActionSequenceParameterMgr) PojoComponent(org.pentaho.platform.engine.services.solution.PojoComponent)

Aggregations

ActionSequenceParameterMgr (org.pentaho.platform.engine.services.actionsequence.ActionSequenceParameterMgr)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Element (org.dom4j.Element)1 IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)1 SqlDataAction (org.pentaho.actionsequence.dom.actions.SqlDataAction)1 IAction (org.pentaho.platform.api.action.IAction)1 IComponent (org.pentaho.platform.api.engine.IComponent)1 IParameterResolver (org.pentaho.platform.api.engine.IParameterResolver)1 IRuntimeElement (org.pentaho.platform.api.repository.IRuntimeElement)1 ActionDelegate (org.pentaho.platform.engine.services.solution.ActionDelegate)1 PojoComponent (org.pentaho.platform.engine.services.solution.PojoComponent)1