Skip to content
Snippets Groups Projects
Commit acd6d903 authored by Alexander Görlitz's avatar Alexander Görlitz
Browse files

Implemented reference for Operation to OperationTeam, only thing to do is the...

Implemented reference for Operation to OperationTeam, only thing to do is the orElse() Function in OperationServiceImpl.java Z.61
parent 6ca3426b
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ public record Operation(
LocalDate date,
LocalTime startTime,
LocalTime endTime,
Id<OperationTeam> operationTeamId,
Instant lastUpdate
) {
......@@ -45,14 +47,18 @@ public record Operation(
public static record Create(
LocalDate date,
LocalTime startTime,
LocalTime endTime
LocalTime endTime,
Id<OperationTeam> operationTeamId
) implements Command {}
public static record Update(
Id<Operation> id,
Optional<LocalDate> date,
Optional<LocalTime> startTime,
Optional<LocalTime> endTime
Optional<LocalTime> endTime,
Id<OperationTeam> operationTeamId
) implements Command {}
public static record Delete(
......
......@@ -40,6 +40,7 @@ public class OperationServiceImpl implements OperationService {
cr.date(),
cr.startTime(),
cr.endTime(),
cr.operationTeamId(),
Instant.now());
repo.save(operation);
......@@ -57,6 +58,7 @@ public class OperationServiceImpl implements OperationService {
up.date().orElse(currentOperation.date()),
up.startTime().orElse(currentOperation.startTime()),
up.endTime().orElse(currentOperation.endTime()),
up.operationTeamId(), //TODO
Instant.now());
repo.save(operation);
......
......@@ -230,7 +230,9 @@ class JDBCRepository implements Repository
date DATE NOT NULL,
startTime TIME NOT NULL,
endTime TIME NOT NULL,
lastUpdate TIMESTAMP NOT NULL
operationteamid VARCHAR(50),
lastUpdate TIMESTAMP NOT NULL,
FOREIGN KEY (operationteamid) REFERENCES operationteam(id)
);
""";
......@@ -242,12 +244,13 @@ class JDBCRepository implements Repository
private static String insertSQL(Operation operation){
return
"INSERT INTO operations(" +
"id,date,startTime,endTime,lastUpdate" +
"id,date,startTime,endTime,operationteamid,lastUpdate" +
") VALUES (" +
sqlValue(operation.id().value()) + "," +
sqlValue(operation.date()) + "," +
sqlValue(operation.startTime()) + "," +
sqlValue(operation.endTime()) + "," +
sqlValue(operation.operationTeamId()) + "," +
sqlValue(operation.lastUpdate()) +
");";
}
......@@ -263,6 +266,7 @@ class JDBCRepository implements Repository
"date = " + sqlValue(operation.date()) + "," +
"startTime = " + sqlValue(operation.startTime()) + "," +
"endTime = " + sqlValue(operation.endTime()) + "," +
"operationteamid = " + sqlValue(operation.operationTeamId()) + "," +
"lastUpdate = " + sqlValue(operation.lastUpdate()) + " " +
"WHERE id = " + sqlValue(operation.id().value()) + ";";
}
......@@ -381,6 +385,7 @@ class JDBCRepository implements Repository
rs.getDate("date").toLocalDate(),
rs.getTime("startTime").toLocalTime(),
rs.getTime("endTime").toLocalTime(),
new Id<>(rs.getString("operationteamid")),
rs.getTimestamp("lastUpdate").toInstant()
);
}
......
......@@ -47,6 +47,7 @@ public final class Tests
LocalDate.of(2024, 05, 24),
LocalTime.of(13, 35, 00),
LocalTime.of(14, 00, 00),
new Id<>("31313131"),
Instant.now());
opService = new OperationServiceImpl(repo);
......@@ -61,8 +62,8 @@ public final class Tests
testOperationTeam = new OperationTeam(
new Id<>("31313131"),
("NochCooler"),
new Id<>("31"),
("AmCoolsten"),
Instant.now()
);
......@@ -108,6 +109,7 @@ public final class Tests
LocalDate.of(1999, 01, 01),
testOperation.startTime(),
testOperation.endTime(),
testOperation.operationTeamId(),
Instant.now()
);
......@@ -143,7 +145,8 @@ public final class Tests
Operation.Create createCommand = new Operation.Create(
LocalDate.of(2025, 05, 11),
LocalTime.of(10, 30, 00),
LocalTime.of(11, 00, 00)
LocalTime.of(11, 00, 00),
new Id<OperationTeam>("31313131")
);
Operation createOperation = opService.process(createCommand);
......@@ -162,7 +165,8 @@ public final class Tests
testOperation.id(),
Optional.of(LocalDate.of(1999, 01, 01)),
Optional.empty(),
Optional.empty()
Optional.empty(),
new Id<OperationTeam>("31")
);
opService.getOperation(testOperation.id());
......@@ -186,12 +190,12 @@ public final class Tests
);
}
//@Test
public void testDeleteOperation() throws Exception {
//repo.save(testOperation);
var id = new Id<Operation>("ade321ba-53f7-4f72-9748-bf2bbddfd98c");
var id = new Id<Operation>("1111");
Operation.Delete deleteCommand = new Operation.Delete(
//testOperation.id()
......@@ -209,7 +213,7 @@ public final class Tests
//@Test
public void testGetOperations() {
LocalDate testDate = LocalDate.of(2024, 05, 24);
LocalDate testDate = LocalDate.of(2025, 05, 11);
Operation.Filter filter = new Operation.Filter(Optional.of(testDate));
// Operation.Filter filter = Operation.Filter.NONE;
......@@ -360,7 +364,7 @@ public final class Tests
}
}
@Test
//@Test
public void testGetTeamMemberFromTeam() throws Exception{
var id = new Id<OperationTeam>("31313131");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment