Exemplo n.º 1
0
  public void addFeedProperty(DataModel model, String propertyName, long itemTimestamp) {
    @SuppressWarnings("unchecked")
    DMClassHolder<K, T> classHolder = (DMClassHolder<K, T>) model.getClassHolder(clazz);

    int propertyIndex = classHolder.getPropertyIndex(propertyName);
    if (propertyIndex < 0)
      throw new RuntimeException(
          "Class " + classHolder.getDMOClass().getName() + " has no property " + propertyName);

    addProperty(propertyIndex);

    DMPropertyHolder<K, T, ?> property = classHolder.getProperty(propertyIndex);
    if (!(property instanceof FeedPropertyHolder))
      throw new RuntimeException("session.feedChanged() for a non-feed-valued property");

    int feedPropertyIndex = classHolder.getFeedPropertyIndex(property.getName());

    if (feedTimestamps == null) {
      feedTimestamps = new long[classHolder.getFeedPropertiesCount()];
      for (int i = 0; i < feedTimestamps.length; i++) feedTimestamps[i] = Long.MAX_VALUE;
    }

    if (feedTimestamps[feedPropertyIndex] > itemTimestamp)
      feedTimestamps[feedPropertyIndex] = itemTimestamp;
  }
Exemplo n.º 2
0
  public void invalidate(DataModel model, long timestamp) {
    @SuppressWarnings("unchecked")
    DMClassHolder<K, T> classHolder = (DMClassHolder<K, T>) model.getClassHolder(clazz);

    long v = propertyMask;
    int propertyIndex = 0;
    while (v != 0) {
      if ((v & 1) != 0) {
        DMPropertyHolder<K, T, ?> property = classHolder.getProperty(propertyIndex);

        if (property instanceof FeedPropertyHolder) {
          int feedPropertyIndex = classHolder.getFeedPropertyIndex(property.getName());
          model
              .getStore()
              .invalidateFeed(
                  classHolder, key, propertyIndex, timestamp, feedTimestamps[feedPropertyIndex]);

          logger.debug(
              "Invalidated {}#{}.{}, feedTimestamp={}",
              new Object[] {
                classHolder.getDMOClass().getSimpleName(),
                key,
                property.getName(),
                feedTimestamps[feedPropertyIndex]
              });
        } else {
          model.getStore().invalidate(classHolder, key, propertyIndex, timestamp);

          logger.debug(
              "Invalidated {}#{}.{}",
              new Object[] {classHolder.getDMOClass().getSimpleName(), key, property.getName()});
        }
      }

      propertyIndex++;
      v >>= 1;
    }
  }