Search in sources :

Example 16 with EmailConfigurationDTO

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);
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) NullArgumentException(org.apache.commons.lang.NullArgumentException)

Example 17 with EmailConfigurationDTO

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();
}
Also used : RawAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO) MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 18 with EmailConfigurationDTO

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();
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) POST(javax.ws.rs.POST)

Example 19 with EmailConfigurationDTO

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());
            }
        }
    }
}
Also used : EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)

Example 20 with EmailConfigurationDTO

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;
}
Also used : AnomalyFunctionBean(com.linkedin.thirdeye.datalayer.pojo.AnomalyFunctionBean) ArrayList(java.util.ArrayList) EmailConfigurationDTO(com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Aggregations

EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)23 ArrayList (java.util.ArrayList)8 AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)7 EmailConfigurationBean (com.linkedin.thirdeye.datalayer.pojo.EmailConfigurationBean)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)3 Test (org.testng.annotations.Test)3 AlertConfigDTO (com.linkedin.thirdeye.datalayer.dto.AlertConfigDTO)2 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)2 CronTrigger (org.quartz.CronTrigger)2 SchedulerException (org.quartz.SchedulerException)2 Trigger (org.quartz.Trigger)2 AlertTaskInfo (com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo)1 EmailConfigurationManager (com.linkedin.thirdeye.datalayer.bao.EmailConfigurationManager)1 DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)1 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)1 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)1 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)1 OverrideConfigDTO (com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)1 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)1