Index: /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLab.HiveEngine-3.3.csproj
===================================================================
--- /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLab.HiveEngine-3.3.csproj	(revision 5135)
+++ /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLab.HiveEngine-3.3.csproj	(revision 5136)
@@ -9,6 +9,6 @@
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>HeuristicLab.HiveParallelEngine</RootNamespace>
-    <AssemblyName>HeuristicLab.HiveParallelEngine-3.3</AssemblyName>
+    <RootNamespace>HeuristicLab.HiveEngine</RootNamespace>
+    <AssemblyName>HeuristicLab.HiveEngine-3.3</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
@@ -33,6 +33,15 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="HeuristicLab.Clients.Common-3.3">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Clients.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.Common-3.3">
       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Core-3.3">
@@ -45,6 +54,10 @@
       <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.SequentialEngine-3.3">
+      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
@@ -53,9 +66,29 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ScopeMergeException.cs" />
     <None Include="Properties\AssemblyInfo.cs.frame" />
     <None Include="HeuristicLabHiveEnginePlugin.cs.frame" />
     <Compile Include="HeuristicLabHiveEnginePlugin.cs" />
     <Compile Include="HiveEngine.cs" />
+    <Compile Include="OperationJob.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.DataAccess\3.3\HeuristicLab.DataAccess-3.3.csproj">
+      <Project>{9076697B-C151-46CD-95BC-1D059492B478}</Project>
+      <Name>HeuristicLab.DataAccess-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Hive.Contracts\3.3\HeuristicLab.Hive.Contracts-3.3.csproj">
+      <Project>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</Project>
+      <Name>HeuristicLab.Hive.Contracts-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Hive.ExperimentManager\3.3\HeuristicLab.Hive.ExperimentManager-3.3.csproj">
+      <Project>{A84C0A25-13D0-40A6-924F-53556D9691DC}</Project>
+      <Name>HeuristicLab.Hive.ExperimentManager-3.3</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Hive.JobBase\3.3\HeuristicLab.Hive.JobBase-3.3.csproj">
+      <Project>{21187322-52DD-4243-80A4-A85F0263E63B}</Project>
+      <Name>HeuristicLab.Hive.JobBase-3.3</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Index: /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLabHiveEnginePlugin.cs.frame
===================================================================
--- /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLabHiveEnginePlugin.cs.frame	(revision 5135)
+++ /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HeuristicLabHiveEnginePlugin.cs.frame	(revision 5136)
@@ -5,14 +5,22 @@
 using HeuristicLab.PluginInfrastructure;
 
