Package org.springframework.jdbc.core.namedparam

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


    final DbMapSqlParameterSource args = new DbMapSqlParameterSource()
        .addValue("node_oid", extractOid(uniqueId))
        .addTimestamp("version_as_of_instant", Objects.firstNonNull(versionAsOf, now))
        .addTimestamp("corrected_to_instant", Objects.firstNonNull(correctedTo, now));
    final PortfolioDocumentExtractor extractor = new PortfolioDocumentExtractor(true, false);
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetNodeByOidInstants", args);
    final List<PortfolioDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Node not found: " + uniqueId);
    }
    return docs.get(0).getPortfolio().getRootNode(); // SQL loads desired node in place of the root node
  }
View Full Code Here


  protected ManageablePortfolioNode getNodeById(final UniqueId uniqueId) {
    s_logger.debug("getNodeById {}", uniqueId);
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource()
        .addValue("node_id", extractRowId(uniqueId));
    final PortfolioDocumentExtractor extractor = new PortfolioDocumentExtractor(true, false);
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetNodeById", args);
    final List<PortfolioDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Node not found: " + uniqueId);
    }
    return docs.get(0).getPortfolio().getRootNode(); // SQL loads desired node in place of the root node
  }
View Full Code Here

      @Override
      public Pair<List<D>, Paging> doInTransaction(final TransactionStatus status) {
        final List<D> result = newArrayList();
        Paging paging;
        s_logger.debug("with args {}", args);
        final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
        if (pagingRequest.equals(PagingRequest.ALL)) {
          result.addAll(namedJdbc.query(sql[0], args, extractor));
          paging = Paging.of(pagingRequest, result);
        } else {
          s_logger.debug("executing sql {}", sql[1]);
          final int count = namedJdbc.queryForObject(sql[1], args, Integer.class);
          paging = Paging.of(pagingRequest, count);
          if (count > 0 && !pagingRequest.equals(PagingRequest.NONE)) {
            s_logger.debug("executing sql {}", sql[0]);
            result.addAll(namedJdbc.query(sql[0], args, extractor));
          }
        }
        return Pair.of(result, paging);
      }
    });
View Full Code Here

    versionCorrection = versionCorrection.withLatestFixed(now());
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource()
      .addValue("doc_oid", oid)
      .addTimestamp("version_as_of_instant", versionCorrection.getVersionAsOf())
      .addTimestamp("corrected_to_instant", versionCorrection.getCorrectedTo());
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final UniqueIdExtractor extractor = new UniqueIdExtractor(oid);
    final String sql = getElSqlBundle().getSql("SelectUniqueIdByVersionCorrection", args);
    final UniqueId uniqueId = namedJdbc.query(sql, args, extractor);
    if (uniqueId == null) {
      throw new DataNotFoundException("Unable to find time-series: " + objectId.getObjectId());
    }
    return uniqueId;
  }
View Full Code Here

      args.addValue("paging_offset", request.getPagingRequest().getFirstItem());
      args.addValue("paging_fetch", request.getPagingRequest().getPagingSize());

      String[] sql = {getElSqlBundle().getSql("Search", args), getElSqlBundle().getSql("SearchCount", args) };

      final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
      ConfigDocumentExtractor configDocumentExtractor = new ConfigDocumentExtractor();
      if (request.equals(PagingRequest.ALL)) {
        List<ConfigDocument> queryResult = namedJdbc.query(sql[0], args, configDocumentExtractor);
        for (ConfigDocument configDocument : queryResult) {
          if (request.getType().isInstance(configDocument.getConfig().getValue())) {
            result.getDocuments().add(configDocument);
          }
        }
        result.setPaging(Paging.of(request.getPagingRequest(), result.getDocuments()));
      } else {
        final int count = namedJdbc.queryForObject(sql[1], args, Integer.class);
        result.setPaging(Paging.of(request.getPagingRequest(), count));
        if (count > 0 && request.getPagingRequest().equals(PagingRequest.NONE) == false) {
          List<ConfigDocument> queryResult = namedJdbc.query(sql[0], args, configDocumentExtractor);
          for (ConfigDocument configDocument : queryResult) {
            if (request.getType().isInstance(configDocument.getConfig().getValue())) {
              result.getDocuments().add(configDocument);
            }
          }
View Full Code Here

    ConfigHistoryResult<T> result = new ConfigHistoryResult<T>();
    ConfigDocumentExtractor extractor = new ConfigDocumentExtractor();
    final DbMapSqlParameterSource args = argsHistory(request);
    final String[] sql = {getElSqlBundle().getSql("History", args), getElSqlBundle().getSql("HistoryCount", args) };

    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    if (request.getPagingRequest().equals(PagingRequest.ALL)) {
      List<ConfigDocument> queryResult = namedJdbc.query(sql[0], args, extractor);
      for (ConfigDocument configDocument : queryResult) {
        if (request.getType() == null || request.getType().isInstance(configDocument.getConfig().getValue())) {
          result.getDocuments().add(configDocument);
        }
      }
      result.setPaging(Paging.of(request.getPagingRequest(), result.getDocuments()));
    } else {
      final int count = namedJdbc.queryForObject(sql[1], args, Integer.class);
      result.setPaging(Paging.of(request.getPagingRequest(), count));
      if (count > 0 && request.getPagingRequest().equals(PagingRequest.NONE) == false) {
        List<ConfigDocument> queryResult = namedJdbc.query(sql[0], args, extractor);
        for (ConfigDocument configDocument : queryResult) {
          if (request.getType() == null || request.getType().isInstance(configDocument.getConfig().getValue())) {
            result.getDocuments().add(configDocument);
          }
        }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  public int getSchemaVersion() {
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource().addValue("version_key", "schema_patch");
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetSchemaVersion", args);
    String version = namedJdbc.queryForObject(sql, args, String.class);
    return Integer.parseInt(version);
  }
View Full Code Here

      .addValue("function", functionId.trim())
      .addTimestamp("version_instant", versionAsOf)
      .addValue("paging_offset", 0)
      .addValue("paging_fetch", 1);
    final FunctionCostsDocumentExtractor extractor = new FunctionCostsDocumentExtractor();
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetCosts", args);
    final List<FunctionCostsDocument> docs = namedJdbc.query(sql, args, extractor);
    return docs.isEmpty() ? null : docs.get(0);
  }
View Full Code Here

    final Instant now = now();
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource().addValue("trade_oid", extractOid(uniqueId))
        .addTimestamp("version_as_of_instant", Objects.firstNonNull(versionAsOf, now))
        .addTimestamp("corrected_to_instant", Objects.firstNonNull(correctedTo, now));
    final PositionDocumentExtractor extractor = new PositionDocumentExtractor();
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetTradeByOidInstants", args);
    final List<PositionDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Trade not found: " + uniqueId);
    }
    return docs.get(0).getPosition().getTrades().get(0); // SQL loads desired trade as only trade
  }
View Full Code Here

   */
  protected ManageableTrade getTradeById(final UniqueId uniqueId) {
    s_logger.debug("getTradeById {}", uniqueId);
    final DbMapSqlParameterSource args = new DbMapSqlParameterSource().addValue("trade_id", extractRowId(uniqueId));
    final PositionDocumentExtractor extractor = new PositionDocumentExtractor();
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetTradeById", args);
    final List<PositionDocument> docs = namedJdbc.query(sql, args, extractor);
    if (docs.isEmpty()) {
      throw new DataNotFoundException("Trade not found: " + uniqueId);
    }
    return docs.get(0).getPosition().getTrades().get(0); // SQL loads desired trade as only trade
  }
View Full Code Here

TOP

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

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.