Search in sources :

Example 1 with DatabaseImpl

use of de.dytanic.cloudnet.database.DatabaseImpl in project CloudNet by Dytanic.

the class NameToUUIDDatabase method handleUpdate.

@Deprecated
public void handleUpdate(UpdateConfigurationDatabase updateConfigurationDatabase) {
    if (!updateConfigurationDatabase.get().contains("updated_database_from_2_1_Pv29")) {
        Collection<Document> documents = database.loadDocuments().getDocs();
        String name;
        for (Document document : documents) {
            name = document.getString(Database.UNIQUE_NAME_KEY);
            if (name != null)
                if (name.length() < 32) {
                    database.delete(document.getString(Database.UNIQUE_NAME_KEY));
                    database.insert(document.append(Database.UNIQUE_NAME_KEY, name.toLowerCase()));
                }
        }
        updateConfigurationDatabase.set(updateConfigurationDatabase.get().append("updated_database_from_2_1_Pv29", true));
        ((DatabaseImpl) database).save();
        ((DatabaseImpl) database).clear();
    }
}
Also used : DatabaseImpl(de.dytanic.cloudnet.database.DatabaseImpl) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 2 with DatabaseImpl

use of de.dytanic.cloudnet.database.DatabaseImpl in project CloudNet by Dytanic.

the class PacketDBInGetDocument method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!data.contains("name")) {
        Map<String, Document> docs = ((DatabaseImpl) CloudNet.getInstance().getDatabaseManager().getDatabase(data.getString("db")).loadDocuments()).getDocuments();
        packetSender.sendPacket(getResult(new Document("docs", docs)));
    } else {
        String x = data.getString("name");
        String db = data.getString("db");
        Document document = CloudNet.getInstance().getDatabaseManager().getDatabase(db).getDocument(x);
        packetSender.sendPacket(getResult(new Document("result", document)));
    }
}
Also used : DatabaseImpl(de.dytanic.cloudnet.database.DatabaseImpl) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Aggregations

DatabaseImpl (de.dytanic.cloudnet.database.DatabaseImpl)2 Document (de.dytanic.cloudnet.lib.utility.document.Document)2 DatabaseDocument (de.dytanic.cloudnet.lib.database.DatabaseDocument)1