private void importSelection(ArchiveSelection archSelection, int templateId) { Selection selection = new Selection(archSelection); selection.TaskTemplateID = templateId; selection.save(); archSelection.ID = selection.ID; }
public Archive generateArchiveSystem() { scenarioRelations.Clear(); selectionRelations.Clear(); taskSolverRelations.Clear(); Archive archive = new Archive(); List <Entity> tasks = models.Task.all(typeof(models.Task)); foreach (models.Task task in tasks) { ArchiveTask archTask = new ArchiveTask(task); List <TaskTemplate> templates = TaskTemplate.templatesOfTaskId(task.ID); foreach (TaskTemplate template in templates) { ArchiveTemplate archTemp = new ArchiveTemplate(template); List <Selection> selections = Selection.selectionsOfTaskTemplateId(template.ID); foreach (Selection sel in selections) { ArchiveSelection archSel = new ArchiveSelection(sel); selectionRelations.Add(new RelationExport(sel.ID, archSel)); archTemp.Selections.Add(archSel); } List <Parameter> parameters = Parameter.parametersOfTaskTemplateId(template.ID); foreach (Parameter par in parameters) { ArchiveParameter archPar = new ArchiveParameter(par); archTemp.Parameters.Add(archPar); } archTask.Templates.Add(archTemp); } List <TaskSolver> solvers = TaskSolver.solversOfTaskId(task.ID); foreach (TaskSolver solver in solvers) { ArchiveTaskSolver archSol = new ArchiveTaskSolver(solver); taskSolverRelations.Add(new RelationExport(solver.ID, archSol)); archTask.Solvers.Add(archSol); } archive.Tasks.Add(archTask); } List <Entity> scenarios = LearningScenario.all(typeof(LearningScenario)); foreach (LearningScenario scenario in scenarios) { ArchiveScenario archScenario = new ArchiveScenario(scenario); scenarioRelations.Add(new RelationExport(scenario.ID, archScenario)); archive.Scenarios.Add(archScenario); } List <Entity> lSolvers = LearnedSolver.all(typeof(LearnedSolver)); foreach (LearnedSolver solver in lSolvers) { ArchiveLearnedSolver archSol = new ArchiveLearnedSolver(solver); List <LearningQuality> quailties = LearningQuality.qualitiesOfSolverId(solver.ID); foreach (LearningQuality quality in quailties) { ArchiveLearningQuality archQ = new ArchiveLearningQuality(quality); archSol.Qualities.Add(archQ); } var find = taskSolverRelations.Find(x => x.ID == solver.TaskSolverID); archSol.TaskSolver = (find != null) ? (ArchiveTaskSolver)find.model : null; find = selectionRelations.Find(x => x.ID == solver.SelectionID); archSol.Selection = (find != null) ? (ArchiveSelection)find.model : null; find = scenarioRelations.Find(x => x.ID == solver.LearningScenarioID); archSol.Scenario = (find != null) ? (ArchiveScenario)find.model : null; archive.LearnedSolvers.Add(archSol); } return(archive); }