«
Předchozí
|
Další
»
Revize 6af5c07d
Přidáno uživatelem Vojtěch Danišík před více než 4 roky(ů)
- ID 6af5c07d670cc4d262f088fd7255c1bdf89fdbe4
- Rodič ea163a4c
src/main/java/vldc/aswi/configuration/AppConfig.java | ||
---|---|---|
81 | 81 |
|
82 | 82 |
@Override |
83 | 83 |
protected void configure(HttpSecurity http) throws Exception { |
84 |
// TODO: 04.05.2020 Error pages
|
|
84 |
// Access rights for authorities + set default login / logout page.
|
|
85 | 85 |
http |
86 | 86 |
.authorizeRequests() |
87 | 87 |
.mvcMatchers("/login").permitAll() |
... | ... | |
112 | 112 |
|
113 | 113 |
@Override |
114 | 114 |
public void addResourceHandlers(ResourceHandlerRegistry registry) { |
115 |
// Resource handlers for css / js / webfont files. |
|
115 | 116 |
registry |
116 | 117 |
.addResourceHandler("/css/**") |
117 | 118 |
.addResourceLocations("/css/"); |
src/main/java/vldc/aswi/database/DatabaseInterface.java | ||
---|---|---|
47 | 47 |
public List<String> extractData(ResultSet resultSet) throws SQLException { |
48 | 48 |
List<String> tableColumnNames = new ArrayList<>(); |
49 | 49 |
|
50 |
// Get metadata from database result set. |
|
50 | 51 |
ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); |
51 | 52 |
int columnCount = resultSetMetaData.getColumnCount(); |
52 | 53 |
|
src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java | ||
---|---|---|
50 | 50 |
@JoinColumn(name = "operator_id") |
51 | 51 |
private Operator operator; |
52 | 52 |
|
53 |
/** |
|
54 |
* Creating new table with M:N relationship between Parameter_Hodnota and Parametr_Konfigurace. |
|
55 |
* Specify which functions can be used for parameter. |
|
56 |
*/ |
|
57 |
@ManyToMany |
|
58 |
@JoinTable( |
|
59 |
name = "P_konfigurace_ma_Hodnoty", |
|
60 |
joinColumns = @JoinColumn(name = "parametr_konfigurace_id"), |
|
61 |
inverseJoinColumns = @JoinColumn(name = "parametr_hodnota_id") |
|
62 |
) |
|
63 |
private List<ParameterValue> selectedParameterValues; |
|
64 |
|
|
53 | 65 |
/** |
54 | 66 |
* Creating new table with M:N relationship between ParameterInConfiguration and Function. |
55 | 67 |
* On every ParameterInConfiguration can be applied 0 - every function. |
src/main/java/vldc/aswi/domain/parameter/ParameterValue.java | ||
---|---|---|
6 | 6 |
import vldc.aswi.domain.EntityParent; |
7 | 7 |
|
8 | 8 |
import javax.persistence.*; |
9 |
import java.util.List; |
|
9 | 10 |
|
10 | 11 |
/** |
11 | 12 |
* Domain entity representing Parameter in application. |
... | ... | |
25 | 26 |
@Column(name = "hodnota") |
26 | 27 |
private String value; |
27 | 28 |
|
29 |
/** List of parametersInConfigurations, which using this function. */ |
|
30 |
@ManyToMany(mappedBy = "selectedParameterValues") |
|
31 |
private List<ParameterInConfiguration> parametersInConfigurations; |
|
32 |
|
|
28 | 33 |
/** |
29 | 34 |
* Constructor. |
30 | 35 |
* @param value - Value that can be used in specific parameter. |
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
25 | 25 |
@Slf4j |
26 | 26 |
public class ConfigurationManagerImpl implements ConfigurationManager { |
27 | 27 |
|
28 |
/** Autowired configuration repository. */ |
|
28 |
/** |
|
29 |
* Autowired configuration repository. |
|
30 |
*/ |
|
29 | 31 |
@Autowired |
30 | 32 |
private ConfigurationRepository configurationRepository; |
31 | 33 |
|
32 |
/** Autowired assembly repository. */ |
|
34 |
/** |
|
35 |
* Autowired assembly repository. |
|
36 |
*/ |
|
33 | 37 |
@Autowired |
34 | 38 |
private AssemblyRepository assemblyRepository; |
35 | 39 |
|
36 |
/** Autowired parameterInConfiguration repository. */ |
|
40 |
/** |
|
41 |
* Autowired parameterInConfiguration repository. |
|
42 |
*/ |
|
37 | 43 |
@Autowired |
38 | 44 |
private ParameterInConfigurationRepository parameterInConfigurationRepository; |
39 | 45 |
|
40 |
/** Autowired operator repository. */ |
|
46 |
/** |
|
47 |
* Autowired operator repository. |
|
48 |
*/ |
|
41 | 49 |
@Autowired |
42 | 50 |
private OperatorRepository operatorRepository; |
43 | 51 |
|
44 |
/** Autowired location repository. */ |
|
52 |
/** |
|
53 |
* Autowired location repository. |
|
54 |
*/ |
|
45 | 55 |
@Autowired |
46 | 56 |
private LocationRepository locationRepository; |
47 | 57 |
|
48 |
/** Autowired parameter type manager. */ |
|
58 |
/** |
|
59 |
* Autowired parameter type manager. |
|
60 |
*/ |
|
49 | 61 |
@Autowired |
50 | 62 |
private ParameterTypeManager parameterTypeRepository; |
51 | 63 |
|
52 |
/** Autowired function repository. */ |
|
64 |
/** |
|
65 |
* Autowired function repository. |
|
66 |
*/ |
|
53 | 67 |
@Autowired |
54 | 68 |
private FunctionRepository functionRepository; |
55 | 69 |
|
56 |
/** Autowired user repository. */ |
|
70 |
/** |
|
71 |
* Autowired user repository. |
|
72 |
*/ |
|
57 | 73 |
@Autowired |
58 | 74 |
private UserRepository userRepository; |
59 | 75 |
|
60 |
/** Autowired parameter in configuration manager. */ |
|
76 |
/** |
|
77 |
* Autowired parameter in configuration manager. |
|
78 |
*/ |
|
61 | 79 |
@Autowired |
62 | 80 |
private ParameterInConfigurationManager parameterInConfigurationManager; |
63 | 81 |
|
... | ... | |
79 | 97 |
if (this.configurationRepository.count() == 0) { |
80 | 98 |
// Just checking if table exists. |
81 | 99 |
} |
82 |
} |
|
83 |
catch (InvalidDataAccessResourceUsageException e) { |
|
100 |
} catch (InvalidDataAccessResourceUsageException e) { |
|
84 | 101 |
log.error("Table \"Konfigurace\" did not exists in database!"); |
85 | 102 |
System.exit(1); |
86 | 103 |
} |
... | ... | |
88 | 105 |
|
89 | 106 |
/** |
90 | 107 |
* Get all configurations from database. |
108 |
* |
|
91 | 109 |
* @return List of configurations. |
92 | 110 |
*/ |
93 | 111 |
@Override |
... | ... | |
104 | 122 |
|
105 | 123 |
/** |
106 | 124 |
* Gets configuration according to its ID |
125 |
* |
|
107 | 126 |
* @param id ID of configuration |
108 | 127 |
* @return configuration by ID |
109 | 128 |
*/ |
... | ... | |
117 | 136 |
|
118 | 137 |
/** |
119 | 138 |
* Saves configuration and its contents into database |
139 |
* |
|
120 | 140 |
* @param newConfiguration configuration to save |
121 |
* @param id id of configuration, if not empty configuration is updated |
|
141 |
* @param id id of configuration, if not empty configuration is updated
|
|
122 | 142 |
* @return saved configuration |
123 | 143 |
*/ |
124 | 144 |
@Override |
125 | 145 |
public Configuration saveConfiguration(Configuration newConfiguration, String id) { |
126 | 146 |
if (id.equals("")) { |
127 | 147 |
return addConfiguration(newConfiguration); |
128 |
} |
|
129 |
else { |
|
148 |
} else { |
|
130 | 149 |
return editConfiguration(newConfiguration, Long.valueOf(id)); |
131 | 150 |
} |
132 | 151 |
} |
133 | 152 |
|
134 | 153 |
/** |
135 | 154 |
* Delete single configuration by id. |
155 |
* |
|
136 | 156 |
* @param id - ID of configuration. |
137 | 157 |
* @return True if deleting was successful, false if not. |
138 | 158 |
*/ |
... | ... | |
149 | 169 |
|
150 | 170 |
/** |
151 | 171 |
* Delete all configurations by assembly id. |
172 |
* |
|
152 | 173 |
* @param assemblyId - ID of assembly. |
153 | 174 |
* @return True if all configurations were successfully deleted, false if not. |
154 | 175 |
*/ |
... | ... | |
172 | 193 |
|
173 | 194 |
/** |
174 | 195 |
* Saves new configuration into database |
196 |
* |
|
175 | 197 |
* @param newConfiguration container with data for a new configuration |
176 | 198 |
* @return saved configuration |
177 | 199 |
*/ |
... | ... | |
229 | 251 |
|
230 | 252 |
/** |
231 | 253 |
* Saves edited configuration with given ID |
254 |
* |
|
232 | 255 |
* @param newConfiguration container with data for edited configuration |
233 |
* @param id ID of edited configuration |
|
256 |
* @param id ID of edited configuration
|
|
234 | 257 |
* @return saved configuration |
235 | 258 |
*/ |
236 | 259 |
private Configuration editConfiguration(Configuration newConfiguration, Long id) { |
... | ... | |
238 | 261 |
configuration.setName(newConfiguration.getName()); |
239 | 262 |
configuration.setTableName(newConfiguration.getTableName()); |
240 | 263 |
|
241 |
for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) { |
|
264 |
for (int i = 0; i < configuration.getParametersInConfiguration().size(); i++) {
|
|
242 | 265 |
ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i); |
243 | 266 |
parameterInConfiguration.setParameterOrder(newConfiguration.getParametersInConfiguration().get(i).getParameterOrder()); |
244 | 267 |
parameterInConfiguration.setOperatorValue(newConfiguration.getParametersInConfiguration().get(i).getOperatorValue()); |
245 |
if(newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null && |
|
268 |
if (newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null &&
|
|
246 | 269 |
!newConfiguration.getParametersInConfiguration().get(i).getColumnName().equals("")) { |
247 | 270 |
parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName()); |
248 | 271 |
} |
249 |
if(newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) { |
|
272 |
if (newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) {
|
|
250 | 273 |
parameterInConfiguration.setLocation(locationRepository.getById( |
251 | 274 |
newConfiguration.getParametersInConfiguration().get(i).getLocation().getId())); |
252 |
} |
|
253 |
else { |
|
275 |
} else { |
|
254 | 276 |
parameterInConfiguration.setLocation(null); |
255 | 277 |
} |
256 |
if(newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) { |
|
278 |
if (newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) {
|
|
257 | 279 |
parameterInConfiguration.setOperator(operatorRepository.getByName( |
258 | 280 |
newConfiguration.getParametersInConfiguration().get(i).getOperator().getName())); |
259 | 281 |
} |
260 |
if(newConfiguration.getParametersInConfiguration().get(i).getFunctions() != null) { |
|
282 |
if (newConfiguration.getParametersInConfiguration().get(i).getFunctions() != null) {
|
|
261 | 283 |
parameterInConfiguration.setFunctions(new ArrayList<>()); |
262 | 284 |
for (Function function : newConfiguration.getParametersInConfiguration().get(i).getFunctions()) { |
263 | 285 |
parameterInConfiguration.getFunctions().add(functionRepository.getByName(function.getName())); |
src/main/java/vldc/aswi/service/ExportManagerImpl.java | ||
---|---|---|
94 | 94 |
|
95 | 95 |
} catch (Exception e) { |
96 | 96 |
System.out.println("pdf export FAILED 1"); |
97 |
e.printStackTrace(); |
|
97 | 98 |
// TODO: print error message - file not created. |
98 | 99 |
} |
99 | 100 |
} |
src/main/java/vldc/aswi/service/RoleManager.java | ||
---|---|---|
26 | 26 |
* @param name name of the role |
27 | 27 |
* @return List of roles. |
28 | 28 |
*/ |
29 |
public Role getRole(String name);
|
|
29 |
Role getRole(String name); |
|
30 | 30 |
} |
src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java | ||
---|---|---|
103 | 103 |
*/ |
104 | 104 |
private void initializeContingencyTableDataLists(List<NameUserName> rowNames, List<NameUserName> columnNames, |
105 | 105 |
List<ValueFunction> valueFunctions, List<ParameterInConfiguration> parametersInConfiguration) { |
106 |
|
|
107 |
// Iterate through every parameterInConfiguration. |
|
106 | 108 |
for (ParameterInConfiguration parameterInConfiguration : parametersInConfiguration) { |
109 |
|
|
110 |
// If parameterInConfiguration is located as ROW. |
|
107 | 111 |
if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Řádek")) { |
112 |
|
|
113 |
// Set column name. |
|
108 | 114 |
if (parameterInConfiguration.getColumnName() != null && !parameterInConfiguration.getColumnName().equals("")) { |
109 | 115 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
110 | 116 |
parameterInConfiguration.getColumnName())); |
... | ... | |
113 | 119 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
114 | 120 |
parameterInConfiguration.getParameter().getName())); |
115 | 121 |
} |
122 |
|
|
123 |
// If parameterInConfiguration is located as COLUMN. |
|
116 | 124 |
} else if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Sloupec")) { |
125 |
|
|
126 |
// Set column name. |
|
117 | 127 |
if (parameterInConfiguration.getColumnName() != null && !parameterInConfiguration.getColumnName().equals("")) { |
118 | 128 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
119 | 129 |
parameterInConfiguration.getColumnName())); |
... | ... | |
122 | 132 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
123 | 133 |
parameterInConfiguration.getParameter().getName())); |
124 | 134 |
} |
135 |
|
|
136 |
// If parameterInConfiguration is located as VALUE. |
|
125 | 137 |
} else if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Hodnota")) { |
138 |
|
|
139 |
// Iterate through all functions in parameterInConfiguration and add it to the list. |
|
126 | 140 |
for (Function function : parameterInConfiguration.getFunctions()) { |
127 | 141 |
valueFunctions.add(new ValueFunction(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
128 | 142 |
parameterInConfiguration.getParameter().getName(), function.getName().toUpperCase(), |
129 | 143 |
parameterInConfiguration.getParameter().getParameterType().getName())); |
130 | 144 |
} |
145 |
|
|
131 | 146 |
if (valueFunctions.size() == 0) { |
132 | 147 |
valueFunctions.add(new ValueFunction(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
133 | 148 |
parameterInConfiguration.getParameter().getName(), "", |
src/main/java/vldc/aswi/service/UserManager.java | ||
---|---|---|
19 | 19 |
* Add new user into database. |
20 | 20 |
* @param username - login username for user. |
21 | 21 |
* @param password - password for user. |
22 |
* @param roleId - Role ID. |
|
22 | 23 |
* @return ID of newly created user. |
23 | 24 |
*/ |
24 | 25 |
Long addUser(String username, String password, Long roleId); |
src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java | ||
---|---|---|
126 | 126 |
} |
127 | 127 |
} |
128 | 128 |
|
129 |
/** |
|
130 |
* Delete parameterInConfiguration from configuration. |
|
131 |
* @param parameterInConfiguration - Parameter in configuration. |
|
132 |
* @return True if parameter was deleted successfully, false if not. |
|
133 |
*/ |
|
129 | 134 |
private boolean deleteParameterInConfiguration(ParameterInConfiguration parameterInConfiguration) { |
130 | 135 |
try { |
131 | 136 |
|
src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java | ||
---|---|---|
11 | 11 |
import vldc.aswi.dao.FunctionRepository; |
12 | 12 |
import vldc.aswi.dao.LocationRepository; |
13 | 13 |
import vldc.aswi.dao.OperatorRepository; |
14 |
import vldc.aswi.dao.parameter.ParameterInConfigurationRepository; |
|
15 | 14 |
import vldc.aswi.dao.parameter.ParameterRepository; |
16 | 15 |
import vldc.aswi.dao.parameter.ParameterTypeRepository; |
17 | 16 |
import vldc.aswi.dao.parameter.ParameterValueRepository; |
18 | 17 |
import vldc.aswi.domain.*; |
19 | 18 |
import vldc.aswi.domain.parameter.Parameter; |
20 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
|
21 | 19 |
import vldc.aswi.domain.parameter.ParameterValue; |
22 | 20 |
|
23 | 21 |
import javax.transaction.Transactional; |
src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java | ||
---|---|---|
9 | 9 |
import org.springframework.stereotype.Service; |
10 | 10 |
import vldc.aswi.dao.parameter.ParameterRepository; |
11 | 11 |
import vldc.aswi.dao.parameter.ParameterValueRepository; |
12 |
import vldc.aswi.domain.parameter.Parameter; |
|
13 | 12 |
import vldc.aswi.domain.parameter.ParameterValue; |
14 | 13 |
|
15 | 14 |
import javax.transaction.Transactional; |
src/main/java/vldc/aswi/utils/AuthControl.java | ||
---|---|---|
25 | 25 |
.map(GrantedAuthority::getAuthority).collect(Collectors.toSet()); |
26 | 26 |
return roles.iterator().next().replace("ROLE_", ""); |
27 | 27 |
} else { |
28 |
// TODO: 04.05.2020 error message, user not authenticated |
|
29 | 28 |
return null; |
30 | 29 |
} |
31 | 30 |
} |
... | ... | |
39 | 38 |
if (!(authentication instanceof AnonymousAuthenticationToken)) { |
40 | 39 |
return authentication.getName(); |
41 | 40 |
} else { |
42 |
// TODO: 04.05.2020 error message, user not authenticated |
|
43 | 41 |
return null; |
44 | 42 |
} |
45 | 43 |
} |
src/main/java/vldc/aswi/utils/Converter.java | ||
---|---|---|
85 | 85 |
long startTime1 = System.nanoTime(); |
86 | 86 |
columnNodes = new ArrayList<>(); |
87 | 87 |
List<List<String>> values = new ArrayList<>(); |
88 |
|
|
89 |
// Add column names into temp list with contingency table. |
|
88 | 90 |
for(NameUserName nameUserName : columnNames) { |
89 | 91 |
TableColumn column = tableColumns.get(nameUserName.getName()); |
90 | 92 |
values.add(getOriginalValuesFromList(column.getValues())); |
91 | 93 |
} |
92 | 94 |
|
95 |
// Generate columns. |
|
93 | 96 |
Node startNode = new Node(); |
94 | 97 |
generateColumns(0, values, columnNodes, startNode); |
95 | 98 |
|
src/main/java/vldc/aswi/utils/ExporterPDF.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.utils; |
2 | 2 |
|
3 |
import be.quodlibet.boxable.BaseTable; |
|
4 | 3 |
import com.lowagie.text.*; |
5 | 4 |
import com.lowagie.text.Font; |
6 | 5 |
import com.lowagie.text.alignment.HorizontalAlignment; |
7 | 6 |
import com.lowagie.text.alignment.VerticalAlignment; |
8 | 7 |
import com.lowagie.text.pdf.PdfWriter; |
9 |
import org.apache.pdfbox.pdmodel.PDPage; |
|
10 |
import org.apache.pdfbox.pdmodel.font.PDType1Font; |
|
11 | 8 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
12 | 9 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRowCell; |
13 | 10 |
|
14 |
import java.awt.*; |
|
15 | 11 |
import java.io.File; |
16 | 12 |
import java.io.FileOutputStream; |
17 | 13 |
import java.util.List; |
... | ... | |
69 | 65 |
doc.close(); |
70 | 66 |
} catch (Exception e) { |
71 | 67 |
|
68 |
System.out.println("PDF export failed."); |
|
72 | 69 |
} |
73 | 70 |
} |
74 | 71 |
|
... | ... | |
159 | 156 |
|
160 | 157 |
return columnCount; |
161 | 158 |
} |
162 |
|
|
163 |
|
|
164 |
public static void exportt(File tmpFile, List<ContingencyTableRow> contingencyTableRows) { |
|
165 |
/* |
|
166 |
//Dummy Table |
|
167 |
float margin = 50; |
|
168 |
|
|
169 |
// starting y position is whole page height subtracted by top and bottom margin |
|
170 |
float yStartNewPage = myPage.getMediaBox().getHeight() - (2 * margin); |
|
171 |
|
|
172 |
// we want table across whole page width (subtracted by left and right margin ofcourse) |
|
173 |
float tableWidth = myPage.getMediaBox().getWidth() - (2 * margin); |
|
174 |
|
|
175 |
boolean drawContent = true; |
|
176 |
float yStart = yStartNewPage; |
|
177 |
float bottomMargin = 70; |
|
178 |
// y position is your coordinate of top left corner of the table |
|
179 |
float yPosition = 550; |
|
180 |
|
|
181 |
BaseTable table = new BaseTable(yPosition, yStartNewPage, bottomMargin, tableWidth, margin, mainDocument, myPage, true, drawContent); |
|
182 |
|
|
183 |
|
|
184 |
Row<PDPage> headerRow = table.createRow(15f); |
|
185 |
Cell<PDPage> cell = headerRow.createCell(100, "Header"); |
|
186 |
table.addHeaderRow(headerRow); |
|
187 |
|
|
188 |
|
|
189 |
Row<PDPage> row = table.createRow(12); |
|
190 |
cell = row.createCell(30, "Data 1"); |
|
191 |
cell = row.createCell(70, "Some value"); |
|
192 |
|
|
193 |
table.draw(); |
|
194 |
|
|
195 |
|
|
196 |
contentStream.close(); |
|
197 |
mainDocument.addPage(myPage); |
|
198 |
mainDocument.save("testfile.pdf"); |
|
199 |
mainDocument.close(); |
|
200 |
*/ |
|
201 |
} |
|
202 | 159 |
} |
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
12 | 12 |
import vldc.aswi.domain.*; |
13 | 13 |
import vldc.aswi.domain.parameter.Parameter; |
14 | 14 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
15 |
import vldc.aswi.domain.parameter.ParameterType; |
|
15 | 16 |
import vldc.aswi.model.ExportType; |
16 | 17 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
17 | 18 |
import vldc.aswi.service.*; |
... | ... | |
130 | 131 |
return new ModelAndView("redirect:/"); |
131 | 132 |
} |
132 | 133 |
|
133 |
Configuration configuration = new Configuration();
|
|
134 |
List<Operator> operatorList = operatorManager.getOperators();
|
|
134 | 135 |
|
136 |
Configuration configuration = new Configuration(); |
|
135 | 137 |
configuration.setAssembly(assembly); |
136 | 138 |
configuration.setTableName(assembly.getName()); |
137 | 139 |
configuration.setParametersInConfiguration(new ArrayList<>()); |
... | ... | |
139 | 141 |
ParameterInConfiguration parameterInConfiguration = new ParameterInConfiguration(); |
140 | 142 |
parameterInConfiguration.setParameter(parameter); |
141 | 143 |
parameterInConfiguration.setConfiguration(configuration); |
142 |
parameterInConfiguration.setOperator(new Operator()); |
|
144 |
|
|
145 |
if (parameter.getParameterType().getName().toLowerCase().equals("výčet")) { |
|
146 |
|
|
147 |
for (Operator operator : operatorList) { |
|
148 |
|
|
149 |
if (operator.getName().toLowerCase().equals("in")) { |
|
150 |
parameterInConfiguration.setOperator(operator); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
} else { |
|
155 |
parameterInConfiguration.setOperator(new Operator()); |
|
156 |
} |
|
143 | 157 |
parameterInConfiguration.setLocation(new Location()); |
144 | 158 |
parameterInConfiguration.setParameterOrder(parameter.getParameterOrder()); |
145 | 159 |
configuration.getParametersInConfiguration().add(parameterInConfiguration); |
src/main/java/vldc/aswi/web/controller/BasicController.java | ||
---|---|---|
22 | 22 |
protected String getFullErrorMessage(BindingResult result) { |
23 | 23 |
String message = ""; |
24 | 24 |
|
25 |
// Iterate through all errors from validating. |
|
25 | 26 |
for (Object object : result.getAllErrors()) { |
27 |
|
|
28 |
// If error is type "FieldError". |
|
26 | 29 |
if (object instanceof FieldError) { |
27 | 30 |
FieldError fieldError = (FieldError) object; |
28 | 31 |
|
... | ... | |
35 | 38 |
continue; |
36 | 39 |
} |
37 | 40 |
|
41 |
// If error is type "ObjectError". |
|
38 | 42 |
if (object instanceof ObjectError) { |
39 | 43 |
ObjectError objectError = (ObjectError) object; |
40 | 44 |
|
src/main/java/vldc/aswi/web/controller/ConfigurationController.java | ||
---|---|---|
8 | 8 |
import org.springframework.web.bind.annotation.*; |
9 | 9 |
import org.springframework.web.servlet.ModelAndView; |
10 | 10 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
11 |
import vldc.aswi.domain.Assembly; |
|
12 |
import vldc.aswi.domain.Configuration; |
|
13 |
import vldc.aswi.domain.Location; |
|
14 |
import vldc.aswi.domain.Operator; |
|
11 |
import vldc.aswi.domain.*; |
|
12 |
import vldc.aswi.domain.parameter.Parameter; |
|
15 | 13 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
14 |
import vldc.aswi.domain.parameter.ParameterValue; |
|
16 | 15 |
import vldc.aswi.model.ExportType; |
17 | 16 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
18 | 17 |
import vldc.aswi.service.*; |
... | ... | |
25 | 24 |
import vldc.aswi.validators.ConfigurationValidator; |
26 | 25 |
|
27 | 26 |
import javax.validation.Valid; |
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Comparator; |
|
30 |
import java.util.List; |
|
27 |
import java.util.*; |
|
31 | 28 |
|
32 | 29 |
/** |
33 | 30 |
* Manager for configuration. |
... | ... | |
102 | 99 |
configuration.setParametersInConfiguration(parametersInConfiguration); |
103 | 100 |
|
104 | 101 |
initializeFields(configuration); |
105 |
|
|
106 | 102 |
modelMap.addAttribute("configuration", configuration); |
107 | 103 |
modelMap.addAttribute("formAction", "/configuration?configurationID=" + configuration.getId()); |
108 | 104 |
|
... | ... | |
124 | 120 |
* @param redirectAttributes Attributes. |
125 | 121 |
* @param saveConfiguration String used to check if save configuration button was clicked. |
126 | 122 |
* @param response HTTP servlet response. |
127 |
* @param request HTTP servlet request. |
|
128 | 123 |
* @return ModelAndView for assembly. |
129 | 124 |
*/ |
130 | 125 |
@PostMapping("/configuration") |
... | ... | |
137 | 132 |
@RequestParam(required=false, value="exportPdf") String exportPdf, |
138 | 133 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration, |
139 | 134 |
RedirectAttributes redirectAttributes, |
140 |
HttpServletRequest request, |
|
141 | 135 |
HttpServletResponse response |
142 | 136 |
) |
143 | 137 |
{ |
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
86 | 86 |
|
87 | 87 |
</div> |
88 | 88 |
<div th:if="${configuration.parametersInConfiguration[__${itemStat.index}__].parameter.parameterType.name.equals('Výčet')}" class="col select-filter"> |
89 |
<select class="mbSelect selectpicker assembly-enum-picker" multiple data-live-search="true" title="Nic nevybráno" >
|
|
90 |
<option th:each="parameterValue : ${configuration.parametersInConfiguration[__${itemStat.index}__].parameter.parameterValues}" th:value="${parameterValue.id}" th:text="${parameterValue.value}">Hodnota 1</option>
|
|
89 |
<select th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].selectedParameterValues}" class="mbSelect selectpicker assembly-enum-picker" multiple data-live-search="true" title="Nic nevybráno">
|
|
90 |
<option th:each="parameterValue : ${configuration.parametersInConfiguration[__${itemStat.index}__].parameter.parameterValues}" th:value="${parameterValue.id}" th:text="${parameterValue.value}"></option> |
|
91 | 91 |
</select> |
92 | 92 |
</div> |
93 | 93 |
</td> |
Také k dispozici: Unified diff
final commit