Revize ae1ff627
Přidáno uživatelem Vojtěch Danišík před téměř 5 roky(ů)
src/main/java/vldc/aswi/dao/parameter/ParameterInConfigurationRepository.java | ||
---|---|---|
26 | 26 |
*/ |
27 | 27 |
List<ParameterInConfiguration> getAllByConfigurationId(Long configurationId); |
28 | 28 |
|
29 |
/** |
|
30 |
* Get all parameters in configuration by parameter id. |
|
31 |
* @param parameterId - ID of configuration. |
|
32 |
* @return List of parameters in configuration. |
|
33 |
*/ |
|
34 |
List<ParameterInConfiguration> getAllByParameterId(Long parameterId); |
|
35 |
|
|
29 | 36 |
/** |
30 | 37 |
* Delete all parameters in configuration by configuration id. |
31 | 38 |
* @param configurationId - ID of configuration. |
src/main/java/vldc/aswi/dao/parameter/ParameterRepository.java | ||
---|---|---|
3 | 3 |
import org.springframework.data.repository.CrudRepository; |
4 | 4 |
import org.springframework.stereotype.Repository; |
5 | 5 |
import vldc.aswi.domain.parameter.Parameter; |
6 |
import vldc.aswi.domain.parameter.ParameterValue; |
|
7 | 6 |
|
8 | 7 |
import java.util.List; |
9 | 8 |
|
src/main/java/vldc/aswi/database/DatabaseInterface.java | ||
---|---|---|
53 | 53 |
// The column count starts from 1. |
54 | 54 |
for (int i = 1; i <= columnCount; i++ ) { |
55 | 55 |
String columnName = resultSetMetaData.getColumnName(i); |
56 |
tableColumnNames.add(columnName); |
|
56 |
tableColumnNames.add(columnName.toLowerCase());
|
|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
return tableColumnNames; |
src/main/java/vldc/aswi/domain/Assembly.java | ||
---|---|---|
33 | 33 |
private int isPublic; |
34 | 34 |
|
35 | 35 |
/** List of configurations, which using this assembly. */ |
36 |
@OneToMany(mappedBy = "assembly", cascade = CascadeType.ALL)
|
|
36 |
@OneToMany(mappedBy = "assembly") |
|
37 | 37 |
private List<Configuration> configurations; |
38 | 38 |
|
39 | 39 |
/** List of parameters, which using this assembly. */ |
40 |
@OneToMany(mappedBy = "assembly", cascade = CascadeType.ALL)
|
|
40 |
@OneToMany(mappedBy = "assembly", fetch = FetchType.EAGER, orphanRemoval = true)
|
|
41 | 41 |
private List<Parameter> parameters; |
42 | 42 |
|
43 | 43 |
/** |
src/main/java/vldc/aswi/domain/Configuration.java | ||
---|---|---|
36 | 36 |
private Assembly assembly; |
37 | 37 |
|
38 | 38 |
/** List of parametersInConfiguration, which is part of this configuration. */ |
39 |
@OneToMany(mappedBy = "configuration", cascade = CascadeType.ALL)
|
|
39 |
@OneToMany(mappedBy = "configuration") |
|
40 | 40 |
private List<ParameterInConfiguration> parametersInConfiguration; |
41 | 41 |
|
42 | 42 |
/** |
src/main/java/vldc/aswi/domain/EntityParent.java | ||
---|---|---|
23 | 23 |
* @return true if objects are same. |
24 | 24 |
*/ |
25 | 25 |
@Override |
26 |
public boolean equals(Object obj) |
|
27 |
{ |
|
26 |
public boolean equals(Object obj) { |
|
28 | 27 |
if(this == obj) { |
29 | 28 |
return true; |
30 | 29 |
} |
src/main/java/vldc/aswi/domain/parameter/Parameter.java | ||
---|---|---|
25 | 25 |
private String nameOfSelect; |
26 | 26 |
|
27 | 27 |
/** Specific assembly, in which this parameter will be part of. */ |
28 |
@ManyToOne(fetch = FetchType.LAZY)
|
|
28 |
@ManyToOne(fetch = FetchType.EAGER)
|
|
29 | 29 |
@JoinColumn(name = "sestava_id") |
30 | 30 |
private Assembly assembly; |
31 | 31 |
|
32 | 32 |
/** Specific type of parameter, which represents type of entry. */ |
33 |
@ManyToOne(fetch=FetchType.LAZY)
|
|
33 |
@ManyToOne(fetch=FetchType.EAGER)
|
|
34 | 34 |
@JoinColumn(name = "parametr_typ_id") |
35 | 35 |
private ParameterType parameterType; |
36 | 36 |
|
... | ... | |
43 | 43 |
private int parameterOrder; |
44 | 44 |
|
45 | 45 |
/** List of parametersInConfiguration, which using this parameter. */ |
46 |
@OneToMany(mappedBy = "parameter", cascade = CascadeType.ALL)
|
|
46 |
@OneToMany(mappedBy = "parameter") |
|
47 | 47 |
private List<ParameterInConfiguration> parametersInConfiguration; |
48 | 48 |
|
49 | 49 |
/** List of parametersInConfiguration, which using this parameter. */ |
50 |
@OneToMany(mappedBy = "parameter", cascade = CascadeType.ALL)
|
|
50 |
@OneToMany(mappedBy = "parameter") |
|
51 | 51 |
private List<ParameterValue> parameterValues; |
52 | 52 |
|
53 | 53 |
/** |
54 | 54 |
* Creating new table with M:N relationship between Parameter and Location. |
55 | 55 |
* Specify which locations can be used for parameter. |
56 | 56 |
*/ |
57 |
@ManyToMany(cascade = CascadeType.PERSIST)
|
|
57 |
@ManyToMany |
|
58 | 58 |
@JoinTable( |
59 | 59 |
name = "Parametr_ma_Umisteni", |
60 | 60 |
joinColumns = @JoinColumn(name = "parametr_id"), |
... | ... | |
66 | 66 |
* Creating new table with M:N relationship between Parameter and Function. |
67 | 67 |
* Specify which functions can be used for parameter. |
68 | 68 |
*/ |
69 |
@ManyToMany(cascade = CascadeType.PERSIST)
|
|
69 |
@ManyToMany |
|
70 | 70 |
@JoinTable( |
71 | 71 |
name = "Parametr_ma_Funkce", |
72 | 72 |
joinColumns = @JoinColumn(name = "parametr_id"), |
... | ... | |
78 | 78 |
* Creating new table with M:N relationship between Parameter and Operator. |
79 | 79 |
* Specify which operators can be used for parameter. |
80 | 80 |
*/ |
81 |
@ManyToMany(cascade = CascadeType.PERSIST)
|
|
81 |
@ManyToMany |
|
82 | 82 |
@JoinTable( |
83 | 83 |
name = "Parametr_ma_Operator", |
84 | 84 |
joinColumns = @JoinColumn(name = "parametr_id"), |
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
122 | 122 |
@Override |
123 | 123 |
public boolean deleteConfiguration(Long id) { |
124 | 124 |
try { |
125 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(id); |
|
125 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(id, true);
|
|
126 | 126 |
this.configurationRepository.deleteById(id); |
127 | 127 |
return true; |
128 | 128 |
} catch (Exception e) { |
... | ... | |
141 | 141 |
// Delete parameters in current configuration. |
142 | 142 |
List<Configuration> configurations = this.configurationRepository.getByAssemblyId(assemblyId); |
143 | 143 |
for (Configuration configuration : configurations) { |
144 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(configuration.getId()); |
|
144 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(configuration.getId(), true);
|
|
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
// Delete configuration. |
src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManager.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
/** |
19 | 19 |
* Delete all parameters in configuration by configuration id. |
20 |
* @param configurationID - ID of configuration.
|
|
21 |
* @return True if all parameters in configuration was deleted, false if not.
|
|
20 |
* @param id - ID of parameter / configuration.
|
|
21 |
* @return List of deleted parameters in configuration.
|
|
22 | 22 |
*/ |
23 |
boolean deleteParametersInConfiguration(Long configurationID);
|
|
23 |
boolean deleteParametersInConfiguration(Long id, boolean configurationUsed);
|
|
24 | 24 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
/** |
57 | 57 |
* Delete all parameters in configuration by configuration id. |
58 |
* @param configurationID - ID of configuration.
|
|
58 |
* @param id - ID of parameter / configuration.
|
|
59 | 59 |
* @return List of deleted parameters in configuration. |
60 | 60 |
*/ |
61 |
public boolean deleteParametersInConfiguration(Long configurationID) { |
|
61 |
@Override |
|
62 |
public boolean deleteParametersInConfiguration(Long id, boolean configurationUsed) { |
|
62 | 63 |
try { |
63 |
List<ParameterInConfiguration> parameterInConfigurations = this.parameterInConfigurationRepository.getAllByConfigurationId(configurationID); |
|
64 |
for (ParameterInConfiguration parameterInConfiguration : parameterInConfigurations) { |
|
64 |
List<ParameterInConfiguration> parameterInConfigurations = null; |
|
65 | 65 |
|
66 |
// Delete all functions used in current parameter in table 'Parametr_Konfigurace_ma_Funkce'. |
|
67 |
List<Function> functionList = new ArrayList<>(parameterInConfiguration.getFunctions()); |
|
68 |
for (Function function : functionList) { |
|
69 |
parameterInConfiguration.removeFunction(function); |
|
66 |
if (configurationUsed) { |
|
67 |
parameterInConfigurations = this.parameterInConfigurationRepository.getAllByConfigurationId(id); |
|
68 |
} |
|
69 |
else { |
|
70 |
parameterInConfigurations = this.parameterInConfigurationRepository.getAllByParameterId(id); |
|
71 |
} |
|
72 |
for (ParameterInConfiguration parameterInConfiguration : parameterInConfigurations) { |
|
73 |
boolean success = deleteParameterInConfiguration(parameterInConfiguration); |
|
74 |
if (!success) { |
|
75 |
return false; |
|
70 | 76 |
} |
71 | 77 |
} |
72 | 78 |
|
... | ... | |
77 | 83 |
return false; |
78 | 84 |
} |
79 | 85 |
} |
86 |
|
|
87 |
private boolean deleteParameterInConfiguration(ParameterInConfiguration parameterInConfiguration) { |
|
88 |
try { |
|
89 |
|
|
90 |
// Delete all functions used in current parameter in table 'Parametr_Konfigurace_ma_Funkce'. |
|
91 |
List<Function> functionList = new ArrayList<>(parameterInConfiguration.getFunctions()); |
|
92 |
for (Function function : functionList) { |
|
93 |
parameterInConfiguration.removeFunction(function); |
|
94 |
} |
|
95 |
|
|
96 |
return true; |
|
97 |
} |
|
98 |
catch (Exception e) { |
|
99 |
|
|
100 |
return false; |
|
101 |
} |
|
102 |
} |
|
80 | 103 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java | ||
---|---|---|
10 | 10 |
import vldc.aswi.dao.FunctionRepository; |
11 | 11 |
import vldc.aswi.dao.LocationRepository; |
12 | 12 |
import vldc.aswi.dao.OperatorRepository; |
13 |
import vldc.aswi.dao.parameter.ParameterInConfigurationRepository; |
|
13 | 14 |
import vldc.aswi.dao.parameter.ParameterRepository; |
14 | 15 |
import vldc.aswi.dao.parameter.ParameterTypeRepository; |
15 | 16 |
import vldc.aswi.dao.parameter.ParameterValueRepository; |
16 | 17 |
import vldc.aswi.domain.*; |
17 | 18 |
import vldc.aswi.domain.parameter.Parameter; |
19 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
|
18 | 20 |
import vldc.aswi.domain.parameter.ParameterValue; |
19 | 21 |
|
20 | 22 |
import javax.transaction.Transactional; |
... | ... | |
57 | 59 |
@Autowired |
58 | 60 |
private ParameterValueRepository parameterValueRepository; |
59 | 61 |
|
62 |
/** Autowired parameter in configuration manager. */ |
|
63 |
@Autowired |
|
64 |
private ParameterInConfigurationManager parameterInConfigurationManager; |
|
65 |
|
|
60 | 66 |
/** |
61 | 67 |
* Initialization setup for parameter manager. Check if parameter repository contains |
62 | 68 |
* records and if not, initialize default values. |
... | ... | |
92 | 98 |
@Override |
93 | 99 |
public void addParameters(Long assemblyId, List<Parameter> parameterValuesList) { |
94 | 100 |
Assembly assembly = this.assemblyRepository.getById(assemblyId); |
95 |
// TODO: test it. |
|
96 | 101 |
if (parameterValuesList == null) return; |
97 | 102 |
|
98 | 103 |
for (Parameter parameterValues : parameterValuesList) { |
99 | 104 |
// Create new parameter and assign him all values. |
100 | 105 |
Parameter parameter = new Parameter(); |
101 |
parameter.setName(parameterValues.getNameOfSelect());
|
|
106 |
parameter.setName(parameterValues.getName()); |
|
102 | 107 |
parameter.setNameOfSelect(parameterValues.getNameOfSelect()); |
103 | 108 |
parameter.setAssembly(assembly); |
109 |
parameter.setParameterOrder(parameterValues.getParameterOrder()); |
|
104 | 110 |
parameter.setParameterType(this.parameterTypeRepository.findByName(parameterValues.getParameterType().getName())); |
105 | 111 |
parameter.setDefaultValue(parameterValues.getDefaultValue()); |
106 | 112 |
|
... | ... | |
130 | 136 |
} |
131 | 137 |
} |
132 | 138 |
|
133 |
// Try to put all operators into list. |
|
134 |
if (parameterValues.getParameterValues() != null && parameterValues.getParameterValues().size() > 0) { |
|
135 |
for (ParameterValue parameterValue : parameterValues.getParameterValues()) { |
|
136 |
valueList.add(this.parameterValueRepository.getById(parameterValue.getId())); |
|
139 |
if (parameter.getParameterType().getName().equals("Výčet")) { |
|
140 |
// Try to put all values into list. |
|
141 |
if (parameterValues.getParameterValues() != null && parameterValues.getParameterValues().size() > 0) { |
|
142 |
for (ParameterValue parameterValue : parameterValues.getParameterValues()) { |
|
143 |
valueList.add(this.parameterValueRepository.getById(parameterValue.getId())); |
|
144 |
} |
|
137 | 145 |
} |
146 |
|
|
147 |
parameter.setParameterValues(valueList); |
|
138 | 148 |
} |
139 | 149 |
|
140 | 150 |
// Set lists of values into parameter. |
141 | 151 |
parameter.setLocations(locationList); |
142 | 152 |
parameter.setFunctions(functionList); |
143 | 153 |
parameter.setOperators(operatorList); |
144 |
parameter.setParameterValues(valueList); |
|
145 | 154 |
|
146 | 155 |
// Insert parameter into database. |
147 | 156 |
this.parameterRepository.save(parameter); |
... | ... | |
159 | 168 |
List<Parameter> currentAssemblyParameters = assembly.getParameters(); |
160 | 169 |
|
161 | 170 |
if (newAssemblyParameters != null) { |
171 |
// Remove removed parameters. |
|
172 |
newAssemblyParameters = removeRemovedParametersFromList(newAssemblyParameters); |
|
173 |
|
|
162 | 174 |
// Find new parameters. |
163 | 175 |
List<Parameter> currentAssemblyParametersNew = new LinkedList<>(currentAssemblyParameters); |
164 | 176 |
List<Parameter> newAssemblyParametersNew = new LinkedList<>(newAssemblyParameters); |
... | ... | |
179 | 191 |
return; |
180 | 192 |
|
181 | 193 |
// Remove deleted parameters. |
182 |
for (Parameter parameter : currentAssemblyParametersDeleted) { |
|
183 |
for (ParameterValue parameterValue : parameter.getParameterValues()) { |
|
184 |
// Remove parameters values. |
|
185 |
this.parameterValueRepository.delete(parameterValue); |
|
186 |
} |
|
187 |
|
|
188 |
// Remove parameter. |
|
189 |
this.parameterRepository.delete(parameter); |
|
194 |
for (Parameter parameterWithValues : currentAssemblyParametersDeleted) { |
|
195 |
deleteParameter(parameterWithValues.getId()); |
|
190 | 196 |
} |
191 | 197 |
|
192 | 198 |
// Update rest parameters. |
... | ... | |
194 | 200 |
|
195 | 201 |
// Add new parameters |
196 | 202 |
addParameters(assemblyId, newAssemblyParametersNew); |
203 |
|
|
204 |
assembly.setParameters(this.parameterRepository.getByAssemblyId(assemblyId)); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Remove removed parameters by web application. |
|
210 |
* Web page returns list of parameters, even those, which was removed, but those parameters |
|
211 |
* are empty object (null values in every attribute), so we need to remove them from list. |
|
212 |
* @param parameterValuesList - List of parameters from web. |
|
213 |
* @return Filtered list of parameters. |
|
214 |
*/ |
|
215 |
private List<Parameter> removeRemovedParametersFromList(List<Parameter> parameterValuesList) { |
|
216 |
List<Parameter> filteredParametersWithValues = new ArrayList<Parameter>(); |
|
217 |
|
|
218 |
for (Parameter parameterWithValues : parameterValuesList) { |
|
219 |
// Because name of parameter is required, then we know that parameter |
|
220 |
// with name == null is just empty object. |
|
221 |
if (parameterWithValues.getName() != null) { |
|
222 |
filteredParametersWithValues.add(parameterWithValues); |
|
223 |
} |
|
197 | 224 |
} |
225 |
|
|
226 |
return filteredParametersWithValues; |
|
198 | 227 |
} |
199 | 228 |
|
200 | 229 |
/** |
... | ... | |
207 | 236 |
Parameter parameter = this.parameterRepository.getById(parameterValues.getId()); |
208 | 237 |
// Update current parameter values. |
209 | 238 |
parameter.setName(parameterValues.getName()); |
239 |
parameter.setParameterOrder(parameterValues.getParameterOrder()); |
|
210 | 240 |
parameter.setNameOfSelect(parameterValues.getNameOfSelect()); |
211 | 241 |
parameter.setAssembly(this.assemblyRepository.getById(parameterValues.getAssembly().getId())); |
212 | 242 |
parameter.setParameterType(this.parameterTypeRepository.getById(parameterValues.getParameterType().getId())); |
... | ... | |
216 | 246 |
this.parameterRepository.save(parameter); |
217 | 247 |
|
218 | 248 |
// Update parameter values, locations, functions and operators. |
219 |
updateParameterValues(parameterValues.getId(), parameterValues.getParameterValues()); |
|
249 |
if (parameter.getParameterType().equals("Výčet")) { |
|
250 |
updateParameterValues(parameterValues.getId(), parameterValues.getParameterValues()); |
|
251 |
} |
|
252 |
|
|
220 | 253 |
updateParameterLocations(parameterValues.getId(), parameterValues.getLocations()); |
221 | 254 |
updateParameterFunctions(parameterValues.getId(), parameterValues.getFunctions()); |
222 | 255 |
updateParameterOperators(parameterValues.getId(), parameterValues.getOperators()); |
... | ... | |
396 | 429 |
} |
397 | 430 |
} |
398 | 431 |
|
432 |
/** |
|
433 |
* Delete parameter by id. |
|
434 |
* @param parameterId - ID of parameter. |
|
435 |
* @return True if parameter was successfully deleted, false if not. |
|
436 |
*/ |
|
437 |
private boolean deleteParameter(Long parameterId) { |
|
438 |
try { |
|
439 |
Parameter parameter = this.parameterRepository.getById(parameterId); |
|
440 |
|
|
441 |
this.parameterInConfigurationManager.deleteParametersInConfiguration(parameterId, false); |
|
442 |
|
|
443 |
// Delete removed parameter values. |
|
444 |
for (ParameterValue parameterValue : parameter.getParameterValues()) { |
|
445 |
this.parameterValueRepository.delete(parameterValue); |
|
446 |
} |
|
447 |
|
|
448 |
// Delete all functions from parameter in table 'Parametr_ma_Funkce'. |
|
449 |
List<Function> functionList = new ArrayList<>(parameter.getFunctions()); |
|
450 |
for (Function function : functionList) { |
|
451 |
parameter.removeFunction(function); |
|
452 |
} |
|
453 |
|
|
454 |
// Delete all operators from parameter in table 'Parametr_ma_Operator'. |
|
455 |
List<Operator> operatorList = new ArrayList<>(parameter.getOperators()); |
|
456 |
for (Operator operator : operatorList) { |
|
457 |
parameter.removeOperator(operator); |
|
458 |
} |
|
459 |
|
|
460 |
// Delete all locations from parameter in table 'Parametr_ma_Umisteni'. |
|
461 |
List<Location> locationList = new ArrayList<>(parameter.getLocations()); |
|
462 |
for (Location location : locationList) { |
|
463 |
parameter.removeLocation(location); |
|
464 |
} |
|
465 |
|
|
466 |
this.parameterRepository.delete(parameter); |
|
467 |
|
|
468 |
return true; |
|
469 |
} |
|
470 |
catch (Exception e) { |
|
471 |
return false; |
|
472 |
} |
|
473 |
} |
|
474 |
|
|
399 | 475 |
/** |
400 | 476 |
* Delete parameters by assembly id. |
401 | 477 |
* @param assemblyId - ID of assembly. |
478 |
* @return True if all parameters were successfully deleted, false if not. |
|
402 | 479 |
*/ |
403 | 480 |
@Override |
404 | 481 |
public boolean deleteParameters(Long assemblyId) { |
... | ... | |
406 | 483 |
List<Parameter> parameters = this.parameterRepository.getByAssemblyId(assemblyId); |
407 | 484 |
|
408 | 485 |
for (Parameter parameter : parameters) { |
409 |
// Delete all functions from parameter in table 'Parametr_ma_Funkce'. |
|
410 |
List<Function> functionList = new ArrayList<>(parameter.getFunctions()); |
|
411 |
for (Function function : functionList) { |
|
412 |
parameter.removeFunction(function); |
|
413 |
} |
|
414 |
|
|
415 |
// Delete all operators from parameter in table 'Parametr_ma_Operator'. |
|
416 |
List<Operator> operatorList = new ArrayList<>(parameter.getOperators()); |
|
417 |
for (Operator operator : operatorList) { |
|
418 |
parameter.removeOperator(operator); |
|
419 |
} |
|
420 |
|
|
421 |
// Delete all locations from parameter in table 'Parametr_ma_Umisteni'. |
|
422 |
List<Location> locationList = new ArrayList<>(parameter.getLocations()); |
|
423 |
for (Location location : locationList) { |
|
424 |
parameter.removeLocation(location); |
|
486 |
boolean success = deleteParameter(parameter.getId()); |
|
487 |
if (success == false) { |
|
488 |
return false; |
|
425 | 489 |
} |
426 | 490 |
} |
427 |
|
|
428 |
// Delete all parameters. |
|
429 |
this.parameterRepository.deleteAll(parameters); |
|
430 | 491 |
return true; |
431 | 492 |
} catch (Exception e) { |
432 | 493 |
return false; |
src/main/java/vldc/aswi/validators/AssemblyValidator.java | ||
---|---|---|
52 | 52 |
for (int i = 0; i < assembly.getParameters().size(); i++) { |
53 | 53 |
Parameter parameter = assembly.getParameters().get(i); |
54 | 54 |
|
55 |
// If parameter does not have name then it means, that it is deleted parameter. |
|
56 |
if (parameter.getName() == null) { |
|
57 |
continue; |
|
58 |
} |
|
59 |
|
|
55 | 60 |
// Check if parameter's nameOfSelect is contained in column names of SQL query. |
56 |
if (parameter.getNameOfSelect() == null || !columnNames.stream().anyMatch(parameter.getNameOfSelect()::equalsIgnoreCase)) {
|
|
61 |
if (parameter.getNameOfSelect() == null || !columnNames.stream().anyMatch(n-> n.equalsIgnoreCase(parameter.getNameOfSelect()))) {
|
|
57 | 62 |
errors.reject("parameters[" + i + "].nameOfSelect", "Název parametru v SQL query není validní u parametru '" + parameter.getName() + "'!"); |
58 | 63 |
} |
59 | 64 |
|
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
175 | 175 |
*/ |
176 | 176 |
@GetMapping("/assembly_edit") |
177 | 177 |
public ModelAndView assemblyEditGet(@Valid @ModelAttribute("assemblyID") String id) { |
178 |
long startTime = System.currentTimeMillis(); |
|
178 | 179 |
ModelAndView modelAndView = new ModelAndView("assembly_manage"); |
179 | 180 |
|
180 | 181 |
ModelMap modelMap = modelAndView.getModelMap(); |
... | ... | |
190 | 191 |
modelMap.addAttribute("allFunctions", this.functionManager.getFunctions()); |
191 | 192 |
modelMap.addAttribute("allOperators", this.operatorManager.getOperators()); |
192 | 193 |
modelMap.addAttribute("allLocations", this.locationManager.getLocations()); |
194 |
long estimatedTime = System.currentTimeMillis() - startTime; |
|
195 |
System.out.println("EDIT GET estimated - " + ((double)estimatedTime / 1000) + " sekund "); |
|
193 | 196 |
|
194 | 197 |
return modelAndView; |
195 | 198 |
} |
... | ... | |
204 | 207 |
@PostMapping("/assembly_edit") |
205 | 208 |
public ModelAndView assemblyEditPost(@Valid @ModelAttribute("assembly") Assembly assembly, BindingResult result, |
206 | 209 |
@Valid @ModelAttribute("checkboxPublic") String assemblyIsPublic) { |
207 |
|
|
210 |
long startTime = System.currentTimeMillis(); |
|
208 | 211 |
ModelAndView modelAndView = new ModelAndView("assembly_manage"); |
209 | 212 |
ModelMap modelMap = modelAndView.getModelMap(); |
210 | 213 |
|
... | ... | |
221 | 224 |
// TODO: chybí defaultValue. |
222 | 225 |
Long assemblyID = this.assemblyManager.updateAssembly(assembly); |
223 | 226 |
this.parameterManager.updateParameters(assemblyID, assembly.getParameters()); |
224 |
Assembly updatedAssembly = this.assemblyManager.getAssemblyById(assembly.getId());
|
|
227 |
Assembly updatedAssembly = this.assemblyManager.getAssemblyById(assemblyID);
|
|
225 | 228 |
|
226 | 229 |
modelMap.addAttribute("assembly", updatedAssembly); |
227 | 230 |
modelMap.addAttribute(assemblyTitleName, assemblyEditTitleText + " " + updatedAssembly.getName()); |
... | ... | |
232 | 235 |
modelMap.addAttribute("allFunctions", this.functionManager.getFunctions()); |
233 | 236 |
modelMap.addAttribute("allOperators", this.operatorManager.getOperators()); |
234 | 237 |
modelMap.addAttribute("allLocations", this.locationManager.getLocations()); |
238 |
long estimatedTime = System.currentTimeMillis() - startTime; |
|
239 |
System.out.println("EDIT POST estimated - " + ((double)estimatedTime / 1000) + " sekund "); |
|
235 | 240 |
|
236 | 241 |
return modelAndView; |
237 | 242 |
} |
src/main/java/vldc/aswi/web/controller/BasicController.java | ||
---|---|---|
20 | 20 |
if (object instanceof FieldError) { |
21 | 21 |
FieldError fieldError = (FieldError) object; |
22 | 22 |
|
23 |
if (fieldError.getCode() == null) message += fieldError.getDefaultMessage() + ", "; |
|
24 |
else message += fieldError.getCode() + ", "; |
|
23 |
message += fieldError.getDefaultMessage() + ", "; |
|
25 | 24 |
continue; |
26 | 25 |
} |
27 | 26 |
|
28 | 27 |
if (object instanceof ObjectError) { |
29 | 28 |
ObjectError objectError = (ObjectError) object; |
30 | 29 |
|
31 |
if (objectError.getCode() == null) message += objectError.getDefaultMessage() + ", "; |
|
32 |
else message += objectError.getCode() + ", "; |
|
30 |
message += objectError.getDefaultMessage() + ", "; |
|
33 | 31 |
continue; |
34 | 32 |
} |
35 | 33 |
} |
src/main/webapp/WEB-INF/templates/assembly_manage.html | ||
---|---|---|
108 | 108 |
<div th:id="'collapse' + ${i.index}" class="panel-collapse collapse"> |
109 | 109 |
<div class="panel-body"> |
110 | 110 |
<div class="form-group row"> |
111 |
<label for="name" class="col-sm-2 col-form-label">Název:</label>
|
|
111 |
<label th:for="'parameterName' + ${i.index}" class="col-sm-2 col-form-label">Název:</label>
|
|
112 | 112 |
<div class="col-sm-10"> |
113 | 113 |
<input type="text" class="form-control" th:name="'parameterName' + ${i.index}" th:id="'parameterName' + ${i.index}" th:field="*{parameters[__${i.index}__].name}" th:value="*{parameters[__${i.index}__].name}" required> |
114 | 114 |
</div> |
115 | 115 |
</div> |
116 | 116 |
<div class="form-group row"> |
117 |
<label for="name" class="col-sm-2 col-form-label">V SQL:</label>
|
|
117 |
<label th:for="'parameterSQLName' + ${i.index}" class="col-sm-2 col-form-label">V SQL:</label>
|
|
118 | 118 |
<div class="col-sm-10"> |
119 | 119 |
<input type="text" class="form-control" th:name="'parameterSQLName' + ${i.index}" th:id="'parameterSQLName' + ${i.index}" th:field="*{parameters[__${i.index}__].nameOfSelect}" th:value="*{parameters[__${i.index}__].nameOfSelect}" required> |
120 | 120 |
</div> |
Také k dispozici: Unified diff
re #7988 Parameters are now deleted from assembly + deleted parametersInConfiguration, which was created by deleted parameter.
re #7989 Added / deleted parameters are now instantly showed in page (refreshing not needed).