Package com.opengamma.util.beancompare

Examples of com.opengamma.util.beancompare.BeanCompare


      }
    };
    Map<MetaProperty<?>, Comparator<Object>> comparators = ImmutableMap.<MetaProperty<?>, Comparator<Object>>of(
        ManageableSecurity.meta().uniqueId(), alwaysEqualComparator,
        ManageableSecurity.meta().externalIdBundle(), alwaysEqualComparator);
    _beanCompare = new BeanCompare(comparators, Collections.<Class<?>, Comparator<Object>>emptyMap());

    //_currentPath = new String[0];
    //_securityIdToPosition = new HashMap<ObjectId, ManageablePosition>();

    _multithread = multithread;
View Full Code Here


   * @return the persisted security
   */
  public static ManageableSecurity addOrUpdateSecurity(SecurityMaster securityMaster, ManageableSecurity security, boolean deleteAndReAdd) {
   
    ArgumentChecker.notNull(security, "security");
    BeanCompare beanCompare = new BeanCompare();
    SecuritySearchRequest searchReq = new SecuritySearchRequest();
    ExternalIdSearch idSearch = new ExternalIdSearch(security.getExternalIdBundle())// match any one of the IDs
    searchReq.setVersionCorrection(VersionCorrection.ofVersionAsOf(Instant.now())); // valid now
    searchReq.setExternalIdSearch(idSearch);
    searchReq.setFullDetail(true);
    searchReq.setSortOrder(SecuritySearchSortOrder.VERSION_FROM_INSTANT_DESC);
    SecuritySearchResult searchResult = securityMaster.search(searchReq);
    if (deleteAndReAdd) {
      for (ManageableSecurity foundSecurity : searchResult.getSecurities()) {
        securityMaster.remove(foundSecurity.getUniqueId());
      }
    } else {
      for (ManageableSecurity foundSecurity : searchResult.getSecurities()) {
        List<BeanDifference<?>> differences = null;
        if (foundSecurity.getClass().equals(security.getClass())) {
          try {
            differences = beanCompare.compare(foundSecurity, security);
          } catch (Exception e) {
            s_logger.error("Error comparing securities with ID bundle " + security.getExternalIdBundle(), e);
            return null;
          }
        }
View Full Code Here

TOP

Related Classes of com.opengamma.util.beancompare.BeanCompare

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.