Package com.opengamma.master.historicaltimeseries

Examples of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeries$Meta


      while (rs.next()) {
        Timestamp ver = rs.getTimestamp("max_ver_instant");
        Timestamp corr = rs.getTimestamp("max_corr_instant");
        Instant verInstant = ver != null ? DbDateUtils.fromSqlTimestamp(ver) : null;
        Instant corrInstant = (corr != null ? DbDateUtils.fromSqlTimestamp(corr) : verInstant);
        ManageableHistoricalTimeSeries hts = new ManageableHistoricalTimeSeries();
        hts.setUniqueId(createTimeSeriesUniqueId(_objectId, verInstant, corrInstant));
        hts.setVersionInstant(verInstant);
        hts.setCorrectionInstant(corrInstant);
       
        return hts;
      }
      return null;
    }
View Full Code Here


      final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final ComputedValue htsValue = inputs.getComputedValue(ValueRequirementNames.HISTORICAL_TIME_SERIES);
    if (htsValue == null) {
      s_logger.warn("Cannot get time series for {}", target);
    }
    final ManageableHistoricalTimeSeries mhts = (ManageableHistoricalTimeSeries) htsValue.getValue();
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    return Collections.singleton(new ComputedValue(
        new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints()), mhts.getTimeSeries()));
  }
View Full Code Here

    }
  }
 
  private boolean diffAndCopy(UniqueId sourceId, UniqueId destinationId, boolean fastCopy, boolean verbose) {
    if (fastCopy) {
      ManageableHistoricalTimeSeries sourceTimeSeries = _sourceMaster.getTimeSeries(sourceId, HistoricalTimeSeriesGetFilter.ofLatestPoint());
      ManageableHistoricalTimeSeries destTimeSeries = _destinationMaster.getTimeSeries(destinationId, HistoricalTimeSeriesGetFilter.ofLatestPoint());
      if (!sourceTimeSeries.getTimeSeries().equals(destTimeSeries.getTimeSeries())) {
        HistoricalTimeSeriesGetFilter filter = new HistoricalTimeSeriesGetFilter();
        LocalDate lastSourceDate = sourceTimeSeries.getTimeSeries().getLatestTime();
        LocalDate lastDestinationDate = destTimeSeries.getTimeSeries().getLatestTime();
        if (lastSourceDate.isAfter(lastDestinationDate)) {
          filter.setEarliestDate(lastDestinationDate.plusDays(1));
          filter.setLatestDate(lastSourceDate);
          sourceTimeSeries = _sourceMaster.getTimeSeries(sourceId, filter);
          // get JUST the new days
          _destinationMaster.updateTimeSeriesDataPoints(destinationId, sourceTimeSeries.getTimeSeries());
          if (verbose) {
            System.out.println("Fast updating " + sourceTimeSeries.getTimeSeries().size() + " data points");
          }
          return true;
        } else {
          s_logger.warn("Destination for " + destinationId + " has more up to date data than source, skipping!");
          return false;
        }
      } else {
        if (verbose) {
          System.out.println("Fast compare of source and destination show they are the same, skipping");
        }
      }
      return false;
    } else {
      ManageableHistoricalTimeSeries sourceTimeSeries = _sourceMaster.getTimeSeries(sourceId);
      ManageableHistoricalTimeSeries destTimeSeries = _destinationMaster.getTimeSeries(destinationId);
      if (!sourceTimeSeries.getTimeSeries().equals(destTimeSeries.getTimeSeries())) {
        sourceTimeSeries = _sourceMaster.getTimeSeries(sourceId);
        HistoricalTimeSeriesMasterUtils masterUtils = new HistoricalTimeSeriesMasterUtils(_destinationMaster);
        masterUtils.writeTimeSeries(destinationId, sourceTimeSeries.getTimeSeries());
        if (verbose) {
          System.out.println("Full (slow) copy of source data to destination");
        } else {
          System.out.println("Full (slow) compare of source and destination show they are the same, skipping");
        }
      }
      return sourceTimeSeries.getTimeSeries().equals(destTimeSeries.getTimeSeries());
    }
  }
View Full Code Here

      _idMap.put(htsId, oId);
    }

    // TODO check if update could be used more often instead of correct
    ManageableHistoricalTimeSeries orig = _htsMaster.getTimeSeries(oId, VersionCorrection.LATEST, HistoricalTimeSeriesGetFilter.ofRange(series.getEarliestTime(), null, 1));
    if (orig.getTimeSeries().isEmpty()) {
      _htsMaster.updateTimeSeriesDataPoints(oId, series);
    } else {
      _htsMaster.correctTimeSeriesDataPoints(oId, series);
    }
    return series;
