コード例 #1
0
 /**
  * Configure the matchers based on a single record.
  *
  * @param record
  */
 protected final void configureMatchers(EventList matchers, Record record) {
   final DataAccessorFactory daf = DataAccessorFactory.getInstance();
   final PredicateFactory pf = PredicateFactory.getInstance();
   final Lock lock = matchers.getReadWriteLock().writeLock();
   lock.lock();
   try {
     final String sendSubject = record.getSendSubject();
     if (sendSubject != null && sendSubject.length() > 0) {
       matchers.add(
           new RvSnoopMatcherEditor(
               daf.createSendSubjectAccessor(),
               pf.createStringStartsWithPredicate(sendSubject, false)));
     }
     final String replySubject = record.getReplySubject();
     if (replySubject != null && replySubject.length() > 0) {
       matchers.add(
           new RvSnoopMatcherEditor(
               daf.createReplySubjectAccessor(),
               pf.createStringStartsWithPredicate(replySubject, false)));
     }
     final String trackingId = record.getTrackingId();
     if (trackingId != null && trackingId.length() > 0) {
       matchers.add(
           new RvSnoopMatcherEditor(
               daf.createTrackingIdAccessor(),
               pf.createStringStartsWithPredicate(trackingId, false)));
     }
   } finally {
     lock.unlock();
   }
 }
コード例 #2
0
  @Override
  public void run(final TaskMonitor taskMonitor) {
    taskMonitor.setTitle("Adding variations...");
    taskMonitor.setProgress(0.0d);

    if (!mergeStrategy.isRetain()) {
      final Lock nodesReadLock = model.nodes().getReadWriteLock().readLock();
      final Lock featuresReadLock = model.features().getReadWriteLock().readLock();
      final Lock variationsWriteLock = model.variations().getReadWriteLock().writeLock();
      nodesReadLock.lock();
      featuresReadLock.lock();
      variationsWriteLock.lock();
      try {
        for (int i = 0, size = model.features().size(); i < size; i++) {
          Feature feature = model.features().get(i);
          taskMonitor.setStatusMessage(
              "Retrieving variations associated with feature " + feature + "...");
          final List<Variation> variations = model.getVariationService().variations(feature);
          taskMonitor.setStatusMessage(
              resultStatusMessage(variations.size(), "variation", "feature", feature));

          // todo:  merge strategy
          for (Variation variation : variations) {
            if (!model.variations().contains(variation)) {
              model.variations().add(variation);
            }
          }

          // todo:  count doesn't consider existing variations
          for (CyNode node : model.nodesFor(feature)) {
            addCount(node, model.getNetwork(), "variation_count", variations.size());
          }
          taskMonitor.setProgress(i / (double) size);
        }
      } finally {
        nodesReadLock.unlock();
        featuresReadLock.unlock();
        variationsWriteLock.unlock();
      }
    }
    taskMonitor.setProgress(1.0d);
  }
コード例 #3
0
 /**
  * Sets the input object upon which the message view is based.
  *
  * @param inHistory a <code>FIXMessageHistory</code> value containing the messages to display
  */
 public void setInput(TradeReportsHistory inHistory) {
   EventList<ReportHolder> list = getMessageList(inHistory);
   // Get the write lock since it is needed for sorting (see PN-416)
   Lock writeLock = list.getReadWriteLock().writeLock();
   writeLock.lock();
   try {
     super.setInput(new FilterList<ReportHolder>(list, getFilterMatcherEditor()));
   } finally {
     writeLock.unlock();
   }
 }
コード例 #4
0
 public void actionPerformed(ActionEvent e) {
   final Lock writeLock = separatorList.getReadWriteLock().writeLock();
   writeLock.lock();
   boolean collapsed;
   try {
     collapsed = separator.getLimit() == 0;
     separator.setLimit(collapsed ? Integer.MAX_VALUE : 0);
   } finally {
     writeLock.unlock();
   }
   expandButton.setIcon(collapsed ? COLLAPSED_ICON : EXPANDED_ICON);
 }
コード例 #5
0
  /** Configure the matchers based on multiple records. */
  protected final void configureMatchers(EventList matchers, Record[] records) {
    final DataAccessorFactory daf = DataAccessorFactory.getInstance();
    final PredicateFactory pf = PredicateFactory.getInstance();
    final String[] strings = new String[records.length];
    final Lock lock = matchers.getReadWriteLock().writeLock();
    lock.lock();
    try {
      for (int i = 0, imax = records.length; i < imax; ++i) {
        strings[i] = records[i].getSendSubject();
      }
      final String sendSubject = findLongestCommonSubstring(strings);
      if (sendSubject != null && sendSubject.length() > 0) {
        matchers.add(
            new RvSnoopMatcherEditor(
                daf.createSendSubjectAccessor(),
                pf.createStringStartsWithPredicate(sendSubject, false)));
      }

      for (int i = 0, imax = records.length; i < imax; ++i) {
        strings[i] = records[i].getReplySubject();
      }
      final String replySubject = findLongestCommonSubstring(strings);
      if (replySubject != null && replySubject.length() > 0) {
        matchers.add(
            new RvSnoopMatcherEditor(
                daf.createReplySubjectAccessor(),
                pf.createStringStartsWithPredicate(replySubject, false)));
      }

      for (int i = 0, imax = records.length; i < imax; ++i) {
        strings[i] = records[i].getTrackingId();
      }
      final String trackingId = findLongestCommonSubstring(strings);
      if (trackingId != null && trackingId.length() > 0) {
        matchers.add(
            new RvSnoopMatcherEditor(
                daf.createTrackingIdAccessor(),
                pf.createStringStartsWithPredicate(trackingId, false)));
      }
    } finally {
      lock.unlock();
    }
  }