-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from effectivemade/backendApp/hotfix/booking
booking fix
- Loading branch information
Showing
10 changed files
with
105 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...kend/src/main/kotlin/office/effective/common/utils/impl/DatabaseTransactionManagerImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package office.effective.common.utils.impl | ||
|
||
import office.effective.common.utils.DatabaseTransactionManager | ||
import org.ktorm.database.Database | ||
import org.ktorm.database.TransactionIsolation | ||
import org.ktorm.database.TransactionManager | ||
import org.slf4j.LoggerFactory | ||
|
||
/** | ||
* Class used for creation database transaction on the facade layer | ||
*/ | ||
class DatabaseTransactionManagerImpl(database: Database) : DatabaseTransactionManager { | ||
private val transactionManager: TransactionManager = database.transactionManager | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
/** | ||
* Executes code in a database transaction. | ||
* | ||
* Rollbacks the transaction if an exception was thrown. | ||
* | ||
* @param serviceCall lambda function to be executed | ||
* @param isolation transaction isolation | ||
*/ | ||
override fun <T> useTransaction(serviceCall: () -> T, isolation: TransactionIsolation): T { | ||
logger.debug("Opening new database {} transaction", isolation.name) | ||
val transaction = transactionManager.newTransaction(isolation = isolation) | ||
val result: T | ||
try { | ||
result = serviceCall() | ||
transaction.commit() | ||
logger.debug("Transaction committed") | ||
} catch (e: Throwable) { | ||
logger.debug("Rollback transaction") | ||
transaction.rollback() | ||
throw e | ||
} finally { | ||
transaction.close() | ||
} | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
...end/src/main/kotlin/office/effective/features/booking/converters/RecurrenceRuleFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters