Examples of ItemIF


Examples of de.nava.informa.core.ItemIF

      // get description element
      String strDesc = getDescription(item, defNS);

      // generate new news item (link to article)
      ItemIF curItem = cBuilder.createItem(item, chnl, strTitle, strDesc,
                                           ParserUtils.getURL(strLink));

      //TODO enclosure data
      curItem.setFound(dateParsed);

      List itemAuthors = item.getChildren("author", defNS);

      curItem.setCreator(getAuthorString(itemAuthors, defNS));

      // get published element
      Element elIssued = item.getChild("published", defNS);

      if (elIssued == null) {
        // published element may not be present (but updated should be)
        Element elUpdated = item.getChild("updated", defNS);

        // TODO there should be some way to determining which one are we
        // returning
        if (elUpdated != null) {
          curItem.setDate(ParserUtils.getDate(elUpdated.getTextTrim()));
        }
      } else {
        curItem.setDate(ParserUtils.getDate(elIssued.getTextTrim()));
      }

      // get category element
      Element elCategory = item.getChild("category", defNS);

      if (elCategory != null) {
        // TODO: multiple category elements may be present
        curItem.setSubject(elCategory.getTextTrim());
      }
    }

    // set to current date
    chnl.setLastUpdated(dateParsed);
View Full Code Here

Examples of de.nava.informa.core.ItemIF

            logHowManyAdded++;
            /*
             * A persistent item is created, using all the state from the memory based item produced
             * by parser.
             */
            ItemIF newItem = builder.createItem(chan, transientItem);
            mgr.notifyItemAdded((Item) newItem);
          }
        } // while it.hasNext()
      }
      builder.endTransaction();
View Full Code Here

Examples of de.nava.informa.core.ItemIF

          if (tempChannel.getItems().isEmpty()) {
            logger.warn("No items found in channel " + channel);
          } else {
            Iterator it = tempChannel.getItems().iterator();
            while (it.hasNext()) {
              ItemIF item = (ItemIF) it.next();
              if (!channel.getItems().contains(item)) {
                logger.debug("Found new item: " + item);
                channel.addItem(builder.createItem(null, item));
                //                                                              }
              }
View Full Code Here

Examples of de.nava.informa.core.ItemIF

      if (elDesc != null) {
        strDesc = elDesc.getTextTrim();
      }

      // generate new RSS item (link to article)
      ItemIF rssItem =
        cBuilder.createItem(
          item,
          chnl,
          strTitle,
          strDesc,
          ParserUtils.getURL(strLink));
      rssItem.setFound(dateParsed);

      // get source element (an RSS 0.92 element)
      Element source = item.getChild("source");
      if (source != null) {
        String sourceName = source.getTextTrim();
        Attribute sourceAttribute = source.getAttribute("url");
        if (sourceAttribute != null) {
          String location = sourceAttribute.getValue().trim();
          ItemSourceIF itemSource =
            cBuilder.createItemSource(rssItem, sourceName, location, null);
          rssItem.setSource(itemSource);
        }
      }

      // get enclosure element (an RSS 0.92 element)
      Element enclosure = item.getChild("enclosure");
      if (enclosure != null) {
        URL location = null;
        String type = null;
        int length = -1;
        Attribute urlAttribute = enclosure.getAttribute("url");
        if (urlAttribute != null) {
          location = ParserUtils.getURL(urlAttribute.getValue().trim());
        }
        Attribute typeAttribute = enclosure.getAttribute("type");
        if (typeAttribute != null) {
          type = typeAttribute.getValue().trim();
        }
        Attribute lengthAttribute = enclosure.getAttribute("length");
        if (lengthAttribute != null) {
          try {
            length = Integer.parseInt(lengthAttribute.getValue().trim());
          } catch (NumberFormatException e) {
            logger.warn(e);
          }
        }
        ItemEnclosureIF itemEnclosure =
          cBuilder.createItemEnclosure(rssItem, location, type, length);
        rssItem.setEnclosure(itemEnclosure);
      }
    }

    // 0..1 image element
    Element image = channel.getChild("image");
View Full Code Here

Examples of de.nava.informa.core.ItemIF

      if (elDesc != null) {
        strDesc = elDesc.getTextTrim();
      }

      // generate new RSS item (link to article)
      ItemIF rssItem = cBuilder.createItem(item, chnl, strTitle, strDesc,
          ParserUtils.getURL(strLink));
      rssItem.setFound(dateParsed);

      // get creator element
      Element elCreator = item.getChild("creator", dcNS);
      if (elCreator != null) {
        rssItem.setCreator(elCreator.getTextTrim());
      }

      // get subject element
      Element elSubject = item.getChild("subject", dcNS);
      if (elSubject != null) {
        // TODO: Mulitple subject elements not handled currently
        rssItem.setSubject(elSubject.getTextTrim());
      }

      // get date element
      Element elDate = item.getChild("date", dcNS);
      if (elDate != null) {
        rssItem.setDate(ParserUtils.getDate(elDate.getTextTrim()));
      }

      // get source element - default to Aggregation module, then try Dublin Core
      String sourceName = null;
      String sourceLocation = null;
      Date sourceTimestamp = null;

      Element elSourceURL = item.getChild("sourceURL", agNS);
      if (elSourceURL == null) { //  No Aggregation module - try Dublin Core
        elSourceURL = item.getChild("source", dcNS);
        if (elSourceURL != null) {
          sourceLocation = elSourceURL.getTextTrim();
          sourceName = "Source";
        }
      } else { // Aggregation module
        sourceLocation = elSourceURL.getTextTrim();
        Element elSourceName = item.getChild("source", agNS);
        if (elSourceName != null) {
          sourceName = elSourceName.getTextTrim();
        }
        Element elSourceTimestamp = item.getChild("timestamp", agNS);
        if (elSourceTimestamp != null) {
          sourceTimestamp = ParserUtils
              .getDate(elSourceTimestamp.getTextTrim());
        }
      }

      if (sourceLocation != null) {
        ItemSourceIF itemSource = cBuilder.createItemSource(rssItem,
            sourceName, sourceLocation, sourceTimestamp);
        rssItem.setSource(itemSource);
      }

      // comments element - use Annotation module
      Element elReference = item.getChild("reference", annotateNS);
      if (elReference != null) {
        Attribute resource = elReference.getAttribute("resource", ParserUtils
            .getNamespace(elReference, "rdf"));
        if (resource != null) {
          URL resourceURL = ParserUtils.getURL(resource.getValue());
          if (resourceURL != null) {
            rssItem.setComments(resourceURL);
          }
        }
      }

    }
