/** * Creates an AuditLogEntry. * * @param time the event time (required) * @param user the event user (required) * @param action the event action (required) * @param experiment the experiment (if applicable) * @param bucketLabel the bucket label (if applicable) * @param changedProperty the changed property (if applicable) * @param before the property before (if applicable) * @param after the property after (if applicable) */ public AuditLogEntry(Calendar time, UserInfo user, AuditLogAction action, ExperimentBase experiment, Bucket.Label bucketLabel, String changedProperty, String before, String after) { this(time, user, action, experiment == null ? null : experiment.getApplicationName(), experiment == null ? null : experiment.getLabel(), experiment == null ? null : experiment.getID(), bucketLabel, changedProperty, before, after); }
/** * 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); }
if (event instanceof ExperimentEvent) { expLabel = ((ExperimentEvent) event).getExperiment().getLabel(); expId = ((ExperimentEvent) event).getExperiment().getID();