Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.MergeResult


   * org.rssowl.core.persist.IConditionalGet, boolean,
   * org.eclipse.core.runtime.IProgressMonitor)
   */
  public final void handleFeedReload(IBookMark bookMark, IFeed interpretedFeed, IConditionalGet conditionalGet, boolean deleteConditionalGet, final IProgressMonitor monitor) {
    fWriteLock.lock();
    MergeResult mergeResult = null;
    try {
      /* Resolve reloaded Feed */
      IFeed feed = bookMark.getFeedLinkReference().resolve();

      /* Feed could have been deleted meanwhile! */
      if (feed == null)
        return;

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Copy over Properties to reloaded Feed to keep them */
      Map<String, Serializable> feedProperties = feed.getProperties();
      if (feedProperties != null) {
        feedProperties.entrySet();
        for (Map.Entry<String, Serializable> entry : feedProperties.entrySet())
          interpretedFeed.setProperty(entry.getKey(), entry.getValue());
      }

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Merge with existing */
      mergeResult = feed.mergeAndCleanUp(interpretedFeed);
      final List<INews> newNewsAdded = getNewNewsAdded(feed);

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Update Date of last added news in Bookmark */
      if (!newNewsAdded.isEmpty()) {
        Date mostRecentDate = DateUtils.getRecentDate(newNewsAdded);
        Date previousMostRecentDate = bookMark.getMostRecentNewsDate();
        if (previousMostRecentDate == null || mostRecentDate.after(previousMostRecentDate)) {
          bookMark.setMostRecentNewsDate(mostRecentDate);
          fDb.store(bookMark);
        }
      }

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Update state of added news if equivalent news already exists */
      SafeRunner.run(new LoggingSafeRunnable() {
        public void run() throws Exception { //See Bug 1216 (NPE in ModelSearchImpl.getCurrentSearcher)
          updateStateOfUnsavedNewNews(newNewsAdded, monitor);
        }
      });

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Retention Policy */
      final List<INews> deletedNews = RetentionStrategy.process(bookMark, feed);
      for (INews news : deletedNews)
        mergeResult.addUpdatedObject(news);

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Set ID to News and handle Description entity */
      IDGenerator generator = Owl.getPersistenceService().getIDGenerator();
      for (INews news : newNewsAdded) {

        /* Return early on cancellation */
        if (monitor.isCanceled() || Owl.isShuttingDown())
          return;

        long id;
        if (generator instanceof DB4OIDGenerator)
          id = ((DB4OIDGenerator) generator).getNext(false);
        else
          id = generator.getNext();

        news.setId(id);

        String description = ((News) news).getTransientDescription();
        if (description != null) {
          mergeResult.addUpdatedObject(new Description(news, description));
        }
      }

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
View Full Code Here


    news1.setLink(news1Link);
    DynamicDAO.save(feed);
    long feedId = feed.getId();
    INews news = feed.getNews().get(0);
    feed.removeNews(news);
    MergeResult mergeResult = new MergeResult();
    mergeResult.addRemovedObject(news);
    mergeResult.addUpdatedObject(feed);
    TestUtils.saveFeed(mergeResult);
    feed = null;
    news0 = null;
    news1 = null;
    mergeResult = null;
View Full Code Here

          emptyFeed.setProperty(entry.getKey(), entry.getValue());
      }

      /* Merge with existing (remember number of added new news) */
      List<INews> newNewsBeforeMerge = feed.getNewsByStates(EnumSet.of(INews.State.NEW));
      MergeResult mergeResult = feed.mergeAndCleanUp(emptyFeed);
      List<INews> newNewsAdded = getNewNewsAdded(feed, newNewsBeforeMerge);
      updateStateOfUnsavedNewNews(newNewsAdded);

      /* Retention Policy */
      List<INews> deletedNews = RetentionStrategy.process(bookMark, feed, newNewsAdded.size());

      for (INews news : deletedNews)
        mergeResult.addUpdatedObject(news);

      saveFeed(mergeResult);

      /* Update Conditional GET */
      if (conditionalGet != null) {
View Full Code Here

  private MergeResult merge(IFeed objectToMerge, boolean cleanUp) {
    Assert.isLegal(getLink().toString().equals(objectToMerge.getLink().toString()),
        "Only feeds with the same link can be merged."); //$NON-NLS-1$
   
    MergeResult result = new MergeResult();
    boolean updated = processListMergeResult(result, mergeNews(objectToMerge.getNews(), cleanUp));
    updated |= processListMergeResult(result, mergeCategories(objectToMerge.getCategories()));
    updated |= processListMergeResult(result, mergeAuthor(objectToMerge.getAuthor()));
    updated |= processListMergeResult(result, mergeImage(objectToMerge.getImage()));
    updated |= !simpleFieldsEqual(objectToMerge);

    setBase(objectToMerge.getBase());
    fCopyright = objectToMerge.getCopyright();
    fDescription = objectToMerge.getDescription();
    setDocs(objectToMerge.getDocs());
    fFormat = objectToMerge.getFormat();
    fGenerator = objectToMerge.getGenerator();
    setHomepage(objectToMerge.getHomepage());
    fLanguage = objectToMerge.getLanguage();
    fLastBuildDate = objectToMerge.getLastBuildDate();
    fLastModifiedDate = objectToMerge.getLastModifiedDate();
    fPublishDate = objectToMerge.getPublishDate();
    fTitle = objectToMerge.getTitle();
    fTTL = objectToMerge.getTTL();
    fWebmaster = objectToMerge.getWebmaster();
   
    ComplexMergeResult<?> propertiesResult = MergeUtils.mergeProperties(this, objectToMerge);
    if (updated || propertiesResult.isStructuralChange()) {
      result.addUpdatedObject(this);
      result.addAll(propertiesResult);
    }
    return result;
  }
View Full Code Here

      assertEquals(INews.State.READ, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(2).getState());

      /* Check Deleted News now being Deleted from DB */
      IFeed emptyFeed = fFactory.createFeed(null, new URI("http://www.feed.com"));
      IFeed savedFeed = feedRef.resolve();
      MergeResult mergeResult = savedFeed.mergeAndCleanUp(emptyFeed);
      TestUtils.saveFeed(mergeResult);

      feed = null;
      news1 = null;
      news2 = null;
View Full Code Here

  public synchronized MergeResult merge(INews news) {
    Assert.isNotNull(news, "news cannot be null"); //$NON-NLS-1$
    synchronized (news) {
      boolean updated = mergeState(news);

      MergeResult result = new MergeResult();
      /* Merge all items except for feed and id */
      updated |= processListMergeResult(result, mergeAttachments(news.getAttachments()));
      updated |= processListMergeResult(result, mergeCategories(news.getCategories()));
      updated |= processListMergeResult(result, mergeAuthor(news.getAuthor()));
      updated |= processListMergeResult(result, mergeGuid(news.getGuid()));
      updated |= processListMergeResult(result, mergeSource(news.getSource()));
      updated |= !simpleFieldsEqual(news);

      setBase(news.getBase());
      fComments = news.getComments();
      setDescription(news.getDescription());
      setLink(news.getLink());
      fModifiedDate = news.getModifiedDate();
      fPublishDate = news.getPublishDate();
      fTitle = news.getTitle();
      fInReplyTo = news.getInReplyTo();

      ComplexMergeResult<?> propertiesResult = MergeUtils.mergeProperties(this, news);
      if (updated || propertiesResult.isStructuralChange()) {
        result.addUpdatedObject(this);
        result.addAll(propertiesResult);
      }
      return result;
    }
  }
View Full Code Here

      assertEquals(INews.State.READ, DynamicDAO.load(IFeed.class, feedRef.getId()).getNews().get(2).getState());

      /* Check Deleted News now being Deleted from DB */
      IFeed emptyFeed = fFactory.createFeed(null, new URI("http://www.feed.com"));
      IFeed savedFeed = feedRef.resolve();
      MergeResult mergeResult = savedFeed.mergeAndCleanUp(emptyFeed);
      TestUtils.saveFeed(mergeResult);

      feed = null;
      news1 = null;
      news2 = null;
View Full Code Here

  public MergeResult merge(IGuid objectToMerge) {
    boolean updated = fIsPermaLink != objectToMerge.isPermaLink();
    fIsPermaLink = objectToMerge.isPermaLink();
    updated |= !MergeUtils.equals(fValue, objectToMerge.getValue());
    fValue = objectToMerge.getValue();
    MergeResult mergeResult = new MergeResult();
    if (updated)
      mergeResult.addUpdatedObject(this);

    return mergeResult;
  }
View Full Code Here

    boolean updated = !MergeUtils.equals(fName, objectToMerge.getName());
    fName = objectToMerge.getName();
    updated |= !MergeUtils.equals(getLink(), objectToMerge.getLink());
    setLink(objectToMerge.getLink());

    MergeResult mergeResult = new MergeResult();
    if (updated)
      mergeResult.addUpdatedObject(this);

    return mergeResult;
  }
View Full Code Here

    setHomepage(objectToMerge.getHomepage());
    fTitle = objectToMerge.getTitle();
    setLink(objectToMerge.getLink());
    fWidth = objectToMerge.getWidth();
    fDescription = objectToMerge.getDescription();
    MergeResult mergeResult = new MergeResult();
    if (updated)
      mergeResult.addUpdatedObject(this);

    return mergeResult;
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.MergeResult

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.