/** * Sets the set of security object identifiers, null to not limit by security object identifiers. * Note that an empty set will return no securities. * * @param securityIds the new security identifiers, null clears the security id search */ public void setObjectIds(Iterable<? extends ObjectIdentifiable> securityIds) { if (securityIds == null) { _objectIds = null; } else { _objectIds = new ArrayList<ObjectId>(); for (ObjectIdentifiable securityId : securityIds) { _objectIds.add(securityId.getObjectId()); } } }
@Override public void remove(ObjectIdentifiable objectIdentifiable) { ArgumentChecker.notNull(objectIdentifiable, "objectIdentifiable"); PortfolioDocument storedDocument = _store.remove(objectIdentifiable.getObjectId()); if (storedDocument == null) { throw new DataNotFoundException("Portfolio not found " + objectIdentifiable); } removeNodes(storedDocument.getPortfolio().getRootNode()); _changeManager.entityChanged( ChangeType.REMOVED, objectIdentifiable.getObjectId(), null, null, Instant.now()); updateCaches(storedDocument, null); }
@Override public synchronized YieldCurveDefinitionDocument get( ObjectIdentifiable objectIdable, VersionCorrection versionCorrection) { ArgumentChecker.notNull(objectIdable, "objectIdable"); ObjectId objectId = objectIdable.getObjectId(); if (!getUniqueIdScheme().equals(objectId.getScheme())) { throw new DataNotFoundException( "Scheme '" + objectId.getScheme() + "' not valid for '" + getUniqueIdScheme() + "'"); } final int i = objectId.getValue().indexOf('_'); if (i <= 0) { throw new DataNotFoundException( "Identifier '" + objectId.getValue() + "' not valid for '" + getUniqueIdScheme() + "'"); } final String name = objectId.getValue().substring(0, i); final String iso = objectId.getValue().substring(i + 1); final Currency currency; try { currency = Currency.of(iso); } catch (IllegalArgumentException e) { throw new DataNotFoundException( "Identifier '" + objectId.getValue() + "' not valid for '" + getUniqueIdScheme() + "'", e); } final TreeMap<Instant, YieldCurveDefinition> definitions = _definitions.get(Pair.of(currency, name)); if (definitions == null) { throw new DataNotFoundException("Curve definition not found"); } final YieldCurveDefinition definition = definitions.lastEntry().getValue(); if (definition == null) { throw new DataNotFoundException("Curve definition not found"); } return new YieldCurveDefinitionDocument(objectId.atLatestVersion(), definition); }
/** * Adds a single security object identifier to the set. * * @param securityId the security object identifier to add, not null */ public void addObjectId(ObjectIdentifiable securityId) { ArgumentChecker.notNull(securityId, "securityId"); if (_objectIds == null) { _objectIds = new ArrayList<ObjectId>(); } _objectIds.add(securityId.getObjectId()); }
@Override public synchronized void remove(ObjectIdentifiable objectIdentifiable) { ArgumentChecker.notNull(objectIdentifiable, "objectIdentifiable"); if (!getUniqueIdScheme().equals(objectIdentifiable.getObjectId().getScheme())) { throw new DataNotFoundException( "Scheme '" + objectIdentifiable.getObjectId().getScheme() + "' not valid for '" + getUniqueIdScheme() + "'"); } final int i = objectIdentifiable.getObjectId().getValue().indexOf('_'); if (i <= 0) { throw new DataNotFoundException( "Identifier '" + objectIdentifiable.getObjectId().getValue() + "' not valid for '" + getUniqueIdScheme() + "'"); } final String name = objectIdentifiable.getObjectId().getValue().substring(0, i); final String iso = objectIdentifiable.getObjectId().getValue().substring(i + 1); final Currency currency; try { currency = Currency.of(iso); } catch (IllegalArgumentException e) { throw new DataNotFoundException( "Identifier '" + objectIdentifiable.getObjectId().getValue() + "' not valid for '" + getUniqueIdScheme() + "'", e); } final Pair<Currency, String> key = Pair.of(currency, name); if (_sourceVersionCorrection.getVersionAsOf() != null) { final TreeMap<Instant, YieldCurveDefinition> value = _definitions.get(key); if (value == null) { throw new DataNotFoundException("Curve definition not found"); } // Don't need to keep the old values before the one needed by "versionAsOfInstant" final Instant oldestNeeded = value.floorKey(_sourceVersionCorrection.getVersionAsOf()); if (oldestNeeded != null) { value.headMap(oldestNeeded).clear(); } // Store a null to indicate the delete value.put(Instant.now(), null); } else { if (_definitions.remove(key) == null) { throw new DataNotFoundException("Curve definition not found"); } } changeManager() .entityChanged( ChangeType.REMOVED, objectIdentifiable.getObjectId(), null, null, Instant.now()); }
@Override public PortfolioDocument get(ObjectIdentifiable objectId, VersionCorrection versionCorrection) { ArgumentChecker.notNull(objectId, "objectId"); ArgumentChecker.notNull(versionCorrection, "versionCorrection"); final PortfolioDocument document = _store.get(objectId.getObjectId()); if (document == null) { throw new DataNotFoundException("Portfolio not found: " + objectId); } return clonePortfolioDocument(document); }
@Override public SecurityDocument get(ObjectIdentifiable objectId, VersionCorrection versionCorrection) { final RestTarget target = _targetSecurity.resolve(objectId.getObjectId().toString()); if (versionCorrection != null && versionCorrection.getVersionAsOf() != null) { target.resolveQuery( "versionAsOf", Collections.singletonList(versionCorrection.getVersionAsOf().toString())); } if (versionCorrection != null && versionCorrection.getCorrectedTo() != null) { target.resolveQuery( "correctedTo", Collections.singletonList(versionCorrection.getCorrectedTo().toString())); } s_logger.debug("get-get to {}", target); final FudgeMsg message = getRestClient().getMsg(target); if (message == null) { s_logger.debug("get-recv NULL"); throw new DataNotFoundException("Security with identifier " + objectId); } s_logger.debug("get-recv {}", message); return getFudgeDeserializer().fudgeMsgToObject(SecurityDocument.class, message); }