PC-966 Implement support for teams to be assigned to a report
This commit is contained in:
parent
f1d1585585
commit
d115097eb9
@ -8,6 +8,7 @@ import java.util.Set;
|
|||||||
import mineplex.core.report.ReportCategory;
|
import mineplex.core.report.ReportCategory;
|
||||||
import mineplex.core.report.ReportHandlerTask;
|
import mineplex.core.report.ReportHandlerTask;
|
||||||
import mineplex.core.report.ReportResult;
|
import mineplex.core.report.ReportResult;
|
||||||
|
import mineplex.core.report.ReportTeam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds data for a Report.
|
* Holds data for a Report.
|
||||||
@ -22,6 +23,7 @@ public class Report
|
|||||||
private Integer _handlerId = null;
|
private Integer _handlerId = null;
|
||||||
private Integer _snapshotId = null;
|
private Integer _snapshotId = null;
|
||||||
private ReportResult _reportResult = null;
|
private ReportResult _reportResult = null;
|
||||||
|
private ReportTeam _assignedTeam = null;
|
||||||
|
|
||||||
private ReportHandlerTask _handlerTask = null;
|
private ReportHandlerTask _handlerTask = null;
|
||||||
|
|
||||||
@ -107,6 +109,16 @@ public class Report
|
|||||||
_reportResult = reportResult;
|
_reportResult = reportResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<ReportTeam> getAssignedTeam()
|
||||||
|
{
|
||||||
|
return Optional.ofNullable(_assignedTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssignedTeam(ReportTeam assignedTeam)
|
||||||
|
{
|
||||||
|
_assignedTeam = assignedTeam;
|
||||||
|
}
|
||||||
|
|
||||||
public ReportMessage getLatestMessage()
|
public ReportMessage getLatestMessage()
|
||||||
{
|
{
|
||||||
ReportMessage latest = null;
|
ReportMessage latest = null;
|
||||||
|
@ -36,6 +36,7 @@ import mineplex.core.report.ReportManager;
|
|||||||
import mineplex.core.report.ReportResult;
|
import mineplex.core.report.ReportResult;
|
||||||
import mineplex.core.report.ReportResultType;
|
import mineplex.core.report.ReportResultType;
|
||||||
import mineplex.core.report.ReportRole;
|
import mineplex.core.report.ReportRole;
|
||||||
|
import mineplex.core.report.ReportTeam;
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ public class ReportRepository
|
|||||||
private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId)\n" +
|
private static final String INSERT_REPORT = "INSERT INTO reports (suspectId, categoryId, snapshotId)\n" +
|
||||||
"VALUES (?, ?, ?);";
|
"VALUES (?, ?, ?);";
|
||||||
|
|
||||||
private static final String UPDATE_REPORT = "UPDATE reports SET snapshotId = ? WHERE id = ?;";
|
private static final String UPDATE_REPORT = "UPDATE reports SET snapshotId = ?, assignedTeam = ? WHERE id = ?;";
|
||||||
|
|
||||||
private static final String SET_REPORT_MESSAGE = "REPLACE INTO reportReasons (reportId, reporterId, reason, `server`, weight, `time`)" +
|
private static final String SET_REPORT_MESSAGE = "REPLACE INTO reportReasons (reportId, reporterId, reason, `server`, weight, `time`)" +
|
||||||
" VALUES (?, ?, ?, ?, ?, ?);";
|
" VALUES (?, ?, ?, ?, ?, ?);";
|
||||||
@ -326,6 +327,21 @@ public class ReportRepository
|
|||||||
report.setHandlerId(handlerId);
|
report.setHandlerId(handlerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short teamId = resultSet.getShort("assignedTeam");
|
||||||
|
if (!resultSet.wasNull())
|
||||||
|
{
|
||||||
|
ReportTeam team = ReportTeam.getById(teamId);
|
||||||
|
|
||||||
|
if (team != null)
|
||||||
|
{
|
||||||
|
report.setAssignedTeam(team);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.log(Level.WARNING, "Unrecognised report team found in database: " + teamId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<ReportMessage> reportMessages = getReportReasons(connection, reportId);
|
Set<ReportMessage> reportMessages = getReportReasons(connection, reportId);
|
||||||
reportMessages.forEach(report::addReportReason);
|
reportMessages.forEach(report::addReportReason);
|
||||||
|
|
||||||
@ -511,7 +527,18 @@ public class ReportRepository
|
|||||||
{
|
{
|
||||||
PreparedStatement updateReportStatement = connection.prepareStatement(UPDATE_REPORT);
|
PreparedStatement updateReportStatement = connection.prepareStatement(UPDATE_REPORT);
|
||||||
updateReportStatement.setInt(1, snapshotIdOptional.get());
|
updateReportStatement.setInt(1, snapshotIdOptional.get());
|
||||||
updateReportStatement.setLong(2, reportId);
|
|
||||||
|
Optional<ReportTeam> teamOptional = report.getAssignedTeam();
|
||||||
|
if (teamOptional.isPresent())
|
||||||
|
{
|
||||||
|
updateReportStatement.setShort(2, teamOptional.get().getDatabaseId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateReportStatement.setNull(2, Types.TINYINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateReportStatement.setLong(3, reportId);
|
||||||
updateReportStatement.execute();
|
updateReportStatement.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user