Skip to content

Package: DefaultJobEventExplorerPresentationControl

DefaultJobEventExplorerPresentationControl

nameinstructionbranchcomplexitylinemethod
afterPropertiesSet()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
destroy()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
initialize()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
lambda$onProjectSelectedEvent$0(JobEvent)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$onProjectSelectedEvent$1(JobEventSpi)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
onProjectSelectedEvent(ProjectSelectedEvent)
M: 29 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
setBeanFactory(BeanFactory)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueHour: open source accounting
5: * http://tidalwave.it/projects/bluehour
6: *
7: * Copyright (C) 2013 - 2024 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluehour-src
22: * git clone https://github.com/tidalwave-it/bluehour-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.accounting.ui.jobeventexplorer.impl;
27:
28: import javax.annotation.Nonnull;
29: import org.springframework.stereotype.Component;
30: import it.tidalwave.accounting.commons.ProjectSelectedEvent;
31: import it.tidalwave.accounting.model.Project;
32: import it.tidalwave.accounting.model.spi.JobEventSpi;
33: import it.tidalwave.accounting.ui.jobeventexplorer.JobEventExplorerPresentation;
34: import it.tidalwave.accounting.ui.jobeventexplorer.JobEventExplorerPresentationControl;
35: import it.tidalwave.util.annotation.VisibleForTesting;
36: import it.tidalwave.role.ui.Visible;
37: import it.tidalwave.dci.annotation.DciContext;
38: import it.tidalwave.messagebus.MessageBus;
39: import it.tidalwave.messagebus.annotation.ListensTo;
40: import it.tidalwave.messagebus.annotation.SimpleMessageSubscriber;
41: import lombok.RequiredArgsConstructor;
42: import lombok.extern.slf4j.Slf4j;
43: import static java.util.Comparator.*;
44: import static it.tidalwave.util.Parameters.r;
45: import static it.tidalwave.role.ui.Presentable._Presentable_;
46: import static it.tidalwave.role.ui.spi.PresentationModelCollectors.toCompositePresentationModel;
47:
48: /***************************************************************************************************************************************************************
49: *
50: * @author Fabrizio Giudici
51: *
52: **************************************************************************************************************************************************************/
53: @Component @RequiredArgsConstructor @DciContext @SimpleMessageSubscriber @Slf4j
54: public class DefaultJobEventExplorerPresentationControl implements JobEventExplorerPresentationControl
55: {
56: @Nonnull
57: private final MessageBus messageBus;
58:
59: @Nonnull
60: private final JobEventExplorerPresentation presentation;
61:
62: /***********************************************************************************************************************************************************
63: *
64: **********************************************************************************************************************************************************/
65: @Override
66: public void initialize()
67: {
68: log.info("initialize()");
69: }
70:
71: /***********************************************************************************************************************************************************
72: * Reacts to the notification that a {@link Project} has been selected by populating the presentation with
73: * its job events.
74: *
75: * @param event the notification event
76: **********************************************************************************************************************************************************/
77: @VisibleForTesting void onProjectSelectedEvent (@Nonnull @ListensTo final ProjectSelectedEvent event)
78: {
79: log.info("onProjectSelectedEvent({})", event);
80: presentation.populate(event.getProject().findChildren()
81: .stream()
82: .map(jobEvent -> (JobEventSpi)jobEvent)
83: .sorted(comparing(JobEventSpi::getDateTime))
84: .map(jobEvent -> jobEvent.as(_Presentable_).createPresentationModel())
85: .collect(toCompositePresentationModel(r(Visible.INVISIBLE))));
86: }
87: }