| /******************************************************************************* |
| * Copyright (c) 2013 Ericsson |
| * |
| * All rights reserved. This program and the accompanying materials are |
| * made available under the terms of the Eclipse Public License v1.0 which |
| * accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Description: |
| * This class implements the implementation of the review table view information. |
| * |
| * Contributors: |
| * Jacques Bouthillier - Initial Implementation of the table view information |
| ******************************************************************************/ |
| package org.eclipse.mylyn.reviews.r4e_gerrit.ui.internal.model; |
| |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import org.eclipse.mylyn.reviews.r4e_gerrit.core.R4EGerritTask; |
| import org.eclipse.mylyn.tasks.core.TaskRepository; |
| |
| /** |
| * @author Jacques Bouthillier |
| * @version $Revision: 1.0 $ |
| */ |
| public class ReviewTableData { |
| |
| // ------------------------------------------------------------------------ |
| // Member variables |
| // ------------------------------------------------------------------------ |
| |
| // The list of reviews indexed by the SHORT_CHANGE_ID |
| private Map<String, R4EGerritTask> fReviewList; |
| |
| private TaskRepository fTaskRepo = null; |
| |
| private String fQuery = null; |
| |
| /** |
| * Create a new review entry to insert to the list of reviews |
| * |
| * @param Object |
| */ |
| @SuppressWarnings("restriction") |
| public void createReviewItem(R4EGerritTask[] aList, String aQuery, |
| TaskRepository aTaskRepo) { |
| |
| // Create the new object |
| // if (fQuery != aQuery) { |
| fReviewList = new HashMap<String, R4EGerritTask>(); |
| for (R4EGerritTask review : aList) { |
| fReviewList.put( |
| review.getAttribute(R4EGerritTask.SHORT_CHANGE_ID), |
| review); |
| } |
| fTaskRepo = aTaskRepo; |
| fQuery = aQuery; |
| |
| // } else { |
| // //Need to reset the list, we just created a null entry |
| // reset(); |
| // } |
| } |
| |
| /** |
| * Provide the list of review available for the table list |
| * |
| * @return the list of gerrit reviews |
| */ |
| public R4EGerritTask[] getReviews() { |
| if (fReviewList == null) { |
| fReviewList = new HashMap<String, R4EGerritTask>(); |
| } |
| return fReviewList.values().toArray(new R4EGerritTask[0]); |
| } |
| |
| /** |
| * Provide the review with the specified ID |
| * |
| * @param id |
| * the requested ID (SHORT_CHANGE_ID) |
| * @return the requested review (or null) |
| */ |
| public R4EGerritTask getReview(String id) { |
| if (id != null && fReviewList.containsKey(id)) { |
| return fReviewList.get(id); |
| } |
| return null; |
| } |
| |
| /** |
| * Get the current TaskRepo populating the table list view |
| * |
| * @return TaskRepository |
| */ |
| public TaskRepository getCurrentTaskRepo() { |
| return fTaskRepo; |
| } |
| |
| /** |
| * Return the query information used to populate the review table |
| * |
| * @return String |
| */ |
| public String getQueryInfo() { |
| return fQuery; |
| } |
| |
| // private void reset() { |
| // if (fReviewList != null) { |
| // fReviewList = new HashMap<String, R4EGerritReviewData>(); |
| // } |
| // } |
| |
| } |