Package: CreateContentRequestActionProvider
CreateContentRequestActionProvider
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CreateContentRequestActionProvider(MessageBus, Content) |
|
|
|
|
|
||||||||||||||||||||
getActions() |
|
|
|
|
|
||||||||||||||||||||
publish() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone git@bitbucket.org:tidalwave/northernwind-rca-src.git
7: * %%
8: * Copyright (C) 2013 - 2021 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.rca.ui.contentmanager.impl;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Collection;
31: import java.util.Collections;
32: import it.tidalwave.util.annotation.VisibleForTesting;
33: import it.tidalwave.dci.annotation.DciRole;
34: import it.tidalwave.messagebus.MessageBus;
35: import it.tidalwave.role.ui.Displayable;
36: import it.tidalwave.role.ui.UserAction;
37: import it.tidalwave.role.ui.UserActionProvider;
38: import it.tidalwave.role.ui.spi.DefaultUserActionProvider;
39: import it.tidalwave.northernwind.core.model.Content;
40: import it.tidalwave.northernwind.rca.ui.event.CreateContentRequest;
41: import lombok.RequiredArgsConstructor;
42: import lombok.ToString;
43:
44: /***********************************************************************************************************************
45: *
46: * A {@link UserActionProvider} for {@link Content} that sends a {@link CreateContentRequest} for creating a new
47: * {@code Content} child.
48: *
49: * @stereotype role
50: *
51: * @author Fabrizio Giudici
52: *
53: **********************************************************************************************************************/
54:•@DciRole(datumType = Content.class) @RequiredArgsConstructor @ToString(of = "content")
55: public class CreateContentRequestActionProvider extends DefaultUserActionProvider
56: {
57: @Nonnull
58: private final MessageBus messageBus;
59:
60: @Nonnull
61: private final Content content;
62:
63: @VisibleForTesting final UserAction sendCreateContentRequestAction =
64: UserAction.of(this::publish, Displayable.of("New content"));
65:
66: @Override @Nonnull
67: public Collection<? extends UserAction> getActions()
68: {
69: return Collections.singletonList(sendCreateContentRequestAction);
70: }
71:
72: private void publish()
73: {
74: messageBus.publish(CreateContentRequest.of(content));
75: }
76: }