Skip to content

Commit 43576f2

Browse files
Merge pull request #15 from dynamiatools/3.x
Upgrade to DynamiaTools v5.4.1
2 parents c3d98ed + 4af190d commit 43576f2

File tree

9 files changed

+136
-17
lines changed

9 files changed

+136
-17
lines changed

sources/api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
<parent>
2727
<groupId>tools.dynamia.modules</groupId>
2828
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
29-
<version>3.4.1</version>
29+
<version>3.4.2</version>
3030
</parent>
3131
<artifactId>tools.dynamia.modules.saas.api</artifactId>
3232

3333
<name>DynamiaModules - SaaS API</name>
3434
<url>https://www.dynamia.tools/modules/saas</url>
35-
<version>3.4.1</version>
35+
<version>3.4.2</version>
3636

3737
<build>
3838
<plugins>

sources/core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
<parent>
2323
<groupId>tools.dynamia.modules</groupId>
2424
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
25-
<version>3.4.1</version>
25+
<version>3.4.2</version>
2626
</parent>
2727
<artifactId>tools.dynamia.modules.saas</artifactId>
28-
<version>3.4.1</version>
28+
<version>3.4.2</version>
2929
<name>DynamiaModules - SaaS Core</name>
3030
<url>https://www.dynamia.tools/modules/saas</url>
3131

@@ -49,12 +49,12 @@
4949
<dependency>
5050
<groupId>tools.dynamia.modules</groupId>
5151
<artifactId>tools.dynamia.modules.saas.api</artifactId>
52-
<version>3.4.1</version>
52+
<version>3.4.2</version>
5353
</dependency>
5454
<dependency>
5555
<groupId>tools.dynamia.modules</groupId>
5656
<artifactId>tools.dynamia.modules.saas.jpa</artifactId>
57-
<version>3.4.1</version>
57+
<version>3.4.2</version>
5858
</dependency>
5959
<dependency>
6060
<groupId>junit</groupId>

sources/core/src/main/java/tools/dynamia/modules/saas/AccountLocaleProvider.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,40 @@
2424

2525
import java.util.Locale;
2626

