Search in sources :

Example 51 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class ServerPreferencePie method turnToSlices.

private static List<PieSlice> turnToSlices(Map<ServerUUID, String> serverNames, Map<ServerUUID, WorldTimes> serverWorldTimes, String unknown) {
    List<PieSlice> slices = new ArrayList<>();
    for (Map.Entry<ServerUUID, WorldTimes> server : serverWorldTimes.entrySet()) {
        ServerUUID serverUUID = server.getKey();
        WorldTimes worldTimes = server.getValue();
        String serverName = serverNames.getOrDefault(serverUUID, unknown);
        long num = worldTimes.getTotal();
        slices.add(new PieSlice(serverName, num));
    }
    return slices;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) ArrayList(java.util.ArrayList) WorldTimes(com.djrapitops.plan.gathering.domain.WorldTimes) Map(java.util.Map)

Example 52 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class DataValueGatherer method storeExtensionInformation.

public void storeExtensionInformation() {
    String pluginName = extension.getPluginName();
    Icon pluginIcon = extension.getPluginIcon();
    long time = System.currentTimeMillis();
    ServerUUID serverUUID = serverInfo.getServerUUID();
    Database database = dbSystem.getDatabase();
    database.executeTransaction(new StoreIconTransaction(pluginIcon));
    database.executeTransaction(new StorePluginTransaction(pluginName, time, serverUUID, pluginIcon));
    for (TabInformation tab : extension.getPluginTabs()) {
        database.executeTransaction(new StoreIconTransaction(tab.getTabIcon()));
        database.executeTransaction(new StoreTabInformationTransaction(pluginName, serverUUID, tab));
    }
    database.executeTransaction(new RemoveInvalidResultsTransaction(pluginName, serverUUID, extension.getInvalidatedMethods()));
}
Also used : StoreIconTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.StoreIconTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) Database(com.djrapitops.plan.storage.database.Database) StoreTabInformationTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.StoreTabInformationTransaction) TabInformation(com.djrapitops.plan.extension.implementation.TabInformation) Icon(com.djrapitops.plan.extension.icon.Icon) StorePluginTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.StorePluginTransaction)

Example 53 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class ExtensionInformationQueries method allExtensions.

public static Query<Map<ServerUUID, List<ExtensionInformation>>> allExtensions() {
    String sql = SELECT + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.ID + " as id," + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.PLUGIN_NAME + " as plugin_name," + ExtensionPluginTable.SERVER_UUID + ',' + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ICON_NAME + " as icon_name," + ExtensionIconTable.COLOR + ',' + ExtensionIconTable.FAMILY + FROM + ExtensionPluginTable.TABLE_NAME + INNER_JOIN + ExtensionIconTable.TABLE_NAME + " on " + ExtensionPluginTable.ICON_ID + "=" + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ID;
    return new QueryAllStatement<Map<ServerUUID, List<ExtensionInformation>>>(sql, 100) {

        @Override
        public Map<ServerUUID, List<ExtensionInformation>> processResults(ResultSet set) throws SQLException {
            Map<ServerUUID, List<ExtensionInformation>> byServerUUID = new HashMap<>();
            while (set.next()) {
                ServerUUID serverUUID = ServerUUID.fromString(set.getString(ExtensionPluginTable.SERVER_UUID));
                List<ExtensionInformation> information = byServerUUID.computeIfAbsent(serverUUID, Lists::create);
                information.add(extractExtensionInformationFromQuery(set));
            }
            return byServerUUID;
        }
    };
}
Also used : QueryAllStatement(com.djrapitops.plan.storage.database.queries.QueryAllStatement) ServerUUID(com.djrapitops.plan.identification.ServerUUID) HashMap(java.util.HashMap) Lists(com.djrapitops.plan.utilities.java.Lists) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) ExtensionInformation(com.djrapitops.plan.extension.implementation.results.ExtensionInformation)

Example 54 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class GraphsJSONResolver method getGraphJSON.

private JSONStorage.StoredJSON getGraphJSON(Request request, DataID dataID) {
    Optional<Long> timestamp = Identifiers.getTimestamp(request);
    JSONStorage.StoredJSON storedJSON;
    if (request.getQuery().get("server").isPresent()) {
        // Can throw BadRequestException
        ServerUUID serverUUID = identifiers.getServerUUID(request);
        storedJSON = jsonResolverService.resolve(timestamp, dataID, serverUUID, theServerUUID -> generateGraphDataJSONOfType(dataID, theServerUUID, request.getQuery()));
    } else {
        // Assume network
        storedJSON = jsonResolverService.resolve(timestamp, dataID, () -> generateGraphDataJSONOfType(dataID));
    }
    return storedJSON;
}
Also used : MimeType(com.djrapitops.plan.delivery.web.resolver.MimeType) Request(com.djrapitops.plan.delivery.web.resolver.request.Request) ServerUUID(com.djrapitops.plan.identification.ServerUUID) URIQuery(com.djrapitops.plan.delivery.web.resolver.request.URIQuery) Singleton(javax.inject.Singleton) Response(com.djrapitops.plan.delivery.web.resolver.Response) Inject(javax.inject.Inject) AsyncJSONResolverService(com.djrapitops.plan.delivery.webserver.cache.AsyncJSONResolverService) Resolver(com.djrapitops.plan.delivery.web.resolver.Resolver) WebUser(com.djrapitops.plan.delivery.web.resolver.request.WebUser) Identifiers(com.djrapitops.plan.identification.Identifiers) BadRequestException(com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException) Optional(java.util.Optional) JSONStorage(com.djrapitops.plan.delivery.webserver.cache.JSONStorage) GraphJSONCreator(com.djrapitops.plan.delivery.rendering.json.graphs.GraphJSONCreator) Collections(java.util.Collections) DataID(com.djrapitops.plan.delivery.webserver.cache.DataID) ServerUUID(com.djrapitops.plan.identification.ServerUUID) JSONStorage(com.djrapitops.plan.delivery.webserver.cache.JSONStorage)

Example 55 with ServerUUID

use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.

the class PlayersTableJSONResolver method getStoredJSON.

private JSONStorage.StoredJSON getStoredJSON(Request request) {
    Optional<Long> timestamp = Identifiers.getTimestamp(request);
    JSONStorage.StoredJSON storedJSON;
    if (request.getQuery().get("server").isPresent()) {
        // Can throw BadRequestException
        ServerUUID serverUUID = identifiers.getServerUUID(request);
        storedJSON = jsonResolverService.resolve(timestamp, DataID.PLAYERS, serverUUID, jsonFactory::serverPlayersTableJSON);
    } else {
        // Assume players page
        storedJSON = jsonResolverService.resolve(timestamp, DataID.PLAYERS, jsonFactory::networkPlayersTableJSON);
    }
    return storedJSON;
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) JSONStorage(com.djrapitops.plan.delivery.webserver.cache.JSONStorage)

Aggregations

ServerUUID (com.djrapitops.plan.identification.ServerUUID)105 UUID (java.util.UUID)26 ResultSet (java.sql.ResultSet)23 PreparedStatement (java.sql.PreparedStatement)21 Database (com.djrapitops.plan.storage.database.Database)17 Test (org.junit.jupiter.api.Test)17 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)14 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)12 Nickname (com.djrapitops.plan.delivery.domain.Nickname)11 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)11 Server (com.djrapitops.plan.identification.Server)11 HashMap (java.util.HashMap)11 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)9 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)9 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)9 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)9 Lists (com.djrapitops.plan.utilities.java.Lists)9 CallEvents (com.djrapitops.plan.extension.CallEvents)8 List (java.util.List)8 Map (java.util.Map)8