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.
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog2.dashboards.widgets.strategies;
import com.google.common.collect.ImmutableMap;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import org.graylog2.dashboards.widgets.InvalidWidgetConfigurationException;
import org.graylog2.indexer.FieldTypeException;
import org.graylog2.indexer.results.HistogramResult;
import org.graylog2.indexer.searches.Searches;
import org.graylog2.plugin.dashboards.widgets.ComputationResult;
import org.graylog2.plugin.dashboards.widgets.WidgetStrategy;
import org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange;
import org.graylog2.plugin.indexer.searches.timeranges.TimeRange;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.google.common.base.Strings.isNullOrEmpty;
public class StackedChartWidgetStrategy extends ChartWidgetStrategy {
public interface Factory extends WidgetStrategy.Factory {
@Override
StackedChartWidgetStrategy create(Map config, TimeRange timeRange, String widgetId);
}
private static final Logger LOG = LoggerFactory.getLogger(StackedChartWidgetStrategy.class);
private final List chartSeries;
private final Searches searches;
private final TimeRange timeRange;
private final String widgetId;
@AssistedInject
public StackedChartWidgetStrategy(Searches searches, @Assisted Map config, @Assisted TimeRange timeRange, @Assisted String widgetId) throws InvalidWidgetConfigurationException {
super(config);
this.searches = searches;
this.timeRange = timeRange;
this.widgetId = widgetId;
if (!checkConfig(config)) {
throw new InvalidWidgetConfigurationException("Missing or invalid widget configuration. Provided config was: " + config.toString());
}
final Object persistedSeries = config.get("series");
if (persistedSeries instanceof List) {
final List chartSeries = (List) persistedSeries;
this.chartSeries = new ArrayList<>(chartSeries.size());
for (final Object series : chartSeries) {
this.chartSeries.add(Series.fromMap((Map) series));
}
} else {
throw new InvalidWidgetConfigurationException("Invalid widget configuration, 'series' should be a list: " + config.toString());
}
}
@Override
public ComputationResult compute() {
String filter = null;
if (!isNullOrEmpty(streamId)) {
filter = "streams:" + streamId;
}
final List