Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 3309eb3e

Přidáno uživatelem Michal Linha před téměř 4 roky(ů)

re #7885 added option to show empty rows and columns, bug fixes re #8134 nothing; re #8154 added validator; re #8136 added column names no comments

Zobrazit rozdíly:

src/main/java/vldc/aswi/web/controller/AssemblyController.java
3 3
import org.springframework.beans.factory.annotation.Autowired;
4 4
import org.springframework.stereotype.Controller;
5 5
import org.springframework.ui.ModelMap;
6
import org.springframework.validation.BeanPropertyBindingResult;
6 7
import org.springframework.validation.BindingResult;
7 8
import org.springframework.web.bind.WebDataBinder;
8 9
import org.springframework.web.bind.annotation.GetMapping;
......
22 23
import vldc.aswi.utils.AuthControl;
23 24
import vldc.aswi.validators.AssemblyValidator;
24 25
import vldc.aswi.utils.Utils;
26
import vldc.aswi.validators.ConfigurationValidator;
25 27

  
26 28
import javax.validation.Valid;
27 29
import java.util.ArrayList;
......
76 78
    @Autowired
77 79
    private AssemblyValidator assemblyValidator;
78 80

  
81
    /** Autowired configuration validator */
82
    @Autowired
83
    private ConfigurationValidator configurationValidator;
84

  
79 85
    /** Name of thymeleaf parameter, which will contain text in assembly form. */
80 86
    private String assemblyTitleName = "title";
81 87

  
......
85 91
    /** Title text for new assembly form. */
86 92
    private String assemblyNewTitleText = "Vytvoření nové sestavy";
87 93

  
94
    /** Title text for table generation form.  */
95
    private String generateTableTitleText = "Generování tabulky - ";
96

  
88 97
    /**
89 98
     * Bind assembly validator.
90 99
     * @param binder Binder.
......
167 176
    {
168 177

  
169 178
        ModelAndView modelAndView = new ModelAndView();
179
        ModelMap modelMap = modelAndView.getModelMap();
170 180

  
171 181
        if (bindingResult.hasErrors()) {
172 182
            // TODO: 04.05.2020 Error message
......
188 198

  
189 199
            System.out.println("Generuj tabulku");
190 200
            prepareForTable(newConfiguration);
201
            BindingResult errors = new BeanPropertyBindingResult(newConfiguration, newConfiguration.getClass().getName());
202
            configurationValidator.validate(newConfiguration, errors);
203
            if (errors.hasErrors()) {
204
                addConfigurationDataIntoModelAndView(newConfiguration, modelAndView, modelMap);
191 205

  
192
            List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration.getAssembly().getSQLQuery(),
193
                    newConfiguration.getParametersInConfiguration());
206
                modelMap.addAttribute(assemblyErrorName, getFullErrorMessage(errors));
207
                modelMap.addAttribute(assemblyTitleName, generateTableTitleText + " " + newConfiguration.getName());
208
            }
209
            else {
210
                List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration);
194 211

  
195
            System.out.println("Generuj tabulku");
196
            ModelMap modelMap = modelAndView.getModelMap();
197
            modelMap.addAttribute("configurationID", id);
198
            modelMap.addAttribute("contingencyTableRows", rows);
199
            Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder());
200
            initializeFields(newConfiguration);
201

  
202
            modelMap.addAttribute("configuration", newConfiguration);
203
            modelMap.addAttribute("comparator", comparator);
204
            modelMap.addAttribute("formAction", "/assembly?assemblyID=" + newConfiguration.getAssembly().getId());
205
            modelAndView.setViewName("assembly");
212
                System.out.println("Generuj tabulku");
213
                modelMap.addAttribute("configurationID", id);
214
                modelMap.addAttribute("contingencyTableRows", rows);
215
                addConfigurationDataIntoModelAndView(newConfiguration, modelAndView, modelMap);
216
            }
206 217
        }
207 218
        else if (exportXls != null)
208 219
        {
......
243 254
 */
244 255
    }
245 256

  
257
    private void addConfigurationDataIntoModelAndView(Configuration newConfiguration, ModelAndView modelAndView, ModelMap modelMap) {
258
        Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder());
259
        initializeFields(newConfiguration);
260
        modelMap.addAttribute("configuration", newConfiguration);
261
        modelMap.addAttribute("comparator", comparator);
262
        modelMap.addAttribute("formAction", "/assembly?assemblyID=" + newConfiguration.getAssembly().getId());
263
        modelAndView.setViewName("assembly");
264
    }
265

  
246 266
    /**
247 267
     * Get method for assembly delete.
248 268
     * @param id - ID of assembly.

Také k dispozici: Unified diff