Ejemplo n.º 1
0
 private void updateMetricInDb(
     DbSession dbSession, MetricDto metricInDb, MetricDto metricTemplate) {
   String key = metricTemplate.getKey();
   String name = metricTemplate.getShortName();
   String type = metricTemplate.getValueType();
   String domain = metricTemplate.getDomain();
   String description = metricTemplate.getDescription();
   if (key != null) {
     metricInDb.setKey(key);
   }
   if (name != null) {
     metricInDb.setShortName(name);
   }
   if (type != null) {
     metricInDb.setValueType(type);
   }
   if (domain != null) {
     metricInDb.setDomain(domain);
   }
   if (description != null) {
     metricInDb.setDescription(description);
   }
   dbClient.metricDao().update(dbSession, metricInDb);
   dbSession.commit();
 }
Ejemplo n.º 2
0
  private static MetricDto newMetricTemplate(Request request) {
    int id = request.mandatoryParamAsInt(PARAM_ID);
    String key = request.param(PARAM_KEY);
    if (key != null) {
      MetricKeyValidator.checkMetricKeyFormat(key);
    }
    String type = request.param(PARAM_TYPE);
    String name = request.param(PARAM_NAME);
    String domain = request.param(PARAM_DOMAIN);
    String description = request.param(PARAM_DESCRIPTION);

    MetricDto metricTemplate = new MetricDto().setId(id);
    if (key != null) {
      metricTemplate.setKey(key);
    }
    if (type != null) {
      metricTemplate.setValueType(type);
    }
    if (name != null) {
      metricTemplate.setShortName(name);
    }
    if (domain != null) {
      metricTemplate.setDomain(domain);
    }
    if (description != null) {
      metricTemplate.setDescription(description);
    }
    return metricTemplate;
  }