rename StorylineHistoryRepository
This commit is contained in:
parent
2f620af594
commit
f1b1cc1afe
@ -4,7 +4,7 @@ import dev.struchkov.godfather.main.domain.StorylineHistory;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface StorylineRepository {
|
||||
public interface StorylineHistoryRepository {
|
||||
|
||||
Uni<Void> save(@NotNull StorylineHistory storylineHistory);
|
||||
|
@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface StorylineRepository {
|
||||
public interface StorylineHistoryRepository {
|
||||
|
||||
void save(@NotNull StorylineHistory storylineHistory);
|
||||
|
@ -3,7 +3,7 @@ package dev.struchkov.godfather.quarkus.core.service;
|
||||
import dev.struchkov.godfather.main.domain.StorylineHistory;
|
||||
import dev.struchkov.godfather.main.domain.UnitPointer;
|
||||
import dev.struchkov.godfather.main.domain.content.Mail;
|
||||
import dev.struchkov.godfather.quarkus.context.repository.StorylineRepository;
|
||||
import dev.struchkov.godfather.quarkus.context.repository.StorylineHistoryRepository;
|
||||
import dev.struchkov.godfather.quarkus.context.service.UnitPointerService;
|
||||
import dev.struchkov.godfather.quarkus.core.Storyline;
|
||||
import dev.struchkov.godfather.quarkus.core.StorylineFactory;
|
||||
@ -26,24 +26,24 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||
public class StorylineMailService implements StorylineService<Mail> {
|
||||
|
||||
private final UnitPointerService unitPointerService;
|
||||
private final StorylineRepository storylineRepository;
|
||||
private final StorylineHistoryRepository storylineHistoryRepository;
|
||||
private final Storyline<Mail> storyLine;
|
||||
private String defaultUnitName;
|
||||
|
||||
public StorylineMailService(
|
||||
UnitPointerService unitPointerService,
|
||||
StorylineRepository storylineRepository,
|
||||
StorylineHistoryRepository storylineHistoryRepository,
|
||||
List<Object> unitConfigurations
|
||||
) {
|
||||
this.storyLine = new StorylineFactory<Mail>(unitConfigurations).createStoryLine();
|
||||
this.unitPointerService = unitPointerService;
|
||||
this.storylineRepository = storylineRepository;
|
||||
this.storylineHistoryRepository = storylineHistoryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<Void> save(@NotNull StorylineHistory storylineHistory) {
|
||||
isNotNull(storylineHistory);
|
||||
return storylineRepository.save(storylineHistory);
|
||||
return storylineHistoryRepository.save(storylineHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +69,7 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
if (checkNotNull(unit) && checkNotEmpty(unit.getNextUnits())) {
|
||||
return Uni.createFrom().item(unit.getNextUnits());
|
||||
} else {
|
||||
return storylineRepository.cleanHistoryByPersonId(personId)
|
||||
return storylineHistoryRepository.cleanHistoryByPersonId(personId)
|
||||
.onItem().transform(v -> storyLine.getStartingUnits());
|
||||
}
|
||||
}
|
||||
@ -94,18 +94,18 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
storylineHistory.setPersonId(personId);
|
||||
storylineHistory.setUnitName(unitName);
|
||||
storylineHistory.setMessage(mail);
|
||||
return storylineRepository.save(storylineHistory);
|
||||
return storylineHistoryRepository.save(storylineHistory);
|
||||
}).replaceWithVoid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack) {
|
||||
return storylineRepository.findByCountLast(personId, countUnitsToBack);
|
||||
return storylineHistoryRepository.findByCountLast(personId, countUnitsToBack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uni<StorylineHistory> replaceUserToBack(String personId, String unitName) {
|
||||
return storylineRepository.findByCountLast(personId, unitName);
|
||||
return storylineHistoryRepository.findByCountLast(personId, unitName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -121,7 +121,7 @@ public class StorylineMailService implements StorylineService<Mail> {
|
||||
|
||||
@Override
|
||||
public Uni<Void> cleanHistoryByPersonId(@NotNull String personId) {
|
||||
return storylineRepository.cleanHistoryByPersonId(personId)
|
||||
return storylineHistoryRepository.cleanHistoryByPersonId(personId)
|
||||
.call(() -> unitPointerService.removeByPersonId(personId));
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package dev.struchkov.godfather.simple.core.service;
|
||||
import dev.struchkov.godfather.main.domain.StorylineHistory;
|
||||
import dev.struchkov.godfather.main.domain.UnitPointer;
|
||||
import dev.struchkov.godfather.main.domain.content.Message;
|
||||
import dev.struchkov.godfather.simple.context.repository.StorylineRepository;
|
||||
import dev.struchkov.godfather.simple.context.repository.StorylineHistoryRepository;
|
||||
import dev.struchkov.godfather.simple.context.service.UnitPointerService;
|
||||
import dev.struchkov.godfather.simple.core.Storyline;
|
||||
import dev.struchkov.godfather.simple.core.StorylineFactory;
|
||||
@ -22,24 +22,24 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
|
||||
public class StorylineMailService<T extends Message> implements StorylineService<T> {
|
||||
|
||||
private final UnitPointerService unitPointerService;
|
||||
private final StorylineRepository storylineRepository;
|
||||
private final StorylineHistoryRepository storylineHistoryRepository;
|
||||
private final Storyline<T> storyLine;
|
||||
private String defaultUnitName;
|
||||
|
||||
public StorylineMailService(
|
||||
UnitPointerService unitPointerService,
|
||||
StorylineRepository storylineRepository,
|
||||
StorylineHistoryRepository storylineHistoryRepository,
|
||||
List<Object> unitConfigurations
|
||||
) {
|
||||
this.storyLine = new StorylineFactory<T>(unitConfigurations).createStoryLine();
|
||||
this.unitPointerService = unitPointerService;
|
||||
this.storylineRepository = storylineRepository;
|
||||
this.storylineHistoryRepository = storylineHistoryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(@NotNull StorylineHistory storylineHistory) {
|
||||
isNotNull(storylineHistory);
|
||||
storylineRepository.save(storylineHistory);
|
||||
storylineHistoryRepository.save(storylineHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,7 +55,7 @@ public class StorylineMailService<T extends Message> implements StorylineService
|
||||
.map(MainUnit::getNextUnits)
|
||||
.filter(mainUnits -> !mainUnits.isEmpty());
|
||||
if (optMainUnits.isEmpty()) {
|
||||
storylineRepository.cleanHistoryByPersonId(personId);
|
||||
storylineHistoryRepository.cleanHistoryByPersonId(personId);
|
||||
}
|
||||
final Set<MainUnit<T>> nextUnits = optMainUnits.orElse(storyLine.getStartingUnits());
|
||||
nextUnits.addAll(storyLine.getGlobalUnits());
|
||||
@ -71,17 +71,17 @@ public class StorylineMailService<T extends Message> implements StorylineService
|
||||
storylineHistory.setPersonId(personId);
|
||||
storylineHistory.setUnitName(unitName);
|
||||
storylineHistory.setMessage(mail);
|
||||
storylineRepository.save(storylineHistory);
|
||||
storylineHistoryRepository.save(storylineHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> replaceUserToBack(String personId, int countUnitsToBack) {
|
||||
return storylineRepository.findByCountLast(personId, countUnitsToBack);
|
||||
return storylineHistoryRepository.findByCountLast(personId, countUnitsToBack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<StorylineHistory> replaceUserToBack(String personId, String unitName) {
|
||||
return storylineRepository.findByCountLast(personId, unitName);
|
||||
return storylineHistoryRepository.findByCountLast(personId, unitName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,7 +97,7 @@ public class StorylineMailService<T extends Message> implements StorylineService
|
||||
|
||||
@Override
|
||||
public void cleanHistoryByPersonId(@NotNull String personId) {
|
||||
storylineRepository.cleanHistoryByPersonId(personId);
|
||||
storylineHistoryRepository.cleanHistoryByPersonId(personId);
|
||||
unitPointerService.removeByPersonId(personId);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.struchkov.godfather.quarkus.data.repository.impl;
|
||||
|
||||
import dev.struchkov.godfather.main.domain.StorylineHistory;
|
||||
import dev.struchkov.godfather.quarkus.context.repository.StorylineRepository;
|
||||
import dev.struchkov.godfather.quarkus.context.repository.StorylineHistoryRepository;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -11,7 +11,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public class StorylineMapRepository implements StorylineRepository {
|
||||
public class StorylineMapHistoryRepository implements StorylineHistoryRepository {
|
||||
|
||||
private final Map<String, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<String, Set<String>> historyUnitName = new HashMap<>();
|
@ -1,7 +1,7 @@
|
||||
package dev.struchkov.godfather.simple.data.repository.impl;
|
||||
|
||||
import dev.struchkov.godfather.main.domain.StorylineHistory;
|
||||
import dev.struchkov.godfather.simple.context.repository.StorylineRepository;
|
||||
import dev.struchkov.godfather.simple.context.repository.StorylineHistoryRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -11,7 +11,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public class StorylineMapRepository implements StorylineRepository {
|
||||
public class StorylineMapHistoryRepository implements StorylineHistoryRepository {
|
||||
|
||||
private final Map<String, Stack<StorylineHistory>> map = new HashMap<>();
|
||||
private final Map<String, Set<String>> historyUnitName = new HashMap<>();
|
Loading…
Reference in New Issue
Block a user