Package org.wikipediacleaner.api.constants

Examples of org.wikipediacleaner.api.constants.WPCConfiguration


   */
  public void actionLanguage() {
    JPopupMenu menu = new JPopupMenu();

    // Common languages
    WPCConfiguration config = wiki.getConfiguration();
    List<String> commonLanguages = config.getStringList(WPCConfigurationStringList.COMMON_LANGUAGES);
    if ((commonLanguages != null) && (commonLanguages.size() > 0)) {
      for (String commonLanguage : commonLanguages) {
        LanguageRegistry.Language tmpLanguage = registry.getLanguage(commonLanguage);
        if (tmpLanguage != null) {
          JMenuItem item = new JMenuItem(tmpLanguage.toString());
View Full Code Here


   */
  @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
        String warningTemplateName = configuration.getString(WPCConfigurationString.DAB_WARNING_TEMPLATE);
        setText(GT._("Retrieving talk pages including {0}", "{{" + warningTemplateName + "}}"));
        String templateTitle = wikiConfiguration.getPageTitle(
            Namespace.TEMPLATE,
            warningTemplateName);
        Page warningTemplate = DataManager.getPage(
            wikipedia, templateTitle, null, null, null);
        api.retrieveEmbeddedIn(
            wikipedia, warningTemplate,
            configuration.getEncyclopedicTalkNamespaces(),
            false);
        List<Page> warningTalkPages = warningTemplate.getRelatedPages(Page.RelatedPages.EMBEDDED_IN);
 
        // Construct list of articles with warning
        setText(GT._("Constructing list of articles with warning"));
        HashSet<Page> tmpWarningPages = new HashSet<Page>();
        for (Page warningPage : warningTalkPages) {
          String title = warningPage.getTitle();
          String todoSubpage = configuration.getString(WPCConfigurationString.TODO_SUBPAGE);
          if (title.endsWith("/" + todoSubpage)) {
            title = title.substring(0, title.length() - 1 - todoSubpage.length());
          }
          int colonIndex = title.indexOf(':');
          if (colonIndex >= 0) {
            for (Integer namespace : configuration.getEncyclopedicTalkNamespaces()) {
              Namespace namespaceTalk = wikiConfiguration.getNamespace(namespace);
              if ((namespaceTalk != null) &&
                  (namespaceTalk.isPossibleName(title.substring(0, colonIndex)))) {
                String tmpTitle = title.substring(colonIndex + 1);
                if (namespace != Namespace.MAIN_TALK) {
View Full Code Here

      Element element, JTextPane textPane, AbstractButton checkBox) {
    List<String> templates = null;
    List<List<String>> templatesAfter = null;
    int templatesCount = 0;
    if (wiki != null) {
      WPCConfiguration config = wiki.getConfiguration();
      templates = config.getStringList(
          WPCConfigurationStringList.TEMPLATES_FOR_NEEDING_HELP);
      if (templates != null) {
        templatesCount += templates.size();
      }
      templatesAfter = config.getTemplatesAfterAskHelp();
      if (templatesAfter != null) {
        templatesCount += templatesAfter.size();
      }
    }
    if ((text != null) && (page != null) &&
View Full Code Here

    api.retrieveContents(getWikipedia(), Collections.singletonList(page), true, false);
    PageAnalysis analysis = page.getAnalysis(page.getContents(), true);

    // Check that robots are authorized to change this page
    if (saveModifications) {
      WPCConfiguration config = getWikipedia().getConfiguration();
      List<String[]> nobotTemplates = config.getStringArrayList(
          WPCConfigurationStringList.NOBOT_TEMPLATES);
      if ((nobotTemplates != null) && (!nobotTemplates.isEmpty())) {
        for (String[] nobotTemplate : nobotTemplates) {
          String templateName = nobotTemplate[0];
          List<PageElementTemplate> templates = analysis.getTemplates(templateName);
View Full Code Here

   * Action called when Update Disambiguation Warning button is pressed.
   */
  public void actionUpdateDabWarning() {
    EnumWikipedia wiki = window.getWikipedia();
    Configuration config = Configuration.getConfiguration();
    WPCConfiguration wpcConfig = wiki.getConfiguration();
    String template = wpcConfig.getString(WPCConfigurationString.DAB_WARNING_TEMPLATE);
    if ((template == null) || (template.trim().length() == 0)) {
      Utilities.displayMessageForMissingConfiguration(
          window.getParentComponent(),
          WPCConfigurationString.DAB_WARNING_TEMPLATE.getAttributeName());
      return;
View Full Code Here

   * @param simulation True if this is a simulation.
   */
  private void actionISBNWarning(boolean simulation) {
    EnumWikipedia wiki = window.getWikipedia();
    if (!simulation) {
      WPCConfiguration wpcConfig = wiki.getConfiguration();
      String template = wpcConfig.getString(WPCConfigurationString.ISBN_WARNING_TEMPLATE);
      if ((template == null) || (template.trim().length() == 0)) {
        Utilities.displayMessageForMissingConfiguration(
            window.getParentComponent(),
            WPCConfigurationString.ISBN_WARNING_TEMPLATE.getAttributeName());
        return;
View Full Code Here

      WPCConfigurationString templateParam) {
    if ((analysis == null) || (user == null)) {
      return;
    }
    String article = analysis.getPage().getTitle();
    WPCConfiguration wpcConfig = analysis.getWPCConfiguration();

    // Prepare elements
    String message = createMessage(article, msgElements, wpcConfig, templateParam);
    if ((message == null) || (message.trim().length() == 0)) {
      return;
    }
    String globalListTemplate = wpcConfig.getString(WPCConfigurationString.MSG_GLOBAL_LIST_TEMPLATE);
    String globalTemplate = wpcConfig.getString(WPCConfigurationString.MSG_GLOBAL_TEMPLATE);
    String globalTitle = wpcConfig.getString(WPCConfigurationString.MSG_GLOBAL_TITLE);
    String title = wpcConfig.getString(titleParam);
    if (title != null) {
      try {
        title = MessageFormat.format(title, article);
      } catch (IllegalArgumentException e) {
        log.warn("Parameter " + titleParam.getAttributeName() + " has an incorrect format");
View Full Code Here

   * @param isbn ISBN.
   */
  protected void addHelpNeededTemplates(
      PageAnalysis analysis, CheckErrorResult errorResult,
      PageElementISBN isbn) {
    WPCConfiguration config = analysis.getWPCConfiguration();
    List<String[]> helpNeededTemplates = config.getStringArrayList(
        WPCConfigurationStringList.ISBN_HELP_NEEDED_TEMPLATES);
    if ((helpNeededTemplates != null) &&
        (!helpNeededTemplates.isEmpty())) {
      String reason = getReason(isbn);
      for (String[] helpNeededTemplate : helpNeededTemplates) {
View Full Code Here

   * @param isbn ISBN.
   */
  protected void addHelpNeededComment(
      PageAnalysis analysis, CheckErrorResult errorResult,
      PageElementISBN isbn) {
    WPCConfiguration config = analysis.getWPCConfiguration();
    String helpNeededComment = config.getString(
        WPCConfigurationString.ISBN_HELP_NEEDED_COMMENT);
    if (helpNeededComment != null) {
      String reason = getReason(isbn);
      String replacement = isbn.askForHelp(helpNeededComment, reason);
      if (replacement != null) {
View Full Code Here

   * @param search String to search.
   */
  protected void addSearchEngines(
      PageAnalysis analysis, CheckErrorResult errorResult,
      String search) {
    WPCConfiguration config = analysis.getWPCConfiguration();
    List<String[]> searchEngines = config.getStringArrayList(
        WPCConfigurationStringList.ISBN_SEARCH_ENGINES);
    if ((searchEngines != null) &&
        (!searchEngines.isEmpty())) {
      List<Actionnable> actions = new ArrayList<Actionnable>();
      for (String[] searchEngine : searchEngines) {
View Full Code Here

TOP

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

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.