class InsertOperation implements MongoDbOperation {

    @Override
    public void execute(final MongoDatabase connection, final Document data) {
        for (final Entry<String, Object> entry : data.entrySet()) {
            final String collectionName = entry.getKey();
            final Object content = entry.getValue();

            final List<Document> indexes = getIndexData(content);
            if (!indexes.isEmpty()) {
                insertIndexes(connection.getCollection(collectionName), indexes);
            }

            final List<Document> entries = getCollectionData(content);
            if (!entries.isEmpty()) {
                insertData(connection.getCollection(collectionName), entries);
            }
        }
    }

}