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

Updated Table opStaffsinOperationTeams: removed Primary and set the Foreign...

Updated Table opStaffsinOperationTeams: removed Primary and set the Foreign Keys opstaffsId and operationteamId as the Primary Key.
Updated the assignStaff method.
parent 578d7603
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,6 @@ import java.time.Instant; ...@@ -2,8 +2,6 @@ import java.time.Instant;
public record TeamMember( public record TeamMember(
Id<TeamMember> teamMemberId,
Id<OperationTeam> operationTeamId, Id<OperationTeam> operationTeamId,
Id<OPStaff> opStaffId, Id<OPStaff> opStaffId,
......
...@@ -24,7 +24,6 @@ public class TeamMemberImpl implements TeamMemberService{ ...@@ -24,7 +24,6 @@ public class TeamMemberImpl implements TeamMemberService{
private TeamMember assignStaffimpl(TeamMember.AssignStaff as) { private TeamMember assignStaffimpl(TeamMember.AssignStaff as) {
TeamMember teammember = TeamMember teammember =
new TeamMember( new TeamMember(
repo.teamMemberId(),
as.operationTeamId(), as.operationTeamId(),
as.opStaffId(), as.opStaffId(),
Instant.now() Instant.now()
...@@ -35,7 +34,6 @@ public class TeamMemberImpl implements TeamMemberService{ ...@@ -35,7 +34,6 @@ public class TeamMemberImpl implements TeamMemberService{
private TeamMember removeStaffimpl(TeamMember.RemoveStaff rs) { private TeamMember removeStaffimpl(TeamMember.RemoveStaff rs) {
TeamMember teammember = TeamMember teammember =
new TeamMember( new TeamMember(
repo.teamMemberId(),
rs.operationTeamId(), rs.operationTeamId(),
rs.opStaffId(), rs.opStaffId(),
Instant.now() Instant.now()
......
...@@ -89,12 +89,12 @@ class JDBCRepository implements Repository ...@@ -89,12 +89,12 @@ class JDBCRepository implements Repository
*/ */
private static final String CREATE_OP_STAFF_IN_OPERATION_TEAM_TABLE = """ private static final String CREATE_OP_STAFF_IN_OPERATION_TEAM_TABLE = """
CREATE TABLE IF NOT EXISTS opStaffsInOperationTeams( CREATE TABLE IF NOT EXISTS opStaffsInOperationTeams(
id VARCHAR(50) PRIMARY KEY,
operationTeamId VARCHAR(50), operationTeamId VARCHAR(50),
opStaffId VARCHAR(50), opStaffId VARCHAR(50),
lastUpdate TIMESTAMP NOT NULL, lastUpdate TIMESTAMP NOT NULL,
FOREIGN KEY (operationTeamId) REFERENCES operationTeams(id), FOREIGN KEY (operationTeamId) REFERENCES operationTeams(id),
FOREIGN KEY (opStaffId) REFERENCES opStaffs(id) FOREIGN KEY (opStaffId) REFERENCES opStaffs(id),
PRIMARY KEY (operationTeamId, opStaffId)
); );
"""; """;
...@@ -248,15 +248,15 @@ class JDBCRepository implements Repository ...@@ -248,15 +248,15 @@ class JDBCRepository implements Repository
*/ */
private static String insertSQL(TeamMember teamMember){ private static String insertSQL(TeamMember teamMember){
return return
"INSERT INTO teamMember(" + "INSERT INTO opStaffsInOperationTeams(" +
"id,operationTeamId,opStaffId,lastUpdate" + "operationTeamId,opStaffId,lastUpdate" +
") VALUES (" + ") VALUES (" +
sqlValue(teamMember.teamMemberId().value()) + "," +
sqlValue(teamMember.operationTeamId()) + "," + sqlValue(teamMember.operationTeamId()) + "," +
sqlValue(teamMember.opStaffId()) + "," + sqlValue(teamMember.opStaffId()) + "," +
sqlValue(teamMember.lastUpdate()) + sqlValue(teamMember.lastUpdate()) +
");"; ");";
} }
//INSERT INTO opStaffsInOperationTeams ("operationteamid","opstaffid","lastupdate") VALUES ('31','4444','2024-06-21 20:55:39.991047');
/** /**
* Creates an Operation object with the given result of a read SQL-Row. * Creates an Operation object with the given result of a read SQL-Row.
......
...@@ -77,7 +77,6 @@ public final class Tests ...@@ -77,7 +77,6 @@ public final class Tests
}; };
testTeamMember = new TeamMember( testTeamMember = new TeamMember(
new Id<>("TeamMember2"),
testOperationTeam.id(), testOperationTeam.id(),
testOPStaff.id(), testOPStaff.id(),
Instant.now() Instant.now()
...@@ -87,7 +86,7 @@ public final class Tests ...@@ -87,7 +86,7 @@ public final class Tests
} }
@Test //@Test
public void testRepoOperationSave(){ public void testRepoOperationSave(){
try { try {
...@@ -102,7 +101,7 @@ public final class Tests ...@@ -102,7 +101,7 @@ public final class Tests
); );
} }
@Test //@Test
public void testRepoOperationUpdate() { public void testRepoOperationUpdate() {
try { try {
...@@ -334,7 +333,7 @@ public final class Tests ...@@ -334,7 +333,7 @@ public final class Tests
OperationTeam deleteOperationTeam = operationTeamService.process(deleteCommand); OperationTeam deleteOperationTeam = operationTeamService.process(deleteCommand);
} }
//@Test @Test
public void testInsertTeamMember1() throws Exception{ public void testInsertTeamMember1() throws Exception{
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment