use of com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO in project pinot by linkedin.
the class MetricConfigResource method deleteMetricConfig.
@GET
@Path("/delete")
public String deleteMetricConfig(@NotNull @QueryParam("dataset") String dataset, @NotNull @QueryParam("id") Long metricConfigId) {
metricConfigDao.deleteById(metricConfigId);
DashboardConfigDTO dashboardConfigDTO = dashboardConfigDAO.findByName(ThirdEyeUtils.getDefaultDashboardName(dataset));
if (dashboardConfigDTO != null) {
List<Long> metricIds = dashboardConfigDTO.getMetricIds();
metricIds.removeAll(Lists.newArrayList(metricConfigId));
dashboardConfigDTO.setMetricIds(metricIds);
dashboardConfigDAO.update(dashboardConfigDTO);
}
return JsonResponseUtil.buildSuccessResponseJSON("Successully deleted " + metricConfigId).toString();
}
use of com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO in project pinot by linkedin.
the class DashboardResource method getDashboardData.
@GET
@Path(value = "/data/customDashboard")
@Produces(MediaType.APPLICATION_JSON)
public String getDashboardData(@QueryParam("dataset") String collection, @QueryParam("dashboard") String dashboardName, @QueryParam("filters") String filterJson, @QueryParam("timeZone") @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone, @QueryParam("baselineStart") Long baselineStart, @QueryParam("baselineEnd") Long baselineEnd, @QueryParam("currentStart") Long currentStart, @QueryParam("currentEnd") Long currentEnd, @QueryParam("compareMode") String compareMode, @QueryParam("aggTimeGranularity") String aggTimeGranularity) {
try {
TabularViewRequest request = new TabularViewRequest();
request.setCollection(collection);
List<MetricExpression> metricExpressions = new ArrayList<>();
DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findByName(dashboardName);
List<Long> metricIds = dashboardConfig.getMetricIds();
for (Long metricId : metricIds) {
MetricConfigDTO metricConfig = metricConfigDAO.findById(metricId);
MetricExpression metricExpression = ThirdEyeUtils.getMetricExpressionFromMetricConfig(metricConfig);
metricExpressions.add(metricExpression);
}
request.setMetricExpressions(metricExpressions);
long maxDataTime = collectionMaxDataTimeCache.get(collection);
if (currentEnd > maxDataTime) {
long delta = currentEnd - maxDataTime;
currentEnd = currentEnd - delta;
baselineEnd = baselineEnd - delta;
}
// The input start and end time (i.e., currentStart, currentEnd, baselineStart, and
// baselineEnd) are given in millisecond since epoch, which is timezone insensitive. On the
// other hand, the start and end time of the request to be sent to backend database (e.g.,
// Pinot) could be converted to SimpleDateFormat, which is timezone sensitive. Therefore,
// we need to store user's start and end time in DateTime objects with data's timezone
// in order to ensure that the conversion to SimpleDateFormat is always correct regardless
// user and server's timezone, including daylight saving time.
DateTimeZone timeZoneForCollection = Utils.getDataTimeZone(collection);
request.setBaselineStart(new DateTime(baselineStart, timeZoneForCollection));
request.setBaselineEnd(new DateTime(baselineEnd, timeZoneForCollection));
request.setCurrentStart(new DateTime(currentStart, timeZoneForCollection));
request.setCurrentEnd(new DateTime(currentEnd, timeZoneForCollection));
if (filterJson != null && !filterJson.isEmpty()) {
filterJson = URLDecoder.decode(filterJson, "UTF-8");
request.setFilters(ThirdEyeUtils.convertToMultiMap(filterJson));
}
request.setTimeGranularity(Utils.getAggregationTimeGranularity(aggTimeGranularity, collection));
TabularViewHandler handler = new TabularViewHandler(queryCache);
String jsonResponse = null;
TabularViewResponse response = handler.process(request);
jsonResponse = OBJECT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(response);
LOG.debug("customDashboard response {}", jsonResponse);
return jsonResponse;
} catch (Exception e) {
LOG.error("Exception while processing /data/tabular call", e);
return "{\"ERROR\": + " + e.getMessage() + "}";
}
}
use of com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO in project pinot by linkedin.
the class DashboardConfigManagerImpl method findWhereNameLike.
public List<DashboardConfigDTO> findWhereNameLike(String name) {
Map<String, Object> parameterMap = new HashMap<>();
parameterMap.put("name", name);
List<DashboardConfigBean> list = genericPojoDao.executeParameterizedSQL(FIND_BY_NAME_LIKE, parameterMap, DashboardConfigBean.class);
List<DashboardConfigDTO> result = new ArrayList<>();
for (DashboardConfigBean bean : list) {
result.add(MODEL_MAPPER.map(bean, DashboardConfigDTO.class));
}
return result;
}
use of com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO in project pinot by linkedin.
the class RunAdhocDatabaseQueriesTool method createDashboard.
private void createDashboard(String dataset) {
String dashboardName = ThirdEyeUtils.getDefaultDashboardName(dataset);
DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findByName(dashboardName);
dashboardConfig.setMetricIds(ConfigGenerator.getMetricIdsFromMetricConfigs(metricConfigDAO.findByDataset(dataset)));
dashboardConfigDAO.update(dashboardConfig);
}
use of com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO in project pinot by linkedin.
the class DataResource method getDashboardNames.
@GET
@Path("summary/dashboards")
public List<String> getDashboardNames() {
List<String> output = new ArrayList<>();
List<DashboardConfigDTO> dashboardConfigDTOs = dashboardConfigDAO.findAll();
for (DashboardConfigDTO dashboardConfigDTO : dashboardConfigDTOs) {
output.add(dashboardConfigDTO.getName());
}
return output;
}
Aggregations