Revize d90fc9de
Přidáno uživatelem Vojtěch Danišík před téměř 4 roky(ů)
src/main/java/vldc/aswi/web/controller/ConfigurationController.java | ||
---|---|---|
5 | 5 |
import org.springframework.ui.ModelMap; |
6 | 6 |
import org.springframework.validation.BeanPropertyBindingResult; |
7 | 7 |
import org.springframework.validation.BindingResult; |
8 |
import org.springframework.web.bind.WebDataBinder; |
|
9 | 8 |
import org.springframework.web.bind.annotation.*; |
10 | 9 |
import org.springframework.web.servlet.ModelAndView; |
11 | 10 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
... | ... | |
14 | 13 |
import vldc.aswi.domain.Location; |
15 | 14 |
import vldc.aswi.domain.Operator; |
16 | 15 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
16 |
import vldc.aswi.model.ExportType; |
|
17 | 17 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
18 |
import vldc.aswi.service.AssemblyManager; |
|
19 |
import vldc.aswi.service.ConfigurationManager; |
|
20 |
import vldc.aswi.service.LocationManager; |
|
21 |
import vldc.aswi.service.SqlQueryManager; |
|
18 |
import vldc.aswi.service.*; |
|
22 | 19 |
import vldc.aswi.service.parameter.ParameterManager; |
23 | 20 |
import vldc.aswi.utils.AuthControl; |
24 | 21 |
import vldc.aswi.utils.Utils; |
25 |
import vldc.aswi.validators.AssemblyValidator; |
|
22 |
|
|
23 |
import javax.servlet.http.HttpServletRequest; |
|
24 |
import javax.servlet.http.HttpServletResponse; |
|
26 | 25 |
import vldc.aswi.validators.ConfigurationValidator; |
27 | 26 |
|
28 | 27 |
import javax.validation.Valid; |
... | ... | |
48 | 47 |
@Autowired |
49 | 48 |
private SqlQueryManager sqlQueryManager; |
50 | 49 |
|
50 |
/** Autowired export manager. */ |
|
51 |
@Autowired |
|
52 |
private ExportManager exportManager; |
|
53 |
|
|
51 | 54 |
/** Autowired parameter manager. */ |
52 | 55 |
@Autowired |
53 | 56 |
private ParameterManager parameterManager; |
... | ... | |
122 | 125 |
@RequestParam("isNotRemoveEmpty") String isNotRemoveEmptyString, |
123 | 126 |
@RequestParam("configurationID") String id, |
124 | 127 |
@RequestParam(required=false, value="generateTable") String generateTable, |
125 |
@RequestParam(required=false, value="exportXls") String exportXls,
|
|
128 |
@RequestParam(required=false, value="exportXlsx") String exportXlsx,
|
|
126 | 129 |
@RequestParam(required=false, value="exportPdf") String exportPdf, |
127 | 130 |
@RequestParam(required=false, value="saveConfiguration") String saveConfiguration, |
128 |
RedirectAttributes redirectAttributes |
|
131 |
RedirectAttributes redirectAttributes, |
|
132 |
HttpServletRequest request, |
|
133 |
HttpServletResponse response |
|
129 | 134 |
) |
130 | 135 |
{ |
131 | 136 |
ModelAndView modelAndView = new ModelAndView(); |
132 | 137 |
ModelMap modelMap = modelAndView.getModelMap(); |
138 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
133 | 139 |
|
134 | 140 |
if (bindingResult.hasErrors()) { |
135 | 141 |
// TODO: 04.05.2020 Error message |
... | ... | |
150 | 156 |
modelMap.addAttribute(assemblyTitleName, generateTableTitleText + " " + newConfiguration.getName()); |
151 | 157 |
} |
152 | 158 |
else { |
153 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
154 | 159 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration.getAssembly(), |
155 | 160 |
newConfiguration.getParametersInConfiguration(), isNotRemoveEmpty); |
156 |
System.out.println("Generuj tabulku"); |
|
161 |
|
|
157 | 162 |
modelMap.addAttribute("configurationID", id); |
158 | 163 |
modelMap.addAttribute("contingencyTableRows", rows); |
159 | 164 |
addConfigurationDataIntoModelAndView(newConfiguration, modelAndView, modelMap); |
160 | 165 |
} |
161 | 166 |
} |
162 |
else if (exportXls != null) |
|
167 |
else if (exportXlsx != null)
|
|
163 | 168 |
{ |
164 |
System.out.println("Generuj XLS"); |
|
169 |
prepareForTable(newConfiguration); |
|
170 |
this.exportManager.exportContingencyTable(newConfiguration, isNotRemoveEmpty, response, ExportType.XLSX); |
|
171 |
|
|
172 |
// Return null, because we want to continue on our page with selected parameters / attributes. |
|
173 |
return null; |
|
165 | 174 |
} |
166 | 175 |
else if (exportPdf != null) |
167 | 176 |
{ |
168 |
System.out.println("Generuj PDF"); |
|
177 |
prepareForTable(newConfiguration); |
|
178 |
this.exportManager.exportContingencyTable(newConfiguration, isNotRemoveEmpty, response, ExportType.PDF); |
|
179 |
|
|
180 |
// Return null, because we want to continue on our page with selected parameters / attributes. |
|
181 |
return null; |
|
169 | 182 |
} |
170 | 183 |
else if (saveConfiguration != null) |
171 | 184 |
{ |
172 |
System.out.println("ulož konfiguraci"); |
|
173 | 185 |
Configuration configuration = configurationManager.saveConfiguration(newConfiguration, id); |
174 | 186 |
|
175 | 187 |
initializeFields(configuration); |
... | ... | |
265 | 277 |
initializeFields(newConfiguration); |
266 | 278 |
modelMap.addAttribute("configuration", newConfiguration); |
267 | 279 |
modelMap.addAttribute("comparator", comparator); |
268 |
modelMap.addAttribute("formAction", "/assembly?assemblyID=" + newConfiguration.getAssembly().getId());
|
|
280 |
modelMap.addAttribute("formAction", "/configuration?configurationID=" + newConfiguration.getAssembly().getId());
|
|
269 | 281 |
modelAndView.setViewName("assembly"); |
270 | 282 |
} |
271 | 283 |
} |
Také k dispozici: Unified diff
re #8133 #8132 Export contingency table to XLSX + PDF (not fully complete).