use of org.apache.hop.workflow.WorkflowExecutionConfiguration in project hop by apache.
the class BaseWorkflowServlet method createWorkflow.
protected IWorkflowEngine<WorkflowMeta> createWorkflow(WorkflowConfiguration workflowConfiguration) throws HopException, HopException, ParseException {
WorkflowExecutionConfiguration workflowExecutionConfiguration = workflowConfiguration.getWorkflowExecutionConfiguration();
IHopMetadataProvider metadataProvider = new MultiMetadataProvider(variables, getServerConfig().getMetadataProvider(), workflowConfiguration.getMetadataProvider());
WorkflowMeta workflowMeta = workflowConfiguration.getWorkflowMeta();
String serverObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = getServletLogging(serverObjectId, workflowExecutionConfiguration.getLogLevel());
// Create the workflow and store in the list...
//
String runConfigurationName = workflowExecutionConfiguration.getRunConfiguration();
final IWorkflowEngine<WorkflowMeta> workflow = WorkflowEngineFactory.createWorkflowEngine(variables, runConfigurationName, metadataProvider, workflowMeta, servletLoggingObject);
// Setting variables
workflow.initializeFrom(null);
workflow.getWorkflowMeta().setMetadataProvider(metadataProvider);
workflow.getWorkflowMeta().setInternalHopVariables(workflow);
workflow.setVariables(workflowConfiguration.getWorkflowExecutionConfiguration().getVariablesMap());
copyWorkflowParameters(workflow, workflowExecutionConfiguration.getParametersMap());
// Check if there is a starting point specified.
String startActionName = workflowExecutionConfiguration.getStartActionName();
if (startActionName != null && !startActionName.isEmpty()) {
ActionMeta startActionMeta = workflowMeta.findAction(startActionName);
workflow.setStartActionMeta(startActionMeta);
}
getWorkflowMap().addWorkflow(workflow.getWorkflowName(), serverObjectId, workflow, workflowConfiguration);
// Remember the generated container ID
//
workflow.setContainerId(serverObjectId);
return workflow;
}
use of org.apache.hop.workflow.WorkflowExecutionConfiguration in project hop by apache.
the class RegisterPackageServlet method generateBody.
@Override
WebResult generateBody(HttpServletRequest request, HttpServletResponse response, boolean useXML, IVariables variables) throws HopException, IOException, HopException, ParseException {
FileObject tempFile = HopVfs.createTempFile("export", ".zip", System.getProperty("java.io.tmpdir"));
OutputStream out = HopVfs.getOutputStream(tempFile, false);
IOUtils.copy(request.getInputStream(), out);
out.flush();
IOUtils.closeQuietly(out);
String archiveUrl = tempFile.getName().toString();
// the resource to load
String load = request.getParameter(PARAMETER_LOAD);
if (!Utils.isEmpty(load)) {
String fileUrl = MessageFormat.format(ZIP_CONT, archiveUrl, load);
boolean isWorkflow = TYPE_WORKFLOW.equalsIgnoreCase(request.getParameter(PARAMETER_TYPE));
String resultId;
String metaStoreJson = getMetaStoreJsonFromZIP(archiveUrl);
SerializableMetadataProvider metadataProvider = new SerializableMetadataProvider(metaStoreJson);
if (isWorkflow) {
Node node = getConfigNodeFromZIP(archiveUrl, Workflow.CONFIGURATION_IN_EXPORT_FILENAME, WorkflowExecutionConfiguration.XML_TAG);
WorkflowExecutionConfiguration workflowExecutionConfiguration = new WorkflowExecutionConfiguration(node);
WorkflowMeta workflowMeta = new WorkflowMeta(fileUrl);
WorkflowConfiguration workflowConfiguration = new WorkflowConfiguration(workflowMeta, workflowExecutionConfiguration, metadataProvider);
IWorkflowEngine<WorkflowMeta> workflow = createWorkflow(workflowConfiguration);
resultId = workflow.getContainerId();
} else {
Node node = getConfigNodeFromZIP(archiveUrl, Pipeline.CONFIGURATION_IN_EXPORT_FILENAME, PipelineExecutionConfiguration.XML_TAG);
PipelineExecutionConfiguration pipelineExecutionConfiguration = new PipelineExecutionConfiguration(node);
PipelineMeta pipelineMeta = new PipelineMeta(fileUrl, metadataProvider, true, Variables.getADefaultVariableSpace());
PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(pipelineMeta, pipelineExecutionConfiguration, metadataProvider);
IPipelineEngine<PipelineMeta> pipeline = createPipeline(pipelineConfiguration);
resultId = pipeline.getContainerId();
}
return new WebResult(WebResult.STRING_OK, fileUrl, resultId);
}
return null;
}
use of org.apache.hop.workflow.WorkflowExecutionConfiguration in project hop by apache.
the class WorkflowResource method addJob.
@PUT
@Path("/add")
@Produces({ MediaType.APPLICATION_JSON })
public WorkflowStatus addJob(String xml) {
// Parse the XML, create a workflow configuration
//
WorkflowConfiguration workflowConfiguration;
try {
// TODO
IVariables variables = Variables.getADefaultVariableSpace();
workflowConfiguration = WorkflowConfiguration.fromXml(xml, variables);
IHopMetadataProvider metadataProvider = new MultiMetadataProvider(variables, HopServerSingleton.getHopServer().getMetadataProvider(), workflowConfiguration.getMetadataProvider());
WorkflowMeta workflowMeta = workflowConfiguration.getWorkflowMeta();
WorkflowExecutionConfiguration workflowExecutionConfiguration = workflowConfiguration.getWorkflowExecutionConfiguration();
String serverObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(getClass().getName(), LoggingObjectType.HOP_SERVER, null);
servletLoggingObject.setContainerObjectId(serverObjectId);
servletLoggingObject.setLogLevel(workflowExecutionConfiguration.getLogLevel());
// Create the workflow and store in the list...
//
String runConfigurationName = workflowConfiguration.getWorkflowExecutionConfiguration().getRunConfiguration();
final IWorkflowEngine<WorkflowMeta> workflow = WorkflowEngineFactory.createWorkflowEngine(variables, runConfigurationName, metadataProvider, workflowMeta, servletLoggingObject);
// Setting variables
//
workflow.initializeFrom(null);
workflow.getWorkflowMeta().setInternalHopVariables(workflow);
workflow.setVariables(workflowConfiguration.getWorkflowExecutionConfiguration().getVariablesMap());
// Also copy the parameters over...
//
workflow.copyParametersFromDefinitions(workflowMeta);
workflow.clearParameterValues();
String[] parameterNames = workflow.listParameters();
for (int idx = 0; idx < parameterNames.length; idx++) {
// Grab the parameter value set in the action
//
String thisValue = workflowExecutionConfiguration.getParametersMap().get(parameterNames[idx]);
if (!Utils.isEmpty(thisValue)) {
// Set the value as specified by the user in the action
//
workflow.setParameterValue(parameterNames[idx], thisValue);
}
}
workflow.activateParameters(workflow);
HopServerSingleton.getInstance().getWorkflowMap().addWorkflow(workflow.getWorkflowName(), serverObjectId, workflow, workflowConfiguration);
return getWorkflowStatus(serverObjectId);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations