package de.uni_potsdam.hpi.bpt.bp2014.jconfiguration;

import de.uni_potsdam.hpi.bpt.bp2014.jcore.eventhandling.EventDispatcher;

import java.util.List;

/**
 * This class executes configurations.
 */
public class Execution {

	/**
	 * This method marks the scenario as deleted if there are no running instances.
	 *
	 * @param scenarioId DatabaseID of the scenario that is supposed to get marked as deleted
	 * @return true if the scenario was deleted (else false)
	 * @throws Exception Running instances of the scenario exist.
	 */
	public boolean deleteScenario(int scenarioId) throws Exception {
		DbConfigurationConnection conn = new DbConfigurationConnection();
		List<Integer> runningInstances = conn.getRunningScenarioInstances(scenarioId);
		if (runningInstances.size() > 0) {
			return false;
		} else {
			conn.deleteScenario(scenarioId);
			EventDispatcher.unregisterStartQuery(scenarioId);
			return true;
		}
	}
}

@@ -665,155 +665,8 @@
 ();%0A
-%09%09List%3CInteger%3E runningInstances = conn.getRunningScenarioInstances(scenarioId);%0A%09%09if (runningInstances.size() %3E 0) %7B%0A%09%09%09return false;%0A%09%09%7D else %7B%0A%09
 %09%09co
@@ -696,17 +696,16 @@
 rioId);%0A
-%09
 %09%09EventD
@@ -750,17 +750,16 @@
 oId);%0A%09%09
-%09
 return t
@@ -767,12 +767,8 @@
 ue;%0A
-%09%09%7D%0A
 %09%7D%0A%7D

Enable scenario deletion via DELETE call at all times (still no button in the frontend unless there are no running instances)