<commit_before>/*
 * Copyright 2012 MeetMe, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.meetme.plugins.jira.gerrit.webpanel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.plugin.PluginParseException;
import com.meetme.plugins.jira.gerrit.data.IssueReviewsManager;
import com.meetme.plugins.jira.gerrit.data.dto.GerritChange;
import com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritQueryException;

@SuppressWarnings("unchecked")
public class GerritReviewsIssueAgilePanel extends AbstractJiraContextProvider {
	private static final String KEY_ISSUE = "issue";
	private static final String KEY_CHANGES = "changes";
	private static final String KEY_ERROR = "error";

	private IssueReviewsManager reviewsManager;

	public GerritReviewsIssueAgilePanel(IssueReviewsManager reviewsManager) {
		super();
		this.reviewsManager = reviewsManager;
	}

	@Override
	public Map<String, Object> getContextMap(User user, JiraHelper jiraHelper) {
		HashMap<String, Object> contextMap = new HashMap<String, Object>();

		Issue currentIssue = (Issue) jiraHelper.getContextParams().get(KEY_ISSUE);

		try {
			List<GerritChange> changes = reviewsManager.getReviewsForIssue(currentIssue.getKey());
			contextMap.put(KEY_CHANGES, changes);
			contextMap.put("atl.gh.issue.details.tab.count",Long.valueOf(changes.size()));
		} catch (GerritQueryException e) {
			contextMap.put(KEY_ERROR, e.getMessage());
		}

		return contextMap;
	}

}<commit_msg>Fix code formatting in GerritReviewsIssueAgilePanel<commit_after>/*
 * Copyright 2012 MeetMe, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.meetme.plugins.jira.gerrit.webpanel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.meetme.plugins.jira.gerrit.data.IssueReviewsManager;
import com.meetme.plugins.jira.gerrit.data.dto.GerritChange;
import com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritQueryException;

@SuppressWarnings("unchecked")
public class GerritReviewsIssueAgilePanel extends AbstractJiraContextProvider {
	private static final String KEY_ISSUE = "issue";
	private static final String KEY_CHANGES = "changes";
	private static final String KEY_ERROR = "error";

	private IssueReviewsManager reviewsManager;

	public GerritReviewsIssueAgilePanel(IssueReviewsManager reviewsManager) {
		super();
		this.reviewsManager = reviewsManager;
	}

	@Override
	public Map<String, Object> getContextMap(User user, JiraHelper jiraHelper) {
		HashMap<String, Object> contextMap = new HashMap<String, Object>();

		Issue currentIssue = (Issue) jiraHelper.getContextParams().get(KEY_ISSUE);

		try {
			List<GerritChange> changes = reviewsManager.getReviewsForIssue(currentIssue.getKey());
			contextMap.put(KEY_CHANGES, changes);
			contextMap.put("atl.gh.issue.details.tab.count", Long.valueOf(changes.size()));
		} catch (GerritQueryException e) {
			contextMap.put(KEY_ERROR, e.getMessage());
		}

		return contextMap;
	}

}
{'fraction_non_alphanumeric': 0.09596072305288998, 'fraction_numerical': 0.0035706315554563713, 'mean_word_length': 5.505079825834543, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4445856', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1320, 'n_words': 347}