Search in sources :

Example 1 with ExecutionState

use of org.graylog.plugins.views.search.rest.ExecutionState in project graylog2-server by Graylog2.

the class Search method applyExecutionState.

public Search applyExecutionState(ObjectMapper objectMapper, ExecutionState executionState) {
    final Builder builder = toBuilder();
    if (!executionState.parameterBindings().isEmpty()) {
        final ImmutableSet<Parameter> parameters = parameters().stream().map(param -> param.applyBindings(executionState.parameterBindings())).collect(toImmutableSet());
        builder.parameters(parameters);
    }
    if (executionState.queries() != null || executionState.globalOverride() != null) {
        final ImmutableSet<Query> queries = queries().stream().map(query -> applyStateToQuery(executionState, query)).collect(toImmutableSet());
        builder.queries(queries);
    }
    return builder.build();
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Id(org.mongojack.Id) EntityDescriptorIds(org.graylog2.contentpacks.EntityDescriptorIds) DateTimeZone(org.joda.time.DateTimeZone) Supplier(java.util.function.Supplier) SearchEntity(org.graylog2.contentpacks.model.entities.SearchEntity) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet.of(com.google.common.collect.ImmutableSet.of) ImmutableSet(com.google.common.collect.ImmutableSet) ContentPackable(org.graylog2.contentpacks.ContentPackable) ImmutableMap(com.google.common.collect.ImmutableMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DateTime(org.joda.time.DateTime) ObjectId(org.mongojack.ObjectId) Set(java.util.Set) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) JsonPOJOBuilder(com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) PluginMetadataSummary(org.graylog.plugins.views.search.views.PluginMetadataSummary) ExecutionStateGlobalOverride(org.graylog.plugins.views.search.rest.ExecutionStateGlobalOverride) ExecutionState(org.graylog.plugins.views.search.rest.ExecutionState) MissingStreamPermissionException(org.graylog2.shared.rest.exceptions.MissingStreamPermissionException) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) AutoValue(com.google.auto.value.AutoValue) Optional(java.util.Optional) JsonDeserialize(com.fasterxml.jackson.databind.annotation.JsonDeserialize) Collections(java.util.Collections) JsonPOJOBuilder(com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder)

Example 2 with ExecutionState

use of org.graylog.plugins.views.search.rest.ExecutionState in project graylog2-server by Graylog2.

the class SearchTest method keepsMultipleSearchTypesWhenOverridden.

@Test
public void keepsMultipleSearchTypesWhenOverridden() {
    Search before = Search.builder().queries(queriesWithSearchTypes("oans,zwoa", "gsuffa")).build();
    ExecutionState executionState = partialResultsMapWithSearchTypes("oans", "gsuffa");
    Search after = before.applyExecutionState(objectMapperProvider.get(), executionState);
    assertThat(searchTypeIdsFrom(after)).containsExactlyInAnyOrder("oans", "gsuffa");
}
Also used : ExecutionState(org.graylog.plugins.views.search.rest.ExecutionState) Test(org.junit.Test)

Example 3 with ExecutionState

use of org.graylog.plugins.views.search.rest.ExecutionState in project graylog2-server by Graylog2.

the class SearchTest method keepsSingleSearchTypeWhenOverridden.

@Test
public void keepsSingleSearchTypeWhenOverridden() {
    Search before = Search.builder().queries(queriesWithSearchTypes("oans,zwoa")).build();
    ExecutionState executionState = partialResultsMapWithSearchTypes("oans");
    Search after = before.applyExecutionState(objectMapperProvider.get(), executionState);
    assertThat(searchTypeIdsFrom(after)).containsOnly("oans");
}
Also used : ExecutionState(org.graylog.plugins.views.search.rest.ExecutionState) Test(org.junit.Test)

Aggregations

ExecutionState (org.graylog.plugins.views.search.rest.ExecutionState)3 Test (org.junit.Test)2 JsonAutoDetect (com.fasterxml.jackson.annotation.JsonAutoDetect)1 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonDeserialize (com.fasterxml.jackson.databind.annotation.JsonDeserialize)1 JsonPOJOBuilder (com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder)1 AutoValue (com.google.auto.value.AutoValue)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.of (com.google.common.collect.ImmutableSet.of)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1