Package org.wikipediacleaner.api.constants

Examples of org.wikipediacleaner.api.constants.EnumWikipedia


    if (analysis == null) {
      return false;
    }

    boolean result = false;
    EnumWikipedia wiki = analysis.getWikipedia();
    MagicWord magicWordImgAlt = wiki.getWikiConfiguration().getMagicWordByName(MagicWord.IMG_ALT);
    for (PageElementImage image : analysis.getImages()) {
      String description = image.getDescription();
      if ((description == null) || (description.trim().length() == 0)) {
        String alt = image.getAlternateDescription();
        if ((alt == null) || (alt.trim().length() == 0)) {
View Full Code Here


    // Check all internal links
    Object highlight = null;
    String contents = analysis.getContents();
    try {
      EnumWikipedia toWiki = analysis.getWikipedia();
      for (PageElementInterwikiLink link : analysis.getInterwikiLinks()) {
        if (isLanguageLink(link, toWiki)) {
          String lgCode = link.getInterwiki().getPrefix();
          EnumWikipedia fromWiki = EnumWikipedia.getWikipedia(lgCode);
          if ((fromWiki != null) && (fromWiki.getSettings().getCode().equals(lgCode))) {
            String pageTitle = link.getLink();
            int beginIndex = link.getBeginIndex();
            int endIndex = link.getEndIndex();
            String replacement = null;
View Full Code Here

      Collection<CheckErrorAlgorithm> algorithms, boolean botFix,
      List<CheckErrorAlgorithm> usedAlgorithms) {
    if ((page == null) || (contents == null)) {
      return contents;
    }
    EnumWikipedia wiki = page.getWikipedia();
    WPCConfiguration config = wiki.getConfiguration();

    // Fix Check Wiki errors
    if (algorithms != null) {
      for (CheckErrorAlgorithm algorithm : algorithms) {
        if (algorithm.isAvailable() &&
View Full Code Here

  /**
   * @param pageName Page name.
   */
  protected void setPageName(String pageName) {
    EnumWikipedia wikipedia = getWikipedia();
    if (wikipedia != null) {
      this.pageName = wikipedia.normalizeTitle(pageName);
    } else {
      this.pageName = pageName;
    }
  }
View Full Code Here

    // Retrieve possible templates to replace the link to other language
    List<String> templatesList = getTemplatesList();

    // Analyzing the text from the beginning
    boolean result = false;
    EnumWikipedia toWiki = analysis.getWikipedia();
    for (PageElementInterwikiLink link : analysis.getInterwikiLinks()) {
      if (isLanguageLink(link, toWiki)) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, link.getBeginIndex(), link.getEndIndex());
        String lgCode = link.getInterwiki().getPrefix();
        EnumWikipedia fromWiki = EnumWikipedia.getWikipedia(lgCode);
        if ((fromWiki != null) && (fromWiki.getSettings().getCode().equals(lgCode))) {
          String pageTitle = link.getLink();
          errorResult.addPossibleAction(
              GT._("Check language links"),
              new CheckLanguageLinkActionProvider(
                  fromWiki, toWiki,
View Full Code Here

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

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

    Stats stats = new Stats();
    try {
      if (!useList) {
        // Retrieve talk pages including a warning
View Full Code Here

    if (link == null) {
      return null;
    }

    // Initialization
    EnumWikipedia otherWikipedia = EnumWikipedia.getWikipedia(link.getLanguage());
    Page otherPage = null;
    if (otherWikipedia != null) {
      otherPage = DataManager.getPage(otherWikipedia, link.getLink(), null, null, null);
    }
View Full Code Here

  @Override
  public Object construct() {
    try {
      setText(GT._("Retrieving MediaWiki API"));
      API api = APIFactory.getAPI();
      EnumWikipedia wiki = getWikipedia();

      // Login
      if (!reloadOnly) {
        setText(GT._("Login"));
        LoginResult result = api.login(wiki, username, new String(password), login);
        if (login) {
          if ((result == null) || (!result.isLoginSuccessful())) {
            throw new APIException("Login unsuccessful: " + ((result != null) ? result.toString() : ""));
          }
        }
        User user = api.retrieveUser(wiki, username);
        username = (user != null) ? user.getName() : null;
        wiki.getConnection().setUser(user);
        api.retrieveTokens(wiki);
        logged = true;
      }

      // Load configuration
      setText(GT._("Loading configuration"));
      api.loadConfiguration(wiki, username);

      // Saving settings
      Configuration configuration = Configuration.getConfiguration();
      configuration.setWikipedia(wiki);
      configuration.setLanguage(language);
      if (login && !reloadOnly && (saveUser != ConfigurationConstants.VALUE_SAVE_USER_NO_CHANGE)) {
        Properties props = configuration.getProperties(wiki, Configuration.PROPERTIES_USERS);
        if (saveUser == ConfigurationConstants.VALUE_SAVE_USER_NONE) {
          props.remove(username);
          configuration.setString(wiki, ConfigurationValueString.LAST_USER, (String) null);
        } else {
          props.setProperty(
              username,
              (saveUser == ConfigurationConstants.VALUE_SAVE_USER_BOTH) ? new String(password) : "");
          configuration.setString(wiki, ConfigurationValueString.LAST_USER, username);
        }
        configuration.setProperties(wiki, Configuration.PROPERTIES_USERS, props);
        configuration.setInt(
            null,
            ConfigurationValueInteger.SAVE_USER,
            saveUser);
      }
      Configuration.getConfiguration().save();

      // Retrieving disambiguation templates
      setText(GT._("Retrieving disambiguation templates"));
      wiki.initDisambiguationTemplates(api);

      // Retrieving suggestions for text replacements
      setText(GT._("Retrieving suggestions for text replacements"));
      wiki.getConfiguration().initSuggestions(api, reloadOnly);

      // Retrieving Check Wiki configuration
      setText(GT._("Retrieving Check Wiki configuration"));
      APIFactory.getCheckWiki().retrieveConfiguration(wiki, this);
    } catch (APIException e) {
View Full Code Here

  /**
   * @return Wiki settings.
   */
  public AbstractWikiSettings getSettings() {
    EnumWikipedia wikipedia = getWikipedia();
    if (wikipedia != null) {
      return wikipedia.getSettings();
    }
    return null;
  }
View Full Code Here

  /**
   * @return Wiki configuration.
   */
  public WikiConfiguration getWikiConfiguration() {
    EnumWikipedia wikipedia = getWikipedia();
    if (wikipedia != null) {
      return wikipedia.getWikiConfiguration();
    }
    return null;
  }
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.