refactoring - made json type infos consistent for all query types

This commit is contained in:
René Scheibe 2013-04-06 12:38:35 +02:00
parent a6dc29cf85
commit 488b3ef8ff
4 changed files with 9 additions and 7 deletions

View File

@ -42,14 +42,16 @@ import java.util.Map;
@JsonSubTypes.Type(name = Query.TIMESERIES, value = TimeseriesQuery.class), @JsonSubTypes.Type(name = Query.TIMESERIES, value = TimeseriesQuery.class),
@JsonSubTypes.Type(name = Query.SEARCH, value = SearchQuery.class), @JsonSubTypes.Type(name = Query.SEARCH, value = SearchQuery.class),
@JsonSubTypes.Type(name = Query.TIME_BOUNDARY, value = TimeBoundaryQuery.class), @JsonSubTypes.Type(name = Query.TIME_BOUNDARY, value = TimeBoundaryQuery.class),
@JsonSubTypes.Type(name = "groupBy", value= GroupByQuery.class), @JsonSubTypes.Type(name = Query.GROUP_BY, value = GroupByQuery.class),
@JsonSubTypes.Type(name = "segmentMetadata", value= SegmentMetadataQuery.class) @JsonSubTypes.Type(name = Query.SEGMENT_METADATA, value = SegmentMetadataQuery.class)
}) })
public interface Query<T> public interface Query<T>
{ {
public static final String TIMESERIES = "timeseries"; public static final String TIMESERIES = "timeseries";
public static final String SEARCH = "search"; public static final String SEARCH = "search";
public static final String TIME_BOUNDARY = "timeBoundary"; public static final String TIME_BOUNDARY = "timeBoundary";
public static final String GROUP_BY = "groupBy";
public static final String SEGMENT_METADATA = "segmentMetadata";
public String getDataSource(); public String getDataSource();

View File

@ -116,7 +116,7 @@ public class GroupByQuery extends BaseQuery<Row>
@Override @Override
public String getType() public String getType()
{ {
return "groupBy"; return Query.GROUP_BY;
} }
@Override @Override

View File

@ -19,6 +19,7 @@
package com.metamx.druid.query.metadata; package com.metamx.druid.query.metadata;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.metamx.druid.BaseQuery; import com.metamx.druid.BaseQuery;
import com.metamx.druid.Query; import com.metamx.druid.Query;
@ -32,6 +33,7 @@ public class SegmentMetadataQuery extends BaseQuery<SegmentAnalysis>
private final ColumnIncluderator toInclude; private final ColumnIncluderator toInclude;
private final boolean merge; private final boolean merge;
@JsonCreator
public SegmentMetadataQuery( public SegmentMetadataQuery(
@JsonProperty("dataSource") String dataSource, @JsonProperty("dataSource") String dataSource,
@JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec,
@ -67,7 +69,7 @@ public class SegmentMetadataQuery extends BaseQuery<SegmentAnalysis>
@Override @Override
public String getType() public String getType()
{ {
return "segmentMetadata"; return Query.SEGMENT_METADATA;
} }
@Override @Override

View File

@ -43,8 +43,6 @@ import java.util.Map;
@JsonTypeName("timeseries") @JsonTypeName("timeseries")
public class TimeseriesQuery extends BaseQuery<Result<TimeseriesResultValue>> public class TimeseriesQuery extends BaseQuery<Result<TimeseriesResultValue>>
{ {
public static final String TIMESERIES = "timeseries";
private final DimFilter dimFilter; private final DimFilter dimFilter;
private final QueryGranularity granularity; private final QueryGranularity granularity;
private final List<AggregatorFactory> aggregatorSpecs; private final List<AggregatorFactory> aggregatorSpecs;
@ -79,7 +77,7 @@ public class TimeseriesQuery extends BaseQuery<Result<TimeseriesResultValue>>
@Override @Override
public String getType() public String getType()
{ {
return TIMESERIES; return Query.TIMESERIES;
} }
@JsonProperty("filter") @JsonProperty("filter")