View Full Code Here

Examples of de.nava.informa.core.ItemIF

   */
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof ItemIF)) return false;

    final ItemIF item = (ItemIF) o;

    final String itemTitle = item.getTitle();
    if (title != null
      ? !title.equals(itemTitle)
      : itemTitle != null) return false;

    // Comparison of links uses synchronized code of Java-NET.
    // This may hurt multi-threaded applications. So, please think twice
    // before using direct comparison of links.
    final URL itemLink = item.getLink();
    if (link != null
      ? itemLink == null || !link.toString().equalsIgnoreCase(itemLink.toString())
      : itemLink != null) return false;

    final String itemDescription = item.getDescription();
    if (description != null
      ? !description.equals(itemDescription)
      : itemDescription != null) return false;

    return true;
View Full Code Here

Examples of de.nava.informa.core.ItemIF

    return createItem(null, channel, title, description, link);
  }

  public ItemIF createItem(Element itemElement, ChannelIF channel, String title, String description,
                           URL link) {
    ItemIF item = new Item(itemElement, channel, title, description, link);
    if (channel != null) {
      channel.addItem(item);
    }
    return item;
  }
View Full Code Here

Examples of de.nava.informa.core.ItemIF

  public ItemIF getItem(long itemId) {
    // TODO: improve performance
    // hibernate query cannot be used (not possible: no session object)
    // may be use transient map: items.get(new Long(id));
    ItemIF theItem = null;
    Iterator it = items.iterator();
    while (it.hasNext()) {
      ItemIF curItem = (ItemIF) it.next();
      if (curItem.getId() == itemId) {
        theItem = curItem;
        break;
      }
    }
    return theItem;
View Full Code Here

Examples of de.nava.informa.core.ItemIF

    final ItemIF[] newItems = (ItemIF[]) items.toArray(new ItemIF[items.size()]);
    final Collection currentItems = existingChannel.getItems();

    boolean finish = false;
    for (int i = 0; !record.isCanceled() && !finish && i < newItems.length; i++) {
      final ItemIF newItem = newItems[i];

      // If current list of item has no this item and approver allows to add item then proceed.
      if (!record.isCanceled() && !currentItems.contains(newItem)) {
        doAdditionIfApproved(newItem, existingChannel);
      } else if (itemScanningPolicy == POLICY_SKIP_AFTER_EXISTING) {
View Full Code Here

Examples of de.nava.informa.core.ItemIF

   */
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof ItemIF)) return false;

    final ItemIF item = (ItemIF) o;

    final String itemTitle = item.getTitle();
    if (title != null
      ? !title.equals(itemTitle)
      : itemTitle != null) return false;

    // Comparison of links uses synchronized code of Java-NET.
    // This may hurt multi-threaded applications. So, please think twice
    // before using direct comparison of links.
    final URL itemLink = item.getLink();
    if (link != null
      ? itemLink == null || !link.toString().equalsIgnoreCase(itemLink.toString())
      : itemLink != null) return false;

    final String itemDescription = item.getDescription();
    if (description != null
      ? !description.equals(itemDescription)
      : itemDescription != null) return false;

    return true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.