use of com.djrapitops.plan.storage.database.transactions.ExecStatement 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.ExecStatement in project Plan by plan-player-analytics.
the class RemoveOldExtensionsTransaction method removeProviders.
private void removeProviders() {
execute(new ExecStatement(DELETE_FROM + ExtensionProviderTable.TABLE_NAME + WHERE + ExtensionProviderTable.PLUGIN_ID + " IN (" + SELECT + ExtensionPluginTable.ID + FROM + ExtensionPluginTable.TABLE_NAME + WHERE + ExtensionPluginTable.LAST_UPDATED + "<?" + AND + ExtensionPluginTable.SERVER_UUID + "=?)") {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setLong(1, deleteOlder);
statement.setString(2, serverUUID.toString());
}
});
execute(new ExecStatement(DELETE_FROM + ExtensionTableProviderTable.TABLE_NAME + WHERE + ExtensionTableProviderTable.PLUGIN_ID + " IN (" + SELECT + ExtensionPluginTable.ID + FROM + ExtensionPluginTable.TABLE_NAME + WHERE + ExtensionPluginTable.LAST_UPDATED + "<?" + AND + ExtensionPluginTable.SERVER_UUID + "=?)") {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setLong(1, deleteOlder);
statement.setString(2, serverUUID.toString());
}
});
}
use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.
the class CookieChangeTransaction method performOperations.
@Override
protected void performOperations() {
if (username == null) {
execute(new ExecStatement(CookieTable.DELETE_ALL_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) {
// No parameters
}
});
} else if (cookie == null) {
execute(new ExecStatement(CookieTable.DELETE_BY_USER_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, username);
}
});
// Perform cleanup at the same time
execute(new ExecStatement(CookieTable.DELETE_OLDER_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setLong(1, System.currentTimeMillis());
}
});
} else {
execute(new ExecStatement(CookieTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, username);
statement.setString(2, cookie);
statement.setLong(3, expires);
}
});
}
}
use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.
the class ServerIsProxyPatch method applyPatch.
@Override
protected void applyPatch() {
addColumn(ServerTable.TABLE_NAME, ServerTable.PROXY + ' ' + Sql.BOOL + " DEFAULT 0");
String populateFieldSql = "UPDATE " + ServerTable.TABLE_NAME + " SET " + ServerTable.PROXY + "=?" + WHERE + ServerTable.NAME + "=?";
execute(new ExecStatement(populateFieldSql) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setBoolean(1, true);
statement.setString(2, "BungeeCord");
}
});
}
use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.
the class UserInfoHostnameAllowNullPatch method applyPatch.
@Override
protected void applyPatch() {
tempOldTable();
execute(UserInfoTable.createTableSQL(dbType));
execute(new ExecStatement("INSERT INTO " + tableName + " (" + UserInfoTable.ID + ',' + UserInfoTable.USER_UUID + ',' + UserInfoTable.SERVER_UUID + ',' + UserInfoTable.REGISTERED + ',' + UserInfoTable.OP + ',' + UserInfoTable.BANNED + ',' + UserInfoTable.JOIN_ADDRESS + ") SELECT " + UserInfoTable.ID + ',' + UserInfoTable.USER_UUID + ',' + UserInfoTable.SERVER_UUID + ',' + UserInfoTable.REGISTERED + ',' + UserInfoTable.OP + ',' + UserInfoTable.BANNED + ',' + "?" + FROM + tempTableName) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setNull(1, Types.VARCHAR);
}
});
dropTable(tempTableName);
}
Aggregations