Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* .
*/
package org.graylog.plugins.views.migrations.V20191125144500_MigrateDashboardsToViewsSupport;
import com.google.common.collect.Sets;
import org.bson.types.ObjectId;
import org.graylog2.migrations.Migration;
import org.graylog2.plugin.cluster.ClusterConfigService;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.time.ZonedDateTime;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class V20191125144500_MigrateDashboardsToViews extends Migration {
private static final Logger LOG = LoggerFactory.getLogger(V20191125144500_MigrateDashboardsToViews.class);
private final DashboardsService dashboardsService;
private final SearchService searchService;
private final ViewService viewService;
private final ClusterConfigService clusterConfigService;
private final RandomObjectIdProvider randomObjectIdProvider;
private final RandomUUIDProvider randomUUIDProvider;
@Inject
public V20191125144500_MigrateDashboardsToViews(
DashboardsService dashboardsService,
SearchService searchService,
ViewService viewService,
ClusterConfigService clusterConfigService,
RandomObjectIdProvider randomObjectIdProvider,
RandomUUIDProvider randomUUIDProvider) {
this.dashboardsService = dashboardsService;
this.searchService = searchService;
this.viewService = viewService;
this.clusterConfigService = clusterConfigService;
this.randomObjectIdProvider = randomObjectIdProvider;
this.randomUUIDProvider = randomUUIDProvider;
}
@Override
public ZonedDateTime createdAt() {
return ZonedDateTime.parse("2019-11-25T14:45:00Z");
}
@Override
public void upgrade() {
if (hasBeenRunSuccessfully()) {
LOG.debug("Migration already completed.");
return;
}
final Set dashboardIdToViewId = new HashSet<>();
final Consumer recordMigratedDashboardIds = dashboardIdToViewId::add;
final Map> widgetIdMigrationMapping = new HashMap<>();
final Consumer