*/
@Override
protected String getAutomaticComment(PageAnalysis analysis) {
// Comment for translation
WPCConfiguration configuration = getConfiguration();
if (translated) {
String text = configuration.getString(WPCConfigurationString.TRANSLATION_COMMENT);
if ((text != null) && (text.trim().length() > 0)) {
return text;
}
return GT._("Translation");
}
contributions = new Contributions(getWikipedia());
contributions.increasePages(1);
// Comment for fixed links to disambiguation pages
List<String> dabLinks = new ArrayList<String>();
StringBuilder comment = new StringBuilder();
if ((mapLinksTotalCount != null) && (mapLinksTotalCount.size() > 0)) {
List<String> fixed = new ArrayList<String>();
List<String> helpRequested = new ArrayList<String>();
for (Entry<String, Integer> p : mapLinksTotalCount.entrySet()) {
if ((p != null) && (p.getKey() != null) && (p.getValue() != null)) {
Integer currentCount = null;
Integer currentHelpCount = null;
Page page = getPage();
if ((page != null) && (page.getLinks() != null)) {
for (Page link : page.getLinks()) {
if (Page.areSameTitle(p.getKey(), link.getTitle())) {
InternalLinkCount count = analysis.getLinkCount(link);
if (count != null) {
currentCount = Integer.valueOf(count.getTotalLinkCount());
currentHelpCount = Integer.valueOf(count.getHelpNeededCount());
}
}
}
}
if ((currentCount == null) || (currentCount < p.getValue().intValue())) {
fixed.add(p.getKey());
} else {
Integer helpCount = mapLinksHelpNeededCount.get(p.getKey());
if ((helpCount != null) &&
((currentHelpCount == null) || (currentHelpCount > helpCount.intValue()))) {
helpRequested.add(p.getKey());
}
}
}
}
// Compute list of disambiguation links that still need to be fixed
List<Page> links = analysis.getPage().getLinks();
if (links != null) {
analysis.countLinks(links);
for (Page link : links) {
if (Boolean.TRUE.equals(link.isDisambiguationPage())) {
InternalLinkCount linkCount = analysis.getLinkCount(link);
if (linkCount != null) {
if ((linkCount.getInternalLinkCount() > 0) ||
(linkCount.getIncorrectTemplateCount() > 0) ||
(linkCount.getHelpNeededCount() > 0)) {
dabLinks.add(link.getTitle());
}
}
}
}
}
// Add comment
boolean showDabLinks = false;
if (fixed.size() > 0) {
Collections.sort(fixed);
contributions.increaseDabLinks(fixed.size());
comment.append(configuration.getDisambiguationComment(
fixed.size(), fixed));
showDabLinks = true;
} else if (helpRequested.size() > 0) {
Collections.sort(helpRequested);
comment.append(configuration.getDisambiguationCommentHelp(
helpRequested.size(), helpRequested));
showDabLinks = true;
}
if (showDabLinks) {
if (dabLinks.size() > 0) {
Collections.sort(dabLinks);
comment.append(configuration.getDisambiguationCommentTodo(
dabLinks.size(), dabLinks));
dabLinks.clear();
}
}
}
// Comment for fixed Check Wiki errors
if ((getInitialErrors() != null) && (getInitialErrors().size() > 0)) {
List<CheckErrorAlgorithm> errorsFixed = computeErrorsFixed();
if ((errorsFixed != null) && (errorsFixed.size() > 0)) {
if (comment.length() > 0) {
comment.append(" / ");
}
comment.append(getWikipedia().getCWConfiguration().getComment(errorsFixed));
for (CheckErrorAlgorithm errorFixed : errorsFixed) {
contributions.increaseCheckWikiError(errorFixed.getErrorNumber(), 1);
}
}
}
// Comments for added categories / templates
boolean isCategoryAdded = false;
if (addedCategories != null) {
for (PageElementCategory category : analysis.getCategories()) {
for (String category2 : addedCategories) {
if (Page.areSameTitle(category.getName(), category2)) {
isCategoryAdded = true;
}
}
}
}
boolean isTemplateAdded = false;
if (addedTemplates != null) {
for (PageElementTemplate template : analysis.getTemplates()) {
for (String template2 : addedTemplates) {
if (Page.areSameTitle(template.getTemplateName(), template2)) {
isTemplateAdded = true;
}
}
}
}
String strCategoryAdded = configuration.getString(WPCConfigurationString.REDIRECT_CATEGORIES_COMMENT);
String strTemplateAdded = configuration.getString(WPCConfigurationString.REDIRECT_TEMPLATES_COMMENT);
if (strTemplateAdded == null) {
strTemplateAdded = strCategoryAdded;
}
if ((isCategoryAdded && (strCategoryAdded != null)) ||
(isTemplateAdded && (strTemplateAdded != null))) {
if (comment.length() > 0) {
comment.append(" / ");
}
if (isCategoryAdded && (strCategoryAdded != null)) {
comment.append(strCategoryAdded);
if (isTemplateAdded && !strCategoryAdded.equals(strTemplateAdded)) {
comment.append(" - ");
comment.append(strCategoryAdded);
}
} else {
comment.append(strTemplateAdded);
}
}
// Comment for disambiguation links
if ((dabLinks.size() > 0) && (comment.length() > 0)) {
String newComment = configuration.getDisambiguationWarningComment(dabLinks);
if ((newComment != null) && (newComment.length() > 0)) {
comment.append(" / ");
Collections.sort(dabLinks);
comment.append(newComment);
dabLinks.clear();