use of com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO in project pinot by linkedin.
the class AlertJobResource method toggleActive.
private void toggleActive(Long id, boolean state) {
EmailConfigurationDTO alertConfig = emailConfigurationDAO.findById(id);
if (alertConfig == null) {
throw new NullArgumentException("Alert config not found");
}
alertConfig.setActive(state);
emailConfigurationDAO.update(alertConfig);
}
use of com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO in project pinot by linkedin.
the class AnomalyResource method deleteAnomalyFunctions.
// Delete anomaly function
@DELETE
@Path("/anomaly-function/delete")
public Response deleteAnomalyFunctions(@NotNull @QueryParam("id") Long id, @QueryParam("functionName") String functionName) throws IOException {
if (id == null) {
throw new IllegalArgumentException("id is a required query param");
}
// call endpoint to stop if active
AnomalyFunctionDTO anomalyFunctionSpec = anomalyFunctionDAO.findById(id);
if (anomalyFunctionSpec == null) {
throw new IllegalStateException("No anomalyFunctionSpec with id " + id);
}
// delete dependent entities
// email config mapping
List<EmailConfigurationDTO> emailConfigurations = emailConfigurationDAO.findByFunctionId(id);
for (EmailConfigurationDTO emailConfiguration : emailConfigurations) {
emailConfiguration.getFunctions().remove(anomalyFunctionSpec);
emailConfigurationDAO.update(emailConfiguration);
}
// raw result mapping
List<RawAnomalyResultDTO> rawResults = rawAnomalyResultDAO.findAllByTimeAndFunctionId(0, System.currentTimeMillis(), id);
for (RawAnomalyResultDTO result : rawResults) {
rawAnomalyResultDAO.delete(result);
}
// merged anomaly mapping
List<MergedAnomalyResultDTO> mergedResults = anomalyMergedResultDAO.findByFunctionId(id);
for (MergedAnomalyResultDTO result : mergedResults) {
anomalyMergedResultDAO.delete(result);
}
// delete from db
anomalyFunctionDAO.deleteById(id);
return Response.noContent().build();
}
use of com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO in project pinot by linkedin.
the class EmailResource method createEmailConfig.
@POST
public Response createEmailConfig(EmailConfigurationDTO emailConfiguration) {
List<EmailConfigurationDTO> emails = emailDAO.findByCollectionMetric(emailConfiguration.getCollection(), emailConfiguration.getMetric());
if (emails.size() > 0) {
EmailConfigurationDTO base = emails.get(0);
base.setActive(true);
base.setToAddresses(emailConfiguration.getToAddresses());
emailDAO.update(base);
return Response.ok(base.getId()).build();
}
Long id = emailDAO.save(emailConfiguration);
return Response.ok(id).build();
}
use of com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO in project pinot by linkedin.
the class GenerateAnomalyReport method updateEmailConfig.
void updateEmailConfig() {
String recipients = "xyz@linkedin.com";
for (String collection : collections) {
List<EmailConfigurationDTO> emailConfigs = emailConfigurationManager.findByCollection(collection);
for (EmailConfigurationDTO emailConfigurationDTO : emailConfigs) {
if (emailConfigurationDTO.getFunctions().size() > 0) {
emailConfigurationDTO.setToAddresses(recipients);
emailConfigurationManager.update(emailConfigurationDTO);
System.out.println("Email updated " + emailConfigurationDTO.getMetric());
}
}
}
}
use of com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO in project pinot by linkedin.
the class EmailConfigurationManagerImpl method convertEmailConfigurationBean2DTO.
private EmailConfigurationDTO convertEmailConfigurationBean2DTO(EmailConfigurationBean emailConfigurationBean) {
EmailConfigurationDTO emailConfigurationDTO = convertBean2DTO(emailConfigurationBean, EmailConfigurationDTO.class);
List<Long> functionIds = emailConfigurationBean.getFunctionIds();
if (functionIds != null && !functionIds.isEmpty()) {
List<AnomalyFunctionBean> list = genericPojoDao.get(functionIds, AnomalyFunctionBean.class);
List<AnomalyFunctionDTO> functions = new ArrayList<>();
for (AnomalyFunctionBean bean : list) {
AnomalyFunctionDTO dto = convertBean2DTO(bean, AnomalyFunctionDTO.class);
functions.add(dto);
}
emailConfigurationDTO.setFunctions(functions);
}
return emailConfigurationDTO;
}
Aggregations