Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2314


Ignore:
Timestamp:
08/27/09 17:47:37 (15 years ago)
Author:
mkommend
Message:

extended IModelingDatabase interface to return persisted model (ticket #712)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2306 r2314  
    6868    }
    6969
    70     public void Persist(HeuristicLab.Modeling.IAlgorithm algorithm) {
     70    public IModel Persist(HeuristicLab.Modeling.IAlgorithm algorithm) {
    7171      GetOrCreateProblem(algorithm.Dataset);
    72       Persist(algorithm.Model, algorithm.Name, algorithm.Description);
    73     }
    74 
    75     public void Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription) {
     72      return Persist(algorithm.Model, algorithm.Name, algorithm.Description);
     73    }
     74
     75    public IModel Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription) {
    7676      Dictionary<string, Variable> variables = GetAllVariables();
    7777      Algorithm algo = GetOrCreateAlgorithm(algorithmName, algorithmDescription);
     
    133133        ctx.SubmitChanges();
    134134      }
     135
     136      //if connected to database return inserted model
     137      if (this.ctx != null)
     138        return this.ctx.Models.Where(x => x.Id == m.Id).Single();
     139      return null;
    135140    }
    136141
     
    149154      IProblem problem;
    150155      if (ctx.Problems.Count() == 0)
    151         problem =  PersistProblem(dataset);
     156        problem = PersistProblem(dataset);
    152157      else
    153158        problem = ctx.Problems.Single();
  • trunk/sources/HeuristicLab.Modeling.Database/3.2/IModelingDatabase.cs

    r2304 r2314  
    2828namespace HeuristicLab.Modeling.Database {
    2929  public interface IModelingDatabase {
    30     void Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription);
    31     void Persist(HeuristicLab.Modeling.IAlgorithm algorithm);
     30    IModel Persist(HeuristicLab.Modeling.IAlgorithm algorithm);
     31    IModel Persist(HeuristicLab.Modeling.IAnalyzerModel model, string algorithmName, string algorithmDescription);
    3232    IProblem PersistProblem(Dataset dataset);
    3333
Note: See TracChangeset for help on using the changeset viewer.