@Override public ComplexIssueInputFieldValue apply(T value) { return ComplexIssueInputFieldValue.with(key, value); } });
@Override public ComplexIssueInputFieldValue apply(T value) { return ComplexIssueInputFieldValue.with(key, value); } });
/** * Allows overwriting the optionKey with the value defined in {@link #optionKeySupplier}. * * @param fieldId the id of the field * @param defaultKey the default option key (e.g. value, name, key, etc.) * @param value The value to set * @return The {@link ComplexIssueInputFieldValue} either with defaultKey or the key defined in jira.properties. * * @see org.opennms.netmgt.ticketer.jira.FieldMapperRegistry#buildLookupMap(Properties) */ public ComplexIssueInputFieldValue createComplexIssueInputField(String fieldId, String defaultKey, Object value) { Objects.requireNonNull(defaultKey); return ComplexIssueInputFieldValue.with(getOptionKey(fieldId, defaultKey), value); }
/** * Allows overwriting the optionKey with the value defined in {@link #optionKeySupplier}. * * @param fieldId the id of the field * @param defaultKey the default option key (e.g. value, name, key, etc.) * @param value The value to set * @return The {@link ComplexIssueInputFieldValue} either with defaultKey or the key defined in jira.properties. * * @see org.opennms.netmgt.ticketer.jira.FieldMapperRegistry#buildLookupMap(Properties) */ public ComplexIssueInputFieldValue createComplexIssueInputField(String fieldId, String defaultKey, Object value) { Objects.requireNonNull(defaultKey); return ComplexIssueInputFieldValue.with(getOptionKey(fieldId, defaultKey), value); }
public IssueInputBuilder setIssueTypeId(Long issueTypeId) { return setFieldInput(new FieldInput( IssueFieldId.ISSUE_TYPE_FIELD, ComplexIssueInputFieldValue.with("id", issueTypeId.toString()) )); }
public IssueInputBuilder setIssueTypeId(Long issueTypeId) { return setFieldInput(new FieldInput( IssueFieldId.ISSUE_TYPE_FIELD, ComplexIssueInputFieldValue.with("id", issueTypeId.toString()) )); }
public IssueInputBuilder setPriorityId(Long id) { return setFieldInput(new FieldInput(IssueFieldId.PRIORITY_FIELD, ComplexIssueInputFieldValue.with("id", id.toString()))); }
public IssueInputBuilder setPriorityId(Long id) { return setFieldInput(new FieldInput(IssueFieldId.PRIORITY_FIELD, ComplexIssueInputFieldValue.with("id", id.toString()))); }
@Override public Object mapToFieldValue(String fieldId, FieldSchema schema, String attributeValue) { if (!Strings.isNullOrEmpty(attributeValue)) { final String[] split = attributeValue.split(","); // split by "," if (split != null && split.length >= 1) { // we have at least one value final String optionKey = getOptionKey(fieldId, "value"); final Map<String, Object> parentValueMap = new HashMap<>(); parentValueMap.put(optionKey, split[0]); // set first value final ComplexIssueInputFieldValue parentValue = new ComplexIssueInputFieldValue(parentValueMap); if (split.length >= 2) { // if we have a 2nd value, set it as child of value 1 parentValue.getValuesMap().put("child", ComplexIssueInputFieldValue.with(optionKey, split[1])); } return parentValue; } } return null; } }
@Override public Object mapToFieldValue(String fieldId, FieldSchema schema, String attributeValue) { if (!Strings.isNullOrEmpty(attributeValue)) { final String[] split = attributeValue.split(","); // split by "," if (split != null && split.length >= 1) { // we have at least one value final String optionKey = getOptionKey(fieldId, "value"); final Map<String, Object> parentValueMap = new HashMap<>(); parentValueMap.put(optionKey, split[0]); // set first value final ComplexIssueInputFieldValue parentValue = new ComplexIssueInputFieldValue(parentValueMap); if (split.length >= 2) { // if we have a 2nd value, set it as child of value 1 parentValue.getValuesMap().put("child", ComplexIssueInputFieldValue.with(optionKey, split[1])); } return parentValue; } } return null; } }
public IssueInputBuilder setAssigneeName(String assignee) { return setFieldInput(new FieldInput(IssueFieldId.ASSIGNEE_FIELD, ComplexIssueInputFieldValue.with("name", assignee))); }
public IssueInputBuilder setProjectKey(String projectKey) { return setFieldInput(new FieldInput(IssueFieldId.PROJECT_FIELD, ComplexIssueInputFieldValue.with("key", projectKey))); }
public IssueInputBuilder setReporterName(String reporterName) { return setFieldInput(new FieldInput(IssueFieldId.REPORTER_FIELD, ComplexIssueInputFieldValue.with("name", reporterName))); }
public IssueInputBuilder setProjectKey(String projectKey) { return setFieldInput(new FieldInput(IssueFieldId.PROJECT_FIELD, ComplexIssueInputFieldValue.with("key", projectKey))); }
public IssueInputBuilder setReporterName(String reporterName) { return setFieldInput(new FieldInput(IssueFieldId.REPORTER_FIELD, ComplexIssueInputFieldValue.with("name", reporterName))); }
public IssueInputBuilder setAssigneeName(String assignee) { return setFieldInput(new FieldInput(IssueFieldId.ASSIGNEE_FIELD, ComplexIssueInputFieldValue.with("name", assignee))); }
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(); }
private void updateStreamStatus(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, Map<String, Version> versionsMap, IssueInputBuilder inputBuilder) throws NotFoundException { String customField = JSON_CUSTOM_FIELD + TARGET_RELEASE; IssueField issueField = jiraIssue.getField(customField); if (issueField == null || (issueField.getType() == null && issueField.getValue() == null)) { String msg = String.format("Unable to set a stream status for issue %1$s as %2$s projects do not utilise field: %3$s", jiraIssue.getKey(), jiraIssue.getProject().getName(), customField); Utils.logWarnMessage(LOG, msg); return; } for (Map.Entry<String, FlagStatus> entry : issue.getStreamStatus().entrySet()) { if (entry.getValue() != FlagStatus.ACCEPTED) { String streamName = entry.getKey(); Version version = versionsMap.get(streamName); if (version != null) { inputBuilder.setFieldInput(new FieldInput(customField, ComplexIssueInputFieldValue.with("value", version.getId()))); } else { throw new NotFoundException("No Stream exists for this project with the name : " + streamName); } } } }