Package com.opengamma.master.config

Examples of com.opengamma.master.config.ConfigDocument$Meta


    assertSame(_cachingSource.getConfig(ExternalId.class, uniqueId), CONFIG);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }

  public void getConfig_objectId() {
    final UniqueId uniqueId = _underlyingConfigMaster.add(new ConfigDocument(ITEM)).getUniqueId();
    assertSame(_cachingSource.getConfig(ExternalId.class, uniqueId.getObjectId(), VC), CONFIG);
    assertSame(_cachingSource.getConfig(ExternalId.class, uniqueId.getObjectId(), VC), CONFIG);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }
View Full Code Here


    assertSame(_cachingSource.getConfig(ExternalId.class, uniqueId.getObjectId(), VC), CONFIG);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }

  public void getByName() {
    _underlyingConfigMaster.add(new ConfigDocument(ITEM));
    final VersionCorrection versionCorrection = VersionCorrection.of(Instant.now().plusSeconds(120), null)// avoid race condition with insert
    assertSame(_cachingSource.get(ExternalId.class, CONFIG_NAME, versionCorrection).iterator().next(), ITEM);
    assertSame(_cachingSource.get(ExternalId.class, CONFIG_NAME, versionCorrection).iterator().next(), ITEM);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }
View Full Code Here

    assertSame(_cachingSource.get(ExternalId.class, CONFIG_NAME, versionCorrection).iterator().next(), ITEM);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }

  public void getLatestByName() {
    _underlyingConfigMaster.add(new ConfigDocument(ITEM));
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), CONFIG);
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), CONFIG);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }
View Full Code Here

    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }

  public void getConfigs() {
    final Collection<ExternalId> configs = Lists.newArrayList(CONFIG, CONFIG);
    _underlyingConfigMaster.add(new ConfigDocument(ITEM));
    _underlyingConfigMaster.add(new ConfigDocument(ITEM));

    assertTrue(configs.contains(_cachingSource.getSingle(ExternalId.class, CONFIG_NAME, VC)));
    assertTrue(configs.contains(_cachingSource.getSingle(ExternalId.class, CONFIG_NAME, VC)));
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }
View Full Code Here

    assertTrue(configs.contains(_cachingSource.getSingle(ExternalId.class, CONFIG_NAME, VC)));
    assertEquals(1, _underlyingConfigMaster.getCounter().get());
  }

  public void getLatestByNameAfterUpdate() {
    final ConfigDocument addedDoc = _underlyingConfigMaster.add(new ConfigDocument(ITEM));
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), CONFIG);
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), CONFIG);
    assertEquals(1, _underlyingConfigMaster.getCounter().get());

    final ExternalId lastestConfig = ExternalId.of ("Test", "sec1");
    addedDoc.setConfig(ConfigItem.of(lastestConfig));
    _underlyingConfigMaster.update(addedDoc);
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), lastestConfig);
    assertSame(_cachingSource.getLatestByName(ExternalId.class, CONFIG_NAME), lastestConfig);
    assertEquals(2, _underlyingConfigMaster.getCounter().get());
  }
View Full Code Here

    ConfigItem<ExternalId> item2 = ConfigItem.of(ExternalId.of("C", "D"), "Test2");
    ConfigItem<ExternalId> item3 = ConfigItem.of(ExternalId.of("E", "F"), "Test3");
    ConfigItem<ExternalId> item4 = ConfigItem.of(ExternalId.of("E", "F"), "Test3");
   
    InMemoryConfigMaster configMaster = new InMemoryConfigMaster();
    _doc1 = configMaster.add(new ConfigDocument(item1));
    _doc2 = configMaster.add(new ConfigDocument(item2));
    _doc3 = configMaster.add(new ConfigDocument(item3));
    _doc4 = configMaster.add(new ConfigDocument(item4));
    _configMaster = configMaster;
  }
View Full Code Here

    System.out.println("Outputting files for " + clazz);
    ConfigSearchRequest searchRequest = new ConfigSearchRequest(clazz);
    ConfigSearchResult searchResult = getConfigMaster().search(searchRequest);
    Set<ConfigDocument> latest = new HashSet<ConfigDocument>();
    for (Object documentObject : searchResult.getDocuments()) {
      ConfigDocument document = (ConfigDocument) documentObject;
      latest.add(getConfigMaster().get(document.getObjectId(), VersionCorrection.LATEST));
    }
   
    FudgeSerializer serializer = new FudgeSerializer(OpenGammaFudgeContext.getInstance());
    File directory = new File(getDestinationDirectory(), clazz.getName());
    directory.mkdir();
    for (ConfigDocument document : latest) {
      File documentFile = new File(directory, document.getName() + ".xml");
      System.out.println("-- Creating file " + documentFile.getAbsolutePath());
      FileOutputStream fos = new FileOutputStream(documentFile);
      FudgeXMLStreamWriter xmlStreamWriter = new FudgeXMLStreamWriter(OpenGammaFudgeContext.getInstance(), new OutputStreamWriter(fos));
      MutableFudgeMsg msg = serializer.objectToFudgeMsg(document.getConfig().getValue());
      FudgeMsgWriter fudgeMsgWriter = new FudgeMsgWriter(xmlStreamWriter);
      fudgeMsgWriter.writeMessage(msg);
      fudgeMsgWriter.close();
      fos.close();
    }
View Full Code Here

  }

  @Override
  protected void mergeNonUpdatedFields(ConfigDocument newDocument, ConfigDocument oldDocument) {
    if (newDocument.getConfig() == null) {
      ConfigDocument hackGenerics = newDocument;
      hackGenerics.setConfig(oldDocument.getConfig());
    }
  }
View Full Code Here

        FudgeDeserializer deserializer = new FudgeDeserializer(s_fudgeContext);
        Object configObj = deserializer.fudgeMsgToObject(reifiedType, fudgeMsg);
        ConfigItem<?> item = ConfigItem.of(configObj);
        item.setName(name);
        item.setType(reifiedType);
        ConfigDocument doc = new ConfigDocument(item);
        UniqueId uniqueId = createUniqueId(docOid, docId);
        doc.setUniqueId(uniqueId);
        IdUtils.setInto(configObj, uniqueId);
        doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
        doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
        doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
        doc.setCorrectionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(correctionTo));
        _documents.add(doc);

      } catch (Exception ex) {
        s_logger.warn("Bad fudge message in database, unable to deserialise docOid:" + docOid + " " + fudgeMsg +
                          " to " + configType, ex);
View Full Code Here

    ResponseBuilder builder = request.evaluatePreconditions(etag);
    if (builder != null) {
      return builder.build();
    }
    FlexiBean out = createRootData();
    ConfigDocument doc = data().getVersioned();
    String jsonConfig = toJSON(doc.getConfig().getValue());
    if (jsonConfig != null) {
      out.put("configJSON", jsonConfig);
    } else {
      out.put("configXML", StringEscapeUtils.escapeJavaScript(createXML(doc)));
    }
    out.put("type", data().getTypeMap().inverse().get(doc.getType()));
    String json = getFreemarker().build(JSON_DIR + "config.ftl", out);
    return Response.ok(json).tag(etag).build();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.config.ConfigDocument$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.