use of org.graylog2.contentpacks.model.entities.DashboardEntity in project graylog2-server by Graylog2.
the class DashboardV1Facade method resolveEntityV1.
@SuppressWarnings("UnstableApiUsage")
private Graph<Entity> resolveEntityV1(EntityV1 entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Entity> entities) {
final DashboardEntity dashboardEntity = objectMapper.convertValue(entity.data(), DashboardEntity.class);
final ViewEntity viewEntity = entityConverter.convert(dashboardEntity, parameters);
return resolveViewEntity(entity, viewEntity, entities);
}
use of org.graylog2.contentpacks.model.entities.DashboardEntity in project graylog2-server by Graylog2.
the class EntityConverter method convert.
public ViewEntity convert(DashboardEntity dashboardEntity, Map<String, ValueReference> parameters) {
this.parameters = parameters;
this.dashboardEntity = dashboardEntity;
final String queryId = UUID.randomUUID().toString();
final Map<DashboardWidgetEntity, List<WidgetEntity>> widgets = convertWidgets();
final Map<String, WidgetPositionDTO> widgetPositionMap = DashboardEntity.positionMap(parameters, widgets);
final Titles titles = DashboardEntity.widgetTitles(widgets, parameters);
final Map<String, Set<String>> widgetMapping = new HashMap<>();
final Set<SearchTypeEntity> searchTypes = new HashSet<>();
createSearchTypes(widgets, widgetMapping, searchTypes);
SearchEntity searchEntity;
try {
searchEntity = createSearchEntity(queryId, searchTypes);
} catch (InvalidRangeParametersException e) {
throw new IllegalArgumentException("The provided entity does not have a valid TimeRange", e);
}
final ViewStateEntity viewStateEntity = ViewStateEntity.builder().widgets(widgets.values().stream().flatMap(Collection::stream).collect(Collectors.toSet())).titles(titles).widgetMapping(widgetMapping).widgetPositions(widgetPositionMap).build();
final Map<String, ViewStateEntity> viewStateEntityMap = ImmutableMap.of(queryId, viewStateEntity);
return ViewEntity.builder().search(searchEntity).state(viewStateEntityMap).title(dashboardEntity.title()).properties(Collections.emptySet()).description(dashboardEntity.description()).requires(Collections.emptyMap()).summary(ValueReference.of("Converted Dashboard")).createdAt(DateTime.now(DateTimeZone.UTC)).type(ViewEntity.Type.DASHBOARD).build();
}
use of org.graylog2.contentpacks.model.entities.DashboardEntity in project graylog2-server by Graylog2.
the class DashboardV1Facade method convertEntity.
private EntityV1 convertEntity(EntityV1 entityV1, Map<String, ValueReference> parameters) {
final DashboardEntity dashboardEntity = objectMapper.convertValue(entityV1.data(), DashboardEntity.class);
final ViewEntity viewEntity = entityConverter.convert(dashboardEntity, parameters);
final JsonNode data = objectMapper.convertValue(viewEntity, JsonNode.class);
return entityV1.toBuilder().data(data).type(ModelTypes.DASHBOARD_V2).build();
}
Aggregations