Package org.wikipediacleaner.api.check

Examples of org.wikipediacleaner.api.check.CheckWiki


   * @see org.wikipediacleaner.gui.swing.PageWindow#afterFinishedReloadWorker()
   */
  @Override
  protected void afterFinishedReloadWorker() {
    super.afterFinishedReloadWorker();
    CheckWiki checkWiki = APIFactory.getCheckWiki();
    checkWiki.addListener(this);
    analyzeCheckWiki();
  }
View Full Code Here


    if ((algorithm != null) && (description != null)) {
      // Error type description
      try {
        DocumentBuilderImpl dbi = new DocumentBuilderImpl(ucontext, rcontextDescription);
        InputSource is = new InputSource(new StringReader(description));
        CheckWiki cw = APIFactory.getCheckWiki();
        is.setSystemId(cw.getUrlDescription(getWikipedia(), algorithm));
        Document document = dbi.parse(is);
        textDescription.setDocument(document, rcontextDescription);
      } catch (SAXException e) {
        textDescription.clearDocument();
      } catch (IOException e) {
View Full Code Here

  public void actionErrorList() {
    Object selected = listAllErrors.getSelectedItem();
    if ((selected instanceof CheckError) &&
        (Utilities.isDesktopSupported())) {
      CheckError error = (CheckError) selected;
      CheckWiki checkWiki = APIFactory.getCheckWiki();
      String url = checkWiki.getUrlDescription(getWikipedia(), error.getAlgorithm());
      Utilities.browseURL(url);
    }
  }
View Full Code Here

          errorFound = true;
        }
      }
    }
    if ((error != null) && (errorFound == false)) {
      CheckWiki checkWiki = APIFactory.getCheckWiki();
      List<CheckWikiDetection> detections = checkWiki.check(page);
      int answer = JOptionPane.NO_OPTION;
      if (detections != null) {
        boolean errorDetected = false;
        for (CheckWikiDetection detection : detections) {
          if (detection.getErrorNumber() == error.getErrorNumber()) {
View Full Code Here

    if (pageFixed != null) {
      MediaWikiController.addSimpleTask(new Callable<Page>() {
 
        public Page call() throws Exception
        {
          CheckWiki checkWiki = APIFactory.getCheckWiki();
          if (checkWiki != null) {
            checkWiki.markAsFixed(pageFixed, errorNumber);
          }
          return pageFixed;
        }});
    }
  }
View Full Code Here

   *
   * @param e Event triggering this call.
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    CheckWiki checkWiki = APIFactory.getCheckWiki();
    Page page = DataManager.getPage(wiki, title, null, null, null);
    List<CheckWikiDetection> detections = checkWiki.check(page);
    if (detections == null) {
      Utilities.displayWarning(
          parent,
          GT._("Unable to retrieve analysis from CheckWiki."));
      return;
View Full Code Here

   */
  @Override
  public Object construct() {
    List<CheckError> errors = new ArrayList<CheckError>();
    try {
      CheckWiki checkWiki = APIFactory.getCheckWiki();
      for (CheckErrorAlgorithm algorithm : selectedAlgorithms) {
        if (!shouldContinue()) {
          return null;
        }
        setText(
            GT._("Checking for errors n°{0}", Integer.toString(algorithm.getErrorNumber())) +
            " - " + algorithm.getShortDescriptionReplaced());
        errors.clear();
        checkWiki.retrievePages(algorithm, max, getWikipedia(), errors);
        while (!errors.isEmpty()) {
          CheckError error = errors.remove(0);
          int maxErrors = error.getPageCount();
          for (int numPage = 0;
              (error.getPageCount() > 0) && shouldContinue();
View Full Code Here

          found = true;
        }
      }
    }

    CheckWiki checkWiki = APIFactory.getCheckWiki();
    if (found) {

      // Fix all errors that can be fixed
      String newContents = page.getContents();
      List<CheckErrorAlgorithm> usedAlgorithms = new ArrayList<CheckErrorAlgorithm>();
      newContents = AutomaticFormatter.tidyArticle(page, newContents, allAlgorithms, true, usedAlgorithms);

      // Save page if errors have been fixed
      if ((!newContents.equals(page.getContents())) &&
          (!usedAlgorithms.isEmpty())) {
        if (!saveModifications) {
          return;
        }
        StringBuilder comment = new StringBuilder();
        if ((extraComment != null) && (extraComment.trim().length() > 0)) {
          comment.append(extraComment.trim());
          comment.append(" - ");
        }
        comment.append(getWikipedia().getCWConfiguration().getComment(usedAlgorithms));
        setText(prefix + " - " + GT._("Fixing page {0}", page.getTitle()));
        api.updatePage(
            getWikipedia(), page, newContents,
            getWikipedia().createUpdatePageComment(comment.toString(), null, true),
            false);
        countModified++;
        for (CheckErrorAlgorithm usedAlgorithm : usedAlgorithms) {
          CheckErrorPage errorPage = CheckError.analyzeError(usedAlgorithm, page.getAnalysis(newContents, true));
          if ((errorPage != null) && (!errorPage.getErrorFound())) {
            checkWiki.markAsFixed(page, usedAlgorithm.getErrorNumberString());
            if (selectedAlgorithms.contains(usedAlgorithm)) {
              countMarked++;
            } else {
              countMarkedOther++;
            }
          }
        }
      } else if (analyzeNonFixed) {
        Controller.runFullAnalysis(page.getTitle(), null, getWikipedia());
      }
    } else if (algorithm.isFullDetection()) {
      Boolean errorDetected = checkWiki.isErrorDetected(
          page, algorithm.getErrorNumber());
      if (Boolean.FALSE.equals(errorDetected)) {
        checkWiki.markAsFixed(page, algorithm.getErrorNumberString());
        countMarked++;
      }
    }
  }
View Full Code Here

   * @see org.wikipediacleaner.gui.swing.basic.BasicWorker#construct()
   */
  @Override
  public Object construct() {
    try {
      CheckWiki checkWiki = APIFactory.getCheckWiki();
      MediaWiki mw = MediaWiki.getMediaWikiAccess(this);
      EnumWikipedia wiki = getWikipedia();
      StringBuilder result = new StringBuilder();
      StringBuilder details = new StringBuilder();
      List<CheckErrorAlgorithm> algorithms = CheckErrorAlgorithms.getAlgorithms(wiki);
      for (CheckErrorAlgorithm algorithm : algorithms) {
        int errorNumber = algorithm.getErrorNumber();
        if (algorithm.isAvailable() &&
            CheckErrorAlgorithms.isAlgorithmActive(wiki, errorNumber)) {
          setText(GT._("Checking whitelist for error {0}", String.valueOf(errorNumber)));
          CWConfigurationError cwConfig = wiki.getCWConfiguration().getErrorConfiguration(errorNumber);
          Set<String> whiteList = cwConfig.getWhiteList();
          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(" ");
                      if (Boolean.TRUE.equals(errorDetected)) {
                        details.append(GT._("It's still being detected by CheckWiki."));
                      } else {
View Full Code Here

    }

    // Create sub menus
    menu.addSeparator(popup);
    menu.addItemView(wiki, popup, algorithm.getLink(), GT._("Detail"));
    CheckWiki checkWiki = APIFactory.getCheckWiki();
    String toolserverUrl = checkWiki.getUrlDescription(wiki, algorithm);
    menu.addItemView(null, popup, toolserverUrl, GT._("List on {0}", CheckWiki.getServerName(wiki)));
    menu.addItemView(wiki, popup, algorithm.getWhiteListPageName(), GT._("View or edit whitelist"));

    popup.show(e.getComponent(), e.getX(), e.getY());
  }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.check.CheckWiki

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.