Revize d90fc9de
Přidáno uživatelem Vojtěch Danišík před téměř 4 roky(ů)
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.model.table.BooleanWrapper;
|
|
15 |
import vldc.aswi.model.ExportType;
|
|
16 | 16 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
17 | 17 |
import vldc.aswi.service.*; |
18 | 18 |
import vldc.aswi.service.parameter.ParameterManager; |
... | ... | |
21 | 21 |
import vldc.aswi.validators.AssemblyValidator; |
22 | 22 |
import vldc.aswi.utils.Utils; |
23 | 23 |
import vldc.aswi.validators.ConfigurationValidator; |
24 |
|
|
24 |
import javax.servlet.http.HttpServletResponse; |
|
25 | 25 |
import javax.validation.Valid; |
26 |
import java.util.*; |
|
27 |
import java.util.stream.Collectors; |
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Comparator; |
|
28 |
import java.util.List; |
|
28 | 29 |
|
29 | 30 |
/** |
30 | 31 |
* Controller for assemblies and configurations |
... | ... | |
44 | 45 |
@Autowired |
45 | 46 |
private ParameterManager parameterManager; |
46 | 47 |
|
48 |
/** Autowired export manager. */ |
|
49 |
@Autowired |
|
50 |
private ExportManager exportManager; |
|
51 |
|
|
47 | 52 |
/** Autowired configuration manager */ |
48 | 53 |
@Autowired |
49 | 54 |
private ConfigurationManager configurationManager; |
... | ... | |
151 | 156 |
return modelAndView; |
152 | 157 |
} |
153 | 158 |
|
154 |
|
|
155 | 159 |
/** |
156 | 160 |
* Post method for form, where configuration is created from assembly. |
157 | 161 |
* @param newConfiguration - Configuration values. |
158 | 162 |
* @param bindingResult - Error results from assembly validators. |
159 |
* @param atts - Redirect attributes. |
|
160 | 163 |
* @return ModelAndView for assembly. |
161 | 164 |
*/ |
162 | 165 |
@PostMapping("/assembly") |
... | ... | |
166 | 169 |
@RequestParam("isNotRemoveEmpty") String isNotRemoveEmptyString, |
167 | 170 |
@RequestParam("assemblyID") String id, |
168 | 171 |
@RequestParam(required=false, value="generateTable") String generateTable, |
169 |
@RequestParam(required=false, value="exportXls") String exportXls,
|
|
172 |
@RequestParam(required=false, value="exportXlsx") String exportXlsx,
|
|
170 | 173 |
@RequestParam(required=false, value="exportPdf") String exportPdf, |
171 | 174 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration, |
172 |
RedirectAttributes redirectAttributes) |
|
175 |
RedirectAttributes redirectAttributes, |
|
176 |
HttpServletResponse response |
|
177 |
) |
|
173 | 178 |
{ |
174 | 179 |
|
175 | 180 |
ModelAndView modelAndView = new ModelAndView(); |
176 | 181 |
ModelMap modelMap = modelAndView.getModelMap(); |
182 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
177 | 183 |
|
178 | 184 |
if (bindingResult.hasErrors()) { |
179 | 185 |
// TODO: 04.05.2020 Error message |
... | ... | |
193 | 199 |
newConfiguration.setName(assembly.getName()); |
194 | 200 |
} |
195 | 201 |
|
196 |
System.out.println("Generuj tabulku"); |
|
197 | 202 |
prepareForTable(newConfiguration); |
198 | 203 |
BindingResult errors = new BeanPropertyBindingResult(newConfiguration, newConfiguration.getClass().getName()); |
199 | 204 |
configurationValidator.validate(newConfiguration, errors); |
... | ... | |
204 | 209 |
modelMap.addAttribute(assemblyTitleName, generateTableTitleText + " " + newConfiguration.getName()); |
205 | 210 |
} |
206 | 211 |
else { |
207 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
208 | 212 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration.getAssembly(), |
209 | 213 |
newConfiguration.getParametersInConfiguration(), isNotRemoveEmpty); |
210 | 214 |
|
211 |
System.out.println("Generuj tabulku"); |
|
212 | 215 |
modelMap.addAttribute("configurationID", id); |
213 | 216 |
modelMap.addAttribute("contingencyTableRows", rows); |
214 | 217 |
modelMap.addAttribute("isNotRemoveEmpty", isNotRemoveEmpty); |
215 | 218 |
addConfigurationDataIntoModelAndView(newConfiguration, modelAndView, modelMap); |
216 | 219 |
} |
217 | 220 |
} |
218 |
else if (exportXls != null) |
|
221 |
else if (exportXlsx != null)
|
|
219 | 222 |
{ |
220 |
System.out.println("Generuj XLS"); |
|
223 |
prepareForTable(newConfiguration); |
|
224 |
this.exportManager.exportContingencyTable(newConfiguration, isNotRemoveEmpty, response, ExportType.XLSX); |
|
225 |
|
|
226 |
// Return null, because we want to continue on our page with selected parameters / attributes. |
|
227 |
return null; |
|
221 | 228 |
} |
222 | 229 |
else if (exportPdf != null) |
223 | 230 |
{ |
224 |
System.out.println("Generuj PDF"); |
|
231 |
prepareForTable(newConfiguration); |
|
232 |
this.exportManager.exportContingencyTable(newConfiguration, isNotRemoveEmpty, response, ExportType.PDF); |
|
233 |
|
|
234 |
// Return null, because we want to continue on our page with selected parameters / attributes. |
|
235 |
return null; |
|
236 |
|
|
225 | 237 |
} |
226 | 238 |
else if (saveConfiguration != null) |
227 | 239 |
{ |
228 |
System.out.println("ulož konfiguraci"); |
|
229 |
|
|
230 | 240 |
Configuration configuration = configurationManager.saveConfiguration(newConfiguration, ""); |
231 | 241 |
|
232 | 242 |
initializeFields(configuration); |
... | ... | |
237 | 247 |
} |
238 | 248 |
|
239 | 249 |
return modelAndView; |
240 |
/* |
|
241 |
ModelMap modelMap = modelAndView.getModelMap(); |
|
242 |
|
|
243 |
long assemblyID = assembly.getId(); |
|
244 |
System.out.println(assemblyID); |
|
245 |
|
|
246 |
Assembly assembly2 = this.assemblyManager.getAssemblyById(assemblyID); |
|
247 |
|
|
248 |
modelMap.addAttribute("assemblies", this.assemblyManager.getAssemblies()); |
|
249 |
modelMap.addAttribute("assembly", assembly2); |
|
250 |
modelMap.addAttribute("contingencyTableRows", this.sqlQueryManager.getContingencyTableRow(assembly2.getSQLQuery())); |
|
251 |
|
|
252 |
return modelAndView; |
|
253 |
|
|
254 |
*/ |
|
255 | 250 |
} |
256 | 251 |
|
257 | 252 |
/** |
Také k dispozici: Unified diff
re #8133 #8132 Export contingency table to XLSX + PDF (not fully complete).