001/* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2013 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * SonarQube is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.wsclient.issue; 021 022import org.sonar.wsclient.internal.EncodingUtils; 023 024import java.util.Date; 025import java.util.HashMap; 026import java.util.Map; 027 028/** 029 * @since 3.6 030 */ 031public class IssueQuery { 032 033 private final Map<String, Object> params = new HashMap<String, Object>(); 034 035 private IssueQuery() { 036 } 037 038 public static IssueQuery create() { 039 return new IssueQuery(); 040 } 041 042 /** 043 * URL query string, for internal use 044 */ 045 public Map<String, Object> urlParams() { 046 return params; 047 } 048 049 public IssueQuery issues(String... keys) { 050 return addParam("issues", keys); 051 } 052 053 public IssueQuery severities(String... severities) { 054 return addParam("severities", severities); 055 } 056 057 public IssueQuery statuses(String... statuses) { 058 return addParam("statuses", statuses); 059 } 060 061 public IssueQuery resolutions(String... resolutions) { 062 return addParam("resolutions", resolutions); 063 } 064 065 public IssueQuery components(String... components) { 066 return addParam("components", components); 067 } 068 069 public IssueQuery componentRoots(String... componentRoots) { 070 return addParam("componentRoots", componentRoots); 071 } 072 073 public IssueQuery rules(String... s) { 074 return addParam("rules", s); 075 } 076 077 public IssueQuery actionPlans(String... s) { 078 return addParam("actionPlans", s); 079 } 080 081 public IssueQuery reporters(String... s) { 082 return addParam("reporters", s); 083 } 084 085 public IssueQuery assignees(String... s) { 086 return addParam("assignees", s); 087 } 088 089 public IssueQuery assigned(Boolean assigned) { 090 params.put("assigned", assigned); 091 return this; 092 } 093 094 public IssueQuery planned(Boolean planned) { 095 params.put("planned", planned); 096 return this; 097 } 098 099 public IssueQuery resolved(Boolean resolved) { 100 params.put("resolved", resolved); 101 return this; 102 } 103 104 public IssueQuery createdAfter(Date d) { 105 params.put("createdAfter", EncodingUtils.toQueryParam(d, true)); 106 return this; 107 } 108 109 public IssueQuery createdBefore(Date d) { 110 params.put("createdBefore", EncodingUtils.toQueryParam(d, true)); 111 return this; 112 } 113 114 public IssueQuery sort(String sort) { 115 params.put("sort", sort); 116 return this; 117 } 118 119 public IssueQuery asc(boolean asc) { 120 params.put("asc", asc); 121 return this; 122 } 123 124 public IssueQuery pageSize(int pageSize) { 125 params.put("pageSize", pageSize); 126 return this; 127 } 128 129 public IssueQuery pageIndex(int pageIndex) { 130 params.put("pageIndex", pageIndex); 131 return this; 132 } 133 134 private IssueQuery addParam(String key, String[] values) { 135 if (values != null) { 136 params.put(key, EncodingUtils.toQueryParam(values)); 137 } 138 return this; 139 } 140 141}