UpdateTask.java
/*
* BSD 2-Clause License
*
* Copyright (c) 2023, [Aleksandra Serba, Marcin Czerniak, Bartosz Wawrzyniak, Adrian Antkowiak]
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package dev.vernite.vernite.task;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import dev.vernite.vernite.common.constraints.NullOrNotBlank;
import dev.vernite.vernite.integration.git.IssueAction;
import dev.vernite.vernite.integration.git.IssueActionDeserializer;
import dev.vernite.vernite.integration.git.PullAction;
import dev.vernite.vernite.integration.git.PullActionDeserializer;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Class containing information needed to create new task entity.
* Has required constraints annotated using Java Bean Validation.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UpdateTask {
/**
* The name of the task.
*/
@NullOrNotBlank(message = "Task name cannot be blank")
@Size(min = 1, max = 100, message = "Task name must be between 1 and 100 characters")
private String name;
/**
* The description of the task.
*/
@Size(max = 1000, message = "Task description must be less than 1000 characters")
private String description;
/**
* The id of the status to which the task belongs.
*/
@Positive(message = "Task status id must be positive")
private Long statusId;
/**
* The id of the assignee to which the task belongs.
*/
@Positive(message = "Task assignee id must be positive")
private Long assigneeId;
@JsonIgnore
private boolean assigneeIdSet;
/**
* The type of the task.
*/
@PositiveOrZero(message = "Task type must be positive or zero")
private Integer type;
/**
* The priority of the task.
*/
@NullOrNotBlank(message = "Task priority cannot be blank")
@Size(min = 1, max = 100, message = "Task priority must be between 1 and 100 characters")
private String priority;
/**
* The estimated date of the task.
*/
private Date estimatedDate;
/**
* The due date of the task.
*/
private Date deadline;
/**
* The id of the parent task to which the task belongs.
*/
@Positive(message = "Task parent task id must be positive")
private Long parentTaskId;
@JsonIgnore
private boolean parentTaskIdSet;
/**
* Instead of word 'attach' send issue object received from other endpoint:
* /project/{id}/integration/git/issue
*/
@JsonDeserialize(using = IssueActionDeserializer.class)
private IssueAction issue;
/**
* Instead of word 'attach' send pull object received from other endpoint:
* /project/{id}/integration/git/pull
*/
@JsonDeserialize(using = PullActionDeserializer.class)
private PullAction pull;
/**
* The id of the sprint to which the task belongs.
*/
@Positive(message = "Task sprint id must be positive")
private Long sprintId;
@JsonIgnore
private boolean sprintIdSet;
/**
* The amount of story points assigned to the task.
*/
@PositiveOrZero(message = "Task story points must be positive or zero")
private Long storyPoints;
/**
* The id of the release to which the task belongs.
*/
@Positive(message = "Task release id must be positive")
private Long releaseId;
@JsonIgnore
private boolean releaseIdSet;
/**
* Sets the assignee id of the task. Also sets the assignee id set flag to true.
*
* @param assigneeId the assignee id of the task
*/
public void setAssigneeId(Long assigneeId) {
this.assigneeId = assigneeId;
this.assigneeIdSet = true;
}
/**
* Sets the parent task id of the task. Also sets the parent task id set flag to
* true.
*
* @param parentTaskId the parent task id of the task
*/
public void setParentTaskId(Long parentTaskId) {
this.parentTaskId = parentTaskId;
this.parentTaskIdSet = true;
}
/**
* Sets the sprint id of the task. Also sets the sprint id set flag to true.
*
* @param sprintId the sprint id of the task
*/
public void setSprintId(Long sprintId) {
this.sprintId = sprintId;
this.sprintIdSet = true;
}
/**
* Sets the release id of the task. Also sets the release id set flag to true.
*
* @param releaseId the release id of the task
*/
public void setReleaseId(Long releaseId) {
this.releaseId = releaseId;
this.releaseIdSet = true;
}
/**
* Constructor for updating task with only required fields.
*
* @param name name of the task
* @param description description of the task
* @param statusId id of the status to which the task belongs
* @param type type of the task
* @param priority priority of the task
*/
public UpdateTask(String name, String description, Long statusId, Integer type, String priority) {
this(name, description, statusId, null, false, type, priority, null, null, null, false, null, null, null, false,
null, null, false);
}
}