public ProjectBean(BasicProject project){ this.name = project.getName(); this.key = project.getKey(); }
public IssueInputBuilder setProject(BasicProject project) { return setProjectKey(project.getKey()); }
public IssueInputBuilder setProject(BasicProject project) { return setProjectKey(project.getKey()); }
public List<String> getProjectsKeys() { Iterable<BasicProject> projects = Collections.emptyList(); try { projects = jiraRestClient.getProjectClient().getAllProjects().get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get project keys error. cause: " + e.getMessage(), e); } final List<String> keys = new ArrayList<>(); for (BasicProject project : projects) { keys.add(project.getKey()); } return keys; }
@Override protected void doExecute(JiraRestClient jiraRestClient) throws Exception { Iterable<BasicProject> basicProjects = jiraRestClient.getProjectClient().getAllProjects().get(); if (!basicProjects.iterator().hasNext()) { System.out.println("No projects available or visible to the current user"); } else { System.out.println(String.format(DEFAULT_ROW_FORMAT, "Key", "Name", "Description")); for (BasicProject eachProject : basicProjects) { String description = jiraRestClient.getProjectClient().getProject(eachProject.getKey()).get().getDescription(); System.out.println( String.format(DEFAULT_ROW_FORMAT, eachProject.getKey(), eachProject.getName(), description == null ? "" : removeNewLines(description))); } } } }
@Override protected void doExecute(JiraRestClient jiraRestClient) throws Exception { Iterable<BasicProject> basicProjects = jiraRestClient.getProjectClient().getAllProjects().get(); if (!basicProjects.iterator().hasNext()) { System.out.println("No projects available or visible to the current user"); } else { System.out.println(String.format(DEFAULT_ROW_FORMAT, "Key", "Name", "Description")); for (BasicProject eachProject : basicProjects) { String description = jiraRestClient.getProjectClient().getProject(eachProject.getKey()).get().getDescription(); System.out.println( String.format(DEFAULT_ROW_FORMAT, eachProject.getKey(), eachProject.getName(), description == null ? "" : removeNewLines(description))); } } } }
private Set<Project> getProjects(JiraRestClient client) { Set<Project> projects = new HashSet<>(); ProjectRestClient projectClient = client.getProjectClient(); for (BasicProject project : projectClient.getAllProjects().claim()) { projects.add(projectClient.getProject(project.getKey()).claim()); } return projects; }
public Object apply(Object rawValue) { if (rawValue == null) { return null; } else if (rawValue instanceof String || rawValue instanceof Number || rawValue instanceof ComplexIssueInputFieldValue) { return rawValue; } else if (rawValue instanceof BasicProject) { return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("key", ((BasicProject) rawValue).getKey())); } else if (rawValue instanceof CustomFieldOption) { return transformCustomFieldOption((CustomFieldOption) rawValue); } else if (rawValue instanceof TimeTracking) { return transformTimeTracking((TimeTracking) rawValue); } else if (rawValue instanceof IdentifiableEntity) { final IdentifiableEntity identifiableEntity = (IdentifiableEntity) rawValue; return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("id", identifiableEntity.getId().toString())); } else if (rawValue instanceof NamedEntity) { final NamedEntity namedEntity = (NamedEntity) rawValue; return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("name", namedEntity.getName())); } return CANNOT_HANDLE; }
public Object apply(Object rawValue) { if (rawValue == null) { return null; } else if (rawValue instanceof String || rawValue instanceof Number || rawValue instanceof ComplexIssueInputFieldValue) { return rawValue; } else if (rawValue instanceof BasicProject) { return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("key", ((BasicProject) rawValue).getKey())); } else if (rawValue instanceof CustomFieldOption) { return transformCustomFieldOption((CustomFieldOption) rawValue); } else if (rawValue instanceof TimeTracking) { return transformTimeTracking((TimeTracking) rawValue); } else if (rawValue instanceof IdentifiableEntity) { final IdentifiableEntity identifiableEntity = (IdentifiableEntity) rawValue; return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("id", identifiableEntity.getId().toString())); } else if (rawValue instanceof NamedEntity) { final NamedEntity namedEntity = (NamedEntity) rawValue; return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of("name", namedEntity.getName())); } return CANNOT_HANDLE; }
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(); }
@Override public CimProject parse(final JSONObject json) throws JSONException { final BasicProject basicProject = basicProjectJsonParser.parse(json); final JSONArray issueTypesArray = json.optJSONArray("issuetypes"); final Iterable<CimIssueType> issueTypes = (issueTypesArray != null) ? issueTypesParser.parse(issueTypesArray) : Collections.<CimIssueType>emptyList(); final Map<String, URI> avatarUris = JsonParseUtil.getAvatarUris(json.getJSONObject("avatarUrls")); return new CimProject(basicProject.getSelf(), basicProject.getKey(), basicProject.getId(), basicProject.getName(), avatarUris, issueTypes); } }
@Override public CimProject parse(final JSONObject json) throws JSONException { final BasicProject basicProject = basicProjectJsonParser.parse(json); final JSONArray issueTypesArray = json.optJSONArray("issuetypes"); final Iterable<CimIssueType> issueTypes = (issueTypesArray != null) ? issueTypesParser.parse(issueTypesArray) : Collections.<CimIssueType>emptyList(); final Map<String, URI> avatarUris = JsonParseUtil.getAvatarUris(json.getJSONObject("avatarUrls")); return new CimProject(basicProject.getSelf(), basicProject.getKey(), basicProject.getId(), basicProject.getName(), avatarUris, issueTypes); } }
issue.setProjectId(jiraIssue.getProject().getKey()); issue.setCreationDate(jiraIssue.getCreationDate()); issue.setDescription(jiraIssue.getDescription());