Search in sources :

Example 1 with ActionStart

use of org.apache.hop.workflow.actions.start.ActionStart in project hop by apache.

the class Workflow method executeFromStart.

/**
 * Execute a workflow without previous results. This is an action point (not recursive)<br>
 * <br>
 *
 * @return the result of the execution
 * @throws HopException
 */
private Result executeFromStart() throws HopException {
    try {
        log.snap(Metrics.METRIC_WORKFLOW_START);
        setFinished(false);
        setStopped(false);
        HopEnvironment.setExecutionInformation(this);
        log.logBasic(BaseMessages.getString(PKG, "Workflow.Comment.WorkflowStarted"));
        ExtensionPointHandler.callExtensionPoint(log, this, HopExtensionPoint.WorkflowStart.id, this);
        // Start the tracking...
        ActionResult jerStart = new ActionResult(null, null, BaseMessages.getString(PKG, "Workflow.Comment.WorkflowStarted"), BaseMessages.getString(PKG, "Workflow.Reason.Started"), null, null);
        workflowTracker.addWorkflowTracker(new WorkflowTracker(workflowMeta, jerStart));
        setActive(true);
        // Where do we start?
        ActionMeta startpoint;
        // synchronize this to a parent workflow if needed.
        // 
        Object syncObject = this;
        if (parentWorkflow != null) {
            // parallel execution in a workflow
            syncObject = parentWorkflow;
        }
        synchronized (syncObject) {
            beginProcessing();
        }
        Result res = null;
        if (startActionMeta == null) {
            startpoint = workflowMeta.findStart();
        } else {
            startpoint = startActionMeta;
            res = startActionResult;
        }
        if (startpoint == null) {
            throw new HopWorkflowException(BaseMessages.getString(PKG, "Workflow.Log.CounldNotFindStartingPoint"));
        }
        ActionResult jerEnd = null;
        if (startpoint.isStart()) {
            // Perform optional looping in the special Start action...
            // 
            boolean isFirst = true;
            // Use a result obj coming from input otherwise init an empty Result object
            Result inputRes = null;
            if (result != null) {
                inputRes = result;
            } else {
                inputRes = new Result();
            }
            // Perhaps there is already a list of input rows available?
            if (getSourceRows() != null) {
                inputRes.setRows(getSourceRows());
            }
            ActionStart jes = (ActionStart) startpoint.getAction();
            while ((jes.isRepeat() || isFirst) && !isStopped()) {
                isFirst = false;
                res = executeFromStart(0, inputRes, startpoint, null, BaseMessages.getString(PKG, "Workflow.Reason.Started"));
            }
            jerEnd = new ActionResult(res, jes.getLogChannelId(), BaseMessages.getString(PKG, "Workflow.Comment.WorkflowFinished"), BaseMessages.getString(PKG, "Workflow.Reason.Finished"), null, null);
        } else {
            res = executeFromStart(0, res, startpoint, null, BaseMessages.getString(PKG, "Workflow.Reason.Started"));
            jerEnd = new ActionResult(res, startpoint.getAction().getLogChannel().getLogChannelId(), BaseMessages.getString(PKG, "Workflow.Comment.WorkflowFinished"), BaseMessages.getString(PKG, "Workflow.Reason.Finished"), null, null);
        }
        // Save this result...
        workflowTracker.addWorkflowTracker(new WorkflowTracker(workflowMeta, jerEnd));
        log.logBasic(BaseMessages.getString(PKG, "Workflow.Comment.WorkflowFinished"));
        setActive(false);
        if (!isStopped()) {
            setFinished(true);
        }
        return res;
    } finally {
        log.snap(Metrics.METRIC_WORKFLOW_STOP);
    }
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopWorkflowException(org.apache.hop.core.exception.HopWorkflowException) WorkflowTracker(org.apache.hop.core.gui.WorkflowTracker) FileObject(org.apache.commons.vfs2.FileObject) ActionStart(org.apache.hop.workflow.actions.start.ActionStart)

Example 2 with ActionStart

use of org.apache.hop.workflow.actions.start.ActionStart in project hop by apache.

the class Workflow method executeFromStart.

/**
 * Execute a workflow with previous results passed in.<br>
 * <br>
 * Execute called by ActionWorkflow: don't clear the actionResults.
 *
 * @param nr The action number
 * @param result the result of the previous execution
 * @return Result of the workflow execution
 * @throws HopWorkflowException
 */
public Result executeFromStart(int nr, Result result) throws HopException {
    setFinished(false);
    setActive(true);
    setInitialized(true);
    HopEnvironment.setExecutionInformation(this);
    // Where do we start?
    ActionMeta startpoint;
    // Perhaps there is already a list of input rows available?
    if (getSourceRows() != null) {
        result.setRows(getSourceRows());
    }
    startpoint = workflowMeta.findStart();
    if (startpoint == null) {
        throw new HopWorkflowException(BaseMessages.getString(PKG, "Workflow.Log.CounldNotFindStartingPoint"));
    }
    ActionStart jes = (ActionStart) startpoint.getAction();
    Result res;
    do {
        res = executeFromStart(nr, result, startpoint, null, BaseMessages.getString(PKG, "Workflow.Reason.StartOfAction"));
        setActive(false);
    } while (jes.isRepeat() && !isStopped());
    return res;
}
Also used : ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopWorkflowException(org.apache.hop.core.exception.HopWorkflowException) ActionStart(org.apache.hop.workflow.actions.start.ActionStart)

Example 3 with ActionStart

use of org.apache.hop.workflow.actions.start.ActionStart in project hop by apache.

the class WorkflowActionMetaTest method setUp.

@Before
public void setUp() throws Exception {
    originActionMeta = new ActionMeta();
    copyActionMeta = new ActionMeta();
    originAction = new ActionStart("EntrySpecial");
    originAction.setChanged(false);
    originActionMeta.setAction(originAction);
    originActionMeta.setAttribute(ATTRIBUTE_GROUP, ATTRIBUTE_KEY, ATTRIBUTE_VALUE);
}
Also used : ActionStart(org.apache.hop.workflow.actions.start.ActionStart) Before(org.junit.Before)

Example 4 with ActionStart

use of org.apache.hop.workflow.actions.start.ActionStart in project hop by apache.

the class HopWorkflowFileType method newFile.

@Override
public IHopFileTypeHandler newFile(HopGui hopGui, IVariables parentVariableSpace) throws HopException {
    try {
        // This file is created in the data orchestration perspective
        // 
        HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
        perspective.activate();
        // Create the empty pipeline
        // 
        WorkflowMeta workflowMeta = new WorkflowMeta();
        workflowMeta.setName(BaseMessages.getString(PKG, "HopWorkflowFileType.New.Text"));
        // Pass the MetaStore for reference lookups
        // 
        workflowMeta.setMetadataProvider(hopGui.getMetadataProvider());
        // Add a Start action by default...
        // 
        ActionStart start = new ActionStart("Start");
        ActionMeta startMeta = new ActionMeta(start);
        startMeta.setLocation(50, 50);
        workflowMeta.addAction(startMeta);
        // 
        return perspective.addWorkflow(hopGui, workflowMeta, this);
    } catch (Exception e) {
        throw new HopException("Error creating new workflow", e);
    }
}
Also used : HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopException(org.apache.hop.core.exception.HopException) ActionStart(org.apache.hop.workflow.actions.start.ActionStart) HopException(org.apache.hop.core.exception.HopException) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta)

Aggregations

ActionStart (org.apache.hop.workflow.actions.start.ActionStart)4 ActionMeta (org.apache.hop.workflow.action.ActionMeta)3 HopWorkflowException (org.apache.hop.core.exception.HopWorkflowException)2 FileObject (org.apache.commons.vfs2.FileObject)1 HopException (org.apache.hop.core.exception.HopException)1 WorkflowTracker (org.apache.hop.core.gui.WorkflowTracker)1 HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)1 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)1 Before (org.junit.Before)1