Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IPerson


  public static boolean isAuthorChange(Set<? extends ModelEvent> events) {
    for (ModelEvent modelEvent : events) {
      if (modelEvent instanceof NewsEvent) {
        NewsEvent event = (NewsEvent) modelEvent;

        IPerson oldAuthor = event.getOldNews() != null ? event.getOldNews().getAuthor() : null;
        IPerson newAuthor = event.getEntity().getAuthor();

        if (newAuthor != null && !newAuthor.equals(oldAuthor))
          return true;
        else if (oldAuthor != null && !oldAuthor.equals(newAuthor))
          return true;
      }
    }
View Full Code Here


        category.setName(attribute.getValue());
    }
  }

  private void processAuthor(Element element, IPersistable type) {
    IPerson person = Owl.getModelFactory().createPerson(null, type);

    /* Check wether the Attributes are to be processed by a Contribution */
    processNamespaceAttributes(element, person);

    /* Interpret Children */
    List< ? > personChilds = element.getChildren();
    for (Iterator< ? > iter = personChilds.iterator(); iter.hasNext();) {
      Element child = (Element) iter.next();
      String name = child.getName().toLowerCase();

      /* Check wether this Element is to be processed by a Contribution */
      if (processElementExtern(child, person))
        continue;

      /* Name */
      else if ("name".equals(name)) { //$NON-NLS-1$
        person.setName(child.getText());
        processNamespaceAttributes(child, person);
      }

      /* EMail */
      else if ("email".equals(name)) { //$NON-NLS-1$
        URI uri = URIUtils.createURI(child.getText());
        if (uri != null)
          person.setEmail(uri);
        processNamespaceAttributes(child, person);
      }

      /* URI */
      else if ("uri".equals(name)) { //$NON-NLS-1$
        URI uri = URIUtils.createURI(child.getText());
        if (uri != null)
          person.setUri(uri);
        processNamespaceAttributes(child, person);
      }
    }
  }
View Full Code Here

        ((INews) type).setPublishDate(DateUtils.parseDate(element.getText()));
    }

    /* Creator */
    else if ("creator".equals(name)) { //$NON-NLS-1$
      IPerson person = Owl.getModelFactory().createPerson(null, type);
      person.setName(element.getText());
    }

    /* Publisher (only if creator is not set) */
    else if ("publisher".equals(name)) { //$NON-NLS-1$
      boolean usePublisher = true;
      if (type instanceof IFeed && ((IFeed) type).getAuthor() != null)
        usePublisher = false;
      else if (type instanceof INews && ((INews) type).getAuthor() != null)
        usePublisher = false;

      if (usePublisher) {
        IPerson person = Owl.getModelFactory().createPerson(null, type);
        person.setName(element.getText());
      }
    }

    /* Language */
    else if ("language".equals(name) && type instanceof IFeed) //$NON-NLS-1$
View Full Code Here

    else if (entity instanceof IFeed) {
      IFeed feed = (IFeed) entity;
      modelEvent = new FeedEvent(feed, root);
    }
    else if (entity instanceof IPerson) {
      IPerson person = (IPerson) entity;
      modelEvent = new PersonEvent(person, root);
    }
    else if (entity instanceof IBookMark) {
      IBookMark mark = (IBookMark) entity;
      BookMarkEvent eventTemplate = (BookMarkEvent) template;
View Full Code Here

          if (received != null)
            text = fDateFormat.format(received);
          break;

        case AUTHOR:
          IPerson author = news.getAuthor();
          if (author != null) {
            if (author.getName() != null)
              text = author.getName();
            else if (author.getEmail() != null)
              text = author.getEmail().toString();
          }
          break;

        case CATEGORY:
          List<ICategory> categories = news.getCategories();
View Full Code Here

  public byte[] getFeedIcon(URI link, IProgressMonitor monitor) {
    return loadFavicon(link, false, monitor);
  }

  private void interpretFrom(INews news, String value) {
    IPerson person = Owl.getModelFactory().createPerson(null, news);
    value = value.trim();

    /* Complex value */
    if (value.contains(" ")) { //$NON-NLS-1$

      /* Remove quotes first */
      value = value.replace("\"", ""); //$NON-NLS-1$//$NON-NLS-2$
      value = value.replace("'", ""); //$NON-NLS-1$ //$NON-NLS-2$

      /* foo@bar.com (Forename Name) */
      if (value.contains("(") && value.contains(")")) { //$NON-NLS-1$ //$NON-NLS-2$
        int start = value.indexOf('(');
        int end = value.indexOf(')');

        /* E-Mail */
        if (start > 0)
          person.setEmail(URIUtils.createURI(value.substring(0, start)));

        /* Name */
        if (start < end)
          person.setName(value.substring(start + 1, end).trim());
      }

      /* Forename Name <foo@bar.com> */
      if (value.contains("<") && value.contains(">")) { //$NON-NLS-1$ //$NON-NLS-2$
        int start = value.indexOf('<');
        int end = value.indexOf('>');

        /* Name */
        if (start > 0)
          person.setName(value.substring(0, start).trim());

        /* E-Mail */
        if (start < end)
          person.setEmail(URIUtils.createURI(value.substring(start + 1, end)));
      }
    }

    /* Simple Value (EMail) */
    else if (value.contains("@")) //$NON-NLS-1$
      person.setEmail(URIUtils.createURI(value));

    /* Simple Value (Name) */
    else
      person.setName(value);

    news.setAuthor(person);
  }
View Full Code Here

              };
            });

            /* Find Related by Author */
            if (news.getAuthor() != null) {
              IPerson person = news.getAuthor();
              String name = person.getName();
              String email = (person.getEmail() != null) ? person.getEmail().toASCIIString() : null;

              final String author = StringUtils.isSet(name) ? name : email;
              if (StringUtils.isSet(author)) {
                manager.add(new Separator());
                manager.add(new Action(NLS.bind(Messages.NewsBrowserViewer_AUTHORED_BY, escapeForMenu(author))) {
View Full Code Here

          if (received != null)
            text = DateUtils.isAfterIncludingToday(received, fTodayInMillies) ? fTimeFormat.format(received) : fDateFormat.format(received);
          break;

        case AUTHOR:
          IPerson author = news.getAuthor();
          if (author != null) {
            if (author.getName() != null)
              text = author.getName();
            else if (author.getEmail() != null)
              text = author.getEmail().toString();
          }
          break;

        case CATEGORY:
          List<ICategory> categories = news.getCategories();
View Full Code Here

   * {@link MergeUtils#merge(org.rssowl.core.persist.MergeCapable, org.rssowl.core.persist.MergeCapable)}
   * .
   */
  @Test
  public void testSingleItemMergeWithNullDestination() {
    IPerson person = new Person((Long) null);
    ComplexMergeResult<IPerson> mergeResult = MergeUtils.merge(null, person);
    assertEquals(person, mergeResult.getMergedObject());
    assertEquals(true, mergeResult.isStructuralChange());
  }
View Full Code Here

   * {@link MergeUtils#merge(org.rssowl.core.persist.MergeCapable, org.rssowl.core.persist.MergeCapable)}
   * .
   */
  @Test
  public void testSingleItemMergeWithNonNullDestinationAndNullOrigin() {
    IPerson person = new Person((Long) null);
    ComplexMergeResult<IPerson> mergeResult = MergeUtils.merge(person, null);
    assertNull(mergeResult.getMergedObject());
    assertEquals(true, mergeResult.isStructuralChange());
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IPerson

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.