Package org.wikipediacleaner.api.constants

Examples of org.wikipediacleaner.api.constants.EnumWikipedia


    List<PageElementFunction> tags = analysis.getDefaultSorts();
    if ((tags == null) || (tags.isEmpty())) {
      return false;
    }
    boolean result = false;
    EnumWikipedia wiki = analysis.getWikipedia();
    for (PageElementFunction tag : tags) {
      if (tag != null) {
        boolean characterFound = false;
        boolean characterReplaced = false;
        String unknownCharacters = "";
View Full Code Here


  /**
   * Action called when Check White Lists button is pressed.
   */
  public void actionCWCheckWhiteLists() {
    EnumWikipedia wiki = window.getWikipedia();
    CWCheckWhiteListsWorker worker = new CWCheckWhiteListsWorker(wiki, window);
    worker.start();
  }
View Full Code Here

   * @param pages List of all disambiguation pages.
   * @throws APIException
   */
  private void constructAllDab(List<Page> pages) throws APIException {
    final API api = APIFactory.getAPI();
    EnumWikipedia wiki = getWikipedia();
    List<Page> tmpPages = wiki.constuctDisambiguationPages(api);
    if (tmpPages != null) {
      pages.addAll(tmpPages);
    }
  }
View Full Code Here

   * @param pages List of pages with missing templates.
   * @throws APIException
   */
  private void constructMissingTemplates(List<Page> pages) throws APIException {
    final API api = APIFactory.getAPI();
    EnumWikipedia wiki = getWikipedia();
    setText(GT._("Retrieving list of missing templates"));
    List<Page> tmpPages = api.getQueryPages(wiki, EnumQueryPage.WANTED_TEMPLATES);
    if (tmpPages == null) {
      return;
    }
    setText(GT._("Checking that the templates are still missing"));
    api.retrieveInfo(wiki, tmpPages);
    List<Page> tmpPages2 = new ArrayList<Page>();
    for (Page tmpPage : tmpPages) {
      Boolean exists = tmpPage.isExisting();
      if (!Boolean.TRUE.equals(exists)) {
        tmpPages2.add(tmpPage);
      }
    }
    MediaWiki mw = MediaWiki.getMediaWikiAccess(this);
    List<Page> tmpPages3 = mw.retrieveAllEmbeddedIn(
        wiki, tmpPages2,
        wiki.getConfiguration().getEncyclopedicNamespaces(), true);
    pages.addAll(tmpPages3);
    Collections.sort(pages, PageComparator.getNamespaceFirstComparator());
  }
View Full Code Here

   * @param pages List of protected titles with backlinks.
   * @throws APIException
   */
  private void constructProtectedTitles(List<Page> pages) throws APIException {
    final API api = APIFactory.getAPI();
    EnumWikipedia wiki = getWikipedia();
    setText(GT._("Retrieving list of protected titles"));
    List<Page> tmpPages = api.getProtectedTitles(
        wiki, Collections.singletonList(Namespace.MAIN), false);
    if ((tmpPages == null) || (tmpPages.isEmpty())) {
      return;
View Full Code Here

   * @param pages List of pages.
   * @throws APIException
   */
  private void constructQueryPage(List<Page> pages) throws APIException {
    final API api = APIFactory.getAPI();
    EnumWikipedia wiki = getWikipedia();
    EnumQueryPage query = EnumQueryPage.findByCode(elementNames.get(0));
    List<Page> tmpPages = api.getQueryPages(wiki, query);
    if (tmpPages != null) {
      pages.addAll(tmpPages);
    }
View Full Code Here

   * @see org.wikipediacleaner.gui.swing.basic.BasicWorker#construct()
   */
  @Override
  public Object construct() {
    long startTime = System.currentTimeMillis();
    EnumWikipedia wiki = getWikipedia();
    WPCConfiguration configuration = wiki.getConfiguration();

    setText(GT._("Retrieving MediaWiki API"));
    API api = APIFactory.getAPI();
    int lastCount = 0;
    WikiConfiguration wikiConfiguration = wiki.getWikiConfiguration();

    Stats stats = new Stats();
    Map<String, List<String>> errors = null;
    try {
      if (!useList) {
View Full Code Here

   * @param errorNumber Error number.
   * @param pages List of pages to complete.
   */
  private void retrieveCheckWikiPages(int errorNumber, List<Page> pages) {
    CheckWiki cw = APIFactory.getCheckWiki();
    EnumWikipedia wiki = getWikipedia();
    CheckErrorAlgorithm algorithm = CheckErrorAlgorithms.getAlgorithm(wiki, errorNumber);
    List<CheckError> errors = new ArrayList<CheckError>();
    try {
      cw.retrievePages(algorithm, 10000, wiki, errors);
      for (CheckError error: errors) {
View Full Code Here

    // Errors
    if (errors != null) {

      // Configuration
      EnumWikipedia wiki = getWikipedia();
      List<String[]> issnSearchEngines = wiki.getConfiguration().getStringArrayList(
          WPCConfigurationStringList.ISSN_SEARCH_ENGINES);
      String issnUrl = null;
      if ((issnSearchEngines != null) &&
          !issnSearchEngines.isEmpty()) {
        String[] issnSearchEngine0 = issnSearchEngines.get(0);
        if ((issnSearchEngine0 != null) && (issnSearchEngine0.length > 1)) {
          issnUrl = issnSearchEngine0[1];
        }
      }

      // Compute synthesis
      StringBuilder buffer = new StringBuilder();
      List<String> keys = new ArrayList<String>(errors.keySet());
      Collections.sort(keys);
      for (String key : keys) {
        List<String> values = errors.get(key);
        buffer.append("* ");
        if (values != null) {
          buffer.append(values.size());
          buffer.append(" x ");
        }
        buffer.append("ISBN ");
        buffer.append(key);
        if (issnUrl != null) {
          String clean = key.replaceAll("\\&\\#x3D\\;", "=");
          clean = PageElementISBN.cleanISBN(clean);
          if (clean.length() == 8) {
            buffer.append(" ([");
            buffer.append(MessageFormat.format(issnUrl, clean));
            buffer.append(" ISSN?])");
          }
        }
        buffer.append(" : ");
        if (values != null) {
          Collections.sort(values);
          int valueNum = 0;
          while (valueNum < values.size()) {
            if (valueNum > 0) {
              buffer.append(", ");
            }
            String value = values.get(valueNum);
            int begin = valueNum;
            while ((valueNum < values.size()) &&
                   (values.get(valueNum).equals(value))) {
              valueNum++;
            }
            if (valueNum > begin + 1) {
              buffer.append(valueNum - begin);
              buffer.append(" x ");
            }
            buffer.append("[[");
            buffer.append(value);
            buffer.append("]]");
          }
        }
        buffer.append("\n");
      }

      // Update synthesis on dedicated page
      WPCConfiguration config = wiki.getConfiguration();
      String pageName = config.getString(WPCConfigurationString.ISBN_ERRORS_PAGE);
      boolean saved = false;
      if ((pageName != null) && (pageName.trim().length() > 0)) {
        boolean updatePage = false;
        if (simulation && (getWindow() != null)) {
          int answer = Utilities.displayYesNoWarning(
              getWindow().getParentComponent(),
              GT._("Do you want to update {0}?", pageName));
          if (answer == JOptionPane.YES_OPTION) {
            updatePage = true;
          }
        } else {
          updatePage = true;
        }

        if (updatePage) {
          try {
            Page page = DataManager.getPage(wiki, pageName, null, null, null);
            API api = APIFactory.getAPI();
            api.retrieveContents(wiki, Collections.singletonList(page), false, false);
            String contents = page.getContents();
            if (contents != null) {
              int begin = -1;
              int end = -1;
              for (PageElementComment comment : page.getAnalysis(contents, true).getComments()) {
                String value = comment.getComment().trim();
                if ("BOT BEGIN".equals(value)) {
                  if (begin < 0) {
                    begin = comment.getEndIndex();
                  }
                } else if ("BOT END".equals(value)) {
                  end = comment.getBeginIndex();
                }
              }
              if ((begin >= 0) && (end > begin)) {
                StringBuilder newText = new StringBuilder();
                newText.append(contents.substring(0, begin));
                newText.append("\n");
                newText.append(buffer.toString());
                newText.append(contents.substring(end));
                api.updatePage(
                    wiki, page, newText.toString(),
                    wiki.formatComment(
                        config.getString(WPCConfigurationString.ISBN_ERRORS_PAGE_COMMENT),
                        true),
                    false);
                saved = true;
              }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.constants.EnumWikipedia

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.