Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/22/10 17:13:27 (14 years ago)
Author:
cneumuel
Message:

#1233

  • added plugin management features
  • took over client-GUI from old branch
  • merged with bugfixes from old branch
  • added hive-web (for IIS)
Location:
branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New

    • Property svn:ignore
      •  

        old new  
        11*.suo
         2Tests
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Convert.cs

    r4649 r4905  
    4545        SlaveId = source.SlaveId,
    4646        JobState = source.JobState,
    47         UserId = source.UserId
     47        UserId = source.UserId,
     48        PluginsNeededIds = source.RequiredPlugins.Select(x => x.PluginId).ToList()
    4849      };
    4950    }
     
    6970        target.JobState = source.JobState;
    7071        target.UserId = source.UserId;
     72//        target.RequiredPlugins = db.Plugins.Select(x => source.PluginsNeededIds.Contains(x.PluginId)); - this is difficult
    7173      }
    7274    }
     
    107109    #endregion
    108110
     111    #region Plugin
     112    public static DT.Plugin ToDto(Plugin source) {
     113      if (source == null) return null;
     114      return new DT.Plugin { Id = source.PluginId, Name = source.Name, Version = new Version(source.Version) };
     115    }
     116    public static Plugin ToEntity(DT.Plugin source) {
     117      if (source == null) return null;
     118      var entity = new Plugin(); ToEntity(source, entity);
     119      return entity;
     120    }
     121    public static void ToEntity(DT.Plugin source, Plugin target) {
     122      if ((source != null) && (target != null)) {
     123        target.PluginId = source.Id; target.Name = source.Name; target.Version = source.Version.ToString();
     124      }
     125    }
     126    #endregion
     127
     128    #region PluginData
     129    public static DT.PluginData ToDto(PluginData source) {
     130      if (source == null) return null;
     131      return new DT.PluginData { PluginId = source.PluginId, Data = source.Data.ToArray() };
     132    }
     133    public static PluginData ToEntity(DT.PluginData source) {
     134      if (source == null) return null;
     135      var entity = new PluginData(); ToEntity(source, entity);
     136      return entity;
     137    }
     138    public static void ToEntity(DT.PluginData source, PluginData target) {
     139      if ((source != null) && (target != null)) {
     140        target.PluginId = source.PluginId; target.Data = new Binary(source.Data);
     141      }
     142    }
     143    #endregion
     144
    109145    #region Slave
    110146    public static DT.Slave ToDto(Slave source) {
     
    137173      if ((source != null) && (target != null)) {
    138174        target.ResourceId = source.Id;
    139         target.Name = source.Name; 
     175        target.Name = source.Name;
    140176        //target.SlaveGroup_Resources_Children = // TODO: see how working with groups will work, then decide how to handle enumerations in here
    141177        //target.SlaveGroup_Resources_Parents =
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLab.Services.Hive.DataAccess-3.3.csproj

    r4796 r4905  
    5050      <HintPath>..\..\..\..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    5151    </Reference>
    52     <Reference Include="HeuristicLab.Tracing-3.3, Version=3.2.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     52    <Reference Include="HeuristicLab.Tracing-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     53      <SpecificVersion>False</SpecificVersion>
     54      <HintPath>..\..\..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Tracing-3.3.dll</HintPath>
     55    </Reference>
    5356    <Reference Include="System" />
    5457    <Reference Include="System.Core" />
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDao.cs

    r4649 r4905  
    1111
    1212  public class HiveDao : IHiveDao {
    13     public HiveDataContext CreateContext() {
     13    public static HiveDataContext CreateContext() {
    1414      return new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
    1515    }
     
    7474    }
    7575
    76     public IEnumerable<DT.Job> GetAvailableJobs(DT.Slave slave) {
     76    public IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave) {
    7777      using (var db = CreateContext()) {
    7878        var query = from j in db.Jobs
     
    166166    #endregion
    167167
     168    #region Plugin Methods
     169    public DT.Plugin GetPlugin(Guid id) {
     170      using (var db = CreateContext()) {
     171        return Convert.ToDto(db.Plugins.SingleOrDefault(x => x.PluginId == id));
     172      }
     173    }
     174
     175    public IEnumerable<DT.Plugin> GetPlugins(Expression<Func<Plugin, bool>> predicate) {
     176      using (var db = CreateContext()) {
     177        return db.Plugins.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     178      }
     179    }
     180
     181    public Guid AddPlugin(DT.Plugin dto) {
     182      using (var db = CreateContext()) {
     183        var entity = Convert.ToEntity(dto);
     184        db.Plugins.InsertOnSubmit(entity);
     185        db.SubmitChanges();
     186        return entity.PluginId;
     187      }
     188    }
     189
     190    public void UpdatePlugin(DT.Plugin dto) {
     191      using (var db = CreateContext()) {
     192        var entity = db.Plugins.FirstOrDefault(x => x.PluginId == dto.Id);
     193        if (entity == null) db.Plugins.InsertOnSubmit(Convert.ToEntity(dto));
     194        else Convert.ToEntity(dto, entity);
     195        db.SubmitChanges();
     196      }
     197    }
     198
     199    public void DeletePlugin(Guid id) {
     200      using (var db = CreateContext()) {
     201        var entity = db.Plugins.FirstOrDefault(x => x.PluginId == id);
     202        if (entity != null) db.Plugins.DeleteOnSubmit(entity);
     203        db.SubmitChanges();
     204      }
     205    }
     206    #endregion
     207
     208    #region PluginData Methods
     209
     210    public DT.PluginData GetPluginData(Guid id) {
     211      using (var db = CreateContext()) {
     212        return Convert.ToDto(db.PluginDatas.SingleOrDefault(x => x.PluginId == id));
     213      }
     214    }
     215
     216    public IEnumerable<DT.PluginData> GetPluginDatas(Expression<Func<PluginData, bool>> predicate) {
     217      using (var db = CreateContext()) {
     218        return db.PluginDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     219      }
     220    }
     221
     222    public Guid AddPluginData(DT.PluginData dto) {
     223      using (var db = CreateContext()) {
     224        var entity = Convert.ToEntity(dto);
     225        db.PluginDatas.InsertOnSubmit(entity);
     226        db.SubmitChanges();
     227        return entity.PluginId;
     228      }
     229    }
     230
     231    public void UpdatePluginData(DT.PluginData dto) {
     232      using (var db = CreateContext()) {
     233        var entity = db.PluginDatas.FirstOrDefault(x => x.PluginId == dto.PluginId);
     234        if (entity == null) db.PluginDatas.InsertOnSubmit(Convert.ToEntity(dto));
     235        else Convert.ToEntity(dto, entity);
     236        db.SubmitChanges();
     237      }
     238    }
     239
     240    public void DeletePluginData(Guid id) {
     241      using (var db = CreateContext()) {
     242        var entity = db.PluginDatas.FirstOrDefault(x => x.PluginId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
     243        if (entity != null) db.PluginDatas.DeleteOnSubmit(entity);
     244        db.SubmitChanges();
     245      }
     246    }
     247    #endregion
     248
    168249    #region Slave Methods
    169250    public DT.Slave GetSlave(Guid id) {
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml

    r4649 r4905  
    4040      <Column Name="Name" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" />
    4141      <Column Name="Version" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" />
    42       <Column Name="BuildDate" Type="System.String" DbType="VarChar(20)" CanBeNull="false" />
    4342      <Association Name="Plugin_RequiredPlugin" Member="RequiredPlugins" ThisKey="PluginId" OtherKey="PluginId" Type="RequiredPlugin" />
    4443      <Association Name="Plugin_PluginData" Member="PluginData" ThisKey="PluginId" OtherKey="PluginId" Type="PluginData" Cardinality="One" />
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout

    r4615 r4905  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 17.25, 12.5" name="HiveDataContext">
     2<ordesignerObjectsDiagram dslVersion="1.0.0.0" absoluteBounds="0, 0, 17.25, 12.25" name="HiveDataContext">
    33  <DataContextMoniker Name="/HiveDataContext" />
    44  <nestedChildShapes>
     
    2727      </nestedChildShapes>
    2828    </classShape>
    29     <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="9, 10.625, 2, 1.5785953776041666">
     29    <classShape Id="7d998e56-4fba-41ca-a1a8-1dcdb9068edf" absoluteBounds="9, 10.625, 2, 1.3862939453125005">
    3030      <DataClassMoniker Name="/HiveDataContext/Plugin" />
    3131      <nestedChildShapes>
    32         <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="9.015, 11.085, 1.9700000000000002, 1.0185953776041665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     32        <elementListCompartment Id="ec4ba325-6dff-4418-baad-59af81ae2024" absoluteBounds="9.015, 11.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    3333      </nestedChildShapes>
    3434    </classShape>
     
    189189      </nestedChildShapes>
    190190    </classShape>
    191     <associationConnector edgePoints="[(11 : 11.2219962565104); (11.5 : 11.2219962565104)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     191    <associationConnector edgePoints="[(11 : 11.2219962565104); (11.5 : 11.2219962565104)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    192192      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_PluginData" />
    193193      <nodes>
     
    203203      </nodes>
    204204    </associationConnector>
    205     <associationConnector edgePoints="[(10.125 : 10.625); (10.125 : 10.2612939453125)]" fixedFrom="NotFixed" fixedTo="NotFixed">
     205    <associationConnector edgePoints="[(10.125 : 10.625); (10.125 : 10.2612939453125)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    206206      <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_RequiredPlugin" />
    207207      <nodes>
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs

    r4649 r4905  
    907907    private string _Version;
    908908   
    909     private string _BuildDate;
    910    
    911909    private EntitySet<RequiredPlugin> _RequiredPlugins;
    912910   
     
    921919    partial void OnVersionChanging(string value);
    922920    partial void OnVersionChanged();
    923     partial void OnBuildDateChanging(string value);
    924     partial void OnBuildDateChanged();
    925921    #endregion
    926922   
     
    987983          this.SendPropertyChanged("Version");
    988984          this.OnVersionChanged();
    989         }
    990       }
    991     }
    992    
    993     [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_BuildDate", DbType="VarChar(20)", CanBeNull=false)]
    994     public string BuildDate
    995     {
    996       get
    997       {
    998         return this._BuildDate;
    999       }
    1000       set
    1001       {
    1002         if ((this._BuildDate != value))
    1003         {
    1004           this.OnBuildDateChanging(value);
    1005           this.SendPropertyChanging();
    1006           this._BuildDate = value;
    1007           this.SendPropertyChanged("BuildDate");
    1008           this.OnBuildDateChanged();
    1009985        }
    1010986      }
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Interfaces/IHiveDao.cs

    r4629 r4905  
    1515    void UpdateJob(DT.Job dto);
    1616    void DeleteJob(Guid id);
    17     IEnumerable<DT.Job> GetAvailableJobs(DT.Slave slave);
     17    IEnumerable<DT.Job> GetWaitingJobs(DT.Slave slave);
    1818    #endregion
    1919
     
    3535
    3636    #region Plugin Methods
     37    DT.Plugin GetPlugin(Guid id);
     38    IEnumerable<DT.Plugin> GetPlugins(Expression<Func<Plugin, bool>> predicate);
     39    Guid AddPlugin(DT.Plugin dto);
     40    void UpdatePlugin(DT.Plugin dto);
     41    void DeletePlugin(Guid id);
    3742    #endregion
    3843
    3944    #region PluginData Methods
     45    DT.PluginData GetPluginData(Guid id);
     46    IEnumerable<DT.PluginData> GetPluginDatas(Expression<Func<PluginData, bool>> predicate);
     47    Guid AddPluginData(DT.PluginData dto);
     48    void UpdatePluginData(DT.PluginData dto);
     49    void DeletePluginData(Guid id);
    4050    #endregion
    4151
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Tools/CreateHiveDatabaseApplication.cs

    r4649 r4905  
    2727
    2828    public override void Run() {
    29       var dao = new HiveDao();
    30       using (var db = dao.CreateContext()) {
     29      using (var db = HiveDao.CreateContext()) {
    3130        if (db.DatabaseExists())
    3231          db.DeleteDatabase();
  • branches/HeuristicLab.Hive/sources/HeuristicLab.Hive.New/HeuristicLab.Services.Hive.DataAccess/3.3/Tools/prepareHiveDatabase.sql

    r4629 r4905  
    3131ALTER TABLE dbo.AssignedResources ALTER COLUMN AssignedRessourcesId ADD ROWGUIDCOL;
    3232ALTER TABLE dbo.AssignedResources WITH NOCHECK ADD CONSTRAINT [DF_AssignedResources_AssignedRessourcesId] DEFAULT (newid()) FOR AssignedRessourcesId;
     33ALTER TABLE [dbo].[AssignedResources]  DROP  CONSTRAINT [Job_AssignedResource]
     34ALTER TABLE [dbo].[AssignedResources]  WITH CHECK ADD  CONSTRAINT [Job_AssignedResource] FOREIGN KEY([JobId])
     35REFERENCES [dbo].[Job] ([JobId])
     36ON UPDATE CASCADE
     37ON DELETE CASCADE
     38GO
     39ALTER TABLE [dbo].[AssignedResources]  DROP  CONSTRAINT [Resource_AssignedResource]
     40ALTER TABLE [dbo].[AssignedResources]  WITH CHECK ADD  CONSTRAINT [Resource_AssignedResource] FOREIGN KEY([ResourceId])
     41REFERENCES [dbo].[Resource] ([ResourceId])
     42ON UPDATE CASCADE
     43ON DELETE CASCADE
     44GO
    3345
    3446ALTER TABLE dbo.Job ALTER COLUMN JobId ADD ROWGUIDCOL;
     
    5062ALTER TABLE dbo.RequiredPlugins WITH NOCHECK ADD CONSTRAINT [DF_RequiredPlugins_RequiredPluginId] DEFAULT (newid()) FOR RequiredPluginId;
    5163
     64ALTER TABLE [dbo].[RequiredPlugins]  DROP  CONSTRAINT [Job_RequiredPlugin]
     65ALTER TABLE [dbo].[RequiredPlugins]  WITH CHECK ADD  CONSTRAINT [Job_RequiredPlugin] FOREIGN KEY([JobId])
     66REFERENCES [dbo].[Job] ([JobId])
     67ON UPDATE CASCADE
     68ON DELETE CASCADE
     69GO
     70
     71ALTER TABLE [dbo].[RequiredPlugins]  DROP  CONSTRAINT [Plugin_RequiredPlugin]
     72ALTER TABLE [dbo].[RequiredPlugins]  WITH CHECK ADD  CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY([PluginId])
     73REFERENCES [dbo].[Plugin] ([PluginId])
     74ON UPDATE CASCADE
     75ON DELETE CASCADE
     76GO
     77
    5278ALTER TABLE dbo.Resource ALTER COLUMN ResourceId ADD ROWGUIDCOL;
    5379ALTER TABLE dbo.Resource WITH NOCHECK ADD CONSTRAINT [DF_Resource_ResourceId] DEFAULT (newid()) FOR ResourceId;
     
    6490/* create indices */
    6591CREATE INDEX Index_RequiredPlugins_JobId ON RequiredPlugins(JobId);
     92
     93/* triggers */
     94SET ANSI_NULLS ON
     95GO
     96SET QUOTED_IDENTIFIER ON
     97GO
     98-- =============================================
     99-- Author:    cneumuel
     100-- Create date: 11.11.2010
     101-- Description: Deletes the root-job of the experiment when experiment is deleted
     102-- =============================================
     103CREATE TRIGGER [dbo].[tr_HiveExperimentDeleteCascade] ON [dbo].[HiveExperiment] FOR DELETE AS
     104SET NOCOUNT ON
     105DELETE Job FROM deleted, Job WHERE Job.JobId = deleted.RootJobId
     106GO
     107
     108SET ANSI_NULLS ON
     109GO
     110SET QUOTED_IDENTIFIER ON
     111GO
     112-- =============================================
     113-- Author:    cneumuel
     114-- Create date: 11.11.2010
     115-- Description: Recursively deletes all child-jobs of a job when it is deleted. (Source: http://devio.wordpress.com/2008/05/23/recursive-delete-in-sql-server/)
     116-- =============================================
     117CREATE TRIGGER [dbo].[tr_JobDeleteCascade] ON [dbo].[Job] INSTEAD OF DELETE AS
     118BEGIN
     119  CREATE TABLE #Table(
     120    JobId uniqueidentifier
     121  )
     122  INSERT INTO #Table (JobId)
     123  SELECT JobId FROM deleted
     124 
     125  DECLARE @c INT
     126  SET @c = 0
     127 
     128  WHILE @c <> (SELECT COUNT(JobId) FROM #Table) BEGIN
     129    SELECT @c = COUNT(JobId) FROM #Table
     130   
     131    INSERT INTO #Table (JobId)
     132      SELECT Job.JobId
     133      FROM Job
     134      LEFT OUTER JOIN #Table ON Job.JobId = #Table.JobId
     135      WHERE Job.ParentJobId IN (SELECT JobId FROM #Table)
     136        AND #Table.JobId IS NULL
     137  END
     138 
     139  DELETE Job FROM Job INNER JOIN #Table ON Job.JobId = #Table.JobId
     140END
Note: See TracChangeset for help on using the changeset viewer.