Package org.springframework.jdbc.core.namedparam

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


    return template.query(EMPCR_DILUTIONS_BY_RELATED_POOL_ID, new Object[]{poolId}, new EmPCRDilutionMapper(true));
  }

  public Collection<emPCRDilution> listAllEmPcrDilutionsBySearch(String query, PlatformType platformType) {
    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


    Long securityProfileId = dilution.getSecurityProfile().getProfileId();
    if (securityProfileId == null || (this.cascadeType != null)) { // && this.cascadeType.equals(CascadeType.PERSIST))) {
      securityProfileId = securityProfileDAO.save(dilution.getSecurityProfile());
    }

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("concentration", dilution.getConcentration())
            .addValue("emPCR_pcrId", dilution.getEmPCR().getId())
            .addValue("creationDate", dilution.getCreationDate())
            .addValue("dilutionUserName", dilution.getDilutionCreator())
            .addValue("securityProfile_profileId", securityProfileId);

    if (dilution.getId() == AbstractDilution.UNSAVED_ID) {
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
                              .withTableName("emPCRDilution")
                              .usingGeneratedKeyColumns("dilutionId");

      try {
        dilution.setId(DbUtils.getAutoIncrement(template, "emPCRDilution"));

        String name = namingScheme.generateNameFor("name", dilution);
        dilution.setName(name);
        if (namingScheme.validateField("name", dilution.getName())) {
          String barcode = name + "::" + dilution.getEmPCR().getName();
          params.addValue("name", name);

          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);
        }
View Full Code Here

  )
  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);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
View Full Code Here

    this.cascadeType = cascadeType;
  }

  @Transactional(readOnly = false, rollbackFor = IOException.class)
  public long save(RunQC runQC) throws IOException {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("run_runId", runQC.getRun().getId())
            .addValue("qcUserName", runQC.getQcCreator())
            .addValue("qcDate", runQC.getQcDate())
            .addValue("qcMethod", runQC.getQcType().getQcTypeId())
            .addValue("information", runQC.getInformation())
            .addValue("doNotProcess", runQC.getDoNotProcess());

    if (runQC.getId() == AbstractQC.UNSAVED_ID) {
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
                              .withTableName(TABLE_NAME)
                              .usingGeneratedKeyColumns("qcId");
      Number newId = insert.executeAndReturnKey(params);
      runQC.setId(newId.longValue());
    }
    else {
      params.addValue("qcId", runQC.getId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(RUN_QC_UPDATE, params);
    }

    for (Partition p : runQC.getPartitionSelections()) {
      SimpleJdbcInsert pInsert = new SimpleJdbcInsert(template)
              .withTableName("RunQC_Partition");

      MapSqlParameterSource poParams = new MapSqlParameterSource();
      poParams.addValue("runQc_runQcId", runQC.getId())
              .addValue("containers_containerId", p.getSequencerPartitionContainer().getId())
              .addValue("partitionNumber", p.getPartitionNumber());
      try {
        pInsert.execute(poParams);
      }
View Full Code Here

  public boolean remove(RunQC qc) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (qc.isDeletable() &&
           (namedTemplate.update(RUN_QC_DELETE,
                                 new MapSqlParameterSource().addValue("qcId", qc.getId())) == 1)) {
      Run r = qc.getRun();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (r!=null) runDAO.save(r);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
View Full Code Here

    this.cascadeType = cascadeType;
  }

  public Collection<LibraryDilution> listAllLibraryDilutionsBySearch(String query, PlatformType platformType) {
    String squery = "%" + query + "%";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("search", squery);
          //.addValue("platformName", platformType.getKey());
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return namedTemplate.query(LIBRARY_DILUTION_SELECT_BY_SEARCH, params, new LibraryDilutionMapper(true));
  }
View Full Code Here

    Long securityProfileId = dilution.getSecurityProfile().getProfileId();
    if (securityProfileId == null || (this.cascadeType != null)) { // && this.cascadeType.equals(CascadeType.PERSIST))) {
      securityProfileId = securityProfileDAO.save(dilution.getSecurityProfile());
    }

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("concentration", dilution.getConcentration())
            .addValue("library_libraryId", dilution.getLibrary().getId())
            .addValue("creationDate", dilution.getCreationDate())
            .addValue("securityProfile_profileId", securityProfileId)
            .addValue("dilutionUserName", dilution.getDilutionCreator());

    if (dilution.getId() == AbstractDilution.UNSAVED_ID) {
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
                              .withTableName("LibraryDilution")
                              .usingGeneratedKeyColumns("dilutionId");
      try {
        dilution.setId(DbUtils.getAutoIncrement(template, "LibraryDilution"));

        String name = namingScheme.generateNameFor("name", dilution);
        dilution.setName(name);

        if (namingScheme.validateField("name", dilution.getName())) {
          String barcode = name + "::" + dilution.getLibrary().getAlias();
          params.addValue("name", name);

          params.addValue("identificationBarcode", barcode);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != dilution.getId()) {
            log.error("Expected LibraryDilution ID doesn't match returned value from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(LIBRARY_DILUTION_DELETE, new MapSqlParameterSource().addValue("dilutionId", newId.longValue()));
            throw new IOException("Something bad happened. Expected LibraryDilution ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save LibraryDilution - invalid field:" + dilution.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save LibraryDilution - issue with naming scheme", e);
      }

      /*
      String name = "LDI"+ DbUtils.getAutoIncrement(template, "LibraryDilution");
      params.addValue("name", name);
      params.addValue("identificationBarcode", name + "::" + dilution.getLibrary().getAlias());     
      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(LIBRARY_DILUTION_UPDATE, params);
        }
View Full Code Here

  )
  public boolean remove(LibraryDilution d) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (d.isDeletable() &&
           (namedTemplate.update(LIBRARY_DILUTION_DELETE,
                                 new MapSqlParameterSource().addValue("dilutionId", d.getId())) == 1)) {
      Library l = d.getLibrary();
      if(this.cascadeType.equals(CascadeType.PERSIST)) {
        if (l != null) libraryDAO.save(l);
      }
      else if (this.cascadeType.equals(CascadeType.REMOVE)) {
View Full Code Here

//  public Collection<Watchable> getWatchedEntitiesByUserId(Long userId) throws IOException {
//    return template.query(WATCHED_ENTITIES_BY_USER, new Object[]{userId}, new WatchedEntityMapper());
//  }

  public boolean removeWatchedEntity(Watchable watchable) throws IOException {
    MapSqlParameterSource eParams = new MapSqlParameterSource();
    eParams.addValue("entityName", watchable.getWatchableIdentifier());
    NamedParameterJdbcTemplate eNamedTemplate = new NamedParameterJdbcTemplate(template);
    return eNamedTemplate.update(WATCHER_DELETE, eParams) == 1;
  }
View Full Code Here

    return eNamedTemplate.update(WATCHER_DELETE, eParams) == 1;
  }

  public boolean removeWatchedEntityByUser(Watchable watchable, User user) throws IOException {
    if (user != null) {
      MapSqlParameterSource eParams = new MapSqlParameterSource();
      eParams.addValue("entityName", watchable.getWatchableIdentifier());
      eParams.addValue("userId", user.getUserId());

      log.debug("DAO removal of " + user.getUserId() + " from " + watchable.getWatchableIdentifier());

      NamedParameterJdbcTemplate eNamedTemplate = new NamedParameterJdbcTemplate(template);
      return eNamedTemplate.update(WATCHER_DELETE_BY_USER_ID, eParams) == 1;
View Full Code Here

TOP

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

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.