Examples of MapSqlParameterSource


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

   *
   * @see com.odb.core.dao.ODBDAO#getDataSourceAxisInfo(java.lang.String)
   */
  public List<DataSourceAxisInfo> getDataSourceAxisInfo(String dataSourceID) throws SQLException {
    String sql = "select * from ODB_DATASOURCE_AXIS_CONFIG where DATASOURCE_ID=:dataSourceID";
    SqlParameterSource param = new MapSqlParameterSource("dataSourceID", dataSourceID);
    return jdbcTemp.query(sql, param, new DataSourceAxisInfoRowMapper());
  }
View Full Code Here

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

   * com.odb.core.dao.ODBDAO#getDataSourceAxisDetailInfoListBy(java.lang.String
   * )
   */
  public List<DataSourceAxisDetailInfo> getDataSourceAxisDetailInfoListBy(String axisId) throws SQLException {
    String sql = "SELECT * FROM ODB_DATASOURCE_AXIS_DTL_CONFIG WHERE DATASOURCE_AXIS_ID=:dataSourceAxisID";
    SqlParameterSource param = new MapSqlParameterSource("dataSourceAxisID", axisId);
    return jdbcTemp.query(sql, param, new DataSourceAxisDetailInfoRowMapper());
  }
View Full Code Here

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

    /**
     * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit} instance.
     */
    private MapSqlParameterSource createVisitParameterSource(Visit visit) {
        return new MapSqlParameterSource()
                .addValue("id", visit.getId())
                .addValue("visit_date", visit.getDate().toDate())
                .addValue("description", visit.getDescription())
                .addValue("pet_id", visit.getPet().getId());
    }