-namespace HiveParallelEngine {
+namespace HeuristicLab.HiveEngine {
   /// <summary>
-  /// Plugin class for HeuristicLab.HiveParallelEngine plugin.
+  /// Plugin class for HeuristicLab.HiveEngine plugin.
   /// </summary>
-  [Plugin("HeuristicLab.SequentialEngine", "3.3.2.$WCREV$")]
-  [PluginFile("HeuristicLab.SequentialEngine-3.3.dll", PluginFileType.Assembly)]
+  [Plugin("HeuristicLab.HiveEngine", "3.3.2.$WCREV$")]
+  [PluginFile("HeuristicLab.HiveEngine-3.3.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
+  [PluginDependency("HeuristicLab.Collections", "3.3")]
   [PluginDependency("HeuristicLab.Common", "3.3")]
+  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
   [PluginDependency("HeuristicLab.Core", "3.3")]
+  [PluginDependency("HeuristicLab.DataAccess", "3.3")]
+  [PluginDependency("HeuristicLab.Hive.Contracts", "3.3")]
+  [PluginDependency("HeuristicLab.Hive.ExperimentManager", "3.3")]
+  [PluginDependency("HeuristicLab.Hive.JobBase", "3.3")]
   [PluginDependency("HeuristicLab.Persistence", "3.3")]
-  class HeuristicLabHiveParallelEnginePlugin {
+  [PluginDependency("HeuristicLab.SequentialEngine", "3.3")]
+  public class HeuristicLabHiveEnginePlugin : PluginBase {
   }
 }
Index: /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs
===================================================================
--- /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs	(revision 5135)
+++ /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/HiveEngine.cs	(revision 5136)
@@ -6,6 +6,13 @@
 using HeuristicLab.Core;
 using HeuristicLab.Common;
+using HeuristicLab.Hive.Contracts.Interfaces;
+using HeuristicLab.Clients.Common;
+using HeuristicLab.Hive.ExperimentManager;
+using HeuristicLab.Hive.Contracts.BusinessObjects;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Hive.Contracts.ResponseObjects;
+using System.Threading;
 
-namespace HeuristicLab.HiveParallelEngine {
+namespace HeuristicLab.HiveEngine {
   /// <summary>
   /// Represents an engine that executes operations which can be executed in parallel on the hive
@@ -20,5 +27,6 @@
     [StorableConstructor]
     protected HiveEngine(bool deserializing) : base(deserializing) { }
-    protected HiveEngine(HiveEngine original, Cloner cloner) : base(original, cloner) {
+    protected HiveEngine(HiveEngine original, Cloner cloner)
+      : base(original, cloner) {
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -32,13 +40,17 @@
       OperationCollection coll = next as OperationCollection;
 
-      if (coll.Parallel) {
-                
-      } else {
-        while (coll != null) {
+      while (coll != null) {
+        if (coll.Parallel) {
+          IScope scope = ((IAtomicOperation)coll.Where(x => x is IAtomicOperation).First()).Scope;
+          IEnumerable<IOperation> finishedOperations = ExecuteOnHive(coll.Select(op => new OperationJob(op)));
+          foreach (IOperation op in finishedOperations) {
+            ReIntegrateScope(scope, op);
+          }
+        } else {
           for (int i = coll.Count - 1; i >= 0; i--)
             ExecutionStack.Push(coll[i]);
-          next = ExecutionStack.Count > 0 ? ExecutionStack.Pop() : null;
-          coll = next as OperationCollection;
         }
+        next = ExecutionStack.Count > 0 ? ExecutionStack.Pop() : null;
+        coll = next as OperationCollection;
       }
 
@@ -61,4 +73,99 @@
     }
 
+    private static void ReIntegrateScope(IScope scope, IOperation operation) {
+      if (operation is IAtomicOperation) {
+        MergeScopes(scope, ((IAtomicOperation)operation).Scope);
+      } else if (operation is OperationCollection) {
+        foreach (IOperation op in (OperationCollection)operation) {
+          ReIntegrateScope(scope, op);
+        }
+      }
+    }
+
+    private static void MergeScopes(IScope target, IScope source) {
+      foreach (IVariable variable in source.Variables) {
+        if (target.Variables.ContainsKey(variable.Name)) {
+          if (target.Variables[variable.Name] != source.Variables[variable.Name]) {
+            // problem: ResultCollection are not equal altough they contain the same values.
+            //             - either implement ResultCollection.Equals, or consider ResultCollection as special case here
+            //throw new ScopeMergeException(string.Format("Variable {0} already exists in target scope and has a different value ({1}, {2}).", variable.Name, target.Variables[variable.Name].Value, variable.Value));
+          }
+        } else {
+          target.Variables.Add(variable);
+        }
+      }
+
+      //this is not useful on the parentscope of the initial scope
+      //foreach (IScope subScope in source.SubScopes) {
+      //  target.SubScopes.Add(subScope);
+      //}
+
+      if (target.Parent != null && source.Parent != null)
+        MergeScopes(target.Parent, source.Parent);
+    }
+
+
+    private IEnumerable<IOperation> TestExecuteOnHive(IEnumerable<OperationJob> operationJobs) {
+      //var clonedJobs = operationJobs.Select(x => (OperationJob)x.Clone()).ToArray();
+      var results = new List<IOperation>();
+
+      foreach (var job in operationJobs) {
+        job.Start();
+        while (job.ExecutionState != Core.ExecutionState.Stopped) {
+          Thread.Sleep(100);
+        }
+        results.Add(job.Operation);
+      }
+      return results;
+    }
+
+    private IEnumerable<IOperation> ExecuteOnHive(IEnumerable<OperationJob> operationJobs) {
+      IEnumerable<Guid> jobIds;
+      JobResultList results;
+
+
+      using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) {
+        List<JobDto> jobs = new List<JobDto>();
+        foreach (OperationJob operationJob in operationJobs) {
+          var groups = new string[] { "HEAL" };
+          SerializedJob serializedJob = new SerializedJob();
+          serializedJob.SerializedJobData = SerializedJob.Serialize(operationJob);
+          serializedJob.JobInfo = new JobDto();
+          serializedJob.JobInfo.State = JobState.Offline;
+          serializedJob.JobInfo.CoresNeeded = 1;
+          serializedJob.JobInfo.PluginsNeeded = ApplicationManager.Manager.Plugins.Select(x => new HivePluginInfoDto { Name = x.Name, Version = x.Version }).ToList();
+          ResponseObject<JobDto> response = service.Obj.AddJobWithGroupStrings(serializedJob, groups);
+          jobs.Add(response.Obj);
+        }
+        jobIds = jobs.Select(x => x.Id);
+        results = service.Obj.GetJobResults(jobIds).Obj;
+      }
+
+      while (!results.All(
+          x => x.State == JobState.Finished ||
+          x.State == JobState.Failed ||
+          x.State == JobState.Aborted)) {
+        Thread.Sleep(5000);
+        using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) {
+          results = service.Obj.GetJobResults(jobIds).Obj;
+        }
+      }
+
+      // all finished
+      List<OperationJob> finishedJobs = new List<OperationJob>();
+      using (Disposable<IClientFacade> service = ServiceLocator.Instance.StreamedClientFacadePool.GetService()) {
+        foreach (Guid jobId in jobIds) {
+          SerializedJob serializedJob = service.Obj.GetLastSerializedResult(jobId).Obj;
+          OperationJob operationJob = SerializedJob.Deserialize<OperationJob>(serializedJob.SerializedJobData);
+          finishedJobs.Add(operationJob);
+        }
+      }
+
+      // delete jobs
+      // TODO
+
+      return finishedJobs.Select(x => x.Operation);
+    }
+
     public override void Pause() {
       base.Pause();
Index: /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/OperationJob.cs
===================================================================
--- /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/OperationJob.cs	(revision 5136)
+++ /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/OperationJob.cs	(revision 5136)
@@ -0,0 +1,133 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Hive.JobBase;
+using HeuristicLab.Core;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+using System.Drawing;
+
+namespace HeuristicLab.HiveEngine {
+  [StorableClass]
+  public class OperationJob : AbstractJob {
+    [Storable]
+    SequentialEngine.SequentialEngine engine;
+
+    [Storable]
+    protected IOperation operation;
+    public IOperation Operation {
+      get { return operation; }
+      set { operation = value; }
+    }
+
+    public override TimeSpan ExecutionTime {
+      get { return engine.ExecutionTime; }
+    }
+
+    public override ExecutionState ExecutionState {
+      get { return engine.ExecutionState; }
+    }
+
+    #region constructors and cloning
+    public OperationJob() { }
+    public OperationJob(IOperation operation) {
+      this.operation = operation;
+      this.engine = new SequentialEngine.SequentialEngine(); 
+      RegisterEngineEvents();
+    }
+
+    [StorableConstructor]
+    protected OperationJob(bool deserializing) : base(deserializing) { }
+    protected OperationJob(OperationJob original, Cloner cloner)
+      : base(original, cloner) {
+      this.engine = cloner.Clone(original.engine);
+      this.operation = cloner.Clone(original.operation);
+      RegisterEngineEvents();
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new OperationJob(this, cloner);
+    }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      RegisterEngineEvents();
+    }
+    #endregion
+
+    public override bool IsParallelizable {
+      get { return false; }
+    }
+
+    public override void Run() {
+      throw new NotImplementedException();
+    }
+
+    public override void Prepare() { }
+    public override void Start() {
+      engine.Prepare(operation);
+      engine.Start();
+    }
+
+    public override void Stop() {
+      engine.Stop();
+    }
+
+    public override void Resume(IEnumerable<IJob> childJobs) {
+      throw new NotImplementedException();
+    }
+
+    private void RegisterEngineEvents() {
+      engine.Stopped += new EventHandler(engine_Stopped);
+      engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(engine_ExceptionOccurred);
+    }
+
+    void engine_ExceptionOccurred(object sender, EventArgs<Exception> e) {
+      OnJobFailed(e);
+    }
+
+    void engine_Stopped(object sender, EventArgs e) {
+      OnJobStopped();
+    }
+
+    public override bool CanChangeDescription {
+      get { return false; }
+    }
+
+    public override bool CanChangeName {
+      get { return false; }
+    }
+
+    public override string Description {
+      get { return operation is IAtomicOperation ? ((IAtomicOperation)operation).Operator.Name : "OperationCollection"; }
+      set { throw new NotSupportedException(); }
+    }
+
+    public override string Name {
+      get { return operation is IAtomicOperation ? ((IAtomicOperation)operation).Operator.Name : "OperationCollection"; }
+      set { throw new NotSupportedException(); }
+    }
+
+    public override event EventHandler NameChanged;
+    public override event EventHandler<CancelEventArgs<string>> NameChanging;
+    public override event EventHandler ToStringChanged;
+    public override event EventHandler DescriptionChanged;
+
+    public override string ItemDescription {
+      get { return Description; }
+    }
+
+    public override Image ItemImage {
+      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Operator; }
+    }
+
+    public override event EventHandler ItemImageChanged;
+
+    public override string ItemName {
+      get { return "OperationJob"; }
+    }
+
+    public override Version ItemVersion {
+      get { return null; }
+    }
+  }
+}
Index: /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/ScopeMergeException.cs
===================================================================
--- /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/ScopeMergeException.cs	(revision 5136)
+++ /branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.HiveEngine/3.3/ScopeMergeException.cs	(revision 5136)
@@ -0,0 +1,16 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.Serialization;
+
+namespace HeuristicLab.HiveEngine {
+  [Serializable]
+  public class ScopeMergeException : Exception {
+    public ScopeMergeException() : base() { }
+    public ScopeMergeException(string msg) : base(msg) { }
+    public ScopeMergeException(string msg, Exception e) : base(msg, e) { }
+    protected ScopeMergeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+
+  }
+}
