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) {
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

View file

@ -131,9 +131,8 @@ public class BackendUI extends UI {
MenuBar.MenuItem user = menuBar.addItem("", VaadinIcons.USER, null);
user.addItem(SecurityUtils.getUsername()).setEnabled(false);
user.addSeparator();
MenuBar.MenuItem theme = user.addItem("Dark Theme", e -> {
getPage().setLocation(UriComponentsBuilder.fromUri(getPage().getLocation()).replaceQueryParam(DARK_THEME, e.isChecked()).build().toUri());
});
MenuBar.MenuItem theme = user.addItem("Dark Theme",
e -> getPage().setLocation(UriComponentsBuilder.fromUri(getPage().getLocation()).replaceQueryParam(DARK_THEME, e.isChecked()).build().toUri()));
theme.setCheckable(true);
theme.setChecked(isDarkTheme());
user.addSeparator();
@ -151,9 +150,9 @@ public class BackendUI extends UI {
HorizontalLayout footer = new HorizontalLayout();
footer.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
Label footerLabel = new Label("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);
Label footerLabel = new Label(
"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);
footerLabel.setWidth(100, Unit.PERCENTAGE);
footerLabel.addStyleName(AcraTheme.CENTER_TEXT);
footer.addComponent(footerLabel);

View file

@ -34,7 +34,6 @@ import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author Lukas
@ -108,7 +107,7 @@ public class MyNavigator extends SpringNavigator {
fragmentIndex = size;
do {
fragmentIndex--;
newNavState = fragments.subList(fragmentIndex, size).stream().collect(Collectors.joining(SEPARATOR));
newNavState = String.join(SEPARATOR, fragments.subList(fragmentIndex, size));
viewProvider = getViewProvider(newNavState);
} while (fragmentIndex > 0 && viewProvider == null);
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))) {
RequiresRole annotation = getClazz().getAnnotation(RequiresRole.class);
if (annotation == null || SecurityUtils.hasRole(annotation.value())) {
if (((BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory()).getBeanDefinition(applicationContext.getBeanNamesForType(getClazz())[0])
.getScope()
.equals(ViewScopeImpl.VAADIN_VIEW_SCOPE_NAME)) {
if (ViewScopeImpl.VAADIN_VIEW_SCOPE_NAME.equals(((BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory()).getBeanDefinition(
applicationContext.getBeanNamesForType(getClazz())[0]).getScope())) {
final ViewCache viewCache = ViewScopeImpl.getViewCacheRetrievalStrategy().getViewCache(applicationContext);
viewCache.creatingView(viewName);
try {

View file

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