View Full Code Here

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

    /**
     * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Pet} instance.
     */
    private MapSqlParameterSource createPetParameterSource(Pet pet) {
        return new MapSqlParameterSource()
                .addValue("id", pet.getId())
                .addValue("name", pet.getName())
                .addValue("birth_date", pet.getBirthDate().toDate())
                .addValue("type_id", pet.getType().getId())
                .addValue("owner_id", pet.getOwner().getId());
View Full Code Here

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

      if (procName == null) {
        procName = guessSqlProcName();
      }
      boolean success = false;
      T result = null;
      MapSqlParameterSource params = null;
      try {
        if (args.length == 1 && args[0] instanceof MapSqlParameterSource) {
          params = (MapSqlParameterSource)args[0];
        } else {
          params = prepParams(args);
View Full Code Here

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

      if(null != ignores && ignores.contains(pd.getName())){
        continue;
      }
      paramMap.put(pd.getName(), reflectHelper.getMethodValue(pd.getName()));
    }
    MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(paramMap);
    return sqlParameterSource;
  }
View Full Code Here

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

  public void setJdbcTemplate(JdbcTemplate template) {
    this.template = template;
  }

  public long save(PrintJob printJob) throws IOException {
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("printServiceName", printJob.getPrintService().getName())
            .addValue("printDate", printJob.getPrintDate())
            .addValue("jobCreator_userId", printJob.getPrintUser().getUserId())
            .addValue("status", printJob.getStatus());

    Blob barcodeBlob = null;
    try {
      if (printJob.getQueuedElements() != null) {
        byte[] rbytes = LimsUtils.objectToByteArray(printJob.getQueuedElements());
        barcodeBlob = new SerialBlob(rbytes);
        params.addValue("printedElements", barcodeBlob);
      }
      else {
        params.addValue("printedElements", null);
      }
    }
    catch (SerialException e) {
      e.printStackTrace();
    }
    catch (SQLException e) {
      e.printStackTrace();
    }

    if (printJob.getJobId() == AbstractPrintJob.UNSAVED_ID) {
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
              .withTableName(TABLE_NAME)
              .usingGeneratedKeyColumns("jobId");
      Number newId = insert.executeAndReturnKey(params);
      printJob.setJobId(newId.longValue());
    }
    else {
      params.addValue("jobId", printJob.getJobId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PRINT_JOB_UPDATE, params);
    }
    return printJob.getJobId();
  }
View Full Code Here

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

    }
    else {
      log.warn("No status available to save for run: " + run.getAlias());
    }

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("accession", run.getAccession())
            .addValue("alias", run.getAlias())
            .addValue("description", run.getDescription())
            .addValue("platformRunId", run.getPlatformRunId())
            .addValue("pairedEnd", run.getPairedEnd())
            .addValue("cycles", run.getCycles())
            .addValue("filePath", run.getFilePath())
            .addValue("platformType", run.getPlatformType().getKey())
            .addValue("securityProfile_profileId", securityProfileId)
            .addValue("status_statusId", statusId)
            .addValue("sequencerReference_sequencerReferenceId", run.getSequencerReference().getId());

    if (run.getId() == AbstractRun.UNSAVED_ID) {
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
              .withTableName(TABLE_NAME)
              .usingGeneratedKeyColumns("runId");
      try {
        run.setId(DbUtils.getAutoIncrement(template, TABLE_NAME));

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

        if (namingScheme.validateField("name", run.getName())) {
          params.addValue("name", name);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != run.getId()) {
            log.error("Expected Run ID doesn't match returned value from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(RUN_DELETE, new MapSqlParameterSource().addValue("runId", newId.longValue()));
            throw new IOException("Something bad happened. Expected Run ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save Run - invalid field:" + run.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Run - issue with naming scheme", e);
      }
      /*
      String name = "RUN" + DbUtils.getAutoIncrement(template, TABLE_NAME);
      params.addValue("name", name);
      Number newId = insert.executeAndReturnKey(params);
      run.setRunId(newId.longValue());
      run.setName(name);
      */
    }
    else {
      try {
        if (namingScheme.validateField("name", run.getName())) {
          params.addValue("runId", run.getId())
                .addValue("name", run.getName());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(RUN_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save Run - invalid field:" + run.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Run - issue with naming scheme", e);
      }
      /*
      params.addValue("runId", run.getRunId())
            .addValue("name", run.getName());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(RUN_UPDATE, params);
      */
    }

    if (this.cascadeType != null) {
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        for (SequencerPartitionContainer<SequencerPoolPartition> l : ((RunImpl)run).getSequencerPartitionContainers()) {
          l.setSecurityProfile(run.getSecurityProfile());
          if (l.getPlatformType() == null) {
            l.setPlatformType(run.getPlatformType());
          }
          long containerId = sequencerPartitionContainerDAO.save(l);

          SimpleJdbcInsert fInsert = new SimpleJdbcInsert(template).withTableName("Run_SequencerPartitionContainer");
          MapSqlParameterSource fcParams = new MapSqlParameterSource();
          fcParams.addValue("Run_runId", run.getId())
                  .addValue("containers_containerId", containerId);

          try {
            fInsert.execute(fcParams);
          }
View Full Code Here

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

      else {
        log.warn("No status available to save for run: " + run.getAlias());
      }

      try {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue("accession", run.getAccession())
                .addValue("alias", run.getAlias())
                .addValue("description", run.getDescription())
                .addValue("platformRunId", run.getPlatformRunId())
                .addValue("pairedEnd", run.getPairedEnd())
                .addValue("cycles", run.getCycles())
                .addValue("filePath", run.getFilePath())
                .addValue("platformType", run.getPlatformType().getKey())
                .addValue("securityProfile_profileId", securityProfileId)
                .addValue("status_statusId", statusId)
                .addValue("sequencerReference_sequencerReferenceId", run.getSequencerReference().getId());

        if (run.getId() == AbstractRun.UNSAVED_ID) {
          SimpleJdbcInsert insert = new SimpleJdbcInsert(template)
                  .withTableName(TABLE_NAME)
                  .usingGeneratedKeyColumns("runId");
          try {
            run.setId(autoIncrement);

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

            if (namingScheme.validateField("name", run.getName())) {
              params.addValue("name", name);

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

          /*
          String name = "RUN" + autoIncrement;
          params.addValue("name", name);
          Number newId = insert.executeAndReturnKey(params);
          run.setRunId(newId.longValue());
          run.setName(name);
          autoIncrement = newId.longValue() + 1;
          log.debug(run.getName() + ":: Inserted as ID " + run.getRunId());
          */
        }
        else {
          try {
            if (namingScheme.validateField("name", run.getName())) {
              params.addValue("runId", run.getId())
                    .addValue("name", run.getName());
              log.debug(run.getName() + ":: Updating as ID " + run.getId());
              batch.add(params);
            }
            else {
              throw new IOException("Cannot save Run - invalid field:" + run.toString());
            }
          }
          catch (MisoNamingException e) {
            throw new IOException("Cannot save Run - issue with naming scheme", e);
          }
          /*
          params.addValue("runId", run.getRunId())
                .addValue("name", run.getName());
          log.debug(run.getName() + ":: Updating as ID " + run.getRunId());
          batch.add(params);
          */
        }

        if (this.cascadeType != null) {
          if (this.cascadeType.equals(CascadeType.PERSIST)) {
            for (SequencerPartitionContainer<SequencerPoolPartition> l : ((RunImpl)run).getSequencerPartitionContainers()) {
              l.setSecurityProfile(run.getSecurityProfile());
              if (l.getPlatformType() == null) {
                l.setPlatformType(run.getPlatformType());
              }
              long containerId = sequencerPartitionContainerDAO.save(l);

              SimpleJdbcInsert fInsert = new SimpleJdbcInsert(template).withTableName("Run_SequencerPartitionContainer");
              MapSqlParameterSource fcParams = new MapSqlParameterSource();
              fcParams.addValue("Run_runId", run.getId())
                      .addValue("containers_containerId", containerId);

              try {
                fInsert.execute(fcParams);
              }
View Full Code Here

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

  )
  public boolean remove(Run r) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (r.isDeletable() &&
           (namedTemplate.update(RUN_DELETE,
                            new MapSqlParameterSource().addValue("runId", r.getId())) == 1)) {
      purgeListCache(r, false);
      return true;
    }
    return false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.