Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return only summary of existing searches/dashboards (#10280)
* simple first version with a stripped down interface for the DTO and lax requirements on the web side for discussion * Summaries for Dashboards and Searches (ViewDTO) * Linked static strings back to the original ViewDTO to make changes in the future less error prone. * Included a delegation from ViewService to ViewSummaryService so that the Service used everywhere is still ViewService * Added .isRequired back to views in FE Added properties to ViewSummaryDTO that are needed on the FE side and unproblematic on the Backend side * replaced ViewDTO with ViewSummaryDTo to prevent deserialization errors * fixed tests to use ViewSummaryService * added SearchSummary class * removed requirements (unnecessary for the given search) * added/fixed tests to work with new Summary-Classes * removed unnecessary class * cleared up naming, invert filter criteria for better performance
- Loading branch information
Showing
17 changed files
with
412 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
graylog2-server/src/main/java/org/graylog/plugins/views/search/SearchSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* 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 | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.plugins.views.search; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
import com.google.auto.value.AutoValue; | ||
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.mongojack.Id; | ||
import org.mongojack.ObjectId; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Optional; | ||
|
||
import static org.graylog.plugins.views.search.Search.FIELD_CREATED_AT; | ||
import static org.graylog.plugins.views.search.Search.FIELD_OWNER; | ||
|
||
@AutoValue | ||
@JsonAutoDetect | ||
@JsonDeserialize(builder = SearchSummary.Builder.class) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public abstract class SearchSummary { | ||
@Id | ||
@ObjectId | ||
@Nullable | ||
@JsonProperty | ||
public abstract String id(); | ||
|
||
@JsonProperty(FIELD_OWNER) | ||
public abstract Optional<String> owner(); | ||
|
||
@JsonProperty(FIELD_CREATED_AT) | ||
public abstract DateTime createdAt(); | ||
|
||
public abstract Builder toBuilder(); | ||
|
||
public static Builder builder() { | ||
return Builder.create(); | ||
} | ||
|
||
@AutoValue.Builder | ||
@JsonPOJOBuilder(withPrefix = "") | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public abstract static class Builder { | ||
@Id | ||
@JsonProperty | ||
public abstract Builder id(String id); | ||
|
||
@JsonProperty(FIELD_OWNER) | ||
public abstract Builder owner(@Nullable String owner); | ||
|
||
@JsonProperty(FIELD_CREATED_AT) | ||
public abstract Builder createdAt(DateTime createdAt); | ||
|
||
abstract SearchSummary autoBuild(); | ||
|
||
@JsonCreator | ||
public static Builder create() { | ||
return new AutoValue_SearchSummary.Builder().createdAt(DateTime.now(DateTimeZone.UTC)); | ||
} | ||
|
||
public SearchSummary build() { | ||
return autoBuild(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.