Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/20/13 16:56:28 (12 years ago)
Author:
fschoepp
Message:

#1888:

  • DAL: Added a Delete method which deletes by experiment id.
  • HL DataTables will now be transposed and mapped as double[ROWS][COLUMNS] (transposed)
  • JS: Moved all classes into "modules" to prevent namespace pollution (using OAAS_MODEL for model classes, OAAS_VIEW for views and OAAS_CONTROLLER for controllers)
  • JS: Moved DatatypeMapper classes into Backbone views
  • JS: Models now correctly send DELETE requests
  • Added a new job overview page (which also renders run details) using AJAX
  • Using moment.min.js to format DateTime as string
  • Controllers now inherit from BaseController which provides a RedirectToLoginIfNecessary-method
  • Added loading animations to several AJAX bound places (loading experiments / scenarios)
  • Added a section to _Layout.cshtml which allows page-specific JavaScript includes (<script> only for a certain page)
  • Fixed Build/Edit of experiment menu redirecting to the wrong page
  • The Experiment Variation Dialog disables input fields, if the property has not been activated before
Location:
branches/OaaS/HeuristicLab.Services.Optimization.Controller
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs

    r9305 r9324  
    162162    }
    163163
     164    public bool Delete(string username, string experimentId) {
     165      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
     166      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
     167      var entity = (from e in serviceContext.CreateQuery<ExperimentEntity>(AzureConstants.EXPERIMENT_TABLE)
     168                    where e.ExperimentId == experimentId
     169                    select e).FirstOrDefault();
     170
     171      if (entity == null)
     172        return false;
     173
     174      if (entity.ExperimentJsonUrl != null) {
     175        CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER);
     176        container.CreateIfNotExist();
     177        var blob = container.GetBlobReference(entity.ExperimentJsonUrl);
     178        blob.DeleteIfExists();
     179      }
     180
     181      serviceContext.DeleteObject(entity);
     182      serviceContext.SaveChangesWithRetries();
     183      return true;
     184    }
     185
    164186    public bool DeleteByName(string username, string experiment) {
    165187      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
     
    209231    //}
    210232
    211     public IEnumerable<Model.Experiment> GetExperiments(string user) {
     233    public IEnumerable<Model.Experiment> GetExperiments(string user, bool namesOnly=false) {
    212234      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
    213235      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
     
    216238                    select e).ToList();
    217239      var experiments = new List<Experiment>();
    218       CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER);
    219       container.CreateIfNotExist();
    220       foreach (var entity in entites) {
    221         var blob = container.GetBlobReference(entity.ExperimentJsonUrl);
    222         experiments.Add(AlgorithmConverter.ConvertJsonToExperiment(blob.DownloadText()));
    223       }
    224       return experiments;
     240      if (namesOnly) {
     241        return (from e in entites select new Model.Experiment() { Id = e.ExperimentId, Name = e.RowKey.Split('_')[1] });
     242      }
     243      else {
     244        CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER);
     245        container.CreateIfNotExist();
     246        foreach (var entity in entites) {
     247          var blob = container.GetBlobReference(entity.ExperimentJsonUrl);
     248          experiments.Add(AlgorithmConverter.ConvertJsonToExperiment(blob.DownloadText()));
     249        }
     250        return experiments;
     251      }
    225252    }
    226253
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs

    r9305 r9324  
    336336      else if (item is DoubleMatrix) {
    337337        var matrix = item as DoubleMatrix;
    338         double[][] matrixValue = new double[matrix.Rows][];
     338        /*double[][] matrixValue = new double[matrix.Rows][];
    339339        for (int i = 0; i < matrixValue.Length; ++i) {
    340340          matrixValue[i] = new double[matrix.Columns];
     
    342342            matrixValue[i][j] = matrix[i, j];
    343343          }
    344         }
    345         result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalMatrix() { Name = name, Value = matrixValue };
     344        } */
     345        double[][] matrixValue = new double[matrix.Columns][];
     346        for (int i = 0; i < matrix.Columns; ++i) {
     347          matrixValue[i] = new double[matrix.Rows];
     348          for (int j = 0; j < matrix.Rows; ++j) {
     349            matrixValue[i][j] = matrix[j, i];
     350          }
     351        }       
     352        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalMatrix() { Name = name, Value = matrixValue, RowNames = (matrix.ColumnNames.Count() > 0 ? matrix.ColumnNames.ToArray() : null) };
    346353      }
    347354      else if (item is IStringConvertibleArray) {
     
    369376          var columns = table.Rows.ToList()[i];
    370377          names[i] = columns.Name;
    371           results[i] = new double[columns.Values.Count];
     378          results[i] = new double[columns.Values.Count];         
    372379          for (int j=0; j < columns.Values.Count; j++) {
    373380            results[i][j] = columns.Values[j];
    374381          }
    375382        }
     383        results = transpose(results);
    376384        result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalMatrix() { Name = name, Value = results, RowNames = names };
    377385      }
     
    437445    }
    438446
     447    private double[][] transpose(double[][] arr) {
     448      var width = arr.Length;
     449      var height = arr[0].Length;
     450
     451      var res = new double[height][];
     452      for (var i = 0; i < height; i++)
     453        res[i] = new double[width];
     454
     455      for (var i = 0; i < width; i++) {
     456        for (var j = 0; j < height; j++) {
     457          res[j][i] = arr[i][j];
     458        }
     459      }
     460      return res;
     461    }
     462
    439463    private string GetMapperFromBlobStore(string scenarioName) {
    440464      var scenarioDao = dal.ScenarioDao;
     
    482506
    483507    public bool DeleteExperiment(User user, string experiment) {
    484       return dal.ExperimentDao.DeleteByName(user.Username, experiment);
     508      return dal.ExperimentDao.Delete(user.Username, experiment);
    485509    }
    486510
     
    564588    }
    565589
    566     public IEnumerable<Model.Experiment> GetExperiments(User user) {
    567       return dal.ExperimentDao.GetExperiments(user.Username);
     590    public IEnumerable<Model.Experiment> GetExperiments(User user, bool namesOnly=false) {
     591      return dal.ExperimentDao.GetExperiments(user.Username, namesOnly);
    568592    }
    569593
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs

    r9305 r9324  
    2222    bool Update(string username, Experiment experiment);
    2323    bool DeleteByName(string username, string experiment);
     24    bool Delete(string username, string experimentId);
    2425    Experiment FindByName(string username, string experiment);
    25     IEnumerable<Experiment> GetExperiments(string user);
     26    IEnumerable<Experiment> GetExperiments(string user, bool namesOnly = false);
    2627    Experiment GetExperimentByName(string username, string scenario);
    2728
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs

    r9305 r9324  
    5050
    5151    [OperationContract]
    52     IEnumerable<Experiment> GetExperiments(User user);
     52    IEnumerable<Experiment> GetExperiments(User user, bool namesOnly = false);
    5353
    5454    [OperationContract]
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs

    r9305 r9324  
    1717    string SaveExperiment(User user, Experiment experiment);
    1818    IEnumerable<string> GetExperimentNames(User user);
    19     IEnumerable<Model.Experiment> GetExperiments(User user);
     19    IEnumerable<Model.Experiment> GetExperiments(User user, bool namesOnly = false);
    2020    Experiment GetExperimentByName(User user, string scenario);
    2121    Experiment GetExperimentById(User user, string nodeId);
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs

    r9305 r9324  
    279279    }
    280280
    281     public IEnumerable<Model.Experiment> GetExperiments(User user) {
     281    public IEnumerable<Model.Experiment> GetExperiments(User user, bool namesOnly = false) {
    282282      throw new NotImplementedException();
    283283    }
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/AlgorithmConverter.cs

    r9305 r9324  
    184184    }
    185185
     186    public static JObject ConvertRunToJson(Run run) {
     187      var jrun = new JObject();
     188      jrun["id"] = run.Id;
     189      jrun["name"] = run.Name;
     190      jrun["results"] = ConvertParametersToJson(run.Results);
     191      return jrun;
     192    }
     193
     194    public static JArray ConvertRunsToJson(IList<Run> runs) {
     195       var jarray = new JArray();
     196      foreach (var run in runs)
     197        jarray.Add(ConvertRunToJson(run));
     198      return jarray;
     199    }
     200
    186201    public static Experiment ConvertJsonToExperiment(string json) {
    187202      var experiment = new Experiment();
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs

    r9305 r9324  
    185185
    186186
    187     public IEnumerable<Experiment> GetExperiments(User user) {
    188       return hiveManager.GetExperiments(user);
     187    public IEnumerable<Experiment> GetExperiments(User user, bool namesOnly=false) {
     188      return hiveManager.GetExperiments(user, namesOnly);
    189189    }
    190190
Note: See TracChangeset for help on using the changeset viewer.