27+
/**
28+
* AccountLocaleProvider is an implementation of {@link LocaleProvider} for SaaS environments.
29+
* <p>
30+
* Provides the default {@link Locale} based on the current account session context.
31+
* The priority for this provider is set to 10, making it suitable for account-level locale resolution.
32+
* <p>
33+
* If the account session or locale cannot be resolved, this provider returns null.
34+
*
35+
* @author Mario
36+
*/
2737
@Provider
2838
public class AccountLocaleProvider implements LocaleProvider {
29-
39+
/**
40+
* Logger for this provider, using SLF4J.
41+
*/
3042
private final LoggingService logger = new SLF4JLoggingService(AccountLocaleProvider.class);
3143

44+
/**
45+
* Returns the priority of this provider. Lower values indicate higher priority.
46+
*
47+
* @return the priority value (10)
48+
*/
3249
@Override
3350
public int getPriority() {
3451
return 10;
3552
}
3653

54+
/**
55+
* Returns the default {@link Locale} for the current account session.
56+
* <p>
57+
* Attempts to retrieve the account locale from the current session. If unavailable, returns null.
58+
*
59+
* @return the account's default Locale, or null if not available
60+
*/
3761
@Override
3862
public Locale getDefaultLocale() {
3963
try {

sources/core/src/main/java/tools/dynamia/modules/saas/AccountSessionHolder.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import tools.dynamia.modules.saas.services.AccountService;
3232

3333
import java.io.Serializable;
34+
import java.time.ZoneId;
3435
import java.util.Locale;
3536

3637
/**
@@ -45,6 +46,7 @@ public class AccountSessionHolder implements Serializable {
4546
private transient AccountService service;
4647

4748
private Locale accountLocale;
49+
private ZoneId accountTimeZone;
4850
private Long currentId;
4951
private AccountDTO currentDTO;
5052

@@ -82,7 +84,8 @@ public void setCurrent(final Account account) {
8284
try {
8385
DomainUtils.lookupCrudService().executeWithinTransaction(() -> {
8486
var current = getService().getAccountById(account.getId());
85-
accountLocale = current.getLocale() != null ? Locale.forLanguageTag(current.getLocale()) : null;
87+
loadAccountLocale(current);
88+
loadAccountTimeZone(current);
8689
currentId = current.getId();
8790
currentDTO = current.toDTO();
8891
});
@@ -92,6 +95,22 @@ public void setCurrent(final Account account) {
9295
}
9396
}
9497

98+
private void loadAccountTimeZone(Account current) {
99+
try {
100+
accountTimeZone = current.getTimeZone() != null ? ZoneId.of(current.getTimeZone()) : null;
101+
} catch (Exception e) {
102+
accountTimeZone = null;
103+
}
104+
}
105+
106+
private void loadAccountLocale(Account current) {
107+
try {
108+
accountLocale = current.getLocale() != null ? Locale.forLanguageTag(current.getLocale()) : null;
109+
} catch (Exception e) {
110+
accountLocale = null;
111+
}
112+
}
113+
95114

96115
public AccountDTO toDTO() {
97116
return currentDTO;
@@ -114,4 +133,11 @@ private AccountService getService() {
114133
}
115134
return service;
116135
}
136+
137+
public ZoneId getAccountTimeZone() {
138+
if (accountTimeZone == null) {
139+
accountTimeZone = ZoneId.systemDefault();
140+
}
141+
return accountTimeZone;
142+
}
117143
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (C) 2023 Dynamia Soluciones IT S.A.S - NIT 900302344-1
3+
* Colombia / South America
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package tools.dynamia.modules.saas;
19+
20+
import tools.dynamia.commons.TimeZoneProvider;
21+
import tools.dynamia.commons.logger.LoggingService;
22+
import tools.dynamia.commons.logger.SLF4JLoggingService;
23+
import tools.dynamia.integration.sterotypes.Provider;
24+
25+
import java.time.ZoneId;
26+
27+
/**
28+
* AccountTimeZoneProvider is an implementation of {@link TimeZoneProvider} for SaaS environments.
29+
* <p>
30+
* Provides the default {@link ZoneId} based on the current account session context.
31+
* The priority for this provider is set to 10, making it suitable for account-level time zone resolution.
32+
* <p>
33+
* If the account session or time zone cannot be resolved, this provider returns null.
34+
*
35+
* @author Mario
36+
*/
37+
@Provider
38+
public class AccountTimeZoneProvider implements TimeZoneProvider {
39+
/**
40+
* Logger for this provider, using SLF4J.
41+
*/
42+
private final LoggingService logger = new SLF4JLoggingService(AccountTimeZoneProvider.class);
43+
44+
/**
45+
* Returns the priority of this provider. Lower values indicate higher priority.
46+
*
47+
* @return the priority value (10)
48+
*/
49+
@Override
50+
public int getPriority() {
51+
return 10;
52+
}
53+
54+
/**
55+
* Returns the default {@link ZoneId} for the current account session.
56+
* <p>
57+
* Attempts to retrieve the account time zone from the current session. If unavailable, returns null.
58+
*
59+
* @return the account's default ZoneId, or null if not available
60+
*/
61+
@Override
62+
public ZoneId getDefaultTimeZone() {
63+
try {
64+
return AccountSessionHolder.get().getAccountTimeZone();
65+
} catch (Exception e) {
66+
return null;
67+
}
68+
}
69+
}

sources/jpa/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
2424
<groupId>tools.dynamia.modules</groupId>
25-
<version>3.4.1</version>
25+
<version>3.4.2</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828
<name>DynamiaModules - SaaS JPA</name>
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>tools.dynamia.modules</groupId>
3535
<artifactId>tools.dynamia.modules.saas.api</artifactId>
36-
<version>3.4.1</version>
36+
<version>3.4.2</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>tools.dynamia</groupId>

sources/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<modelVersion>4.0.0</modelVersion>
2222
<groupId>tools.dynamia.modules</groupId>
2323
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
24-
<version>3.4.1</version>
24+
<version>3.4.2</version>
2525
<packaging>pom</packaging>
2626
<name>DynamiaModules - SaaS</name>
2727
<description>DynamiaTools extension to create SaaS applications with accounts control and multi tenants in same
@@ -59,7 +59,7 @@
5959
</scm>
6060

6161
<properties>
62-
<dynamiatools.version>5.4.0</dynamiatools.version>
62+
<dynamiatools.version>5.4.1</dynamiatools.version>
6363
<entityfiles.version>7.4.0</entityfiles.version>
6464
<java.version>21</java.version>
6565
<maven.compiler>3.14.0</maven.compiler>
@@ -68,7 +68,7 @@
6868

6969
<oshi.version>6.5.0</oshi.version>
7070
<jna.version>5.14.0</jna.version>
71-
<springboot.version>3.5.3</springboot.version>
71+
<springboot.version>3.5.5</springboot.version>
7272
</properties>
7373

7474
<modules>

sources/remote/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
2424
<groupId>tools.dynamia.modules</groupId>
25-
<version>3.4.1</version>
25+
<version>3.4.2</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

@@ -35,7 +35,7 @@
3535
<dependency>
3636
<groupId>tools.dynamia.modules</groupId>
3737
<artifactId>tools.dynamia.modules.saas.jpa</artifactId>
38-
<version>3.4.1</version>
38+
<version>3.4.2</version>
3939
</dependency>
4040
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
4141
<dependency>

sources/ui/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
<parent>
2323
<groupId>tools.dynamia.modules</groupId>
2424
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
25-
<version>3.4.1</version>
25+
<version>3.4.2</version>
2626
</parent>
2727
<artifactId>tools.dynamia.modules.saas.ui</artifactId>
28-
<version>3.4.1</version>
28+
<version>3.4.2</version>
2929
<name>DynamiaModules - SaaS UI</name>
3030
<url>https://www.dynamia.tools/modules/saas</url>
3131

0 commit comments

Comments
 (0)