Package org.springframework.jdbc.core.namedparam

Examples of org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations.query()


        .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


    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

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

          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

    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
   
    // Get version metadata from the data-points and set up a Manageable HTS accordingly
    // While the HTS doc itself might have been deleted, the data-points can still be retrieved here
    final String sqlVersion = getElSqlBundle().getSql("SelectDataPointsVersion", args);
    ManageableHistoricalTimeSeries result = namedJdbc.query(sqlVersion, args, new ManageableHTSExtractor(oid));
    if (result == null) {
      // No data-points were found, check if the time-series doc exists or existed at some point
      final String sqlExists = getElSqlBundle().getSql("SelectExistential", args);
      result = namedJdbc.query(sqlExists, args, new ManageableHTSExtractor(oid));
      if (result != null) {
View Full Code Here

    final String sqlVersion = getElSqlBundle().getSql("SelectDataPointsVersion", args);
    ManageableHistoricalTimeSeries result = namedJdbc.query(sqlVersion, args, new ManageableHTSExtractor(oid));
    if (result == null) {
      // No data-points were found, check if the time-series doc exists or existed at some point
      final String sqlExists = getElSqlBundle().getSql("SelectExistential", args);
      result = namedJdbc.query(sqlExists, args, new ManageableHTSExtractor(oid));
      if (result != null) {
        // The time series doc exists or existed at some point, it's just that there are no data-points
        result.setTimeSeries(ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES);
        return result;
      } else {
View Full Code Here

    }

    // Get the actual data points and attach to the Manageable HTS
    if (filter.getLatestDate() == null || filter.getEarliestDate() == null || !filter.getLatestDate().isBefore(filter.getEarliestDate())) {
      final String sqlPoints = getElSqlBundle().getSql("SelectDataPoints", args);
      final LocalDateDoubleTimeSeries series = namedJdbc.query(sqlPoints, args, new DataPointsExtractor());
      result.setTimeSeries(series);
    } else {
      //TODO: this is a hack, most of the places that call with this condition want some kind of metadata, which it would be cheaper for us to expose specifically
      result.setTimeSeries(ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES);
    }
View Full Code Here

      .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

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

        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

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.