Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sources/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
<parent>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>
<artifactId>tools.dynamia.modules.saas.api</artifactId>

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

<build>
<plugins>
Expand Down
8 changes: 4 additions & 4 deletions sources/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<parent>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>
<artifactId>tools.dynamia.modules.saas</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<name>DynamiaModules - SaaS Core</name>
<url>https://www.dynamia.tools/modules/saas</url>

Expand All @@ -49,12 +49,12 @@
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.api</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.jpa</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,40 @@

import java.util.Locale;

/**
* AccountLocaleProvider is an implementation of {@link LocaleProvider} for SaaS environments.
* <p>
* Provides the default {@link Locale} based on the current account session context.
* The priority for this provider is set to 10, making it suitable for account-level locale resolution.
* <p>
* If the account session or locale cannot be resolved, this provider returns null.
*
* @author Mario
*/
@Provider
public class AccountLocaleProvider implements LocaleProvider {

/**
* Logger for this provider, using SLF4J.
*/
private final LoggingService logger = new SLF4JLoggingService(AccountLocaleProvider.class);

/**
* Returns the priority of this provider. Lower values indicate higher priority.
*
* @return the priority value (10)
*/
@Override
public int getPriority() {
return 10;
}

/**
* Returns the default {@link Locale} for the current account session.
* <p>
* Attempts to retrieve the account locale from the current session. If unavailable, returns null.
*
* @return the account's default Locale, or null if not available
*/
@Override
public Locale getDefaultLocale() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import tools.dynamia.modules.saas.services.AccountService;

import java.io.Serializable;
import java.time.ZoneId;
import java.util.Locale;

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

private Locale accountLocale;
private ZoneId accountTimeZone;
private Long currentId;
private AccountDTO currentDTO;

Expand Down Expand Up @@ -82,7 +84,8 @@ public void setCurrent(final Account account) {
try {
DomainUtils.lookupCrudService().executeWithinTransaction(() -> {
var current = getService().getAccountById(account.getId());
accountLocale = current.getLocale() != null ? Locale.forLanguageTag(current.getLocale()) : null;
loadAccountLocale(current);
loadAccountTimeZone(current);
currentId = current.getId();
currentDTO = current.toDTO();
});
Expand All @@ -92,6 +95,22 @@ public void setCurrent(final Account account) {
}
}

private void loadAccountTimeZone(Account current) {
try {
accountTimeZone = current.getTimeZone() != null ? ZoneId.of(current.getTimeZone()) : null;
} catch (Exception e) {
accountTimeZone = null;
}
}

private void loadAccountLocale(Account current) {
try {
accountLocale = current.getLocale() != null ? Locale.forLanguageTag(current.getLocale()) : null;
} catch (Exception e) {
accountLocale = null;
}
}


public AccountDTO toDTO() {
return currentDTO;
Expand All @@ -114,4 +133,11 @@ private AccountService getService() {
}
return service;
}

public ZoneId getAccountTimeZone() {
if (accountTimeZone == null) {
accountTimeZone = ZoneId.systemDefault();
}
return accountTimeZone;
}
Comment on lines +137 to +142
Copy link

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method getAccountTimeZone() always returns a non-null value by falling back to system default, but this behavior should be documented in the method's Javadoc to clarify the fallback behavior for API consumers.

Suggested change
public ZoneId getAccountTimeZone() {
if (accountTimeZone == null) {
accountTimeZone = ZoneId.systemDefault();
}
return accountTimeZone;
}
/**
* Returns the account's time zone. If the account time zone is not set,
* this method falls back to the system default time zone ({@link ZoneId#systemDefault()}).
* This method never returns {@code null}.
*
* @return the account's time zone, or the system default if not set
*/
public ZoneId getAccountTimeZone() {
if (accountTimeZone == null) {
accountTimeZone = ZoneId.systemDefault();
}
return accountTimeZone;
}

Copilot uses AI. Check for mistakes.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2023 Dynamia Soluciones IT S.A.S - NIT 900302344-1
* Colombia / South America
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package tools.dynamia.modules.saas;

import tools.dynamia.commons.TimeZoneProvider;
import tools.dynamia.commons.logger.LoggingService;
import tools.dynamia.commons.logger.SLF4JLoggingService;
import tools.dynamia.integration.sterotypes.Provider;

import java.time.ZoneId;

/**
* AccountTimeZoneProvider is an implementation of {@link TimeZoneProvider} for SaaS environments.
* <p>
* Provides the default {@link ZoneId} based on the current account session context.
* The priority for this provider is set to 10, making it suitable for account-level time zone resolution.
* <p>
* If the account session or time zone cannot be resolved, this provider returns null.
*
* @author Mario
*/
@Provider
public class AccountTimeZoneProvider implements TimeZoneProvider {
/**
* Logger for this provider, using SLF4J.
*/
private final LoggingService logger = new SLF4JLoggingService(AccountTimeZoneProvider.class);

/**
* Returns the priority of this provider. Lower values indicate higher priority.
*
* @return the priority value (10)
*/
@Override
public int getPriority() {
return 10;
}

/**
* Returns the default {@link ZoneId} for the current account session.
* <p>
* Attempts to retrieve the account time zone from the current session. If unavailable, returns null.
*
* @return the account's default ZoneId, or null if not available
*/
@Override
public ZoneId getDefaultTimeZone() {
try {
return AccountSessionHolder.get().getAccountTimeZone();
} catch (Exception e) {
return null;
}
}
}
4 changes: 2 additions & 2 deletions sources/jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<groupId>tools.dynamia.modules</groupId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>DynamiaModules - SaaS JPA</name>
Expand All @@ -33,7 +33,7 @@
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.api</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>tools.dynamia</groupId>
Expand Down
6 changes: 3 additions & 3 deletions sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<packaging>pom</packaging>
<name>DynamiaModules - SaaS</name>
<description>DynamiaTools extension to create SaaS applications with accounts control and multi tenants in same
Expand Down Expand Up @@ -59,7 +59,7 @@
</scm>

<properties>
<dynamiatools.version>5.4.0</dynamiatools.version>
<dynamiatools.version>5.4.1</dynamiatools.version>
<entityfiles.version>7.4.0</entityfiles.version>
<java.version>21</java.version>
<maven.compiler>3.14.0</maven.compiler>
Expand All @@ -68,7 +68,7 @@

<oshi.version>6.5.0</oshi.version>
<jna.version>5.14.0</jna.version>
<springboot.version>3.5.3</springboot.version>
<springboot.version>3.5.5</springboot.version>
</properties>

<modules>
Expand Down
4 changes: 2 additions & 2 deletions sources/remote/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<groupId>tools.dynamia.modules</groupId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -35,7 +35,7 @@
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.jpa</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api -->
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions sources/ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<parent>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.parent</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</parent>
<artifactId>tools.dynamia.modules.saas.ui</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<name>DynamiaModules - SaaS UI</name>
<url>https://www.dynamia.tools/modules/saas</url>

Expand Down