use of com.djrapitops.plan.storage.database.transactions.Transaction in project Plan by plan-player-analytics.
the class BukkitImporter method processServerData.
private void processServerData() {
ServerImportData serverImportData = getServerImportData();
if (serverImportData == null) {
return;
}
dbSystem.getDatabase().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(LargeStoreQueries.storeAllTPSData(Collections.singletonMap(serverUUID.get(), serverImportData.getTpsData())));
}
});
}
use of com.djrapitops.plan.storage.database.transactions.Transaction in project Plan by plan-player-analytics.
the class SessionQueriesTest method worldTimesAreSavedWithSessionWithoutWorlds.
@Test
default void worldTimesAreSavedWithSessionWithoutWorlds() {
prepareForSessionSave();
// Remove the worlds from the database so that they need to also be saved.
execute(new ExecStatement("DELETE FROM " + WorldTable.TABLE_NAME) {
@Override
public void prepare(PreparedStatement statement) {
// Nothing needed
}
});
WorldTimes worldTimes = RandomData.randomWorldTimes(worlds);
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID);
session.getExtraData().put(WorldTimes.class, worldTimes);
List<FinishedSession> sessions = new ArrayList<>();
sessions.add(session);
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(LargeStoreQueries.storeAllSessionsWithKillAndWorldData(sessions));
}
});
List<FinishedSession> allSessions = db().query(SessionQueries.fetchAllSessions());
assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get());
}
use of com.djrapitops.plan.storage.database.transactions.Transaction in project Plan by plan-player-analytics.
the class SessionQueriesTest method worldTimesAreSavedWithSession.
@Test
default void worldTimesAreSavedWithSession() {
prepareForSessionSave();
WorldTimes worldTimes = RandomData.randomWorldTimes(worlds);
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID);
session.getExtraData().put(WorldTimes.class, worldTimes);
List<FinishedSession> sessions = new ArrayList<>();
sessions.add(session);
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(LargeStoreQueries.storeAllSessionsWithKillAndWorldData(sessions));
}
});
List<FinishedSession> allSessions = db().query(SessionQueries.fetchAllSessions());
assertEquals(worldTimes, allSessions.get(0).getExtraData(WorldTimes.class).get());
}
use of com.djrapitops.plan.storage.database.transactions.Transaction in project Plan by plan-player-analytics.
the class UserInfoQueriesTest method cleanRemovesOnlyDuplicatedUserInfo.
@Test
default void cleanRemovesOnlyDuplicatedUserInfo() throws ExecutionException, InterruptedException {
// Store one duplicate
db().executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
execute(DataStoreQueries.registerUserInfo(playerUUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
execute(DataStoreQueries.registerUserInfo(player2UUID, 0L, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME.get()));
}
}).get();
db().executeTransaction(new RemoveDuplicateUserInfoTransaction());
Set<UserInfo> found = db().query(UserInfoQueries.fetchUserInformationOfUser(playerUUID));
assertEquals(Collections.singleton(new UserInfo(playerUUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found);
Set<UserInfo> found2 = db().query(UserInfoQueries.fetchUserInformationOfUser(player2UUID));
assertEquals(Collections.singleton(new UserInfo(player2UUID, serverUUID(), 0, false, TestConstants.GET_PLAYER_HOSTNAME.get(), false)), found2);
}
use of com.djrapitops.plan.storage.database.transactions.Transaction in project Plan by plan-player-analytics.
the class DBPatchSQLiteRegressionTest method setUpDBWithOldSchema.
@BeforeEach
void setUpDBWithOldSchema(@TempDir Path tempDir) throws Exception {
component = new PluginMockComponent(tempDir);
underTest = this.component.getPlanSystem().getDatabaseSystem().getSqLiteFactory().usingFileCalled("test");
underTest.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
underTest.init();
// Initialize database with the old table schema
dropAllTables(underTest);
underTest.executeTransaction(new Transaction() {
@Override
protected void performOperations() {
execute(serverTable);
execute(usersTable);
execute(userInfoTable);
execute(geoInfoTable);
execute(nicknameTable);
execute(sessionsTable);
execute(killsTable);
execute(pingTable);
execute(commandUseTable);
execute(tpsTable);
execute(worldsTable);
execute(worldTimesTable);
execute(securityTable);
execute(transferTable);
}
});
underTest.executeTransaction(new CreateTablesTransaction());
insertData(underTest);
}
Aggregations