code cleanup

This commit is contained in:
f43nd1r 2018-07-28 16:21:58 +02:00
parent cdbbdf0d53
commit 5992593d43
5 changed files with 9 additions and 16 deletions

View file

@ -354,7 +354,7 @@ public class DataService implements Serializable {
public <T> Map<T, Long> countReports(@NonNull Predicate where, @NonNull Expression<T> select) { public <T> Map<T, Long> countReports(@NonNull Predicate where, @NonNull Expression<T> select) {
List<Tuple> result = ((JPAQuery<?>) new JPAQuery<>(entityManager)).from(report).where(where).groupBy(select).select(select, report.id.count()).fetch(); List<Tuple> result = ((JPAQuery<?>) new JPAQuery<>(entityManager)).from(report).where(where).groupBy(select).select(select, report.id.count()).fetch();
return result.stream().collect(Collectors.toMap(tuple -> tuple.get(select), tuple -> tuple.get(report.id.count()))); return result.stream().collect(Collectors.toMap(tuple -> tuple.get(select), tuple -> Optional.ofNullable(tuple.get(report.id.count())).orElse(0L)));
} }
@NonNull @NonNull

View file

@ -131,9 +131,8 @@ public class BackendUI extends UI {
MenuBar.MenuItem user = menuBar.addItem("", VaadinIcons.USER, null); MenuBar.MenuItem user = menuBar.addItem("", VaadinIcons.USER, null);
user.addItem(SecurityUtils.getUsername()).setEnabled(false); user.addItem(SecurityUtils.getUsername()).setEnabled(false);
user.addSeparator(); user.addSeparator();
MenuBar.MenuItem theme = user.addItem("Dark Theme", e -> { MenuBar.MenuItem theme = user.addItem("Dark Theme",
getPage().setLocation(UriComponentsBuilder.fromUri(getPage().getLocation()).replaceQueryParam(DARK_THEME, e.isChecked()).build().toUri()); e -> getPage().setLocation(UriComponentsBuilder.fromUri(getPage().getLocation()).replaceQueryParam(DARK_THEME, e.isChecked()).build().toUri()));
});
theme.setCheckable(true); theme.setCheckable(true);
theme.setChecked(isDarkTheme()); theme.setChecked(isDarkTheme());
user.addSeparator(); user.addSeparator();
@ -151,9 +150,9 @@ public class BackendUI extends UI {
HorizontalLayout footer = new HorizontalLayout(); HorizontalLayout footer = new HorizontalLayout();
footer.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); footer.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
Label footerLabel = new Label("Acrarium is developed by <a href=https://github.com/F43nd1r>F43nd1r</a>." Label footerLabel = new Label(
+ " <a href=https://github.com/F43nd1r/acra-backend>Code</a> is licensed under" "Acrarium is developed by <a href=https://github.com/F43nd1r>F43nd1r</a>." + " <a href=https://github.com/F43nd1r/acra-backend>Code</a> is licensed under"
+ " <a href=https://github.com/F43nd1r/acra-backend/blob/master/LICENSE>Apache License v2</a>.", ContentMode.HTML); + " <a href=https://github.com/F43nd1r/acra-backend/blob/master/LICENSE>Apache License v2</a>.", ContentMode.HTML);
footerLabel.setWidth(100, Unit.PERCENTAGE); footerLabel.setWidth(100, Unit.PERCENTAGE);
footerLabel.addStyleName(AcraTheme.CENTER_TEXT); footerLabel.addStyleName(AcraTheme.CENTER_TEXT);
footer.addComponent(footerLabel); footer.addComponent(footerLabel);

View file

@ -34,7 +34,6 @@ import java.util.Arrays;
import java.util.Deque; import java.util.Deque;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @author Lukas * @author Lukas
@ -108,7 +107,7 @@ public class MyNavigator extends SpringNavigator {
fragmentIndex = size; fragmentIndex = size;
do { do {
fragmentIndex--; fragmentIndex--;
newNavState = fragments.subList(fragmentIndex, size).stream().collect(Collectors.joining(SEPARATOR)); newNavState = String.join(SEPARATOR, fragments.subList(fragmentIndex, size));
viewProvider = getViewProvider(newNavState); viewProvider = getViewProvider(newNavState);
} while (fragmentIndex > 0 && viewProvider == null); } while (fragmentIndex > 0 && viewProvider == null);
if (viewProvider != null) return new HierarchyElement(newNavState, viewProvider); if (viewProvider != null) return new HierarchyElement(newNavState, viewProvider);

View file

@ -83,9 +83,8 @@ public abstract class SingleViewProvider<V extends BaseView> implements ViewProv
if (params.isEmpty() || params.charAt(0) == MyNavigator.SEPARATOR_CHAR && isValidParameter(params.substring(1))) { if (params.isEmpty() || params.charAt(0) == MyNavigator.SEPARATOR_CHAR && isValidParameter(params.substring(1))) {
RequiresRole annotation = getClazz().getAnnotation(RequiresRole.class); RequiresRole annotation = getClazz().getAnnotation(RequiresRole.class);
if (annotation == null || SecurityUtils.hasRole(annotation.value())) { if (annotation == null || SecurityUtils.hasRole(annotation.value())) {
if (((BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory()).getBeanDefinition(applicationContext.getBeanNamesForType(getClazz())[0]) if (ViewScopeImpl.VAADIN_VIEW_SCOPE_NAME.equals(((BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory()).getBeanDefinition(
.getScope() applicationContext.getBeanNamesForType(getClazz())[0]).getScope())) {
.equals(ViewScopeImpl.VAADIN_VIEW_SCOPE_NAME)) {
final ViewCache viewCache = ViewScopeImpl.getViewCacheRetrievalStrategy().getViewCache(applicationContext); final ViewCache viewCache = ViewScopeImpl.getViewCacheRetrievalStrategy().getViewCache(applicationContext);
viewCache.creatingView(viewName); viewCache.creatingView(viewName);
try { try {

View file

@ -81,10 +81,6 @@ public class ChangePasswordView extends BaseView {
setCompositionRoot(root); setCompositionRoot(root);
} }
public boolean validate(@Nullable String fragment) {
return true;
}
@SpringComponent @SpringComponent
@UIScope @UIScope
public static class Provider extends SingleViewProvider<ChangePasswordView> { public static class Provider extends SingleViewProvider<ChangePasswordView> {