@Override public CimIssueType parse(final JSONObject json) throws JSONException { final IssueType issueType = issueTypeJsonParser.parse(json); final JSONObject jsonFieldsMap = json.optJSONObject("fields"); final Map<String, CimFieldInfo> fields = (jsonFieldsMap == null) ? Collections.<String, CimFieldInfo>emptyMap() : fieldsParser.parse(jsonFieldsMap); return new CimIssueType(issueType.getSelf(), issueType.getId(), issueType.getName(), issueType.isSubtask(), issueType.getDescription(), issueType.getIconUri(), fields); } }
@Override public boolean equals(Object obj) { if (obj instanceof CimIssueType) { CimIssueType that = (CimIssueType) obj; return super.equals(obj) && Objects.equal(this.fields, that.fields); } return false; }
private static final String JIRA_SERVER = "http://jiralab"; public static void main(String[] args) { try { JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory(); URI uri = new URI(JIRA_SERVER); JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, "admin", "admin"); listAllIssueTypes(client); } catch (Exception ex) { } } private static void listAllIssueTypes(JiraRestClient client) throws Exception { Promise<Iterable<IssueType>> promise = client.getMetadataClient().getIssueTypes(); Iterable<IssueType> issueTypes = promise.claim(); for (IssueType it : issueTypes) { System.out.println("Type ID = " + it.getId() + ", Name = " + it.getName()); } }
@Override protected void doExecute(JiraRestClient jiraRestClient) throws Exception { final String theProjectKey = Strings.isNullOrEmpty(projectKey) ? getConfig().getProjectKey() : projectKey; final Iterable<? extends IssueType> issueTypes = JiraClientUtils.getIssueTypes(jiraRestClient, theProjectKey); if (!issueTypes.iterator().hasNext()) { if (Strings.isNullOrEmpty(theProjectKey)) { System.out.println("No issue types found. The user making the ReST call may not have sufficient permissions."); } else { System.out.println("No issue types found for project with key '" + theProjectKey + "' found. The user making the ReST call may not have sufficient permissions."); } } else { System.out.println(String.format(DEFAULT_ROW_FORMAT, "Id", "Name", "Description")); Lists.newArrayList(issueTypes).stream() .sorted(Comparator.comparing(IssueType::getId)) .forEach(issueType -> System.out.println(String.format(DEFAULT_ROW_FORMAT, issueType.getId(), issueType.getName(), removeNewLines(issueType.getDescription())))); } }
public IssueInputBuilder setIssueType(IssueType issueType) { return setIssueTypeId(issueType.getId()); }
private void setIssueType(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { String type = jiraIssue.getIssueType().getName(); issue.setType(getIssueType(type)); }
@Override public IssueType parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final boolean isSubtask = json.getBoolean("subtask"); final String iconUrl = JsonParseUtil.getOptionalString(json, "iconUrl"); final URI iconUri = iconUrl == null ? null : JsonParseUtil.parseURI(iconUrl); final String description = JsonParseUtil.getOptionalString(json, "description"); return new IssueType(selfUri, id, name, isSubtask, description, iconUri); } }
@Override protected void doExecute(JiraRestClient jiraRestClient) throws Exception { final String theProjectKey = Strings.isNullOrEmpty(projectKey) ? getConfig().getProjectKey() : projectKey; final Iterable<? extends IssueType> issueTypes = JiraClientUtils.getIssueTypes(jiraRestClient, theProjectKey); if (!issueTypes.iterator().hasNext()) { if (Strings.isNullOrEmpty(theProjectKey)) { System.out.println("No issue types found. The user making the ReST call may not have sufficient permissions."); } else { System.out.println("No issue types found for project with key '" + theProjectKey + "' found. The user making the ReST call may not have sufficient permissions."); } } else { System.out.println(String.format(DEFAULT_ROW_FORMAT, "Id", "Name", "Description")); Lists.newArrayList(issueTypes).stream() .sorted(Comparator.comparing(IssueType::getId)) .forEach(issueType -> System.out.println(String.format(DEFAULT_ROW_FORMAT, issueType.getId(), issueType.getName(), removeNewLines(issueType.getDescription())))); } }
public ListBoxModel doFillTypeIdItems() { ListBoxModel items = new ListBoxModel().add(""); // optional field for (JiraSite site : JiraProjectProperty.DESCRIPTOR.getSites()) { JiraSession session = site.getSession(); if (session != null) { for (IssueType type : session.getIssueTypes()) { items.add("[" + site.getName() + "] " + type.getName(), String.valueOf(type.getId())); } } } return items; }
public IssueInputBuilder setIssueType(IssueType issueType) { return setIssueTypeId(issueType.getId()); }
String summary = issue.getSummary(); String status = issue.getStatus().getName(); String type = issue.getIssueType().getName();
@Override public IssueType parse(JSONObject json) throws JSONException { final URI selfUri = JsonParseUtil.getSelfUri(json); final long id = json.getLong("id"); final String name = json.getString("name"); final boolean isSubtask = json.getBoolean("subtask"); final String iconUrl = JsonParseUtil.getOptionalString(json, "iconUrl"); final URI iconUri = iconUrl == null ? null : JsonParseUtil.parseURI(iconUrl); final String description = JsonParseUtil.getOptionalString(json, "description"); return new IssueType(selfUri, id, name, isSubtask, description, iconUri); } }
@Override public CimIssueType parse(final JSONObject json) throws JSONException { final IssueType issueType = issueTypeJsonParser.parse(json); final JSONObject jsonFieldsMap = json.optJSONObject("fields"); final Map<String, CimFieldInfo> fields = (jsonFieldsMap == null) ? Collections.<String, CimFieldInfo>emptyMap() : fieldsParser.parse(jsonFieldsMap); return new CimIssueType(issueType.getSelf(), issueType.getId(), issueType.getName(), issueType.isSubtask(), issueType.getDescription(), issueType.getIconUri(), fields); } }
IssueInput issueToFluentUpdate(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, Project project) throws NotFoundException { checkUnsupportedUpdateFields(issue); IssueInputBuilder inputBuilder = new IssueInputBuilder(jiraIssue.getProject().getKey(), jiraIssue.getIssueType().getId()); issue.getSummary().ifPresent(inputBuilder::setSummary); inputBuilder.setFieldInput(new FieldInput(IssueFieldId.COMPONENTS_FIELD, issue.getComponents().stream().map(e -> ComplexIssueInputFieldValue.with("name", e)).collect(Collectors.toList())) ); issue.getDescription().ifPresent(inputBuilder::setDescription); issue.getAssignee().ifPresent(assignee -> inputBuilder.setFieldInput( new FieldInput(IssueFieldId.ASSIGNEE_FIELD, ComplexIssueInputFieldValue.with("name", assignee.getName().orElseThrow(this::nullUsername))))); // this is ok but does nothing if there is no permissions. issue.getStage().getStateMap().entrySet() .stream().filter(entry -> entry.getValue() != FlagStatus.NO_SET) .forEach(entry -> inputBuilder.setFieldInput(new FieldInput(JSON_CUSTOM_FIELD + FLAG_MAP.get(entry.getKey()), entry.getValue().getSymbol()))); Map<String, Version> versionsMap = StreamSupport.stream(project.getVersions().spliterator(), false) .collect(Collectors.toMap(Version::getName, Function.identity())); updateFixVersions(issue, versionsMap, inputBuilder); updateStreamStatus(issue, jiraIssue, versionsMap, inputBuilder); return inputBuilder.build(); }
issue.setPriority(fromMap(jiraIssue.getPriority().getName(), priorityMapping)); issue.setSeverity(fromMap(jiraIssue.getPriority().getName(), severityMapping)); issue.setType(fromMap(jiraIssue.getIssueType().getName(), typeMapping));
@Override public boolean equals(Object obj) { if (obj instanceof CimIssueType) { CimIssueType that = (CimIssueType) obj; return super.equals(obj) && Objects.equal(this.fields, that.fields); } return false; }