/** * {@inheritDoc} */ @Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); }
/** * This method finds the right attributes to set. The set fields can be found * in the {@link TextTemplates}. * * @param expEvent an {@link ExperimentCreateEvent} that represents the created experiment * @return the message for the email */ private String getExperimentCreatedMessage(ExperimentCreateEvent expEvent) { ST template = new ST(EXPERIMENT_CREATED); Map<String, String> variables = new HashMap<>(); ExperimentBase exp = expEvent.getExperiment(); put(variables, EXPERIMENT_LABEL, exp.getLabel()); put(variables, EXPERIMENT_ID, String.valueOf(exp.getID())); put(variables, APPLICATION_NAME, String.valueOf(exp.getApplicationName())); put(variables, USER_NAME, getUserRepresentation(expEvent.getUser())); return replaceVariablesInTemplate(variables, template); }
/** * This method finds the right attributes to set. The set fields can be found * in the {@link TextTemplates}. * * @param expEvent an {@link ExperimentChangeEvent} that represents the changes * @return the message for the email */ private String getExperimentChangedMessage(ExperimentChangeEvent expEvent) { ST template = new ST(EXPERIMENT_CHANGED); Map<String, String> variables = new HashMap<>(); ExperimentBase exp = expEvent.getExperiment(); put(variables, EXPERIMENT_LABEL, exp.getLabel()); put(variables, EXPERIMENT_ID, String.valueOf(exp.getID())); put(variables, APPLICATION_NAME, String.valueOf(exp.getApplicationName())); put(variables, USER_NAME, getUserRepresentation(expEvent.getUser())); put(variables, FIELD_NAME, expEvent.getPropertyName()); if (expEvent.getPropertyName() != null && "sampling_percent".equalsIgnoreCase(expEvent.getPropertyName())) { put(variables, FIELD_BEFORE, String.valueOf(((double) Math.round(Double.parseDouble(expEvent.getBefore()) * 10000d) / 10000d) * 100).concat("%")); put(variables, FIELD_AFTER, String.valueOf(((double) Math.round(Double.parseDouble(expEvent.getAfter()) * 10000d) / 10000d) * 100).concat("%")); } else { put(variables, FIELD_BEFORE, expEvent.getBefore()); put(variables, FIELD_AFTER, expEvent.getAfter()); } return replaceVariablesInTemplate(variables, template); }
/** * This method finds the right attributes to set. The set fields can be found * in the {@link TextTemplates}. * * @param buckEvent an {@link BucketChangeEvent} that represents the changes * @return the message for the email */ private String getBucketChangedMessage(BucketChangeEvent buckEvent) { ST template = new ST(BUCKET_CHANGE); Map<String, String> variables = new HashMap<>(); Bucket buck = buckEvent.getBucket(); ExperimentBase exp = buckEvent.getExperiment(); put(variables, EXPERIMENT_LABEL, exp.getLabel()); put(variables, BUCKET_NAME, buck.getLabel().toString()); put(variables, APPLICATION_NAME, String.valueOf(exp.getApplicationName())); put(variables, USER_NAME, getUserRepresentation(buckEvent.getUser())); put(variables, FIELD_NAME, buckEvent.getPropertyName()); if (buckEvent.getPropertyName() != null && "allocation".equalsIgnoreCase(buckEvent.getPropertyName())) { put(variables, FIELD_BEFORE, String.valueOf(((double) Math.round(Double.parseDouble(buckEvent.getBefore()) * 10000d) / 10000d) * 100).concat("%")); put(variables, FIELD_AFTER, String.valueOf(((double) Math.round(Double.parseDouble(buckEvent.getAfter()) * 10000d) / 10000d) * 100).concat("%")); } else { put(variables, FIELD_BEFORE, buckEvent.getBefore()); put(variables, FIELD_AFTER, buckEvent.getAfter()); } return replaceVariablesInTemplate(variables, template); }
/** * This method finds the right attributes to set. The set fields can be found * in the {@link TextTemplates}. * * @param buckEvent an {@link BucketCreateEvent} that represents the changes * @return the message for the email */ private String getBucketCreatedMessage(BucketCreateEvent buckEvent) { ST template = new ST(BUCKET_CREATED); Map<String, String> variables = new HashMap<>(); Bucket buck = buckEvent.getBucket(); ExperimentBase exp = buckEvent.getExperiment(); put(variables, EXPERIMENT_LABEL, exp.getLabel()); put(variables, BUCKET_NAME, buck.getLabel().toString()); put(variables, APPLICATION_NAME, String.valueOf(exp.getApplicationName())); put(variables, USER_NAME, getUserRepresentation(buckEvent.getUser())); return replaceVariablesInTemplate(variables, template); }