Package org.springframework.jdbc.core.namedparam

Examples of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate


  @Override
  public List<Plate<? extends List<? extends Plateable>, ? extends Plateable>> listBySearch(String query) throws IOException {
    String squery = "%" + query + "%";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("search", squery);
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return namedTemplate.query(PLATE_SELECT_BY_SEARCH, params, new PlateMapper(true));
  }
View Full Code Here


          params.addValue("identificationBarcode", barcode);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != plate.getId()) {
            log.error("Expected Plate ID doesn't match returned value from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(PLATE_DELETE, new MapSqlParameterSource().addValue("plateId", newId.longValue()));
            throw new IOException("Something bad happened. Expected Plate ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save Plate - invalid field:" + plate.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Plate - issue with naming scheme", e);
      }
      /*
      String name = "PLA"+ DbUtils.getAutoIncrement(template, TABLE_NAME);
      params.addValue("name", name);
      params.addValue("identificationBarcode", name + "::" + plate.getTagBarcode());
      Number newId = insert.executeAndReturnKey(params);
      plate.setPlateId(newId.longValue());
      plate.setName(name);
      */
    }
    else {
      try {
        String plateBarcode = "";
        if (plate.getTagBarcode() != null) {
          plateBarcode = plate.getName() + "::" + plate.getTagBarcode();
        }
        else {
          //TODO this should be alias
          plateBarcode = plate.getName() + "::" + plate.getDescription();
        }
        if (namingScheme.validateField("name", plate.getName())) {
          params.addValue("plateId", plate.getId())
                .addValue("name", plate.getName())
                .addValue("identificationBarcode", plateBarcode);
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(PLATE_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save Plate - invalid field:" + plate.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Plate - issue with naming scheme", e);
      }
      /*
      params.addValue("plateId", plate.getPlateId());
      params.addValue("name", plate.getName());
      params.addValue("identificationBarcode", plate.getName() + "::" + plate.getTagBarcode());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PLATE_UPDATE, params);
      */
    }

    if (this.cascadeType != null && this.cascadeType.equals(CascadeType.PERSIST)) {
      if (!plate.getElements().isEmpty()) {
        String eType = plate.getElementType().getName();
        MapSqlParameterSource eparams = new MapSqlParameterSource();
        eparams.addValue("plate_plateId", plate.getId());
        NamedParameterJdbcTemplate nt = new NamedParameterJdbcTemplate(template);
        nt.update(PLATE_ELEMENT_DELETE_BY_PLATE_ID, eparams);

        SimpleJdbcInsert eInsert = new SimpleJdbcInsert(template)
                .withTableName("Plate_Elements");

        int pos = 1;
View Full Code Here

        @Property(name="includeParameterTypes", value="false")
      }
    )
  )
  public boolean remove(Plate plate) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (plate.isDeletable() &&
           (namedTemplate.update(PLATE_DELETE,
                                 new MapSqlParameterSource().addValue("plateId", plate.getId())) == 1)) {
      MapSqlParameterSource eparams = new MapSqlParameterSource();
      eparams.addValue("plate_plateId", plate.getId());
      namedTemplate.update(PLATE_ELEMENT_DELETE_BY_PLATE_ID, eparams);
      return true;
    }
    return false;
  }
View Full Code Here

      Number newId = insert.executeAndReturnKey(params);
      kit.setId(newId.longValue());
    }
    else {
      params.addValue("kitId", kit.getId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(KIT_UPDATE, params);
    }

    if (this.cascadeType != null && this.cascadeType.equals(CascadeType.PERSIST)) {
      if (!kit.getNotes().isEmpty()) {
        for (Note n : kit.getNotes()) {
View Full Code Here

      Number newId = insert.executeAndReturnKey(params);
      kd.setKitDescriptorId(newId.longValue());
    }
    else {
      params.addValue("kitDescriptorId", kd.getKitDescriptorId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(KIT_DESCRIPTOR_UPDATE, params);
    }

    return kd.getKitDescriptorId();
  }
View Full Code Here

      Number newId = insert.executeAndReturnKey(params);
      printService.setServiceId(newId.longValue());
    }
    else {
      params.addValue("serviceId", printService.getServiceId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PRINT_SERVICE_UPDATE, params);
    }
    return printService.getServiceId();
  }
View Full Code Here

        status.setStatusId(newId.longValue());
      }
      else {
        status.setStatusId(savedStatus.getStatusId());
        params.addValue("statusId", status.getStatusId());
        NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
        namedTemplate.update(STATUS_UPDATE, params);       
      }
    }
    else {
      params.addValue("statusId", status.getStatusId());
      params.addValue("startDate", new SimpleDateFormat("yyyy-MM-dd").format(status.getStartDate()));
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(STATUS_UPDATE, params);
    }

    return status.getStatusId();
  }
View Full Code Here

    String squery = "%" + query + "%";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("search", squery);
          //.addValue("platformName", platformType.getKey());

    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return namedTemplate.query(EMPCR_DILUTION_SELECT_BY_SEARCH, params, new EmPCRDilutionMapper(true));
  }
View Full Code Here

          params.addValue("identificationBarcode", barcode);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != dilution.getId()) {
            log.error("Expected emPCRDilution ID doesn't match returned value from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(EMPCR_DILUTION_DELETE, new MapSqlParameterSource().addValue("dilutionId", newId.longValue()));
            throw new IOException("Something bad happened. Expected emPCRDilution ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save emPCRDilution - invalid field:" + dilution.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save emPCRDilution - issue with naming scheme", e);
      }
      /*
      String name = "EDI"+DbUtils.getAutoIncrement(template, "emPCRDilution");
      params.addValue("name", name);
      params.addValue("identificationBarcode", name + "::" + dilution.getEmPCR().getName());
      Number newId = insert.executeAndReturnKey(params);
      dilution.setDilutionId(newId.longValue());
      dilution.setName(name);
      */
    }
    else {
      try {
        if (namingScheme.validateField("name", dilution.getName())) {
          params.addValue("dilutionId", dilution.getId())
                .addValue("name", dilution.getName())
                .addValue("identificationBarcode", dilution.getName() + "::" + dilution.getLibrary().getAlias());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(EMPCR_DILUTION_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save emPCRDilution - invalid field:" + dilution.toString());
        }
      }
View Full Code Here

                      @Property(name="includeParameterTypes", value="false")
              }
          )
  )
  public boolean remove(emPCRDilution d) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (d.isDeletable() &&
           (namedTemplate.update(EMPCR_DILUTION_DELETE,
                                 new MapSqlParameterSource().addValue("dilutionId", d.getId())) == 1)) {
      emPCR e = d.getEmPCR();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (e != null) emPcrDAO.save(e);
      }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.