Add metadata tag Maps to PositionMeta for API integrations

This commit is contained in:
William278 committed 2022-09-04 23:38:41 +03:00
1 parent 9d80d455f2
commit 0ee8c97a6e
3 files changed
+100 -39

No files matched your search

@@ -174,14 +174,15 @@ public class MySqlDatabase extends Database {
@Override
protected int setSavedPosition(@NotNull SavedPosition position, @NotNull Connection connection) throws SQLException {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
INSERT INTO `%saved_positions_table%` (`position_id`, `name`, `description`, `timestamp`)
VALUES (?,?,?,?);"""),
INSERT INTO `%saved_positions_table%` (`position_id`, `name`, `description`, `tags`, `timestamp`)
VALUES (?,?,?,?,?);"""),
Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, setPosition(position, connection));
statement.setString(2, position.meta.name);
statement.setString(3, position.meta.description);
statement.setTimestamp(4, Timestamp.from(position.meta.creationTime));
statement.setString(4, position.meta.getSerializedTags());
statement.setTimestamp(5, Timestamp.from(position.meta.creationTime));
statement.executeUpdate();
final ResultSet resultSet = statement.getGeneratedKeys();
@@ -208,11 +209,13 @@ public class MySqlDatabase extends Database {
try (PreparedStatement updateStatement = connection.prepareStatement(formatStatementTables("""
UPDATE `%saved_positions_table%`
SET `name`=?,
`description`=?
`description`=?,
`tags`=?
WHERE `id`=?;"""))) {
updateStatement.setString(1, position.meta.name);
updateStatement.setString(2, position.meta.description);
updateStatement.setInt(3, savedPositionId);
updateStatement.setString(3, position.meta.getSerializedTags());
updateStatement.setInt(4, savedPositionId);
updateStatement.executeUpdate();
}
}
@@ -319,7 +322,7 @@ public class MySqlDatabase extends Database {
final List<Home> userHomes = new ArrayList<>();
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
FROM `%homes_table%`
INNER JOIN `%saved_positions_table%` ON `%homes_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -341,7 +344,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("home_uuid")),
user,
resultSet.getBoolean("public")));
@@ -360,7 +364,7 @@ public class MySqlDatabase extends Database {
final List<Warp> warps = new ArrayList<>();
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
FROM `%warps_table%`
INNER JOIN `%saved_positions_table%` ON `%warps_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -378,7 +382,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("warp_uuid"))));
}
}
@@ -395,7 +400,7 @@ public class MySqlDatabase extends Database {
final List<Home> userHomes = new ArrayList<>();
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
FROM `%homes_table%`
INNER JOIN `%saved_positions_table%` ON `%homes_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -415,7 +420,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("home_uuid")),
new User(UUID.fromString(resultSet.getString("owner_uuid")),
resultSet.getString("owner_username")),
@@ -434,7 +440,7 @@ public class MySqlDatabase extends Database {
return CompletableFuture.supplyAsync(() -> {
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
FROM `%homes_table%`
INNER JOIN `%saved_positions_table%` ON `%homes_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -456,7 +462,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("home_uuid")),
new User(UUID.fromString(resultSet.getString("owner_uuid")),
resultSet.getString("owner_username")),
@@ -477,7 +484,7 @@ public class MySqlDatabase extends Database {
return CompletableFuture.supplyAsync(() -> {
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
SELECT `%homes_table%`.`uuid` AS `home_uuid`, `owner_uuid`, `username` AS `owner_username`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`, `public`
FROM `%homes_table%`
INNER JOIN `%saved_positions_table%` ON `%homes_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -497,7 +504,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("home_uuid")),
new User(UUID.fromString(resultSet.getString("owner_uuid")),
resultSet.getString("owner_username")),
@@ -516,7 +524,7 @@ public class MySqlDatabase extends Database {
return CompletableFuture.supplyAsync(() -> {
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
FROM `%warps_table%`
INNER JOIN `%saved_positions_table%` ON `%warps_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -535,7 +543,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("warp_uuid"))));
}
}
@@ -551,7 +560,7 @@ public class MySqlDatabase extends Database {
return CompletableFuture.supplyAsync(() -> {
try (Connection connection = getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(formatStatementTables("""
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
SELECT `%warps_table%`.`uuid` AS `warp_uuid`, `name`, `description`, `tags`, `timestamp`, `x`, `y`, `z`, `yaw`, `pitch`, `world_name`, `world_uuid`, `server_name`
FROM `%warps_table%`
INNER JOIN `%saved_positions_table%` ON `%warps_table%`.`saved_position_id`=`%saved_positions_table%`.`id`
INNER JOIN `%positions_table%` ON `%saved_positions_table%`.`position_id`=`%positions_table%`.`id`
@@ -570,7 +579,8 @@ public class MySqlDatabase extends Database {
new Server(resultSet.getString("server_name")),
new PositionMeta(resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getTimestamp("timestamp").toInstant()),
resultSet.getTimestamp("timestamp").toInstant(),
resultSet.getString("tags")),
UUID.fromString(resultSet.getString("warp_uuid"))));
}
}