Skip to content

Commit 2aeca19

Browse files
authored
CUBA 7.2 support (#18)
1 parent 58dd0f4 commit 2aeca19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1045
-501
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ deploy/*
88
modules/*/build/*
99
out
1010
test-run
11-
.idea
11+
.idea
12+
*.DS_Store

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.8.0] - 2020-03-25
8+
9+
### Added
10+
- ability to send message to multiple receivers
11+
- `MessageService.sendMessage(SendMessageEntity sendMessageEntity)` API to send messages to multiple receivers programmatically
12+
13+
### Changed
14+
- Refactored all Screens to CUBA 7 APIs (in case you extended the previously existing screens, make sure you catch up with the new implementation)
15+
- (Breaking!) `MessageService.countUnreadMessagesForCurrentUser()` returns long instead of int
16+
17+
### Dependencies
18+
- CUBA 7.2.x
19+
720
## [0.7.0] - 2020-03-21
821

922
### Added

README.md

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This CUBA component gives users a mailbox for user to user and system to user me
1616

1717
| Platform Version | Add-on Version |
1818
| ---------------- | -------------- |
19+
| 7.2.x | 0.8.x |
1920
| 7.1.x | 0.7.x |
2021
| 7.0.x | 0.6.x |
2122
| 6.10.x | 0.5.x |
@@ -66,34 +67,31 @@ to the system in order to notify the user about something changed in the system.
6667

6768
![user inbox](/img/4-user-inbox.png)
6869

69-
## Sending messages
70+
## Sending Messages
7071

7172
To send messages to a particular user, there are two options available:
7273

7374
* manually sending message to a user
7475
* system messages that are send programmatically
7576

7677

77-
### Send manual messages
78+
### Send Manual Messages
7879

7980
In order to send a message to a particular user, there is a button "Send message" in the users inbox.
8081

8182
This screen allows to manually send a message. A message contains a subject and a body, just like a regular Email.
8283

8384
![send message manually](/img/1-send-message-manually-editor.png)
8485

85-
This feature can sometimes be helpful but oftentimes sending a regular email is not worse.
86-
87-
#### Context-based messages
86+
#### Context-based Messages
8887

8988
Therefore there is another option to send a Message. In this case it is a message that is send through the context of a particular entity.
9089

9190
This is comparable of sending a email with a link that points to a particular customer / order etc. in your application together with the information from the sender.
9291

9392
![share entities overview](/img/3-share-entities-overview.gif)
9493

95-
96-
##### Share entity instances (CUBA 6 Screens)
94+
##### Share Entity Instances (CUBA 6 Screens)
9795

9896
The way to send context-based messages is to use the `@Shareable` annotation for CUBA 6 based screens (AbstractLookup / AbstractEditor).
9997
The annotation is used in any Entity browse / editor screen.
@@ -155,7 +153,7 @@ public class CustomerBrowse extends StandardLookup<Customer> implements WithEnti
155153

156154
This interface will create a button in the buttonsPanel of the table and add the share button after the default CUBA buttons.
157155

158-
### Send system messages (programmatically)
156+
### Send System Messages (programmatically)
159157

160158
The other way to send a message to a user is that the developer defines points in the application, where it is useful to notify some user
161159
about a particular thing happened. This can be various actions, like:
@@ -188,27 +186,58 @@ public interface MessageService {
188186

189187
## Using pre-defined Main Window Screens
190188

191-
This application component comes with two options for the main screens, that can be used in the final application.
192-
193-
* SideMainwindowWithMessages (side-mainwindow-with-messages.xml)
194-
* AppMainWindowWithMessages (mainwindow-with-messages.xml)
189+
This application component comes with multiple options for the main screens, that can be used in the final application.
190+
191+
* UserInboxSideMenuMainScreen (`userInboxSideMenuMainScreen`) (CUBA 7 based Side Menu)
192+
* SideMainwindowWithMessages (`sideMainWindowWithMessages`) (CUBA 6 based Side Menu)
193+
* AppMainWindowWithMessages (`appMainWindowWithMessages`) (CUBA 6 based Main Menu)
195194

196-
One of these two classes can be used as the mainwinow through the following definition in your web-screens.xml:
195+
One of these classes can be used as the main screen via `web-app.properties`:
197196

198197
````
199-
<!-- either the normal mainwindow with messages badge -->
200-
<screen id="mainWindow"
201-
template="de/diedavids/cuba/userinbox/web/screens/mainwindow-with-messages.xml"/>
198+
cuba.web.mainScreenId=appMainWindowWithMessages
199+
````
202200

203-
<!-- or the side menu main window with messages badge -->
204-
<screen id="mainWindow"
205-
template="de/diedavids/cuba/userinbox/web/screens/side-mainwindow-with-messages.xml"/>
201+
### Custom Main Screen
206202

207-
````
203+
In case you are using a custom main screen, the following logic has to be implemented to leverage the menu entry and
204+
the automatic reload of the new messages:
205+
206+
```java
207+
import de.diedavids.cuba.userinbox.web.screens.UserInboxMessageMenuBadge;
208+
209+
public class CustomApplicationMainScreen extends MainScreen {
210+
211+
@Inject
212+
protected SideMenu sideMenu;
213+
@Inject
214+
protected Timer updateCountersTimer;
215+
216+
@Inject
217+
protected UserInboxMessageMenuBadge userInboxMessageMenuBadge;
218+
219+
@Subscribe
220+
protected void onInit(InitEvent event) {
221+
userInboxMessageMenuBadge.initMessagesMenuItem(
222+
sideMenu,
223+
updateCountersTimer,
224+
this
225+
);
226+
}
227+
228+
@Subscribe
229+
protected void onAfterShow(AfterShowEvent event) {
230+
userInboxMessageMenuBadge.updateMessageCounter(sideMenu);
231+
}
232+
233+
@Subscribe("updateCountersTimer")
234+
protected void onUpdateCountersTimerTimerAction(Timer.TimerActionEvent event) {
235+
userInboxMessageMenuBadge.updateMessageCounter(sideMenu);
236+
}
237+
}
238+
```
208239

209-
You can also extend this screens, so that you can add your own (screen-) logic to the mainwindow.
210-
211-
##### Unread Messages Counter in pre-defined Main Window Screens
240+
### Unread Messages Counter in pre-defined Main Window Screens
212241

213242
In order to display the messages that are marked as unread, the main windows will be refreshed in a particular interval.
214243
The logic is the same as the Count script which is available within the [Application Folders](https://doc.cuba-platform.com/manual-6.8/application_folder.html)

build.gradle

Lines changed: 38 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.cubaVersion = '7.1.0'
2+
ext.cubaVersion = '7.2.0'
33
repositories {
44

55
mavenLocal()
@@ -52,12 +52,8 @@ cuba {
5252
tomcat {
5353
dir = "$project.rootDir/deploy/tomcat"
5454
}
55-
ide {
56-
vcs = 'Git'
57-
}
5855
}
5956

60-
6157
subprojects {
6258
apply plugin: 'com.jfrog.bintray'
6359

@@ -100,14 +96,13 @@ subprojects {
10096

10197
dependencies {
10298
appComponent("com.haulmont.cuba:cuba-global:$cubaVersion")
103-
appComponent('de.balvi.cuba.declarativecontrollers:declarativecontrollers-global:0.9.0')
104-
appComponent('de.diedavids.cuba.entitysoftreference:entity-soft-reference-global:0.6.5')
99+
appComponent('de.balvi.cuba.declarativecontrollers:declarativecontrollers-global:0.10.0')
100+
appComponent('de.diedavids.cuba.entitysoftreference:entity-soft-reference-global:0.7.0')
105101

106102
}
107103

108104
def hsql = 'org.hsqldb:hsqldb:2.4.1'
109105

110-
111106
allprojects {
112107
apply plugin: 'net.saliman.cobertura'
113108
}
@@ -144,13 +139,20 @@ configure([globalModule, coreModule, webModule]) {
144139
apply(plugin: 'cuba')
145140

146141
dependencies {
142+
testCompile('org.junit.jupiter:junit-jupiter-api:5.5.2')
143+
testCompile('org.junit.jupiter:junit-jupiter-engine:5.5.2')
144+
testCompile('org.junit.vintage:junit-vintage-engine:5.5.2')
145+
146+
testCompile 'org.mockito:mockito-core:3.2.4'
147+
testCompile 'org.mockito:mockito-junit-jupiter:3.2.4'
147148

148-
testCompile('junit:junit:4.12')
149-
testCompile 'org.assertj:assertj-core:2.9.0'
150149

151150
testCompile('org.spockframework:spock-core:1.2-groovy-2.5')
152151
testCompile('org.springframework:spring-test:4.3.1.RELEASE')
153-
testRuntime "cglib:cglib-nodep:3.2.4"
152+
153+
154+
testCompile("org.assertj:assertj-core:3.11.1")
155+
154156
}
155157

156158
task sourceJar(type: Jar) {
@@ -161,49 +163,30 @@ configure([globalModule, coreModule, webModule]) {
161163
artifacts {
162164
archives sourceJar
163165
}
166+
test {
167+
useJUnitPlatform()
168+
}
164169
}
165170

171+
166172
configure([globalModule, coreModule, webModule]) {
167173
apply(plugin: 'groovy')
168-
apply plugin: 'net.saliman.cobertura'
169-
apply plugin: 'codenarc'
170-
171-
codenarc {
172-
toolVersion = "1.3"
173-
ignoreFailures = false
174-
reportFormat = 'html'
175-
reportsDir = project.file("build/reports/codenarc")
176-
}
177-
178-
codenarcMain {
179-
configFile = rootProject.file("config/codenarc/rulesMain.groovy")
180-
}
181-
codenarcTest {
182-
configFile = rootProject.file("config/codenarc/rulesTests.groovy")
183-
}
184-
185-
186-
cobertura {
187-
coverageFormats = ['html', 'xml']
188-
coverageIgnoreTrivial = true
189-
coverageIgnores = ['org.slf4j.Logger.*']
190-
coverageReportDir = new File("$buildDir/reports/cobertura")
191-
192-
coverageExcludes = [
193-
'.*Enum',
194-
]
195-
}
196-
197-
test.finalizedBy(project.tasks.cobertura)
198-
test.finalizedBy(project.tasks.coberturaCheck)
199174

200175
sourceSets {
201-
main { groovy { srcDirs = ["src"] } }
202-
test { groovy { srcDirs = ["test"] } }
176+
main {
177+
groovy { srcDirs = ["src"] }
178+
java.outputDir = new File(project.buildDir, "classes/main")
179+
groovy.outputDir = new File(project.buildDir, "classes/main")
180+
}
181+
test {
182+
groovy { srcDirs = ["test"] }
183+
java.outputDir = new File(project.buildDir, "classes/test")
184+
groovy.outputDir = new File(project.buildDir, "classes/test")
185+
}
203186
}
204187

205-
sourceSets.main.output.classesDir = new File(project.buildDir, "classes/main")
206-
sourceSets.test.output.classesDir = new File(project.buildDir, "classes/test")
188+
sourceSets.main.output.classesDirs.setFrom(new File(project.buildDir, "classes/main"))
189+
sourceSets.test.output.classesDirs.setFrom(new File(project.buildDir, "classes/test"))
207190

208191
}
209192

@@ -214,6 +197,7 @@ configure(globalModule) {
214197
runtime('org.glassfish.jaxb:jaxb-runtime:2.3.1')
215198
}
216199
}
200+
217201
entitiesEnhancing {
218202
main {
219203
enabled = true
@@ -255,15 +239,8 @@ configure(coreModule) {
255239
testRuntime(hsql)
256240
}
257241

258-
task cleanConf(description: 'Cleans up conf directory') {
259-
doLast {
260-
def dir = new File(cuba.tomcat.dir, "/conf/${modulePrefix}-core")
261-
if (dir.isDirectory()) {
262-
ant.delete(includeemptydirs: true) {
263-
fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
264-
}
265-
}
266-
}
242+
task cleanConf(description: 'Cleans up conf directory', type: Delete) {
243+
delete "$cuba.appHome/${modulePrefix}-core/conf"
267244
}
268245

269246
task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
@@ -296,6 +273,8 @@ configure(webModule) {
296273
dependencies {
297274
compileOnly(servletApi)
298275
compile(globalModule)
276+
277+
testCompile('de.diedavids.sneferu:sneferu:0.2.0')
299278
}
300279

301280
task webArchive(type: Zip) {
@@ -311,23 +290,16 @@ configure(webModule) {
311290
task deployConf(type: Copy) {
312291
from file('src')
313292
include "de/diedavids/cuba/userinbox/**"
314-
into "$cuba.tomcat.dir/conf/${modulePrefix}"
293+
into "$cuba.appHome/${modulePrefix}/conf"
315294
}
316295

317296
task clearMessagesCache(type: CubaClearMessagesCache) {
318297
appName = "${modulePrefix}"
319298
}
320299
deployConf.dependsOn clearMessagesCache
321300

322-
task cleanConf(description: 'Cleans up conf directory') {
323-
doLast {
324-
def dir = new File(cuba.tomcat.dir, "/conf/${modulePrefix}")
325-
if (dir.isDirectory()) {
326-
ant.delete(includeemptydirs: true) {
327-
fileset(dir: dir, includes: '**/*', excludes: 'local.app.properties')
328-
}
329-
}
330-
}
301+
task cleanConf(description: 'Cleans up conf directory', type: Delete) {
302+
delete "$cuba.appHome/${modulePrefix}/conf"
331303
}
332304

333305
task deploy(dependsOn: [assemble, cleanConf], type: CubaDeployment) {
@@ -350,9 +322,9 @@ task restart(dependsOn: ['stop', ":${modulePrefix}-core:deploy", ":${modulePrefi
350322
socket(server: 'localhost', port: '8787')
351323
}
352324
}
353-
start.execute()
354325
}
355326
}
327+
restart.finalizedBy start
356328

357329

358330
clean {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.7.1-SNAPSHOT
1+
version=0.8.0-SNAPSHOT

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
381 KB
Loading
940 KB
Loading

img/2-read-message.png

706 KB
Loading

img/3-share-entities-overview.gif

865 KB
Loading

0 commit comments

Comments
 (0)