Changeset 2766


Ignore:
Timestamp:
02/08/10 19:14:58 (11 years ago)
Author:
gkronber
Message:

Worked on deployment server. Fixed DB-schema. Implemented all test-cases. #860

Location:
branches/DeploymentServer Prototype/HeuristicLab.Services
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStore.cs

    r2742 r2766  
    5555
    5656    public byte[] PluginFile(PluginDescription pluginDescription) {
    57       return (from file in ctx.PluginPackages
    58               where file.PluginId == pluginDescription.Id
    59               select file.Data.ToArray()).Single();
     57      return GetExistingPlugin(pluginDescription.Name, pluginDescription.Version).PluginPackage.Data.ToArray();
    6058    }
    6159
     
    6361      try {
    6462        using (var transaction = new TransactionScope()) {
    65           InsertOrUpdatePlugin(pluginDescription);
    66           InsertOrUpdatePluginPackage(pluginDescription, pluginPackage);
     63          Plugin pluginEntity = InsertOrUpdatePlugin(pluginDescription);
     64          if (pluginEntity.PluginPackage == null) {
     65            // insert
     66            pluginEntity.PluginPackage = MakePluginPackage(pluginDescription, pluginPackage);
     67          } else {
     68            // update
     69            pluginEntity.PluginPackage.Data = pluginPackage;
     70          }
    6771          ctx.SubmitChanges();
    6872          transaction.Complete();
     
    7276        throw new ArgumentException("Something went wrong while trying to persist plugin", ex);
    7377      }
     78      catch (InvalidOperationException ex) {
     79        throw new ArgumentException("Something went wrong while trying to persist plugin", ex);
     80      }
    7481    }
    7582
    7683    public void Persist(ProductDescription product) {
    77       using (var transaction = new TransactionScope()) {
    78         InsertOrUpdateProduct(product);
    79         foreach (var plugin in product.Plugins) {
    80           InsertOrUpdatePlugin(plugin);
     84      try {
     85        using (var transaction = new TransactionScope()) {
     86          InsertOrUpdateProduct(product);
     87          foreach (var plugin in product.Plugins) {
     88            InsertOrUpdatePlugin(plugin);
     89          }
     90          ctx.SubmitChanges();
     91          transaction.Complete();
    8192        }
    82         ctx.SubmitChanges();
    83         transaction.Complete();
    8493      }
    85     }
    86 
    87     private void InsertOrUpdatePluginPackage(PluginDescription pluginDescription, byte[] pluginPackage) {
    88       var existing = from p in ctx.PluginPackages
    89                      where p.PluginId == pluginDescription.Id
    90                      select p;
    91 
    92       if (existing.Count() == 0) {
    93         ctx.PluginPackages.InsertOnSubmit(MakePluginPackage(pluginDescription, pluginPackage));
    94       } else {
    95         var exisingPackage = existing.Single();
    96         exisingPackage.Data = pluginPackage;
     94      catch (SqlException ex) {
     95        throw new ArgumentException("Something went wrong while trying to persist product", ex);
     96      }
     97      catch (InvalidOperationException ex) {
     98        throw new ArgumentException("Something went wrong while trying to persist product", ex);
    9799      }
    98100    }
    99101
    100102    private void InsertOrUpdateProduct(ProductDescription product) {
    101       var existing = from p in ctx.Products
    102                      where p.Id == product.Id
    103                      select p;
    104       if (existing.Count() == 0) {
    105         var newEntity = MakeProductFromDescription(product);
    106         ctx.Products.InsertOnSubmit(newEntity);
    107         // submit and write back db generated key
     103      var productEntity = (from p in ctx.Products
     104                           where p.Name == product.Name
     105                           where p.Version == product.Version.ToString()
     106                           select p).FirstOrDefault() ?? MakeProductFromDescription(product);
     107
     108      if (productEntity.Id <= 0) {
     109        ctx.Products.InsertOnSubmit(productEntity);
    108110        ctx.SubmitChanges();
    109         product.Id = newEntity.Id;
    110       } else {
    111         var existingProduct = existing.Single();
    112         existingProduct.Name = product.Name;
    113         existingProduct.Version = product.Version.ToString();
    114111      }
     112
     113      product.Id = productEntity.Id;
     114
     115      DeleteOldPlugins(productEntity);
     116
    115117      foreach (var plugin in product.Plugins) {
    116         InsertOrUpdateProductPlugin(plugin, product);
    117         InsertOrUpdatePlugin(plugin);
     118        var existingPlugin = GetExistingPlugin(plugin.Name, plugin.Version);
     119        ProductPlugin prodPlugin = new ProductPlugin();
     120        prodPlugin.PluginId = existingPlugin.Id;
     121        prodPlugin.ProductId = product.Id;
     122        ctx.ProductPlugins.InsertOnSubmit(prodPlugin);
    118123      }
    119124    }
    120125
    121     private void InsertOrUpdateProductPlugin(PluginDescription plugin, ProductDescription product) {
    122       var existing = from pair in ctx.ProductPlugins
    123                      where pair.PluginId == plugin.Id
    124                      where pair.ProductId == product.Id
    125                      select pair;
    126       if (existing.Count() != 0) {
    127         var newEntity = new ProductPlugin();
    128         newEntity.PluginId = plugin.Id;
    129         newEntity.ProductId = product.Id;
    130         ctx.ProductPlugins.InsertOnSubmit(newEntity);
    131       }
     126    private void DeleteOldPlugins(Product productEntity) {
     127      var oldPlugins = (from p in ctx.ProductPlugins
     128                        where p.ProductId == productEntity.Id
     129                        select p).ToList();
     130      ctx.ProductPlugins.DeleteAllOnSubmit(oldPlugins);
     131      ctx.SubmitChanges();
    132132    }
    133133
    134     private void InsertOrUpdatePlugin(PluginDescription plugin) {
    135       var existing = from p in ctx.Plugins
    136                      where p.Name == plugin.Name
    137                      where p.Version == plugin.Version.ToString()
    138                      select p;
    139       if (existing.Count() == 0) {
    140         var newEntity = MakePluginFromDescription(plugin);
    141         ctx.Plugins.InsertOnSubmit(newEntity);
    142         // submit and write back db generated key
     134    private Plugin InsertOrUpdatePlugin(PluginDescription pluginDescription) {
     135      var pluginEntity = (from p in ctx.Plugins
     136                          where p.Name == pluginDescription.Name
     137                          where p.Version == pluginDescription.Version.ToString()
     138                          select p).FirstOrDefault() ?? MakePluginFromDescription(pluginDescription);
     139
     140      if (pluginEntity.Id <= 0) {
     141        ctx.Plugins.InsertOnSubmit(pluginEntity);
    143142        ctx.SubmitChanges();
    144         plugin.Id = newEntity.Id;
    145       } else {
    146         var existingPlugin = existing.Single();
    147         plugin.Id = existingPlugin.Id;
    148143      }
    149       foreach (var dependency in plugin.Dependencies) {
    150         InsertOrUpdateDependency(plugin, dependency);
    151         InsertOrUpdatePlugin(dependency);
     144      pluginDescription.Id = pluginEntity.Id;
     145
     146      DeleteOldDependencies(pluginEntity);
     147
     148      foreach (var dependency in pluginDescription.Dependencies) {
     149        var dependencyEntity = GetExistingPlugin(dependency.Name, dependency.Version);
     150        Dependency d = new Dependency();
     151        d.PluginId = pluginDescription.Id;
     152        d.DependencyId = dependencyEntity.Id;
     153        ctx.Dependencies.InsertOnSubmit(d);
    152154      }
     155      return pluginEntity;
     156
    153157    }
    154158
    155     private void InsertOrUpdateDependency(PluginDescription plugin, PluginDescription dependency) {
    156       var existing = from pair in ctx.Dependencies
    157                      where pair.DependencyId == dependency.Id
    158                      where pair.PluginId == plugin.Id
    159                      select pair;
    160       if (existing.Count() == 0) {
    161         var newEntity = new Dependency();
    162         newEntity.PluginId = plugin.Id;
    163         newEntity.DependencyId = dependency.Id;
    164         ctx.Dependencies.InsertOnSubmit(newEntity);
    165       }
     159    private void DeleteOldDependencies(Plugin pluginEntity) {
     160      var oldDependencies = (from dep in ctx.Dependencies
     161                             where dep.PluginId == pluginEntity.Id
     162                             select dep).ToList();
     163
     164      ctx.Dependencies.DeleteAllOnSubmit(oldDependencies);
     165      ctx.SubmitChanges();
     166    }
     167
     168    private Plugin GetExistingPlugin(string name, Version version) {
     169      return (from p in ctx.Plugins
     170              where p.Name == name
     171              where p.Version == version.ToString()
     172              select p).Single();
    166173    }
    167174
  • branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml

    r2742 r2766  
    66      <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
    77      <Column Name="DependencyId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
    8       <Association Name="Plugin_Dependency" Member="Plugin" ThisKey="DependencyId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
    9       <Association Name="Plugin_Dependency1" Member="Plugin1" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
    108    </Type>
    119  </Table>
    1210  <Table Name="dbo.ProductPlugin" Member="ProductPlugins">
    1311    <Type Name="ProductPlugin">
    14       <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
    15       <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" CanBeNull="false" />
    16       <Association Name="Plugin_ProductPlugin" Member="Plugin" ThisKey="PluginId" OtherKey="Id" Type="Plugin" IsForeignKey="true" />
    17       <Association Name="Product_ProductPlugin" Member="Product" ThisKey="ProductId" OtherKey="Id" Type="Product" IsForeignKey="true" />
     12      <Column Name="ProductId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     13      <Column Name="PluginId" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
    1814    </Type>
    1915  </Table>
     
    2319      <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" />
    2420      <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
    25       <Association Name="Plugin_Dependency" Member="Dependencies" ThisKey="Id" OtherKey="DependencyId" Type="Dependency" />
    26       <Association Name="Plugin_Dependency1" Member="Dependencies1" ThisKey="Id" OtherKey="PluginId" Type="Dependency" />
    27       <Association Name="Plugin_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="PluginId" Type="ProductPlugin" />
    2821      <Association Name="Plugin_PluginPackage" Member="PluginPackage" ThisKey="Id" OtherKey="PluginId" Type="PluginPackage" Cardinality="One" />
    2922    </Type>
     
    3932  <Table Name="dbo.Product" Member="Products">
    4033    <Type Name="Product">
    41       <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
     34      <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    4235      <Column Name="Name" Type="System.String" DbType="NVarChar(300) NOT NULL" CanBeNull="false" />
    4336      <Column Name="Version" Type="System.String" DbType="NVarChar(50) NOT NULL" CanBeNull="false" />
    44       <Association Name="Product_ProductPlugin" Member="ProductPlugins" ThisKey="Id" OtherKey="ProductId" Type="ProductPlugin" />
    4537    </Type>
    4638  </Table>
  • branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.dbml.layout

    r2742 r2766  
    33  <DataContextMoniker Name="/PluginStoreClassesDataContext" />
    44  <nestedChildShapes>
    5     <classShape Id="b23b573a-6180-4641-ba9f-1bd9637deeff" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335">
     5    <classShape Id="8eaeae9c-08a1-4be4-b58a-e3bf24f1961b" absoluteBounds="3.5, 2.625, 2, 1.1939925130208335">
    66      <DataClassMoniker Name="/PluginStoreClassesDataContext/Dependency" />
    77      <nestedChildShapes>
    8         <elementListCompartment Id="0c1faa24-a5ab-4093-b697-127ff9dec797" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     8        <elementListCompartment Id="c05168fe-dac9-499f-bf93-2ba4d92d3a81" absoluteBounds="3.515, 3.085, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    99      </nestedChildShapes>
    1010    </classShape>
    11     <classShape Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335">
     11    <classShape Id="5f1b7d3a-0078-4834-a616-5cf8b1894803" absoluteBounds="3.5, 0.75, 2, 1.1939925130208335">
    1212      <DataClassMoniker Name="/PluginStoreClassesDataContext/ProductPlugin" />
    1313      <nestedChildShapes>
    14         <elementListCompartment Id="6eb3746b-0fec-4c95-8d53-03316bf2003a" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     14        <elementListCompartment Id="66444473-2d73-4b22-9e6b-c440e2654f3f" absoluteBounds="3.515, 1.21, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    1515      </nestedChildShapes>
    1616    </classShape>
    17     <classShape Id="c8a72752-dc21-43bd-8c14-169c06461993" absoluteBounds="0.75, 3.625, 2, 1.3862939453125">
     17    <classShape Id="37f2647d-7364-4f13-a869-2c8ebbc23260" absoluteBounds="0.75, 3.625, 2, 1.3862939453125">
    1818      <DataClassMoniker Name="/PluginStoreClassesDataContext/Plugin" />
    1919      <nestedChildShapes>
    20         <elementListCompartment Id="f85c30fe-b967-4cf5-ba0b-643fc01e8481" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     20        <elementListCompartment Id="70f53f38-ca24-4ef6-8b0a-f3be78ad76c7" absoluteBounds="0.765, 4.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    2121      </nestedChildShapes>
    2222    </classShape>
    23     <classShape Id="3b48239e-4f4a-46d0-9962-fdc1173ba7bb" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005">
     23    <classShape Id="6d0553e8-405a-4315-bc54-7af25f2a415d" absoluteBounds="3.5, 6.625, 2, 1.3862939453125005">
    2424      <DataClassMoniker Name="/PluginStoreClassesDataContext/PluginPackage" />
    2525      <nestedChildShapes>
    26         <elementListCompartment Id="e3a729ff-4cdf-44f7-b4da-0b4adc2bf9db" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     26        <elementListCompartment Id="4bc7352f-2d30-4f49-897e-c741d0a60123" absoluteBounds="3.515, 7.085, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    2727      </nestedChildShapes>
    2828    </classShape>
    29     <classShape Id="2c5978b1-ebd4-4998-88f6-6f519a81c5b9" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003">
     29    <classShape Id="c36a4ae4-62d6-4891-9389-afdef8241ad1" absoluteBounds="0.75, 1.5, 2, 1.3862939453125003">
    3030      <DataClassMoniker Name="/PluginStoreClassesDataContext/Product" />
    3131      <nestedChildShapes>
    32         <elementListCompartment Id="bfbec163-1dd5-435a-92e5-4d99b65b567f" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     32        <elementListCompartment Id="ec5480b9-acee-4912-8ea6-a67dbb78a523" absoluteBounds="0.765, 1.96, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
    3333      </nestedChildShapes>
    3434    </classShape>
    35     <associationConnector edgePoints="[(2.75 : 4.41514372916667); (3.88541416666667 : 4.41514372916667 : JumpStart); (4.05208083333333 : 4.41514372916667 : JumpEnd); (4.5 : 4.41514372916667); (4.5 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    36       <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency" />
    37       <nodes>
    38         <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
    39         <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />
    40       </nodes>
    41     </associationConnector>
    42     <associationConnector edgePoints="[(2.75 : 4.74447133723958); (3.9687475 : 4.74447133723958); (3.9687475 : 3.81899251302083)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    43       <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_Dependency1" />
    44       <nodes>
    45         <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
    46         <classShapeMoniker Id="b23b573a-6180-4641-ba9f-1bd9637deeff" />
    47       </nodes>
    48     </associationConnector>
    49     <associationConnector edgePoints="[(2.75 : 3.625); (3.125 : 3.25); (3.125 : 1.34699625651042); (3.5 : 1.34699625651042)]" fixedFrom="NotFixed" fixedTo="Algorithm">
    50       <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_ProductPlugin" />
    51       <nodes>
    52         <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
    53         <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" />
    54       </nodes>
    55     </associationConnector>
    5635    <associationConnector edgePoints="[(1.75 : 5.0112939453125); (1.75 : 7.31814697265625); (3.5 : 7.31814697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    5736      <AssociationMoniker Name="/PluginStoreClassesDataContext/Plugin/Plugin_PluginPackage" />
    5837      <nodes>
    59         <classShapeMoniker Id="c8a72752-dc21-43bd-8c14-169c06461993" />
    60         <classShapeMoniker Id="3b48239e-4f4a-46d0-9962-fdc1173ba7bb" />
    61       </nodes>
    62     </associationConnector>
    63     <associationConnector edgePoints="[(2.75 : 1.72199625651042); (3.04166666666667 : 1.72199625651042 : JumpStart); (3.20833333333333 : 1.72199625651042 : JumpEnd); (3.5 : 1.72199625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm">
    64       <AssociationMoniker Name="/PluginStoreClassesDataContext/Product/Product_ProductPlugin" />
    65       <nodes>
    66         <classShapeMoniker Id="2c5978b1-ebd4-4998-88f6-6f519a81c5b9" />
    67         <classShapeMoniker Id="89bb29fc-6da5-4fb3-9df3-a33da1cc99f8" />
     38        <classShapeMoniker Id="37f2647d-7364-4f13-a869-2c8ebbc23260" />
     39        <classShapeMoniker Id="6d0553e8-405a-4315-bc54-7af25f2a415d" />
    6840      </nodes>
    6941    </associationConnector>
  • branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.DataAccess/PluginStoreClasses.designer.cs

    r2742 r2766  
    3434    partial void UpdateDependency(Dependency instance);
    3535    partial void DeleteDependency(Dependency instance);
     36    partial void InsertProductPlugin(ProductPlugin instance);
     37    partial void UpdateProductPlugin(ProductPlugin instance);
     38    partial void DeleteProductPlugin(ProductPlugin instance);
    3639    partial void InsertPlugin(Plugin instance);
    3740    partial void UpdatePlugin(Plugin instance);
     
    126129    private long _DependencyId;
    127130   
    128     private EntityRef<Plugin> _Plugin;
    129    
    130     private EntityRef<Plugin> _Plugin1;
    131    
    132131    #region Extensibility Method Definitions
    133132    partial void OnLoaded();
     
    142141    public Dependency()
    143142    {
    144       this._Plugin = default(EntityRef<Plugin>);
    145       this._Plugin1 = default(EntityRef<Plugin>);
    146143      OnCreated();
    147144    }
     
    158155        if ((this._PluginId != value))
    159156        {
    160           if (this._Plugin1.HasLoadedOrAssignedValue)
    161           {
    162             throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    163           }
    164157          this.OnPluginIdChanging(value);
    165158          this.SendPropertyChanging();
     
    182175        if ((this._DependencyId != value))
    183176        {
    184           if (this._Plugin.HasLoadedOrAssignedValue)
    185           {
    186             throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
    187           }
    188177          this.OnDependencyIdChanging(value);
    189178          this.SendPropertyChanging();
     
    195184    }
    196185   
    197     [Association(Name="Plugin_Dependency", Storage="_Plugin", ThisKey="DependencyId", OtherKey="Id", IsForeignKey=true)]
    198     public Plugin Plugin
    199     {
    200       get
    201       {
    202         return this._Plugin.Entity;
    203       }
    204       set
    205       {
    206         Plugin previousValue = this._Plugin.Entity;
    207         if (((previousValue != value)
    208               || (this._Plugin.HasLoadedOrAssignedValue == false)))
    209         {
    210           this.SendPropertyChanging();
    211           if ((previousValue != null))
    212           {
    213             this._Plugin.Entity = null;
    214             previousValue.Dependencies.Remove(this);
    215           }
    216           this._Plugin.Entity = value;
    217           if ((value != null))
    218           {
    219             value.Dependencies.Add(this);
    220             this._DependencyId = value.Id;
    221           }
    222           else
    223           {
    224             this._DependencyId = default(long);
    225           }
    226           this.SendPropertyChanged("Plugin");
    227         }
    228       }
    229     }
    230    
    231     [Association(Name="Plugin_Dependency1", Storage="_Plugin1", ThisKey="PluginId", OtherKey="Id", IsForeignKey=true)]
    232     public Plugin Plugin1
    233     {
    234       get
    235       {
    236         return this._Plugin1.Entity;
    237       }
    238       set
    239       {
    240         Plugin previousValue = this._Plugin1.Entity;
    241         if (((previousValue != value)
    242               || (this._Plugin1.HasLoadedOrAssignedValue == false)))
    243         {
    244           this.SendPropertyChanging();
    245           if ((previousValue != null))
    246           {
    247             this._Plugin1.Entity = null;
    248             previousValue.Dependencies1.Remove(this);
    249           }
    250           this._Plugin1.Entity = value;
    251           if ((value != null))
    252           {
    253             value.Dependencies1.Add(this);
    254             this._PluginId = value.Id;
    255           }
    256           else
    257           {
    258             this._PluginId = default(long);
    259           }
    260           this.SendPropertyChanged("Plugin1");
    261         }
    262       }
    263     }
    264    
    265186    public event PropertyChangingEventHandler PropertyChanging;
    266187   
     
    285206 
    286207  [Table(Name="dbo.ProductPlugin")]
    287   public partial class ProductPlugin
     208  public partial class ProductPlugin : INotifyPropertyChanging, INotifyPropertyChanged
    288209  {
    289210   
     211    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
     212   
    290213    private long _ProductId;
    291214   
    292215    private long _PluginId;
    293216   
     217    #region Extensibility Method Definitions
     218    partial void OnLoaded();
     219    partial void OnValidate(System.Data.Linq.ChangeAction action);
     220    partial void OnCreated();
     221    partial void OnProductIdChanging(long value);
     222    partial void OnProductIdChanged();
     223    partial void OnPluginIdChanging(long value);
     224    partial void OnPluginIdChanged();
     225    #endregion
     226   
    294227    public ProductPlugin()
    295228    {
    296     }
    297    
    298     [Column(Storage="_ProductId", DbType="BigInt NOT NULL")]
     229      OnCreated();
     230    }
     231   
     232    [Column(Storage="_ProductId", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
    299233    public long ProductId
    300234    {
     
    307241        if ((this._ProductId != value))
    308242        {
     243          this.OnProductIdChanging(value);
     244          this.SendPropertyChanging();
    309245          this._ProductId = value;
    310         }
    311       }
    312     }
    313    
    314     [Column(Storage="_PluginId", DbType="BigInt NOT NULL")]
     246          this.SendPropertyChanged("ProductId");
     247          this.OnProductIdChanged();
     248        }
     249      }
     250    }
     251   
     252    [Column(Storage="_PluginId", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
    315253    public long PluginId
    316254    {
     
    323261        if ((this._PluginId != value))
    324262        {
     263          this.OnPluginIdChanging(value);
     264          this.SendPropertyChanging();
    325265          this._PluginId = value;
    326         }
     266          this.SendPropertyChanged("PluginId");
     267          this.OnPluginIdChanged();
     268        }
     269      }
     270    }
     271   
     272    public event PropertyChangingEventHandler PropertyChanging;
     273   
     274    public event PropertyChangedEventHandler PropertyChanged;
     275   
     276    protected virtual void SendPropertyChanging()
     277    {
     278      if ((this.PropertyChanging != null))
     279      {
     280        this.PropertyChanging(this, emptyChangingEventArgs);
     281      }
     282    }
     283   
     284    protected virtual void SendPropertyChanged(String propertyName)
     285    {
     286      if ((this.PropertyChanged != null))
     287      {
     288        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    327289      }
    328290    }
     
    340302   
    341303    private string _Version;
    342    
    343     private EntitySet<Dependency> _Dependencies;
    344    
    345     private EntitySet<Dependency> _Dependencies1;
    346304   
    347305    private EntityRef<PluginPackage> _PluginPackage;
     
    361319    public Plugin()
    362320    {
    363       this._Dependencies = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies), new Action<Dependency>(this.detach_Dependencies));
    364       this._Dependencies1 = new EntitySet<Dependency>(new Action<Dependency>(this.attach_Dependencies1), new Action<Dependency>(this.detach_Dependencies1));
    365321      this._PluginPackage = default(EntityRef<PluginPackage>);
    366322      OnCreated();
     
    424380          this.OnVersionChanged();
    425381        }
    426       }
    427     }
    428    
    429     [Association(Name="Plugin_Dependency", Storage="_Dependencies", ThisKey="Id", OtherKey="DependencyId")]
    430     public EntitySet<Dependency> Dependencies
    431     {
    432       get
    433       {
    434         return this._Dependencies;
    435       }
    436       set
    437       {
    438         this._Dependencies.Assign(value);
    439       }
    440     }
    441    
    442     [Association(Name="Plugin_Dependency1", Storage="_Dependencies1", ThisKey="Id", OtherKey="PluginId")]
    443     public EntitySet<Dependency> Dependencies1
    444     {
    445       get
    446       {
    447         return this._Dependencies1;
    448       }
    449       set
    450       {
    451         this._Dependencies1.Assign(value);
    452382      }
    453383    }
     
    500430        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    501431      }
    502     }
    503    
    504     private void attach_Dependencies(Dependency entity)
    505     {
    506       this.SendPropertyChanging();
    507       entity.Plugin = this;
    508     }
    509    
    510     private void detach_Dependencies(Dependency entity)
    511     {
    512       this.SendPropertyChanging();
    513       entity.Plugin = null;
    514     }
    515    
    516     private void attach_Dependencies1(Dependency entity)
    517     {
    518       this.SendPropertyChanging();
    519       entity.Plugin1 = this;
    520     }
    521    
    522     private void detach_Dependencies1(Dependency entity)
    523     {
    524       this.SendPropertyChanging();
    525       entity.Plugin1 = null;
    526432    }
    527433  }
     
    707613    }
    708614   
    709     [Column(Storage="_Id", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
     615    [Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    710616    public long Id
    711617    {
  • branches/DeploymentServer Prototype/HeuristicLab.Services/HeuristicLab.Services.Deployment.Test/PluginStoreTest.cs

    r2742 r2766  
    194194        // check if the updated file is returned
    195195        byte[] actual = target.PluginFile(newPlugin);
    196         Assert.AreEqual(expected, actual);
     196        // check retrieved file
     197        Assert.AreEqual(expected.Length, actual.Length);
     198        for (int i = 0; i < expected.Length; i++) {
     199          Assert.AreEqual(expected[i], actual[i]);
     200        }
    197201      }
    198202      #endregion
     
    236240        var plugin = new PluginDescription(pluginName, vers01, new PluginDescription[] { depPlugin, depPlugin });
    237241        try {
    238           target.Persist(depPlugin, enc.GetBytes("Zipped " + depName));
     242          target.Persist(plugin, enc.GetBytes("Zipped " + depName));
    239243          Assert.Fail("Expected ArgumentException");
    240244        }
     
    372376
    373377        // persist the plugin first
    374         int oldCount = target.Products.Count();
    375378        target.Persist(plugin1, enc.GetBytes("Zipped " + plugin1.Name));
    376         target.Persist(product);
    377         int newCount = target.Products.Count();
    378         // make sure the store went through
    379         Assert.AreEqual(oldCount + 1, newCount);
    380 
    381379        try {
    382380          target.Persist(product);
Note: See TracChangeset for help on using the changeset viewer.