Revize cc39413d
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
46 | 46 |
@Autowired |
47 | 47 |
private AssemblyManager assemblyManager; |
48 | 48 |
|
49 |
/** Autowired configuration manager */ |
|
50 |
@Autowired |
|
51 |
private ConfigurationManager configurationManager; |
|
52 |
|
|
49 | 53 |
/** Autowired role manager. */ |
50 | 54 |
@Autowired |
51 | 55 |
private RoleManager roleManager; |
... | ... | |
150 | 154 |
|
151 | 155 |
/** |
152 | 156 |
* Post method for form, where configuration is created from assembly. |
153 |
* @param assembly - Assembly values.
|
|
157 |
* @param newConfiguration - Configuration values.
|
|
154 | 158 |
* @param bindingResult - Error results from assembly validators. |
155 | 159 |
* @param atts - Redirect attributes. |
156 | 160 |
* @return ModelAndView for assembly. |
157 | 161 |
*/ |
158 | 162 |
@PostMapping("/assembly") |
159 |
public ModelAndView assemblyPost(Configuration configuration,
|
|
163 |
public ModelAndView assemblyPost(Configuration newConfiguration,
|
|
160 | 164 |
BindingResult bindingResult, |
161 | 165 |
RedirectAttributes atts, |
162 | 166 |
@RequestParam("assemblyID") String id, |
... | ... | |
165 | 169 |
@RequestParam(required=false, value="exportPdf") String exportPdf, |
166 | 170 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration) |
167 | 171 |
{ |
172 |
ModelAndView modelAndView = new ModelAndView(); |
|
173 |
|
|
168 | 174 |
if (generateTable != null) |
169 | 175 |
{ |
170 | 176 |
System.out.println("Generuj tabulku"); |
177 |
prepareForTable(newConfiguration); |
|
178 |
System.out.println("Generuj tabulku"); |
|
179 |
ModelMap modelMap = modelAndView.getModelMap(); |
|
180 |
modelMap.addAttribute("configurationID", id); |
|
181 |
modelMap.addAttribute("contingencyTableRows", this.sqlQueryManager.getContingencyTableRow(newConfiguration)); |
|
182 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
183 |
initializeFields(newConfiguration); |
|
184 |
modelMap.addAttribute("configuration", newConfiguration); |
|
185 |
modelMap.addAttribute("comparator", comparator); |
|
186 |
modelMap.addAttribute("formAction", "/assembly?assemblyID=" + newConfiguration.getAssembly().getId()); |
|
187 |
modelAndView.setViewName("assembly"); |
|
171 | 188 |
} |
172 | 189 |
else if (exportXls != null) |
173 | 190 |
{ |
... | ... | |
180 | 197 |
else if (saveConfiguration != null) |
181 | 198 |
{ |
182 | 199 |
System.out.println("ulož konfiguraci"); |
183 |
} |
|
184 | 200 |
|
201 |
Configuration configuration = configurationManager.saveConfiguration(newConfiguration, ""); |
|
185 | 202 |
|
203 |
initializeFields(configuration); |
|
186 | 204 |
|
187 |
ModelAndView modelAndView = new ModelAndView("redirect:/assembly?assemblyID=" + id); |
|
205 |
modelAndView.setViewName("redirect:/configuration?configurationID=" + configuration.getId()); |
|
206 |
} |
|
188 | 207 |
|
189 | 208 |
return modelAndView; |
190 | 209 |
/* |
... | ... | |
348 | 367 |
|
349 | 368 |
return modelAndView; |
350 | 369 |
} |
370 |
|
|
371 |
/** |
|
372 |
* Initializes fields of a given configuration |
|
373 |
* @param configuration configuration which fields should be initialized |
|
374 |
*/ |
|
375 |
private void initializeFields(Configuration configuration) { |
|
376 |
for(ParameterInConfiguration parameterInConfiguration : configuration.getParametersInConfiguration()) { |
|
377 |
if(parameterInConfiguration.getLocation() == null) { |
|
378 |
parameterInConfiguration.setLocation(new Location()); |
|
379 |
} |
|
380 |
if(parameterInConfiguration.getOperator() == null) { |
|
381 |
parameterInConfiguration.setOperator(new Operator()); |
|
382 |
} |
|
383 |
if(parameterInConfiguration.getFunctions() == null) { |
|
384 |
parameterInConfiguration.setFunctions(new ArrayList<>()); |
|
385 |
} |
|
386 |
} |
|
387 |
} |
|
388 |
|
|
389 |
/** |
|
390 |
* Prepares the configuration for contingency table generation. Initializes assembly and parameters of parameters in |
|
391 |
* configuration. |
|
392 |
* @param configuration configuration to be prepared. |
|
393 |
*/ |
|
394 |
private void prepareForTable(Configuration configuration) { |
|
395 |
Assembly assembly = assemblyManager.getAssemblyById(configuration.getAssembly().getId()); |
|
396 |
configuration.setAssembly(assembly); |
|
397 |
|
|
398 |
for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) { |
|
399 |
ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i); |
|
400 |
parameterInConfiguration.setParameter(assembly.getParameters().get(i)); |
|
401 |
if (parameterInConfiguration.getLocation() != null) { |
|
402 |
parameterInConfiguration.setLocation(locationManager.getLocationById(parameterInConfiguration.getLocation().getId())); |
|
403 |
} |
|
404 |
} |
|
405 |
} |
|
351 | 406 |
} |
Také k dispozici: Unified diff
re #7885 added SUM and ability to work with multiple values and sorted parameters in configuration, optimization