use of com.djrapitops.plan.extension.table.Table in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionServerAggregateQueriesWork.
@Test
default void extensionServerAggregateQueriesWork() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
System.out.println(tabData.getValueOrder());
OptionalAssert.equals("0.0", tabData.getPercentage("boolVal_aggregate").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getPercentage("percentageVal_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal_total").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("5", tabData.getNumber("value_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("5", tabData.getNumber("value_total").map(data -> data.getFormattedValue(Objects::toString)));
List<ExtensionTableData> tableData = tabData.getTableData();
assertEquals(1, tableData.size());
HtmlTable table = tableData.get(0).getHtmlTable();
String result = table.toHtml();
assertTrue(result.contains("<tbody><tr><td>Group</td><td>1</td></tr></tbody>"), result);
}
use of com.djrapitops.plan.extension.table.Table in project Plan by plan-player-analytics.
the class QueriedTables method toQueriedTabs.
public QueriedTabData toQueriedTabs() {
QueriedTabData tabData = new QueriedTabData();
for (Map.Entry<Integer, Map<Integer, Table.Factory>> entry : byPluginID.entrySet()) {
Integer pluginID = entry.getKey();
for (Table.Factory table : entry.getValue().values()) {
// Extra Table information
String tableName = TableAccessor.getTableName(table);
Color tableColor = TableAccessor.getColor(table);
// Extra tab information
String tabName = TableAccessor.getTabName(table);
ExtensionTabData.Builder tab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(table));
tab.putTableData(new ExtensionTableData(tableName, table.build(), tableColor));
}
}
return tabData;
}
use of com.djrapitops.plan.extension.table.Table in project Plan by plan-player-analytics.
the class DataValueGatherer method storePlayerTable.
private void storePlayerTable(Parameters parameters, Conditions conditions, TableDataValue data) {
ProviderInformation information = data.getInformation();
Table value = getValue(conditions, data, information);
if (value == null)
return;
Database db = dbSystem.getDatabase();
for (Icon icon : value.getIcons()) {
if (icon != null)
db.executeTransaction(new StoreIconTransaction(icon));
}
db.executeTransaction(new StoreTableProviderTransaction(information, parameters, value));
db.executeTransaction(new StorePlayerTableResultTransaction(information, parameters, value));
}
use of com.djrapitops.plan.extension.table.Table in project Plan by plan-player-analytics.
the class DataValueGatherer method storeTable.
private void storeTable(Parameters parameters, Conditions conditions, TableDataValue data) {
ProviderInformation information = data.getInformation();
Table value = getValue(conditions, data, information);
if (value == null)
return;
Database db = dbSystem.getDatabase();
for (Icon icon : value.getIcons()) {
if (icon != null)
db.executeTransaction(new StoreIconTransaction(icon));
}
db.executeTransaction(new StoreTableProviderTransaction(information, parameters, value));
db.executeTransaction(new StoreServerTableResultTransaction(information, parameters, value));
}
use of com.djrapitops.plan.extension.table.Table in project Plan by plan-player-analytics.
the class HtmlTableTest method dynamicTableProducesSameHtmlAsOldCode.
@Test
void dynamicTableProducesSameHtmlAsOldCode() {
// Produced by old code
String expected = "<table class=\"table table-bordered table-striped table-hover player-plugin-table\" style=\"width: 100%\"><thead><tr><th><i class=\" fa fa-test\"></i> Col 1</th><th><i class=\" fa fa-test\"></i> Col 2</th><th><i class=\" fa fa-test\"></i> Col 3</th></tr></thead><tbody><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr>" + "<tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr>" + "<tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr><tr><td data-order=\"1\">1</td><td data-order=\"2\">2</td><td>three</td></tr></tbody></table>";
Icon icon = Icon.called("test").build();
Table.Factory buildingTable = Table.builder().columnOne("Col 1", icon).columnTwo("Col 2", icon).columnThree("Col 3", icon);
for (int i = 0; i < 60; i++) {
buildingTable.addRow("1", 2, "three");
}
String result = HtmlTable.fromExtensionTable(buildingTable.build(), Color.AMBER).toHtml();
assertEquals(expected, result);
}
Aggregations