-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] add version optimistic locking for the Competition Hierarchy #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
8b99f6c
af39fb1
ecef479
16d7196
c487336
cd81a3e
f04c1eb
aa4a3f8
71cf224
40acaa9
a73be0a
eaadba9
5f50b29
efd9cea
5bc2249
d7aae16
d493c69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.itasocialacademy.oitassist.competition.exceptions; | ||
|
|
||
| import com.itasocialacademy.oitassist.core.enums.ErrorCode; | ||
| import com.itasocialacademy.oitassist.core.exceptions.BusinessException; | ||
|
|
||
| /** | ||
| * Thrown when a client-submitted {@code version} does not match the entity's | ||
| * current version in the database — i.e. the entity was modified by someone | ||
| * else since the client last read it. | ||
| */ | ||
| public class StaleEntityVersionException extends BusinessException { | ||
| public static final String ERROR_MESSAGE = | ||
| "Object of class [%s] with identifier [%s] was updated by another request."; | ||
|
|
||
| public StaleEntityVersionException(Class<?> entityClass, Object identifier) { | ||
| super(ERROR_MESSAGE | ||
| .formatted(entityClass.getName(), identifier), ErrorCode.ENTITY_VERSION_CONFLICT); | ||
|
antonpampukha marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| package com.itasocialacademy.oitassist.competition.service.interfaces; | ||
|
|
||
| import com.itasocialacademy.oitassist.competition.dao.enums.CompetitionStatus; | ||
| import com.itasocialacademy.oitassist.competition.dto.filter.CompetitionSearchFilter; | ||
| import com.itasocialacademy.oitassist.competition.dto.request.ChangeCompetitionStatusRequest; | ||
| import com.itasocialacademy.oitassist.competition.dto.request.CreateCompetitionRequest; | ||
| import com.itasocialacademy.oitassist.competition.dto.response.CompetitionResponse; | ||
| import com.itasocialacademy.oitassist.competition.dto.response.CompetitionTreeResponse; | ||
|
|
@@ -32,14 +32,14 @@ public interface CompetitionService { | |
| CompetitionResponse getVisibleById(Long competitionId); | ||
|
|
||
| /** | ||
| * Transitions the competition to a new status. Publishing requires at least one | ||
| * Stage and one Tour. | ||
| * Transitions the competition to a new request. Publishing requires at least | ||
| * one Stage and one Tour. | ||
| * | ||
| * @param competitionId Competition ID | ||
| * @param status a status of a Competition | ||
| * @param request a request of a Competition | ||
| * @return {@link CompetitionResponse} | ||
| */ | ||
| CompetitionResponse changeStatus(Long competitionId, CompetitionStatus status); | ||
| CompetitionResponse changeStatus(Long competitionId, ChangeCompetitionStatusRequest request); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the Javadoc status description. “Transitions the competition to a new request” describes the target state incorrectly. State that the method transitions the competition to the requested status. Document that 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Retrieves a paginated list of competitions visible to the current user, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
| https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
|
||
|
|
||
| <changeSet id="add-version-to-competitions" author="Anton Pampukha"> | ||
| <addColumn tableName="competitions"> | ||
| <column name="version" type="BIGINT" defaultValueNumeric="0"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </addColumn> | ||
| </changeSet> | ||
|
|
||
| <changeSet id="add-version-to-stages" author="Anton Pampukha"> | ||
| <addColumn tableName="stages"> | ||
| <column name="version" type="BIGINT" defaultValueNumeric="0"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </addColumn> | ||
| </changeSet> | ||
|
|
||
| <changeSet id="add-version-to-tours" author="Anton Pampukha"> | ||
| <addColumn tableName="tours"> | ||
| <column name="version" type="BIGINT" defaultValueNumeric="0"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </addColumn> | ||
| </changeSet> | ||
| </databaseChangeLog> |
Uh oh!
There was an error while loading. Please reload this page.