Search in sources :

Example 6 with ViewEntity

use of org.graylog2.contentpacks.model.entities.ViewEntity in project graylog2-server by Graylog2.

the class ViewFacadeTest method createViewEntity.

private EntityV1 createViewEntity() throws Exception {
    final QueryEntity query = QueryEntity.builder().id("dead-beef").timerange(KeywordRange.create("last 5 minutes", "Etc/UTC")).filter(OrFilter.or(StreamFilter.ofId(newStreamId))).query(ElasticsearchQueryString.of("author: Mara Jade")).build();
    final SearchEntity searchEntity = SearchEntity.builder().queries(ImmutableSet.of(query)).parameters(ImmutableSet.of()).requires(ImmutableMap.of()).createdAt(DateTime.now(DateTimeZone.UTC)).build();
    final ViewStateEntity viewStateEntity = ViewStateEntity.builder().fields(ImmutableSet.of()).titles(Titles.empty()).widgets(ImmutableSet.of()).widgetMapping(ImmutableMap.of()).widgetPositions(ImmutableMap.of()).formatting(FormattingSettings.builder().highlighting(ImmutableSet.of()).build()).displayModeSettings(DisplayModeSettings.empty()).build();
    final ViewEntity entity = ViewEntity.builder().type(ViewEntity.Type.SEARCH).summary(ValueReference.of("summary")).title(ValueReference.of("title")).description(ValueReference.of("description")).search(searchEntity).properties(ImmutableSet.of()).requires(ImmutableMap.of()).state(ImmutableMap.of(newViewId, viewStateEntity)).createdAt(DateTime.now(DateTimeZone.UTC)).build();
    return EntityV1.builder().id(ModelId.of("1")).type(ModelTypes.SEARCH_V1).data(objectMapper.convertValue(entity, JsonNode.class)).build();
}
Also used : ViewStateEntity(org.graylog2.contentpacks.model.entities.ViewStateEntity) SearchEntity(org.graylog2.contentpacks.model.entities.SearchEntity) ViewEntity(org.graylog2.contentpacks.model.entities.ViewEntity) QueryEntity(org.graylog2.contentpacks.model.entities.QueryEntity)

Example 7 with ViewEntity

use of org.graylog2.contentpacks.model.entities.ViewEntity in project graylog2-server by Graylog2.

the class ViewFacade method exportNativeEntity.

private Entity exportNativeEntity(ViewDTO view, EntityDescriptorIds entityDescriptorIds) {
    final ViewEntity.Builder viewEntityBuilder = view.toContentPackEntity(entityDescriptorIds);
    final Optional<Search> optionalSearch = searchDbService.get(view.searchId());
    final Search search = optionalSearch.orElseThrow(() -> new IllegalArgumentException("Search is missing in view " + view.searchId()));
    SearchEntity searchEntity = search.toContentPackEntity(entityDescriptorIds);
    final ViewEntity viewEntity = viewEntityBuilder.search(searchEntity).build();
    final JsonNode data = objectMapper.convertValue(viewEntity, JsonNode.class);
    return EntityV1.builder().id(ModelId.of(entityDescriptorIds.getOrThrow(EntityDescriptor.create(view.id(), getModelType())))).type(getModelType()).data(data).build();
}
Also used : ViewEntity(org.graylog2.contentpacks.model.entities.ViewEntity) SearchEntity(org.graylog2.contentpacks.model.entities.SearchEntity) Search(org.graylog.plugins.views.search.Search) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 8 with ViewEntity

use of org.graylog2.contentpacks.model.entities.ViewEntity 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();
}
Also used : DashboardEntity(org.graylog2.contentpacks.model.entities.DashboardEntity) ViewEntity(org.graylog2.contentpacks.model.entities.ViewEntity) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

ViewEntity (org.graylog2.contentpacks.model.entities.ViewEntity)7 SearchEntity (org.graylog2.contentpacks.model.entities.SearchEntity)5 ViewStateEntity (org.graylog2.contentpacks.model.entities.ViewStateEntity)5 Search (org.graylog.plugins.views.search.Search)3 ViewDTO (org.graylog.plugins.views.search.views.ViewDTO)3 QueryEntity (org.graylog2.contentpacks.model.entities.QueryEntity)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 HashMap (java.util.HashMap)2 StreamFilter (org.graylog.plugins.views.search.filter.StreamFilter)2 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)2 DashboardEntity (org.graylog2.contentpacks.model.entities.DashboardEntity)2 Entity (org.graylog2.contentpacks.model.entities.Entity)2 EntityDescriptor (org.graylog2.contentpacks.model.entities.EntityDescriptor)2 EventListEntity (org.graylog2.contentpacks.model.entities.EventListEntity)2 MessageListEntity (org.graylog2.contentpacks.model.entities.MessageListEntity)2 NativeEntity (org.graylog2.contentpacks.model.entities.NativeEntity)2 PivotEntity (org.graylog2.contentpacks.model.entities.PivotEntity)2 StreamEntity (org.graylog2.contentpacks.model.entities.StreamEntity)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1