use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class FetchMetricDataAndExistingAnomaliesTool method fetchRawAnomaliesInRangeByFunctionId.
public List<ResultNode> fetchRawAnomaliesInRangeByFunctionId(long functionId, DateTime startTime, DateTime endTime) {
AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(functionId);
LOG.info(String.format("Loading raw anaomaly results of functionId {} from db...", Long.toString(functionId)));
List<ResultNode> resultNodes = new ArrayList<>();
if (anomalyFunction == null) {
// no such function
return resultNodes;
}
List<RawAnomalyResultDTO> rawResults = rawAnomalyResultDAO.findAllByTimeAndFunctionId(startTime.getMillis(), endTime.getMillis(), functionId);
for (RawAnomalyResultDTO rawResult : rawResults) {
ResultNode res = new ResultNode();
res.functionId = functionId;
res.functionName = anomalyFunction.getFunctionName();
res.startTime = new DateTime(rawResult.getStartTime());
res.endTime = new DateTime(rawResult.getEndTime());
res.dimensions = rawResult.getDimensions();
res.setFilters(anomalyFunction.getFilters());
res.severity = rawResult.getWeight();
AnomalyFeedbackDTO feedback = rawResult.getFeedback();
res.feedbackType = (feedback == null) ? null : feedback.getFeedbackType();
resultNodes.add(res);
}
return resultNodes;
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class FetchMetricDataAndExistingAnomaliesTool method fetchMergedAnomaliesInRangeByFunctionId.
public List<ResultNode> fetchMergedAnomaliesInRangeByFunctionId(long functionId, DateTime startTime, DateTime endTime) {
AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(functionId);
LOG.info("Loading merged anaomaly results of functionId {} from db...", functionId);
List<ResultNode> resultNodes = new ArrayList<>();
if (anomalyFunction == null) {
// no such function
return resultNodes;
}
List<MergedAnomalyResultDTO> mergedResults = mergedAnomalyResultDAO.findByStartTimeInRangeAndFunctionId(startTime.getMillis(), endTime.getMillis(), functionId);
for (MergedAnomalyResultDTO mergedResult : mergedResults) {
ResultNode res = new ResultNode();
res.functionId = functionId;
res.functionName = anomalyFunction.getFunctionName();
res.startTime = new DateTime(mergedResult.getStartTime());
res.endTime = new DateTime(mergedResult.getEndTime());
res.dimensions = mergedResult.getDimensions();
res.setFilters(anomalyFunction.getFilters());
res.severity = mergedResult.getWeight();
AnomalyFeedbackDTO feedback = mergedResult.getFeedback();
res.feedbackType = (feedback == null) ? null : feedback.getFeedbackType();
resultNodes.add(res);
}
return resultNodes;
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class AbstractManagerImpl method createRawAnomalyDTOFromBean.
protected RawAnomalyResultDTO createRawAnomalyDTOFromBean(RawAnomalyResultBean rawAnomalyResultBean) {
RawAnomalyResultDTO rawAnomalyResultDTO;
rawAnomalyResultDTO = MODEL_MAPPER.map(rawAnomalyResultBean, RawAnomalyResultDTO.class);
if (rawAnomalyResultBean.getFunctionId() != null) {
AnomalyFunctionBean anomalyFunctionBean = genericPojoDao.get(rawAnomalyResultBean.getFunctionId(), AnomalyFunctionBean.class);
if (anomalyFunctionBean == null) {
LOG.error("this anomaly function bean should not be null");
}
AnomalyFunctionDTO anomalyFunctionDTO = MODEL_MAPPER.map(anomalyFunctionBean, AnomalyFunctionDTO.class);
rawAnomalyResultDTO.setFunction(anomalyFunctionDTO);
}
if (rawAnomalyResultBean.getAnomalyFeedbackId() != null) {
AnomalyFeedbackBean anomalyFeedbackBean = genericPojoDao.get(rawAnomalyResultBean.getAnomalyFeedbackId(), AnomalyFeedbackBean.class);
AnomalyFeedbackDTO anomalyFeedbackDTO = MODEL_MAPPER.map(anomalyFeedbackBean, AnomalyFeedbackDTO.class);
rawAnomalyResultDTO.setFeedback(anomalyFeedbackDTO);
}
return rawAnomalyResultDTO;
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class MergedAnomalyResultManagerImpl method convertMergedAnomalyBean2DTO.
protected MergedAnomalyResultDTO convertMergedAnomalyBean2DTO(MergedAnomalyResultBean mergedAnomalyResultBean, boolean loadRawAnomalies) {
MergedAnomalyResultDTO mergedAnomalyResultDTO;
mergedAnomalyResultDTO = MODEL_MAPPER.map(mergedAnomalyResultBean, MergedAnomalyResultDTO.class);
if (mergedAnomalyResultBean.getFunctionId() != null) {
AnomalyFunctionBean anomalyFunctionBean = genericPojoDao.get(mergedAnomalyResultBean.getFunctionId(), AnomalyFunctionBean.class);
AnomalyFunctionDTO anomalyFunctionDTO = MODEL_MAPPER.map(anomalyFunctionBean, AnomalyFunctionDTO.class);
mergedAnomalyResultDTO.setFunction(anomalyFunctionDTO);
}
if (mergedAnomalyResultBean.getAnomalyFeedbackId() != null) {
AnomalyFeedbackBean anomalyFeedbackBean = genericPojoDao.get(mergedAnomalyResultBean.getAnomalyFeedbackId(), AnomalyFeedbackBean.class);
AnomalyFeedbackDTO anomalyFeedbackDTO = MODEL_MAPPER.map(anomalyFeedbackBean, AnomalyFeedbackDTO.class);
mergedAnomalyResultDTO.setFeedback(anomalyFeedbackDTO);
}
if (loadRawAnomalies && mergedAnomalyResultBean.getRawAnomalyIdList() != null && !mergedAnomalyResultBean.getRawAnomalyIdList().isEmpty()) {
List<RawAnomalyResultDTO> anomalyResults = new ArrayList<>();
List<RawAnomalyResultBean> list = genericPojoDao.get(mergedAnomalyResultBean.getRawAnomalyIdList(), RawAnomalyResultBean.class);
for (RawAnomalyResultBean rawAnomalyResultBean : list) {
anomalyResults.add(createRawAnomalyDTOFromBean(rawAnomalyResultBean));
}
mergedAnomalyResultDTO.setAnomalyResults(anomalyResults);
}
return mergedAnomalyResultDTO;
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class TestMergedAnomalyResultManager method testFeedback.
@Test(dependsOnMethods = { "testMergedResultCRUD" })
public void testFeedback() {
MergedAnomalyResultDTO anomalyMergedResult = mergedAnomalyResultDAO.findById(mergedResult.getId());
AnomalyFeedbackDTO feedback = new AnomalyFeedbackDTO();
feedback.setComment("this is a good find");
feedback.setFeedbackType(AnomalyFeedbackType.ANOMALY);
feedback.setStatus(FeedbackStatus.NEW);
anomalyMergedResult.setFeedback(feedback);
// now we need to make explicit call to anomaly update in order to update the feedback
mergedAnomalyResultDAO.updateAnomalyFeedback(anomalyMergedResult);
//verify feedback
MergedAnomalyResultDTO mergedResult1 = mergedAnomalyResultDAO.findById(mergedResult.getId());
Assert.assertEquals(mergedResult1.getAnomalyResults().get(0).getId(), anomalyResultId);
Assert.assertEquals(mergedResult1.getFeedback().getFeedbackType(), AnomalyFeedbackType.ANOMALY);
}
Aggregations