Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/13 08:46:01 (12 years ago)
Author:
fschoepp
Message:

#1888:

  • Experiments will be saved as JSON elements within the blob store.
  • Added simple model and JSON converters.
  • Backend stores and runs experiments.
  • Updated interfaces to save/read experiments.
  • Added a binding to automatically map incoming JSON ajax requests to experiment models.
  • Added the javascript DatatypeMapper to map parameter inputs to the right html elements and vice versa.
  • Added smartwizard to generate Wizards for creating new experiments (New.cshtml).
Location:
branches/OaaS/HeuristicLab.Services.Optimization.Web
Files:
14 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/ExperimentController.cs

    r9215 r9227  
    88using HeuristicLab.Services.Optimization.ControllerService.Model;
    99using System.Web.Security;
     10using Mvc3TestApplication.Binders;
     11using HeuristicLab.Services.Optimization.ControllerService.Parsers;
    1012
    1113namespace HeuristicLab.Services.Optimization.Web.Controllers
     
    4143          foreach (var scenario in scenarios)
    4244            model.Scenarios.Add(scenario);
     45
     46          Session["experiment"] = new Experiment();
     47
    4348          return View(model);
    4449        }
     50
     51        public ActionResult New() {
     52          return Index();
     53        }
     54
     55        public Experiment Experiment { get { return Session["experiment"] as Experiment; } set { Session["experiment"] = value;} }
    4556
    4657        [HttpPost]
     
    6374            if (currentNode.title == "Experiment")
    6475              continue;
    65             experiment.Scenarios.Add(new OptimizationScenario() { Id = currentNode.title });
     76            experiment.Algorithm.Add(new Algorithm() { Name = currentNode.title });
    6677          }
    6778
     
    94105          return RedirectToAction("Edit");
    95106        }
     107
     108        [HttpPost]
     109        public JsonResult SaveExperiment([ExperimentJson] Experiment experiment) {
     110          return Json(
     111            new {
     112              Success = ControllerService.withControllerService<bool>(service => {
     113                User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
     114                return service.SaveExperiment(u, experiment);
     115              })
     116            });
     117        }
     118
     119        private JsonResult ComplexExperimentCase(string scenario) {
     120          // complex case, find children of experiment
     121          var model = new GetParametersModel() { Type = "Complex" };
     122          model.Subnames = new List<string>();
     123
     124          var experiment = ControllerService.withControllerService<Experiment>(service => {
     125            User user = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
     126            return service.GetExperimentByName(user, scenario);
     127          });
     128
     129          // TODO: Make a tree out of subnames!!
     130          if (experiment != null)
     131            foreach (var algo in experiment.Algorithm)
     132              model.Subnames.Add(algo.Name);
     133
     134          return Json(model, JsonRequestBehavior.AllowGet);
     135        }
     136
     137        [HttpGet]
     138        public JsonResult GetParameters(string scenario, string context, int index) {
     139          if (context == "Experiment" || context == null) {
     140            var optimizationScenario = ControllerService.withControllerService<OptimizationScenario>(service => {
     141              return service.GetOptimizationScenarioByName(scenario);
     142            });
     143
     144            if (optimizationScenario != null) {
     145              var model = new GetParametersModel() { Type = "Basic" };
     146              model.Algorithm = optimizationScenario.FirstAlgorithm;
     147              model.Algorithm.Mapper = optimizationScenario.Id;
     148              var json = Json(model, JsonRequestBehavior.AllowGet);
     149              return json;
     150            }
     151            else {
     152              // complex case, find children of experiment
     153              var model = new GetParametersModel() { Type = "Complex" };
     154              model.Subnames = new List<string>();
     155
     156              var experiment = ControllerService.withControllerService<Experiment>(service => {
     157                User user = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
     158                return service.GetExperimentByName(user, scenario);
     159              });
     160
     161              // TODO: Make a tree out of subnames!!
     162              if (experiment != null)
     163                foreach (var algo in experiment.Algorithm)
     164                  model.Subnames.Add(algo.Name);
     165
     166              return Json(model, JsonRequestBehavior.AllowGet);
     167            }
     168          }
     169          else {
     170            var experiment = ControllerService.withControllerService<Experiment>(service => {
     171              User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
     172              return service.GetExperimentByName(u, context);
     173            });
     174
     175            // if child algorithm is a complex algorithm, return as such
     176            if (experiment.Algorithm[index].ChildAlgorithms.Count > 0) {
     177              var model = new GetParametersModel() { Type = "Complex" };
     178              model.Subnames = new List<string>();
     179              foreach (var algo in experiment.Algorithm[index].ChildAlgorithms)
     180                model.Subnames.Add(algo.Name);
     181              return Json(model, JsonRequestBehavior.AllowGet);
     182            }
     183            else {
     184              // otherwise we have the algorithms just below it
     185              var model = new GetParametersModel() { Type = "Basic" };
     186              model.Algorithm = experiment.Algorithm[index];
     187              model.Algorithm.Mapper = experiment.Algorithm[index].Name;
     188              var json = Json(model, JsonRequestBehavior.AllowGet);
     189              return json;
     190            }
     191          }
     192        }
    96193    }
    97194}
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs

    r9215 r9227  
    5757
    5858        public ActionResult JobDetails(string jobId) {
    59           Job job = ControllerService.withControllerService<Job>((service) => {
     59          var model = ControllerService.withControllerService<JobDetailsModel>((service) => {
    6060            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    61             return service.GetJob(u, jobId);
     61            var job = service.GetJob(u, jobId);
     62            var runs = service.GetJobResults(u, jobId);
     63            return new JobDetailsModel() { Job = job, Runs = runs };
    6264          });
    63           var runs = ControllerService.withControllerService<IList<Run>>((service) => {
    64             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
    65             return service.GetJobResults(u, jobId);
    66           });
    67           JobDetailsModel jdm = new JobDetailsModel() { Job = job, Runs = runs };
    68           Session["jobDetails"] = jdm;
    69           return View(jdm);
    70         }
     65          Session["jobDetails"] = model;
     66          return View(model);
     67       }
    7168
    7269        [HttpPost]
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj

    r9215 r9227  
    9797  </ItemGroup>
    9898  <ItemGroup>
     99    <Content Include="Content\ajax-loader.gif" />
     100    <Content Include="Content\Datatypemapping.js" />
    99101    <Content Include="Content\dynatree\dist\jquery.dynatree.min.js" />
    100102    <Content Include="Content\dynatree\src\skin\icons-rtl.gif" />
     
    105107    <Content Include="Content\dynatree\src\skin\vline.gif" />
    106108    <Content Include="Content\ExperimentSupport.js" />
     109    <Compile Include="Binders\AlgorithmJsonAttribute.cs" />
    107110    <Compile Include="Controllers\AccountController.cs" />
    108111    <Compile Include="Controllers\AdminController.cs" />
     
    369372    </None>
    370373    <Content Include="Views\Status\Index.cshtml" />
     374    <Content Include="Views\Experiment\New.cshtml" />
    371375  </ItemGroup>
    372376  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/ExperimentModel.cs

    r9215 r9227  
    33using System.Linq;
    44using System.Web;
     5using HeuristicLab.Services.Optimization.ControllerService.Model;
    56
    67namespace HeuristicLab.Services.Optimization.Web.Models {
     
    1617    public Node Experiment { get; set; }
    1718    public string Name { get; set; }
     19  }
     20
     21  public class GetParametersModel {
     22    public string Type { get; set; }
     23    public Algorithm Algorithm { get; set; }
     24    public IList<string> Subnames { get; set; }
    1825  }
    1926
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml

    r9215 r9227  
    3030    <script type="text/javascript" src="@Url.Content("~/Content/dynatree/dist/jquery.dynatree.min.js")"></script>
    3131    <script type="text/javascript" src="@Url.Content("~/Content/ExperimentSupport.js")"></script>
     32
     33    <!-- Experiment Additions -->
     34    <script src="@Url.Content("~/Content/Datatypemapping.js")" type="text/javascript"></script>
     35    <link href="@Url.Content("~/Content/smartwizard2.0/styles/smart_wizard.css")" rel="stylesheet" type="text/css" />
     36    <script type="text/javascript" src="@Url.Content("~/Content/smartwizard2.0/js/jquery.smartWizard-2.0.min.js")"></script>
    3237</head>
    3338<body>
Note: See TracChangeset for help on using the changeset viewer.