use of com.gamebuster19901.excite.bot.database.Row in project ExciteBot by TheGameCommunity.
the class Audit method createAudit.
@Nullable
@SuppressWarnings({ "rawtypes", "unchecked" })
protected static Audit createAudit(MessageContext context, Row row) throws SQLException {
AuditType type = AuditType.getType(row);
long auditID = row.getLong(AUDIT_ID);
Class<? extends Audit> auditTypeClazz = AuditType.getType(row).getType();
try {
Constructor<? extends Audit> constructor = auditTypeClazz.getDeclaredConstructor(Row.class);
constructor.setAccessible(true);
Result result = Table.selectAllFromJoinedUsingWhere(new MessageContext(context.getAuthor()), AUDITS, type.getTable(), AUDIT_ID, new Comparison(AUDIT_ID, EQUALS, auditID));
result.next();
if (result.cursorValid()) {
Row resultRow = result.getRow();
return constructor.newInstance(resultRow);
}
return null;
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new AssertionError(e);
}
}
use of com.gamebuster19901.excite.bot.database.Row in project ExciteBot by TheGameCommunity.
the class Audit method addAudit.
@Deprecated
@SuppressWarnings("rawtypes")
protected static Audit addAudit(MessageContext executor, MessageContext context, AuditType type, String description, Instant dateIssued) {
PreparedStatement ps;
try {
ps = Insertion.insertInto(AUDITS).setColumns(AUDIT_TYPE, ISSUER_ID, ISSUER_NAME, DESCRIPTION, DATE_ISSUED).to(type, context.getAuthor().getID(), context.getAuthor().getName(), description, Instant.now()).prepare(executor, true);
ps.execute();
ResultSet results = ps.getGeneratedKeys();
results.next();
long auditID = results.getLong(GENERATED_KEY);
Row row = Table.selectAllFromWhere(executor, AUDITS, new Comparison(AUDIT_ID, EQUALS, auditID)).getRow(true);
return new Audit(row, type);
} catch (SQLException e) {
throw new IOError(e);
}
}
Aggregations