[AB-57] [AB-61] reworked commands and services to work with completable futures and moved the database operations to the very last operation so we have transaction safety in more areas

added some cache annotations to the default repository functions
reworked how the undo cations are processed within commands, they are executed in a post command listener when the state is error
added a counter id to generate ids to be unique within servers, changed a few tables to be unique within a server
added future utils class for wrapping a list of futures into one
moved abstracto tables to separate schema in the installer
refactored experience gain to work with more futures and delayed database access
This commit is contained in:
Sheldan
2020-09-20 11:11:20 +02:00
parent 552ecc26b8
commit 76adda90a3
220 changed files with 2691 additions and 1498 deletions

View File

@@ -49,6 +49,7 @@ public class AssignableRole implements Serializable {
@Setter
@ManyToMany(mappedBy = "roles")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AssignedRoleUser> assignedUsers = new ArrayList<>();
private String description;

View File

@@ -59,6 +59,13 @@ public interface AssignableRolePlaceService {
void changeAssignablePlaceDescription(AServer server, String name, String newDescription);
CompletableFuture<Void> deleteAssignableRolePlace(AServer server, String name);
CompletableFuture<Void> changeText(AServer server, String name, String newText);
/**
* Removes the reactions and the roles from the user from the place, this does not touch the stored data
* @param place The {@link AssignableRolePlace} to which remove the existing reactions and roles from
* @param user The {@link AssignedRoleUser} to the remove *all* reactions and assigned roles from
* @return A {@link CompletableFuture} which completes when both of these actions have been done for all {@link dev.sheldan.abstracto.assignableroles.models.database.AssignableRole}
*/
CompletableFuture<Void> removeExistingReactionsAndRoles(AssignableRolePlace place, AssignedRoleUser user);
CompletableFuture<Void> changeConfiguration(AServer server, String name, AssignableRolePlaceParameterKey keyToChange, Object newValue);

View File

@@ -1,11 +1,20 @@
package dev.sheldan.abstracto.assignableroles.service;
import dev.sheldan.abstracto.assignableroles.models.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.models.database.AssignableRolePlace;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import net.dv8tion.jda.api.entities.Member;
import java.util.concurrent.CompletableFuture;
public interface AssignableRoleService {
CompletableFuture<Void> assignAssignableRoleToUser(Long assignableRoleId, Member toAdd);
void clearAllRolesOfUserInPlace(AssignableRolePlace place, AUserInAServer user);
CompletableFuture<Void> fullyAssignAssignableRoleToUser(Long assignableRoleId, Member toAdd);
CompletableFuture<Void> removeAssignableRoleFromUser(AssignableRole assignableRole, Member member);
CompletableFuture<Void> fullyRemoveAssignableRoleFromUser(AssignableRole assignableRole, Member member);
void addRoleToUser(Long assignableRoleId, AUserInAServer aUserInAServer);
void addRoleToUser(AssignableRole assignableRole, AUserInAServer aUserInAServer);
void removeRoleFromUser(AssignableRole assignableRole, AUserInAServer aUserInAServer);
void removeRoleFromUser(Long assignableRoleId, AUserInAServer aUserInAServer);
}

View File

@@ -5,10 +5,12 @@ import dev.sheldan.abstracto.assignableroles.models.database.AssignableRolePlace
import dev.sheldan.abstracto.assignableroles.models.database.AssignableRolePlacePost;
import dev.sheldan.abstracto.core.models.database.AEmote;
import dev.sheldan.abstracto.core.models.database.ARole;
import net.dv8tion.jda.api.entities.MessageReaction;
public interface AssignableRoleManagementService {
AssignableRole addRoleToPlace(AssignableRolePlace place, AEmote emote, ARole role, String description, AssignableRolePlacePost post);
AssignableRole addRoleToPlace(Long placeId, Integer emoteId, Long roleId, String description, Long messageId);
AssignableRole addRoleToPlace(Long placeId, Integer emoteId, Long roleId, String description);
AssignableRole getByAssignableRoleId(Long assignableRoleId);
AssignableRole getRoleForReactionEmote(MessageReaction.ReactionEmote emote, AssignableRolePlace assignableRolePlace);
}

View File

@@ -11,7 +11,8 @@ public interface AssignableRolePlaceManagementService {
AssignableRolePlace createPlace(AServer server, String name, AChannel channel, String text);
boolean doesPlaceExist(AServer server, String name);
AssignableRolePlace findByServerAndKey(AServer server, String name);
Optional<AssignableRolePlace> findByPlaceId(Long id);
Optional<AssignableRolePlace> findByPlaceIdOptional(Long id);
AssignableRolePlace findByPlaceId(Long id);
void moveAssignableRolePlace(AServer server, String name, AChannel newChannel);
void changeAssignableRolePlaceDescription(AServer server, String name, String newDescription);
void deleteAssignablePlace(AssignableRolePlace place);

View File

@@ -10,6 +10,7 @@ public interface AssignedRoleUserManagementService {
void addAssignedRoleToUser(AssignableRole assignableRole, AUserInAServer aUserInAServer);
void removeAssignedRoleFromUser(AssignableRole assignableRole, AUserInAServer aUserInAServer);
AssignedRoleUser createAssignedRoleUser(AUserInAServer aUserInAServer);
void clearAllAssignedRolesOfUser(AUserInAServer userInAServer);
boolean doesAssignedRoleUserExist(AUserInAServer aUserInAServer);
Optional<AssignedRoleUser> findByUserInServerOptional(AUserInAServer aUserInAServer);
AssignedRoleUser findByUserInServer(AUserInAServer aUserInAServer);