-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #10 Add an ability to choose and apply the resulting estimate. (#11) - #12 Add an ability to choose an estimation scale. Add support for the two new scales: "Classic", "T-shirt size". - #13 Add an ability to terminate the estimation session. - #14 Add support for the "Linear" estimation scale. - Improve user experience by showing "estimation scale" when user click Re-Estimate; - Replace "aui-select" with simple dropdown select. - Update README
- Loading branch information
Showing
39 changed files
with
1,352 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2021 Andriy Preizner | ||
* | ||
* This file is a part of Open Poker jira plugin | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.aprey.jira.plugin.openpoker; | ||
|
||
import java.util.List; | ||
|
||
public interface Deck { | ||
|
||
List<EstimationGrade> getGrades(); | ||
|
||
EstimationGrade getGrade(int gradeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,6 @@ public interface EstimationGrade { | |
int getId(); | ||
|
||
String getValue(); | ||
|
||
boolean isApplicable(); | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/aprey/jira/plugin/openpoker/EstimationScale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2021 Andriy Preizner | ||
* | ||
* This file is a part of Open Poker jira plugin | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.aprey.jira.plugin.openpoker; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum EstimationScale { | ||
CLASSIC_PLANNING("Planning Cards", EstimationUnit.CLASSIC_PLANNING), | ||
FIBONACCI("Fibonacci", EstimationUnit.FIBONACCI), | ||
LINEAR("Linear", EstimationUnit.LINEAR), | ||
T_SHIRT_SIZE("T-shirt size", EstimationUnit.T_SHIRT_SIZE); | ||
|
||
private final String name; | ||
private EstimationUnit estimationUnit; | ||
|
||
EstimationScale(String name, EstimationUnit estimationUnit) { | ||
this.name = name; | ||
this.estimationUnit = estimationUnit; | ||
} | ||
|
||
public static Optional<EstimationUnit> findByName(String name) { | ||
return Arrays.stream(values()) | ||
.filter(e -> e.name.equals(name)) | ||
.map(EstimationScale::getEstimationUnit) | ||
.findFirst(); | ||
} | ||
|
||
public static Optional<EstimationScale> findByUnit(EstimationUnit unit) { | ||
return Arrays.stream(values()) | ||
.filter(e -> e.estimationUnit.equals(unit)) | ||
.findFirst(); | ||
} | ||
|
||
public static List<EstimationScale> getValues() { | ||
return Arrays.stream(values()).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/main/java/com/aprey/jira/plugin/openpoker/IssueServiceFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (C) 2021 Andriy Preizner | ||
* | ||
* This file is a part of Open Poker jira plugin | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.aprey.jira.plugin.openpoker; | ||
|
||
import com.atlassian.jira.bc.issue.IssueService; | ||
import com.atlassian.jira.issue.CustomFieldManager; | ||
import com.atlassian.jira.issue.Issue; | ||
import com.atlassian.jira.issue.IssueInputParameters; | ||
import com.atlassian.jira.issue.IssueManager; | ||
import com.atlassian.jira.issue.fields.CustomField; | ||
import com.atlassian.jira.user.ApplicationUser; | ||
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned; | ||
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; | ||
import java.text.DecimalFormat; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Scanned | ||
@Named | ||
public class IssueServiceFacade { | ||
|
||
private static final String STORY_POINT_FILED_NAME = "Story Points"; | ||
|
||
@ComponentImport | ||
private final CustomFieldManager customFieldManager; | ||
@ComponentImport | ||
private final IssueService issueService; | ||
@ComponentImport | ||
private final IssueManager issueManager; | ||
|
||
@Inject | ||
public IssueServiceFacade(CustomFieldManager customFieldManager, IssueService issueService, | ||
IssueManager issueManager) { | ||
this.customFieldManager = customFieldManager; | ||
this.issueService = issueService; | ||
this.issueManager = issueManager; | ||
} | ||
|
||
public void applyEstimate(String estimate, ApplicationUser user, String issueId) { | ||
Issue issue = issueManager.getIssueObject(issueId); | ||
Optional<CustomField> field = getField(issue); | ||
if (!field.isPresent()) { | ||
log.error("'Story Point' custom field does not exist"); | ||
return; | ||
} | ||
IssueInputParameters inputParameters = buildInputParams(field.get().getIdAsLong(), estimate); | ||
IssueService.UpdateValidationResult updateValidationResult = issueService | ||
.validateUpdate(user, issue.getId(), inputParameters); | ||
|
||
if (!updateValidationResult.isValid()) { | ||
log.error("Validation for updating story point is failed, errors: {}", updateValidationResult | ||
.getErrorCollection().toString()); | ||
return; | ||
} | ||
|
||
IssueService.IssueResult updateResult = issueService.update(user, updateValidationResult); | ||
if (!updateResult.isValid()) { | ||
log.error("ISSUE has NOT been updated. Errors: {}\n" + updateResult.getErrorCollection().toString()); | ||
return; | ||
} | ||
|
||
log.info("The issue {} has been updated with a new story point value", issueId); | ||
} | ||
|
||
private IssueInputParameters buildInputParams(long fieldId, String estimate) { | ||
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); | ||
issueInputParameters.addCustomFieldValue(fieldId, estimate); | ||
issueInputParameters.setSkipScreenCheck(true); | ||
issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(true, true); | ||
|
||
return issueInputParameters; | ||
} | ||
|
||
private Optional<CustomField> getField(Issue issue) { | ||
return customFieldManager.getCustomFieldObjects(issue) | ||
.stream() | ||
.filter(f -> f.getFieldName().equals(STORY_POINT_FILED_NAME)) | ||
.findFirst(); | ||
} | ||
|
||
public Optional<String> getStoryPoints(String issueId) { | ||
Issue issue = issueManager.getIssueObject(issueId); | ||
Optional<Object> value = customFieldManager.getCustomFieldObjects(issue) | ||
.stream() | ||
.filter(f -> f.getFieldName().equals(STORY_POINT_FILED_NAME)) | ||
.map(f -> f.getValue(issue)) | ||
.filter(Objects::nonNull) | ||
.findAny(); | ||
if (!value.isPresent()) { | ||
return Optional.empty(); | ||
} | ||
|
||
return format(value.get()); | ||
} | ||
|
||
private Optional<String> format(Object value) { | ||
if (value instanceof Double) { | ||
DecimalFormat format = new DecimalFormat("0.#"); | ||
return Optional.of(format.format(value)); | ||
} | ||
|
||
if (value instanceof Integer) { | ||
return Optional.of(value.toString()); | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/aprey/jira/plugin/openpoker/api/ApplyVoteProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2021 Andriy Preizner | ||
* | ||
* This file is a part of Open Poker jira plugin | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.aprey.jira.plugin.openpoker.api; | ||
|
||
import com.aprey.jira.plugin.openpoker.persistence.PersistenceService; | ||
import com.atlassian.jira.user.ApplicationUser; | ||
import com.atlassian.jira.user.util.UserManager; | ||
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned; | ||
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; | ||
import java.util.Optional; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.servlet.http.HttpServletRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Named | ||
@Scanned | ||
@Slf4j | ||
public class ApplyVoteProcessor implements ActionProcessor { | ||
|
||
private static final String ESTIMATE_FILED = "finalEstimateId"; | ||
private static final String USER_ID_FIELD = "userId"; | ||
|
||
@ComponentImport | ||
private final UserManager userManager; | ||
|
||
@Inject | ||
public ApplyVoteProcessor(UserManager userManager) { | ||
this.userManager = userManager; | ||
} | ||
|
||
@Override | ||
public void process(PersistenceService persistenceService, HttpServletRequest request, String issueId) { | ||
final long userId = Long.parseLong(request.getParameter(USER_ID_FIELD)); | ||
final int estimateId = Integer.parseInt(request.getParameter(ESTIMATE_FILED)); | ||
Optional<ApplicationUser> applicationUser = userManager.getUserById(userId); | ||
if (!applicationUser.isPresent()) { | ||
log.error("Application user is not found by {} id", userId); | ||
return; | ||
} | ||
|
||
persistenceService.applyFinalEstimate(issueId, estimateId, applicationUser.get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.