Package com.opengamma.financial.temptarget

Examples of com.opengamma.financial.temptarget.TempTargetRepository


      return null;
    }
    final ViewCalculationConfiguration calcConfig = new ViewCalculationConfiguration(tempTarget.getViewDefinition(), context.getViewCalculationConfiguration().getName());
    calcConfig.addSpecificRequirement(requirement);
    tempTarget.getViewDefinition().addViewCalculationConfiguration(calcConfig);
    final TempTargetRepository targets = OpenGammaCompilationContext.getTempTargets(context);
    final UniqueId tempTargetId = targets.locateOrStore(tempTarget);
    return Collections.singleton(new ValueRequirement(ValueRequirementNames.HISTORICAL_TIME_SERIES, new ComputationTargetSpecification(TempTarget.TYPE, tempTargetId), ValueProperties.withAny(
        ViewEvaluationFunction.PROPERTY_CALC_CONFIG).get()));
  }
View Full Code Here


    }
  }

  @Override
  public void init(final ComponentRepository repo, final LinkedHashMap<String, String> configuration) {
    final TempTargetRepository tempTargets = createCachedRepository(createRepository(repo, configuration));
    registerSource(repo, tempTargets);
    registerRepository(repo, tempTargets);
  }
View Full Code Here

    final HistoricalViewEvaluationTarget tempTarget = new HistoricalViewEvaluationTarget(viewDefinition.getMarketDataUser(), startDate.toString(), true, DateConstraint.VALUATION_TIME.toString(),
        false, null, HistoricalViewEvaluationMarketDataMode.HISTORICAL);
    final ViewCalculationConfiguration calcConfig = createViewCalculationConfiguration(tempTarget.getViewDefinition(), context.getViewCalculationConfiguration().getName());
    addValueRequirements(context, target, calcConfig);
    tempTarget.getViewDefinition().addViewCalculationConfiguration(calcConfig);
    final TempTargetRepository targets = OpenGammaCompilationContext.getTempTargets(context);
    final UniqueId tempTargetId = targets.locateOrStore(tempTarget);
    final ComputationTargetSpecification targetSpec = new ComputationTargetSpecification(TempTarget.TYPE, tempTargetId);
    return createRequirements(targetSpec);
  }
View Full Code Here

  }

  public void testLocateOrStore() {
    final InMemoryTempTargetRepository underlying = new InMemoryTempTargetRepository();
    final DataTempTargetRepositoryResource server = new DataTempTargetRepositoryResource(underlying);
    final TempTargetRepository client = new RemoteTempTargetRepository(URI.create("http://localhost/")) {
      @SuppressWarnings("unchecked")
      @Override
      protected UniformInterface accessRemote(final URI uri) {
        assertTrue(uri.getPath().equals("/target"));
        final UniformInterface builder = Mockito.mock(UniformInterface.class);
        Mockito.doAnswer(new Answer<FudgeMsg>() {
          @Override
          public FudgeMsg answer(final InvocationOnMock invocation) throws Throwable {
            return (FudgeMsg) server.locateOrStore((FudgeMsg) invocation.getArguments()[1]).getEntity();
          }
        }).when(builder).post(Mockito.any(Class.class), Mockito.anyObject());
        return builder;
      }
    };
    assertEquals(client.locateOrStore(new MockTempTarget("Test")), UniqueId.of("TmpMem", "1"));
    assertEquals(client.locateOrStore(new MockTempTarget("Test")), UniqueId.of("TmpMem", "1"));
    assertEquals(client.locateOrStore(new MockTempTarget("Foo")), UniqueId.of("TmpMem", "2"));
  }
View Full Code Here

  public void testGet() {
    final InMemoryTempTargetRepository underlying = new InMemoryTempTargetRepository();
    final UniqueId uid = underlying.locateOrStore(new MockTempTarget("Test"));
    assertEquals(uid, UniqueId.of("TmpMem", "1"));
    final DataTempTargetRepositoryResource server = new DataTempTargetRepositoryResource(underlying);
    final TempTargetRepository client = new RemoteTempTargetRepository(URI.create("http://localhost/")) {
      @Override
      protected UniformInterface accessRemote(final URI uri) {
        assertTrue(uri.getPath().startsWith("/target/"));
        final UniformInterface builder = Mockito.mock(UniformInterface.class);
        Mockito.when(builder.get(FudgeMsg.class)).thenAnswer(new Answer<FudgeMsg>() {
          @Override
          public FudgeMsg answer(final InvocationOnMock invocation) throws Throwable {
            try {
              return (FudgeMsg) server.get(uri.getPath().substring(8)).getEntity();
            } catch (final WebApplicationException e) {
              assertEquals(e.getResponse().getStatus(), 404);
              throw new UniformInterfaceException404NotFound(new ClientResponse(404, null, null, null), false);
            }
          }
        });
        return builder;
      }
    };
    assertNull(client.get(UniqueId.of("Invalid", "Foo")));
    assertEquals(client.get(uid), new MockTempTarget("Test"));
  }
View Full Code Here

  @Override
  protected ComputationTargetCollapser createObject() {
    final DefaultComputationTargetCollapser collapser = new DefaultComputationTargetCollapser();
    if (getCompilationContext() != null) {
      final TempTargetRepository tempTargets = OpenGammaCompilationContext.getTempTargets(getCompilationContext());
      if (tempTargets != null) {
        collapser.addCollapser(ViewEvaluationTarget.TYPE, new ViewEvaluationTargetCollapser(tempTargets));
      }
    }
    return collapser;
View Full Code Here

TOP

Related Classes of com.opengamma.financial.temptarget.TempTargetRepository

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.