Revize b66f682e
Přidáno uživatelem Michal Linha před téměř 5 roky(ů)
src/main/java/vldc/aswi/service/ConfigurationManager.java | ||
---|---|---|
15 | 15 |
* @return List of configurations. |
16 | 16 |
*/ |
17 | 17 |
List<Configuration> getConfigurations(); |
18 |
|
|
19 |
Configuration getConfigurationById(Long id); |
|
18 | 20 |
} |
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
7 | 7 |
import org.springframework.core.annotation.Order; |
8 | 8 |
import org.springframework.stereotype.Service; |
9 | 9 |
import vldc.aswi.dao.ConfigurationRepository; |
10 |
import vldc.aswi.domain.Assembly; |
|
10 | 11 |
import vldc.aswi.domain.Configuration; |
11 | 12 |
|
12 | 13 |
import javax.transaction.Transactional; |
... | ... | |
47 | 48 |
this.configurationRepository.findAll().forEach(retVal::add); |
48 | 49 |
return retVal; |
49 | 50 |
} |
51 |
|
|
52 |
@Override |
|
53 |
public Configuration getConfigurationById(Long id) { |
|
54 |
return configurationRepository.getById(id); |
|
55 |
} |
|
50 | 56 |
} |
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
10 | 10 |
import org.springframework.web.servlet.ModelAndView; |
11 | 11 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
12 | 12 |
import vldc.aswi.domain.Assembly; |
13 |
import vldc.aswi.domain.Configuration; |
|
13 | 14 |
import vldc.aswi.service.AssemblyManager; |
15 |
import vldc.aswi.service.ConfigurationManager; |
|
14 | 16 |
import vldc.aswi.service.SqlQueryManager; |
15 | 17 |
|
16 | 18 |
import javax.validation.Valid; |
... | ... | |
24 | 26 |
@Autowired |
25 | 27 |
private AssemblyManager assemblyManager; |
26 | 28 |
|
29 |
@Autowired |
|
30 |
private ConfigurationManager configurationManager; |
|
31 |
|
|
27 | 32 |
@GetMapping("/assembly") |
28 | 33 |
public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) { |
29 | 34 |
ModelAndView modelAndView = new ModelAndView("assembly"); |
... | ... | |
32 | 37 |
|
33 | 38 |
Assembly assembly = assemblyManager.getAssemblyById(Long.parseLong(id)); |
34 | 39 |
|
35 |
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies()); |
|
36 |
modelMap.addAttribute("assembly", assembly); |
|
40 |
Configuration configuration = new Configuration(); |
|
41 |
|
|
42 |
configuration.setAssembly(assembly); |
|
43 |
|
|
44 |
modelMap.addAttribute("configuration", configuration); |
|
45 |
modelMap.addAttribute("assemblyID", id); |
|
37 | 46 |
|
38 | 47 |
return modelAndView; |
39 | 48 |
} |
40 | 49 |
|
50 |
@GetMapping("/assembly") |
|
51 |
public ModelAndView configurationIndex(@Valid @ModelAttribute("assemblyID") String id) { |
|
52 |
ModelAndView modelAndView = new ModelAndView("assembly"); |
|
53 |
|
|
54 |
ModelMap modelMap = modelAndView.getModelMap(); |
|
55 |
|
|
56 |
Configuration configuration = configurationManager.getConfigurationById(Long.parseLong(id)); |
|
57 |
|
|
58 |
modelMap.addAttribute("configuration", configuration); |
|
59 |
modelMap.addAttribute("assemblyID", configuration.getAssembly().getId()); |
|
60 |
|
|
61 |
return modelAndView; |
|
62 |
} |
|
41 | 63 |
|
42 | 64 |
@PostMapping("/assembly") |
43 | 65 |
public ModelAndView indexPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) { |
src/main/java/vldc/aswi/web/controller/IndexController.java | ||
---|---|---|
9 | 9 |
import org.springframework.web.servlet.ModelAndView; |
10 | 10 |
import vldc.aswi.database.DatabaseInterface; |
11 | 11 |
import vldc.aswi.domain.Assembly; |
12 |
import vldc.aswi.domain.parameter.Parameter; |
|
12 | 13 |
import vldc.aswi.model.table.TableColumn; |
13 | 14 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
14 | 15 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRowCell; |
... | ... | |
37 | 38 |
|
38 | 39 |
ModelMap modelMap = modelAndView.getModelMap(); |
39 | 40 |
|
40 |
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies()); |
|
41 |
List<Assembly> assemblies = assemblyManager.getAssemblies(); |
|
42 |
|
|
43 |
List<String> attributes = new ArrayList<>(); |
|
44 |
for(Assembly assembly : assemblies) { |
|
45 |
int i = 0; |
|
46 |
StringBuilder stringBuilder = new StringBuilder(""); |
|
47 |
for(Parameter parameter : assembly.getParameters()) { |
|
48 |
stringBuilder.append(parameter.getName()); |
|
49 |
i++; |
|
50 |
if(i == 3) { |
|
51 |
stringBuilder.append(",..."); |
|
52 |
break; |
|
53 |
} |
|
54 |
else if(i == assembly.getParameters().size()) { |
|
55 |
break; |
|
56 |
} |
|
57 |
else { |
|
58 |
stringBuilder.append(", "); |
|
59 |
} |
|
60 |
} |
|
61 |
attributes.add(stringBuilder.toString()); |
|
62 |
} |
|
63 |
|
|
64 |
modelMap.addAttribute("assemblies", assemblies); |
|
65 |
modelMap.addAttribute("attributes", attributes); |
|
41 | 66 |
|
42 | 67 |
return modelAndView; |
43 | 68 |
} |
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
29 | 29 |
</h1> |
30 | 30 |
</div> |
31 | 31 |
|
32 |
<form th:object="${assembly}" method="post" th:action="@{/assembly(assemblyID=${assembly.id})}">
|
|
32 |
<form th:object="${configuration}" method="post" th:action="@{/assembly(assemblyID=${assemblyID})}">
|
|
33 | 33 |
<input type="hidden" th:field="*{id}" th:value="${assembly?.getId()}" /> |
34 | 34 |
<div class="container box"> |
35 | 35 |
<div class="col-md-12"> |
... | ... | |
49 | 49 |
</tr> |
50 | 50 |
</thead> |
51 | 51 |
<tbody> |
52 |
<tr th:each="parameter, itemStat : ${configuration.parametersInConfiguration}"> |
|
53 |
|
|
54 |
</tr> |
|
52 | 55 |
<tr> |
53 | 56 |
<td><span class="select-text-padding">Akademický rok</span></td> |
54 | 57 |
<td> |
src/main/webapp/WEB-INF/templates/index.html | ||
---|---|---|
70 | 70 |
</tr> |
71 | 71 |
</thead> |
72 | 72 |
<tbody> |
73 |
<tr th:each="iassembly : ${assemblies}"> |
|
73 |
<tr th:each="iassembly, itemStat : ${assemblies}">
|
|
74 | 74 |
<div> |
75 | 75 |
<td><a th:href="@{/assembly(assemblyID=${iassembly.id})}"><span th:text="${iassembly.name}"></span></a></td> |
76 |
<td>Akademický rok, Fakulta, Typ strudia, Ročník, ...</td>
|
|
76 |
<td th:text="${attributes[__${itemStat.index}__]}"></td>
|
|
77 | 77 |
<td> |
78 | 78 |
<div class="action-wrapper"> |
79 | 79 |
<span class="action-button"> |
Také k dispozici: Unified diff
re #7881 loading of attributes of assembly on main page