Package com.opengamma.master.exchange

Examples of com.opengamma.master.exchange.ExchangeDocument


  //-------------------------------------------------------------------------
  @Path("{versionId}")
  public WebExchangeVersionResource findVersion(@PathParam("versionId") String idStr) {
    data().setUriVersionId(idStr);
    ExchangeDocument doc = data().getExchange();
    UniqueId combined = doc.getUniqueId().withVersion(idStr);
    if (doc.getUniqueId().equals(combined) == false) {
      ExchangeDocument versioned = data().getExchangeMaster().get(combined);
      data().setVersioned(versioned);
    } else {
      data().setVersioned(doc);
    }
    return new WebExchangeVersionResource(this);
View Full Code Here


  private URI updateExchange(String name, String idScheme, String idValue, String regionScheme, String regionValue) {
    ManageableExchange exchange = data().getExchange().getExchange().clone();
    exchange.setName(name);
    exchange.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of(idScheme, idValue)));
    exchange.setRegionIdBundle(ExternalIdBundle.of(ExternalId.of(regionScheme, regionValue)));
    ExchangeDocument doc = new ExchangeDocument(exchange);
    doc = data().getExchangeMaster().update(doc);
    data().setExchange(doc);
    URI uri = WebExchangeResource.uri(data());
    return uri;
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @DELETE
  @Produces(MediaType.TEXT_HTML)
  public Response deleteHTML() {
    ExchangeDocument doc = data().getExchange();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    data().getExchangeMaster().remove(doc.getUniqueId());
    URI uri = WebExchangeResource.uri(data());
    return Response.seeOther(uri).build();
  }
View Full Code Here

  }

  @DELETE
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteJSON() {
    ExchangeDocument doc = data().getExchange();
    if (doc.isLatest()) {
      data().getExchangeMaster().remove(doc.getUniqueId());
    }
    return Response.ok().build();
  }
View Full Code Here

   * Creates the output root data.
   * @return the output root data, not null
   */
  protected FlexiBean createRootData() {
    FlexiBean out = super.createRootData();
    ExchangeDocument doc = data().getExchange();
    out.put("exchangeDoc", doc);
    out.put("exchange", doc.getExchange());
    out.put("deleted", !doc.isLatest());
    return out;
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Test
  public void testGetExchange() {
    final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
    final ExchangeDocument result = new ExchangeDocument(target);
    when(_underlying.get(OID, VersionCorrection.LATEST)).thenReturn(result);
   
    Response test = _resource.get(null, null);
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertSame(result, test.getEntity());
View Full Code Here

  }

  @Test
  public void testUpdateExchange() {
    final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
    final ExchangeDocument request = new ExchangeDocument(target);
    request.setUniqueId(OID.atLatestVersion());
   
    final ExchangeDocument result = new ExchangeDocument(target);
    result.setUniqueId(OID.atVersion("1"));
    when(_underlying.update(same(request))).thenReturn(result);
   
    Response test = _resource.update(_uriInfo, request);
    assertEquals(Status.CREATED.getStatusCode(), test.getStatus());
    assertSame(result, test.getEntity());
View Full Code Here

  //-------------------------------------------------------------------------
  @Test
  public void testAddExchange() {
    final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London"));
    final ExchangeDocument request = new ExchangeDocument(target);
   
    final ExchangeDocument result = new ExchangeDocument(target);
    result.setUniqueId(UID);
    when(_underlying.add(same(request))).thenReturn(result);
   
    Response test = _resource.add(_uriInfo, request);
    assertEquals(Status.CREATED.getStatusCode(), test.getStatus());
    assertSame(result, test.getEntity());
View Full Code Here

  @BeforeMethod
  public void setUp() {
    master = new InMemoryExchangeMaster();
    ManageableExchange inputExchange = new ManageableExchange(BUNDLE_FULL, NAME, GB, ZoneId.of("Europe/London"));
    ExchangeDocument inputDoc = new ExchangeDocument(inputExchange);
    addedDoc = master.add(inputDoc);
  }
View Full Code Here

  public void test_get_noMatch() {
    master.get(UniqueId.of("A", "B"));
  }

  public void test_get_match() {
    ExchangeDocument result = master.get(addedDoc.getUniqueId());
    assertEquals(UniqueId.of("MemExg", "1"), result.getUniqueId());
    assertEquals(addedDoc, result);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.exchange.ExchangeDocument

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.