190 |
190 |
191 if (db.getDataSource().isPresent()) { |
191 if (db.getDataSource().isPresent()) { |
192 try (Connection conn = db.getDataSource().get().getConnection()) { |
192 try (Connection conn = db.getDataSource().get().getConnection()) { |
193 final ModuleDao dao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); |
193 final ModuleDao dao = CoreDAOFactory.getModuleDao(db.getSQLDialect()); |
194 final List<Module> modules = dao.listAll(conn); |
194 final List<Module> modules = dao.listAll(conn); |
195 |
195 |
196 final List<Menu> menu = modules |
196 return modules |
197 .stream() |
197 .stream() |
198 .filter((mod) -> mod.isVisible()) |
198 .filter(Module::isVisible) |
199 .collect(Collectors.mapping( |
199 .sorted(new Module.PriorityComparator()) |
200 (mod) -> new Menu( |
200 .map(mod -> new Menu( |
201 mod.getClassname(), |
201 mod.getClassname(), |
202 new ResourceKey( |
202 new ResourceKey( |
203 registeredModules.get(mod.getClassname()).bundleBaseName(), |
203 registeredModules.get(mod.getClassname()).bundleBaseName(), |
204 registeredModules.get(mod.getClassname()).menuKey()), |
204 registeredModules.get(mod.getClassname()).menuKey()), |
205 registeredModules.get(mod.getClassname()).modulePath()), |
205 registeredModules.get(mod.getClassname()).modulePath())) |
206 Collectors.toList()) |
206 .collect(Collectors.toList()); |
207 ); |
|
208 return menu; |
|
209 } catch (SQLException ex) { |
207 } catch (SQLException ex) { |
210 LOG.error("Unexpected SQLException when loading the main menu", ex); |
208 LOG.error("Unexpected SQLException when loading the main menu", ex); |
211 return Collections.emptyList(); |
209 return Collections.emptyList(); |
212 } |
210 } |
213 } else { |
211 } else { |