@Override
  public String execute() {
    Constant constant = constantService.getConstant(id);

    constant.setName(StringUtils.trimToNull(name));
    constant.setShortName(StringUtils.trimToNull(shortName));
    constant.setCode(StringUtils.trimToNull(code));
    constant.setDescription(StringUtils.trimToNull(description));
    constant.setValue(Double.parseDouble(value));

    constantService.updateConstant(constant);

    return SUCCESS;
  }
  public Collection<ValidationResult> validate(
      Date startDate, Date endDate, OrganisationUnit source) {
    Map<String, Double> constantMap = constantService.getConstantMap();

    Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();

    Collection<ValidationRule> relevantRules =
        getRelevantValidationRules(source.getDataElementsInDataSets());

    Set<DataElement> dataElements = getDataElementsInValidationRules(relevantRules);

    Collection<Period> relevantPeriods = periodService.getPeriodsBetweenDates(startDate, endDate);

    for (Period period : relevantPeriods) {
      validationViolations.addAll(
          validateInternal(
              period,
              source,
              relevantRules,
              dataElements,
              constantMap,
              validationViolations.size()));
    }

    return validationViolations;
  }
  public Collection<ValidationResult> validate(
      Date startDate,
      Date endDate,
      Collection<OrganisationUnit> sources,
      ValidationRuleGroup group) {
    Map<String, Double> constantMap = constantService.getConstantMap();

    Collection<ValidationResult> validationViolations = new HashSet<ValidationResult>();

    Collection<Period> relevantPeriods = periodService.getPeriodsBetweenDates(startDate, endDate);

    for (OrganisationUnit source : sources) {
      Collection<ValidationRule> relevantRules =
          getRelevantValidationRules(source.getDataElementsInDataSets());
      relevantRules.retainAll(group.getMembers());

      Set<DataElement> dataElements = getDataElementsInValidationRules(relevantRules);

      if (!relevantRules.isEmpty()) {
        for (Period period : relevantPeriods) {
          validationViolations.addAll(
              validateInternal(
                  period,
                  source,
                  relevantRules,
                  dataElements,
                  constantMap,
                  validationViolations.size()));
        }
      }
    }

    return validationViolations;
  }
  public Collection<ValidationResult> validate(
      DataSet dataSet, Period period, OrganisationUnit source) {
    Map<String, Double> constantMap = constantService.getConstantMap();

    Collection<ValidationRule> relevantRules = null;

    if (DataSet.TYPE_CUSTOM.equals(dataSet.getDataSetType())) {
      relevantRules = getRelevantValidationRules(dataSet);
    } else {
      relevantRules = getRelevantValidationRules(dataSet.getDataElements());
    }

    Set<DataElement> dataElements = getDataElementsInValidationRules(relevantRules);

    return validateInternal(period, source, relevantRules, dataElements, constantMap, 0);
  }