View Full Code Here

      @Override
      protected void doRun() throws Exception {
        final HistoricalTimeSeriesMaster remoteHtsMaster = getToolContext().getHistoricalTimeSeriesMaster();
        for (final HistoricalTimeSeriesInfoDocument infoDoc : HistoricalTimeSeriesInfoSearchIterator.iterable(remoteHtsMaster, new HistoricalTimeSeriesInfoSearchRequest())) {
          ObjectId timeSeriesObjectId = infoDoc.getInfo().getTimeSeriesObjectId();
          final ManageableHistoricalTimeSeries timeSeries = remoteHtsMaster.getTimeSeries(timeSeriesObjectId, VersionCorrection.LATEST);
          _tsList.add(infoDoc);
          _completionService.submit(new Callable<UniqueId>() {
           
            @Override
            public UniqueId call() throws Exception {
              try {
                ManageableHistoricalTimeSeriesInfo added = htsMaster.add(infoDoc).getInfo();
                htsMaster.updateTimeSeriesDataPoints(added.getTimeSeriesObjectId(), timeSeries.getTimeSeries());
                return added.getUniqueId();
              } catch (Exception ex) {
                ex.printStackTrace();
                return null;
              }
View Full Code Here

    Integer maxPoints = filter.getMaxPoints();
    if (((maxPoints != null) && (Math.abs(maxPoints) < subSeries.size()))) {
      subSeries = maxPoints >= 0 ? subSeries.head(maxPoints) : subSeries.tail(-maxPoints);
    }

    final ManageableHistoricalTimeSeries result = new ManageableHistoricalTimeSeries();
    result.setUniqueId(objectId.atLatestVersion());
    result.setTimeSeries(subSeries);
    result.setVersionInstant(now);
    result.setCorrectionInstant(now);
    return result;
  }
View Full Code Here

        if (searchResult.getDocuments().isEmpty()) {
          s_logger.warn("No time series for {}/{}", centreValue.getKey().getFirst(), centreValue.getKey().getSecond());
        } else {
          for (HistoricalTimeSeriesInfoDocument infoDoc : searchResult.getDocuments()) {
            s_logger.debug("Updating {}", infoDoc.getUniqueId());
            final ManageableHistoricalTimeSeries hts = htsMaster.getTimeSeries(infoDoc.getUniqueId(), filter);
            final LocalDateDoubleTimeSeries ldts = hts.getTimeSeries();
            LocalDate pointDate = ldts.getLatestTime();
            if (pointDate.isBefore(now)) {
              final double centre = centreValue.getValue();
              double pointValue = ldts.getLatestValueFast();
              pointDate = DateUtils.nextWeekDay(pointDate);
View Full Code Here

  public WebHistoricalTimeSeriesResource findSeries(@Subscribe @PathParam("timeseriesId") String idStr) {
   
    data().setUriHistoricalTimeSeriesId(idStr);
    UniqueId oid = UniqueId.parse(idStr);
    HistoricalTimeSeriesInfoDocument info;
    ManageableHistoricalTimeSeries series;
   
    try {
      // Try to fetch HTS info
      info = data().getHistoricalTimeSeriesMaster().get(UniqueId.parse(idStr));
    } catch (DataNotFoundException ex) {
      // If not there, try fetching a deleted one from history
      HistoricalTimeSeriesInfoHistoryRequest historyRequest = new HistoricalTimeSeriesInfoHistoryRequest(oid);
      historyRequest.setPagingRequest(PagingRequest.ONE);
      HistoricalTimeSeriesInfoHistoryResult historyResult = data().getHistoricalTimeSeriesMaster().history(historyRequest);
      if (historyResult.getDocuments().size() == 0) {
        // None found in history either; just return
        return null;
      }
      info = historyResult.getFirstDocument();
    }
    data().setInfo(info);
   
    try {
      // Try to fetch the data-points
      series = data().getHistoricalTimeSeriesMaster().getTimeSeries(
          info.getInfo().getTimeSeriesObjectId(), VersionCorrection.LATEST);
    } catch (DataNotFoundException ex) {
      // If not there, return an empty collection of data-points
      series = new ManageableHistoricalTimeSeries();
      series.setTimeSeries(ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES);
    }
    data().setTimeSeries(series);
   
    return new WebHistoricalTimeSeriesResource(this);
  }
View Full Code Here

  @GET
  public Response get(@Context UriInfo uriInfo, @QueryParam("versionAsOf") String versionAsOf, @QueryParam("correctedTo") String correctedTo) {
    VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo);
    HistoricalTimeSeriesGetFilter filter = RestUtils.decodeQueryParams(uriInfo, HistoricalTimeSeriesGetFilter.class);
    if (filter != null) {
      ManageableHistoricalTimeSeries result = getHistoricalTimeSeriesMaster().getTimeSeries(getUrlDataPointsId(), vc, filter);
      return responseOkFudge(result);
    } else {
      ManageableHistoricalTimeSeries result = getHistoricalTimeSeriesMaster().getTimeSeries(getUrlDataPointsId(), vc);
      return responseOkFudge(result);
    }
  }
View Full Code Here

  @GET
  @Path("versions/{versionId}")
  public Response getVersioned(@Context UriInfo uriInfo, @PathParam("versionId") String versionId) {
    HistoricalTimeSeriesGetFilter filter = RestUtils.decodeQueryParams(uriInfo, HistoricalTimeSeriesGetFilter.class);
    if (filter != null) {
      ManageableHistoricalTimeSeries result = getHistoricalTimeSeriesMaster().getTimeSeries(getUrlDataPointsId().atVersion(versionId), filter);
      return responseOkFudge(result);
    } else {
      ManageableHistoricalTimeSeries result = getHistoricalTimeSeriesMaster().getTimeSeries(getUrlDataPointsId().atVersion(versionId));
      return responseOkFudge(result);
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.historicaltimeseries.ManageableHistoricalTimeSeries$Meta

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.