public Run()

in taverna-run-impl/src/main/java/org/apache/taverna/platform/run/impl/Run.java [82:147]


	public Run(RunProfile runProfile) throws InvalidWorkflowException,
			RunProfileException {
		if (runProfile.getWorkflowBundle() == null) {
			String message = "No WorkflowBundle specified in the RunProfile";
			logger.warning(message);
			throw new RunProfileException(message);
		}
		workflowBundle = runProfile.getWorkflowBundle();
		if (runProfile.getWorkflowName() == null) {
			if (workflowBundle.getMainWorkflow() == null) {
				String message = "No Workflow specified in either the RunProfile or the WorkflowBundle";
				logger.warning(message);
				throw new RunProfileException(message);
			}
			logger.info("No Workflow specified - using the main Workflow from the WorkflowBundle");
			workflow = workflowBundle.getMainWorkflow();
		} else {
			workflow = workflowBundle.getWorkflows().getByName(
					runProfile.getWorkflowName());
		}
		if (runProfile.getProfileName() == null) {
			if (workflowBundle.getMainProfile() == null) {
				String message = "No Profile specified in either the RunProfile or the WorkflowBundle";
				logger.warning(message);
				throw new RunProfileException(message);
			}
			logger.info("No Profile specified - using the main Profile from the WorkflowBundle");
			profile = workflowBundle.getMainProfile();
		} else {
			profile = workflowBundle.getProfiles().getByName(
					runProfile.getProfileName());
		}
		if (runProfile.getDataBundle() == null) {
			String message = "No DataBundle specified in the RunProfile";
			logger.warning(message);
			throw new RunProfileException(message);
		}
		dataBundle = runProfile.getDataBundle();
		try {
			DataBundles.setWorkflowBundle(dataBundle, workflowBundle);
		} catch (IOException e) {
			String message = "Could not save workflow bundle to data bundle";
			logger.log(WARNING, message, e);
			throw new InvalidWorkflowException(message, e);
		}
		if (runProfile.getExecutionEnvironment() == null) {
			String message = "No ExecutionEnvironment specified in the RunProfile";
			logger.warning(message);
			throw new RunProfileException(message);
		}
		executionEnvironment = runProfile.getExecutionEnvironment();

		ID = UUID.randomUUID().toString();
		executionID = executionEnvironment.getExecutionService()
				.createExecution(executionEnvironment, workflowBundle,
						workflow, profile, dataBundle);
		try {
			workflowReport = executionEnvironment.getExecutionService()
					.getWorkflowReport(executionID);
		} catch (InvalidExecutionIdException e) {
			String message = "Error while creating a execution on the "
					+ executionEnvironment.getName();
			logger.severe(message);
			throw new RuntimeException(message, e);
		}
	}