use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class TestAlertFilterUtil method getMockMergedAnomalies.
private List<MergedAnomalyResultDTO> getMockMergedAnomalies(int posIdx, int negIdx) {
List<MergedAnomalyResultDTO> anomalyResultDTOS = new ArrayList<>();
int[] ws = { 1, 1, 2, 3, 4, 4, 5, 6, 7 };
double[] severity = { 2.0, 4.0, 2.0, 3.0, 1.0, 3.0, 2.0, 1.0, 3.0 };
AnomalyFeedbackDTO positiveFeedback = new AnomalyFeedbackDTO();
AnomalyFeedbackDTO negativeFeedback = new AnomalyFeedbackDTO();
positiveFeedback.setFeedbackType(ANOMALY);
negativeFeedback.setFeedbackType(NOT_ANOMALY);
for (int i = 0; i < ws.length; i++) {
MergedAnomalyResultDTO anomaly = new MergedAnomalyResultDTO();
anomaly.setStartTime(0l);
anomaly.setEndTime(ws[i] * 3600 * 1000l);
anomaly.setWeight(severity[i]);
if (i == posIdx) {
anomaly.setFeedback(positiveFeedback);
} else if (i == negIdx) {
anomaly.setFeedback(negativeFeedback);
} else {
anomaly.setFeedback(null);
}
anomalyResultDTOS.add(anomaly);
}
return anomalyResultDTOS;
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class TestAnomalyResultManager method testResultFeedback.
@Test(dependsOnMethods = { "testAnomalyResultCRUD" })
public void testResultFeedback() {
RawAnomalyResultDTO result = rawAnomalyResultDAO.findById(anomalyResult.getId());
Assert.assertNotNull(result);
Assert.assertNull(result.getFeedback());
AnomalyFeedbackDTO feedback = new AnomalyFeedbackDTO();
feedback.setComment("this is a good find");
feedback.setFeedbackType(AnomalyFeedbackType.ANOMALY);
feedback.setStatus(FeedbackStatus.NEW);
result.setFeedback(feedback);
rawAnomalyResultDAO.save(result);
RawAnomalyResultDTO resultRet = rawAnomalyResultDAO.findById(anomalyResult.getId());
Assert.assertEquals(resultRet.getId(), result.getId());
Assert.assertNotNull(resultRet.getFeedback());
AnomalyFunctionDTO functionSpec = result.getFunction();
rawAnomalyResultDAO.deleteById(anomalyResult.getId());
anomalyFunctionDAO.deleteById(functionSpec.getId());
}
use of com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO in project pinot by linkedin.
the class AnomaliesResource method updateAnomalyMergedResultFeedback.
/**
* Update anomaly feedback
* @param mergedAnomalyId : mergedAnomalyId
* @param payload : Json payload containing feedback @see com.linkedin.thirdeye.constant.AnomalyFeedbackType
* eg. payload
* <p/>
* { "feedbackType": "NOT_ANOMALY", "comment": "this is not an anomaly" }
*/
@POST
@Path(value = "/updateFeedback/{mergedAnomalyId}")
public void updateAnomalyMergedResultFeedback(@PathParam("mergedAnomalyId") long mergedAnomalyId, String payload) {
try {
MergedAnomalyResultDTO result = mergedAnomalyResultDAO.findById(mergedAnomalyId);
if (result == null) {
throw new IllegalArgumentException("AnomalyResult not found with id " + mergedAnomalyId);
}
AnomalyFeedbackDTO feedback = result.getFeedback();
if (feedback == null) {
feedback = new AnomalyFeedbackDTO();
result.setFeedback(feedback);
}
AnomalyFeedbackDTO feedbackRequest = new ObjectMapper().readValue(payload, AnomalyFeedbackDTO.class);
if (feedbackRequest.getStatus() == null) {
feedback.setStatus(FeedbackStatus.NEW);
} else {
feedback.setStatus(feedbackRequest.getStatus());
}
feedback.setComment(feedbackRequest.getComment());
feedback.setFeedbackType(feedbackRequest.getFeedbackType());
mergedAnomalyResultDAO.updateAnomalyFeedback(result);
} catch (IOException e) {
throw new IllegalArgumentException("Invalid payload " + payload, e);
}
}
Aggregations