Revize ba7a20a1
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
import javax.transaction.Transactional; |
19 | 19 |
import java.util.ArrayList; |
20 |
import java.util.Collections; |
|
21 |
import java.util.Comparator; |
|
20 | 22 |
import java.util.List; |
21 | 23 |
|
22 | 24 |
@Service |
... | ... | |
59 | 61 |
@Autowired |
60 | 62 |
private ParameterInConfigurationManager parameterInConfigurationManager; |
61 | 63 |
|
64 |
/** Autowired assembly manager. */ |
|
65 |
@Autowired |
|
66 |
private AssemblyManager assemblyManager; |
|
67 |
|
|
62 | 68 |
/** |
63 | 69 |
* Initialization setup for configuration manager. |
64 | 70 |
* Check if table "Konfigurace" exists. |
... | ... | |
103 | 109 |
*/ |
104 | 110 |
@Override |
105 | 111 |
public Configuration getConfigurationById(Long id) { |
106 |
return configurationRepository.getById(id); |
|
112 |
Configuration configuration = configurationRepository.getById(id); |
|
113 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
114 |
configuration.getParametersInConfiguration().sort(comparator); |
|
115 |
return configuration; |
|
107 | 116 |
} |
108 | 117 |
|
109 | 118 |
/** |
... | ... | |
172 | 181 |
// TODO: 04.05.2020 error message, user not authenticated |
173 | 182 |
} |
174 | 183 |
Configuration configuration = new Configuration(); |
175 |
Assembly assembly = assemblyRepository.getById(newConfiguration.getAssembly().getId()); |
|
184 |
Assembly assembly = assemblyManager.getAssemblyById(newConfiguration.getAssembly().getId()); |
|
185 |
Collections.sort(assembly.getParameters()); |
|
176 | 186 |
configuration.setAssembly(assembly); |
177 | 187 |
configuration.setName(newConfiguration.getName()); |
178 | 188 |
configuration.setTableName(newConfiguration.getTableName()); |
... | ... | |
224 | 234 |
* @return saved configuration |
225 | 235 |
*/ |
226 | 236 |
private Configuration editConfiguration(Configuration newConfiguration, Long id) { |
227 |
Configuration configuration = configurationRepository.getById(id);
|
|
237 |
Configuration configuration = getConfigurationById(id);
|
|
228 | 238 |
configuration.setName(newConfiguration.getName()); |
229 | 239 |
configuration.setTableName(newConfiguration.getTableName()); |
230 | 240 |
|
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
145 | 145 |
configuration.getParametersInConfiguration().add(parameterInConfiguration); |
146 | 146 |
} |
147 | 147 |
|
148 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
149 |
|
|
150 | 148 |
boolean isNotRemoveEmpty = false; |
151 | 149 |
modelMap.addAttribute("isNotRemoveEmpty", isNotRemoveEmpty); |
152 | 150 |
modelMap.addAttribute("configuration", configuration); |
153 |
modelMap.addAttribute("comparator", comparator); |
|
154 | 151 |
modelMap.addAttribute("formAction", "/assembly?assemblyID=" + assembly.getId()); |
155 | 152 |
|
156 | 153 |
return modelAndView; |
... | ... | |
256 | 253 |
* @param modelMap ModelMap to which data is added. |
257 | 254 |
*/ |
258 | 255 |
private void addConfigurationDataIntoModelAndView(Configuration newConfiguration, ModelAndView modelAndView, ModelMap modelMap) { |
259 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
260 | 256 |
initializeFields(newConfiguration); |
261 | 257 |
modelMap.addAttribute("configuration", newConfiguration); |
262 |
modelMap.addAttribute("comparator", comparator); |
|
263 | 258 |
modelMap.addAttribute("formAction", "/assembly?assemblyID=" + newConfiguration.getAssembly().getId()); |
264 | 259 |
modelAndView.setViewName("assembly"); |
265 | 260 |
} |
src/main/java/vldc/aswi/web/controller/ConfigurationController.java | ||
---|---|---|
100 | 100 |
configuration.setParametersInConfiguration(parametersInConfiguration); |
101 | 101 |
|
102 | 102 |
initializeFields(configuration); |
103 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
104 | 103 |
|
105 | 104 |
modelMap.addAttribute("configuration", configuration); |
106 |
modelMap.addAttribute("comparator", comparator); |
|
107 | 105 |
modelMap.addAttribute("formAction", "/configuration?configurationID=" + configuration.getId()); |
108 | 106 |
|
109 | 107 |
modelMap.addAttribute(assemblySuccessName, successMsg); |
... | ... | |
273 | 271 |
* @param modelMap ModelMap to which data is added. |
274 | 272 |
*/ |
275 | 273 |
private void addConfigurationDataIntoModelAndView(Configuration newConfiguration, ModelAndView modelAndView, ModelMap modelMap) { |
276 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
277 | 274 |
initializeFields(newConfiguration); |
278 | 275 |
modelMap.addAttribute("configuration", newConfiguration); |
279 |
modelMap.addAttribute("comparator", comparator); |
|
280 | 276 |
modelMap.addAttribute("formAction", "/configuration?configurationID=" + newConfiguration.getAssembly().getId()); |
281 | 277 |
modelAndView.setViewName("assembly"); |
282 | 278 |
} |
Také k dispozici: Unified diff
re #8176 removed comparators from controllers, added sorting to configuration manager