implemented updating of event base data. next: update links, attachments, tags

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-12-29 01:01:33 +01:00
parent d797de60c1
commit eee672a3f6
4 changed files with 47 additions and 11 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ dependencies {
implementation(project(":de.srsoftware.cal.api"))
implementation(project(":de.srsoftware.cal.base"))
implementation("de.srsoftware:tools.jdbc:1.1.1")
implementation("de.srsoftware:tools.jdbc:1.1.2")
implementation("de.srsoftware:tools.optionals:1.0.0")
implementation("de.srsoftware:tools.util:1.2.3")
}
@@ -51,4 +51,6 @@ public interface Database {
Result<Appointment> loadEvent(String location, LocalDateTime start);
Result<List<String>> findTags(String infix);
Result<Appointment> update(Appointment baseAppointment);
}
@@ -289,4 +289,23 @@ public class MariaDB implements Database {
public List<Appointment> listByTags(Set<String> tags, Integer count, Integer offset) {
return List.of();
}
@Override
public Result<Appointment> update(Appointment event) {
var end = event.end().map(Timestamp::valueOf).orElse(null);
try {
Query
.update(APPOINTMENTS) //
.set(TITLE, DESCRIPTION, START, END, LOCATION, COORDS)
.where(AID, equal(event.id()))
.prepare(connection)
.apply(event.title(), event.description(), Timestamp.valueOf(event.start()), end, event.location(), event.coords().orElse(null));
// TODO: update links, attachments, tags
return Payload.of(event);
} catch (SQLException sqle) {
return Error.of("Failed to update database entry", sqle);
}
}
}