Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.Page


          if (whiteList != null) {
            details.setLength(0);
            if (whiteList.size() > 0) {
              List<Page> pages = new ArrayList<Page>(whiteList.size());
              for (String pageName : whiteList) {
                Page page = DataManager.getPage(wiki, pageName, null, null, null);
                pages.add(page);
              }
              Collections.sort(pages);
              mw.retrieveContents(wiki, pages, true, false, false, false);
              for (Page page : pages) {
                if (Boolean.FALSE.equals(page.isExisting())) {
                  details.append("<li>");
                  details.append(GT._("The page {0} doesn''t exist on Wikipedia", page.getTitle()));
                  details.append("</li>");
                } else {
                  CheckErrorPage errorPage = CheckError.analyzeError(
                      algorithm, page.getAnalysis(page.getContents(), true));
                  if ((errorPage == null) || (!errorPage.getErrorFound())) {
                    details.append("<li>");
                    String pageLink =
                        "<a href=\"" +
                        wiki.getSettings().getURL(page.getTitle(), false, true) +
                        "\">" +
                        page.getTitle() +
                        "</a>";
                    details.append(GT._("The error hasn''t been detected in page {0}.", pageLink));
                    Boolean errorDetected = checkWiki.isErrorDetected(page, errorNumber);
                    if (errorDetected != null) {
                      details.append(" ");
View Full Code Here


  /* (non-Javadoc)
   * @see javax.swing.table.TableModel#getValueAt(int, int)
   */
  public Object getValueAt(int rowIndex, int columnIndex) {
    if ((pages != null) && (rowIndex >= 0) && (rowIndex < pages.size())) {
      Page page = pages.get(rowIndex);
      switch (columnIndex) {
      case COLUMN_BACKLINKS_MAIN:
        return page.getBacklinksProgressionInMainNamespace();
      case COLUMN_BACKLINKS_TEMPLATE:
        return page.getBacklinksProgressionInTemplateNamespace();
      case COLUMN_BACKLINKS_OTHER:
        return page.getBacklinksProgressionInOtherNamespaces();
      case COLUMN_COMMENTS_TEXT:
        if (page.getComment() != null) {
          return page.getComment().getComment();
        }
        return null;
      case COLUMN_DISAMBIGUATION:
        return page.isDisambiguationPage();
      case COLUMN_PAGE:
        return page.getTitle();
      case COLUMN_REDIRECT:
        return page.isRedirect();
      case COLUMN_WATCHED:
        return watchedPages.contains(page.getTitle());
      }
    }
    return null;
  }
View Full Code Here

   */
  @Override
  protected void afterFinishedReloadWorker() {
    super.afterFinishedReloadWorker();
    Configuration config = Configuration.getConfiguration();
    Page page = getPage();
    backlinksProperties = config.getSubProperties(
        getWikipedia(), Configuration.PROPERTIES_BACKLINKS, page.getTitle());
    listCellRenderer.setPageProperties(backlinksProperties);
    popupListenerLinks.setPage(page);
    popupListenerLinks.setBackLinksProperties(backlinksProperties);
    List<Page> links = page.getBackLinksWithRedirects();
    if (config.getBoolean(null, ConfigurationValueBoolean.IGNORE_DAB_USER_NS)) {
      links = new ArrayList<Page>(links);
      for (int i = links.size(); i > 0; i--) {
        if (links.get(i - 1).isInUserNamespace()) {
          links.remove(i - 1);
        }
      }
    }
    modelLinks.setElements(links);
    Integer countMain = page.getBacklinksCountInMainNamespace();
    Integer countTotal = page.getBacklinksCount();
    linkCount.setText(
        ((countMain != null) ? countMain.toString() : "?") +
        " / " +
        ((countTotal != null) ? countTotal.toString() : "?"));

View Full Code Here

   * Action called when Mark back link button is pressed.
   */
  private void actionMarkBacklink(String mark) {
    for (Object selection : listLinks.getSelectedValues()) {
      if (selection instanceof Page) {
        Page selected = (Page) selection;
        backlinksProperties.put(selected.getTitle(), mark);
      }
    }
    Configuration configuration = Configuration.getConfiguration();
    configuration.setSubProperties(
        getWikipedia(),
View Full Code Here

      String property = backlinksProperties.getProperty(value.toString());
      if ((!Configuration.VALUE_PAGE_NORMAL.equals(property)) &&
          (!Configuration.VALUE_PAGE_HELP_NEEDED.equals(property))) {
        firstSelection = currentLine;
        if (value instanceof Page) {
          Page firstPage = (Page) value;
          firstNamespace = firstPage.getNamespace();
        }
      }
      currentLine++;
    }
    if (firstSelection < 0) {
View Full Code Here

    // Load talk pages and "To do" sub pages
    Map<Page, Page> mapTalkPages = new HashMap<Page, Page>();
    Map<Page, Page> mapTodoSubpages = new HashMap<Page, Page>();
    for (Page page : pages) {
      Page talkPage = page.getTalkPage();
      mapTalkPages.put(page, talkPage);
      String todoSubpageAttr = configuration.getString(WPCConfigurationString.TODO_SUBPAGE);
      if (todoSubpageAttr != null) {
        Page todoSubpage = talkPage.getSubPage(todoSubpageAttr);
        mapTodoSubpages.put(page, todoSubpage);
      }
    }
    MediaWiki mw = MediaWiki.getMediaWikiAccess(worker);
    if (section0) {
View Full Code Here

    if ((warningTemplate == null) || (warningTemplate.trim().length() == 0)) {
      if (!simulation) {
        return false;
      }
    }
    Page page = pageAnalysis.getPage();

    // Retrieving talk page contents
    if (talkPage == null) {
      talkPage = page.getTalkPage();
      setText(GT._("Retrieving page contents - {0}", talkPage.getTitle()));
      if (section0) {
        api.retrieveSectionContents(wiki, talkPage, 0);
      } else {
        api.retrieveContents(wiki, Collections.singletonList(talkPage), false, false);
      }
    }

    // "To do" sub-page
    String todoSubpageAttr = configuration.getString(WPCConfigurationString.TODO_SUBPAGE);
    if (todoSubpageAttr != null) {

      // Retrieving "To do" sub-page contents
      if (todoSubpage == null) {
        todoSubpage = talkPage.getSubPage(todoSubpageAttr);
        setText(GT._("Retrieving page contents - {0}", todoSubpage.getTitle()));
        api.retrieveContents(wiki, Collections.singletonList(todoSubpage), false, false);
      }

      // If we force the use of "To do" sub-page, the warning must be on it
      if ((page.getNamespace() != null) &&
          (page.getNamespace().intValue() == Namespace.MAIN)) {
        if (configuration.getBoolean(WPCConfigurationBoolean.TODO_SUBPAGE_FORCE)) {
          return manageWarningOnTodoSubpage(
              pageAnalysis, pageRevId, todoSubpage, talkPage,
              creator, modifiers, stats);
        }
View Full Code Here

    String signature = config.getString(null, ConfigurationValueString.SIGNATURE);

    // Retrieve user talk page name
    Namespace userTalkNS = wiki.getWikiConfiguration().getNamespace(Namespace.USER_TALK);
    String userTalk = userTalkNS.getTitle() + ":" + user;
    Page userTalkPage = DataManager.getPage(analysis.getWikipedia(), userTalk, null, null, null);

    // Add message
    try {
      if (globalTitle != null) {
        // Check if global title already exists in the talk page
        List<Section> sections = api.retrieveSections(wiki, userTalkPage);
        Section section = null;
        if (sections != null) {
          for (Section tmpSection : sections) {
            if (globalTitle.equals(tmpSection.getLine())) {
              section = tmpSection;
            }
          }
        }

        if (section == null) {
          // Add the title
          StringBuilder fullMessage = new StringBuilder();
          if ((globalTemplate != null) && (globalTemplate.trim().length() > 0)) {
            fullMessage.append("{{");
            fullMessage.append(globalTemplate.trim());
            fullMessage.append("}}\n");
            if ((signature != null) && (signature.trim().length() > 0)) {
              fullMessage.append(signature.trim());
              fullMessage.append("\n\n");
            }
          }
          if ((globalListTemplate != null) && (globalListTemplate.trim().length() > 0)) {
            fullMessage.append("{{");
            fullMessage.append(globalListTemplate.trim());
            fullMessage.append("}}\n");
          }
          if (title != null) {
            fullMessage.append("== ");
            fullMessage.append(title);
            fullMessage.append(" ==\n");
          }
          fullMessage.append(message);
          api.addNewSection(wiki, userTalkPage, globalTitle, fullMessage.toString(), false);
        } else {
          // Add the message in the existing title
          Integer revisionId = userTalkPage.getRevisionId();
          api.retrieveSectionContents(wiki, userTalkPage, section.getIndex());
          if (revisionId.equals(userTalkPage.getRevisionId())) {
            StringBuilder fullMessage = new StringBuilder();
            fullMessage.append(userTalkPage.getContents());
            if (fullMessage.charAt(fullMessage.length() - 1) != '\n') {
              fullMessage.append("\n");
            }
            fullMessage.append(message);
            api.updateSection(wiki, userTalkPage, globalTitle, section.getIndex(), fullMessage.toString(), false);
View Full Code Here

        }
      }

      // Check local page
      if (toWiki != null) {
        Page page = DataManager.getPage(toWiki, title, null, null, null);
        api.retrieveInfo(toWiki, Collections.singletonList(page));
        if (message.length() > 0) {
          message.append("\n");
        }
        if (Boolean.FALSE.equals(page.isExisting())) {
          message.append(GT._(
              "The page {0} doesn''t exist in \"{1}\".",
              new Object[] { title, toWiki.toString() } ));
        } else {
          message.append(GT._(
View Full Code Here

      // Retrieve more information on disambiguation pages
      for (Page link : page.getLinks()) {
        if (Boolean.TRUE.equals(link.isDisambiguationPage())) {
          Iterator<Page> itLink = link.getRedirectIteratorWithPage();
          while (itLink.hasNext()) {
            Page link2 = itLink.next();
            if (!link2.isRedirect()) {
              mw.retrieveAllLinks(wiki, link2, null, knownPages, false, false);
            }
            if (link.hasWiktionaryTemplate() &&
                (link.getContents() == null)) {
              mw.retrieveContents(wiki, link2, false, false, false, true, false);
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.Page

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.