<commit_before>/*******************************************************************************
 * Copyright (c) 2010 <NAME> and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     <NAME> - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.builds.core.operations;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.builds.core.IBuildPlan;
import org.eclipse.mylyn.builds.core.IOperationMonitor;
import org.eclipse.mylyn.internal.builds.core.BuildPlan;
import org.eclipse.mylyn.internal.builds.core.BuildServer;
import org.eclipse.mylyn.internal.builds.core.BuildsCorePlugin;
import org.eclipse.osgi.util.NLS;

/**
 * @author <NAME>
 */
public class RunBuildOperation extends AbstractBuildOperation {

	private final IBuildPlan plan;

	public RunBuildOperation(IBuildPlan plan) {
		super("Running build");
		Assert.isNotNull(plan);
		this.plan = ((BuildPlan) plan).createWorkingCopy();
	}

	@Override
	protected IStatus doExecute(IOperationMonitor monitor) {
		MultiStatus result = new MultiStatus(BuildsCorePlugin.ID_PLUGIN, 0, "Running of build failed", null);
		try {
			doRun(plan, monitor);
		} catch (CoreException e) {
			result.add((new Status(IStatus.ERROR, BuildsCorePlugin.ID_PLUGIN, NLS.bind("Run of build ''{0}'' failed",
					plan.getName(), e))));
		} catch (OperationCanceledException e) {
			return Status.CANCEL_STATUS;
		}
		setStatus(result);
		return Status.OK_STATUS;
	}

	public void doRun(IBuildPlan plan, IOperationMonitor monitor) throws CoreException {
		((BuildServer) plan.getServer()).getBehaviour().runBuild(plan, monitor);
	}

}<commit_msg>RESOLVED - bug 317384: [build] add "Run build" functionality https://bugs.eclipse.org/bugs/show_bug.cgi?id=317384<commit_after>/*******************************************************************************
 * Copyright (c) 2010 <NAME> and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     <NAME> - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.builds.core.operations;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.builds.core.IBuildPlan;
import org.eclipse.mylyn.builds.core.IOperationMonitor;
import org.eclipse.mylyn.internal.builds.core.BuildPlan;
import org.eclipse.mylyn.internal.builds.core.BuildServer;
import org.eclipse.mylyn.internal.builds.core.BuildsCorePlugin;
import org.eclipse.osgi.util.NLS;

/**
 * @author <NAME>
 */
public class RunBuildOperation extends AbstractBuildOperation {

	private final IBuildPlan plan;

	private final BuildServer server;

	public RunBuildOperation(IBuildPlan plan) {
		super("Running build");
		Assert.isNotNull(plan);
		this.plan = ((BuildPlan) plan).createWorkingCopy();
		this.server = (BuildServer) plan.getServer();
	}

	@Override
	protected IStatus doExecute(IOperationMonitor monitor) {
		MultiStatus result = new MultiStatus(BuildsCorePlugin.ID_PLUGIN, 0, "Running of build failed", null);
		try {
			doRun(plan, monitor);
		} catch (CoreException e) {
			result.add((new Status(IStatus.ERROR, BuildsCorePlugin.ID_PLUGIN, NLS.bind("Run of build ''{0}'' failed",
					plan.getName(), e))));
		} catch (OperationCanceledException e) {
			return Status.CANCEL_STATUS;
		}
		setStatus(result);
		return Status.OK_STATUS;
	}

	public void doRun(IBuildPlan plan, IOperationMonitor monitor) throws CoreException {
		server.getBehaviour().runBuild(plan, monitor);
	}

}
{'fraction_non_alphanumeric': 0.17744833782569633, 'fraction_numerical': 0.0071877807726864335, 'mean_word_length': 5.529325513196481, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6967132', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1274, 'n_words': 292}