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

Implemented in operationteam getOperationTeams()

operationTeam ist fertig
parent 26f5e9c7
No related branches found
No related tags found
No related merge requests found
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.util.List;
import java.util.Optional; import java.util.Optional;
public class OperationTeamImpl implements OperationTeamService{ public class OperationTeamImpl implements OperationTeamService{
...@@ -42,12 +43,10 @@ public class OperationTeamImpl implements OperationTeamService{ ...@@ -42,12 +43,10 @@ public class OperationTeamImpl implements OperationTeamService{
} }
@Override @Override
public Optional<OperationTeam> getOperationTeams() { public List<OperationTeam> getOperationTeams() throws SQLException {
return Optional.empty();
}
@Override return repo.getOperationTeamsImp();
public Optional<OPStaff> getOperationTeamOPStaff(Id<OperationTeam> operationTeamId) {
return Optional.empty();
} }
} }
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
import java.util.Optional; import java.util.Optional;
public interface OperationTeamService { public interface OperationTeamService {
...@@ -7,9 +8,9 @@ public interface OperationTeamService { ...@@ -7,9 +8,9 @@ public interface OperationTeamService {
public Optional<OperationTeam> getOperationTeam(Id<OperationTeam> operationTeamId) throws SQLException; public Optional<OperationTeam> getOperationTeam(Id<OperationTeam> operationTeamId) throws SQLException;
public Optional<OperationTeam> getOperationTeams(); public List<OperationTeam> getOperationTeams() throws SQLException;
public Optional<OPStaff> getOperationTeamOPStaff(Id<OperationTeam> operationTeamId); //public Optional<OPStaff> getOperationTeamOPStaff(Id<OperationTeam> operationTeamId);
} }
...@@ -85,6 +85,7 @@ public interface Repository { ...@@ -85,6 +85,7 @@ public interface Repository {
OperationTeam deleteOperationTeam(Id<OperationTeam> id) throws SQLException; OperationTeam deleteOperationTeam(Id<OperationTeam> id) throws SQLException;
Optional<OperationTeam> getOperationTeamImp(Id<OperationTeam> id) throws SQLException; Optional<OperationTeam> getOperationTeamImp(Id<OperationTeam> id) throws SQLException;
List<OperationTeam> getOperationTeamsImp() throws SQLException;
......
No preview for this file type
...@@ -639,6 +639,28 @@ class JDBCRepository implements Repository ...@@ -639,6 +639,28 @@ class JDBCRepository implements Repository
} }
} }
public List<OperationTeam> getOperationTeamsImp() throws SQLException{
try(
var result =
conn.createStatement()
.executeQuery("SELECT * FROM operationteam;");
) {
var operationTeam = new ArrayList<OperationTeam>();
while (result.next()) {
operationTeam.add(readOperationTeamFromRow(result));
}
return operationTeam;
}catch(SQLException e){
throw new RuntimeException(e);
}
}
private static OperationTeam readOperationTeamFromRow(ResultSet rs) throws SQLException{ private static OperationTeam readOperationTeamFromRow(ResultSet rs) throws SQLException{
return new OperationTeam( return new OperationTeam(
......
...@@ -325,7 +325,7 @@ public final class Tests ...@@ -325,7 +325,7 @@ public final class Tests
} }
} }
@Test //@Test
public void testGetOperationTeam() throws Exception{ public void testGetOperationTeam() throws Exception{
var id = new Id<OperationTeam>("31313131"); var id = new Id<OperationTeam>("31313131");
...@@ -340,6 +340,22 @@ public final class Tests ...@@ -340,6 +340,22 @@ public final class Tests
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
}
@Test
public void testGetMultipleOperationTeams() throws Exception{
try{
List<OperationTeam> operationTeam = operationTeamService.getOperationTeams();
for(OperationTeam operationTeam1 : operationTeam){
System.out.println(operationTeam1);
}
} catch (Exception e){
e.printStackTrace();
}
} }
......
No preview for this file type
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