use of org.kie.kogito.taskassigning.core.model.ChainElement in project kogito-apps by kiegroup.
the class StartAndEndTimeUpdatingVariableListener method updateStartAndEndTime.
private static void updateStartAndEndTime(final ScoreDirector<TaskAssigningSolution> scoreDirector, final TaskAssignment sourceTaskAssignment) {
ChainElement previous = sourceTaskAssignment.getPreviousElement();
TaskAssignment shadowTaskAssignment = sourceTaskAssignment;
Integer previousEndTime = previous == null || !previous.isTaskAssignment() ? 0 : ((TaskAssignment) previous).getEndTimeInMinutes();
Integer startTime = previousEndTime;
Integer endTime = calculateEndTime(shadowTaskAssignment, startTime);
while (shadowTaskAssignment != null && !Objects.equals(shadowTaskAssignment.getStartTimeInMinutes(), startTime)) {
scoreDirector.beforeVariableChanged(shadowTaskAssignment, START_TIME_IN_MINUTES);
shadowTaskAssignment.setStartTimeInMinutes(startTime);
scoreDirector.afterVariableChanged(shadowTaskAssignment, START_TIME_IN_MINUTES);
scoreDirector.beforeVariableChanged(shadowTaskAssignment, END_TIME_IN_MINUTES);
shadowTaskAssignment.setEndTimeInMinutes(endTime);
scoreDirector.afterVariableChanged(shadowTaskAssignment, END_TIME_IN_MINUTES);
previousEndTime = shadowTaskAssignment.getEndTimeInMinutes();
shadowTaskAssignment = shadowTaskAssignment.getNextElement();
startTime = previousEndTime;
endTime = calculateEndTime(shadowTaskAssignment, startTime);
}
}
use of org.kie.kogito.taskassigning.core.model.ChainElement in project kogito-apps by kiegroup.
the class TaskByGroupAndSkillsChangeMoveFilter method accept.
@Override
public boolean accept(ScoreDirector<TaskAssigningSolution> scoreDirector, ChangeMove<TaskAssigningSolution> changeMove) {
final TaskAssignment assignmentToMove = (TaskAssignment) changeMove.getEntity();
final ChainElement chainElement = (ChainElement) changeMove.getToPlanningValue();
final User user = chainElement.isTaskAssignment() ? ((TaskAssignment) chainElement).getUser() : (User) chainElement;
return user != null && user.isEnabled() && (ModelConstants.IS_PLANNING_USER.test(user.getId()) || (isPotentialOwner(assignmentToMove.getTask(), user) && hasAllLabels(assignmentToMove.getTask(), user, DefaultLabels.SKILLS.name())));
}
use of org.kie.kogito.taskassigning.core.model.ChainElement in project kogito-apps by kiegroup.
the class AssignTaskProblemFactChange method processExistingTaskAssignment.
private void processExistingTaskAssignment(TaskAssignment existingTaskAssignment, ChainElement insertPosition, TaskAssignment insertPositionNextTask, ScoreDirector<TaskAssigningSolution> scoreDirector) {
if (insertPosition.getNextElement() != existingTaskAssignment) {
// relocate the existingTaskAssignment at the desired position
ChainElement previousElement = existingTaskAssignment.getPreviousElement();
if (previousElement != null) {
// unlink from the current chain position.
unlinkTaskAssignment(existingTaskAssignment, previousElement, scoreDirector);
}
scoreDirector.beforeVariableChanged(existingTaskAssignment, PREVIOUS_ELEMENT);
existingTaskAssignment.setPreviousElement(insertPosition);
scoreDirector.afterVariableChanged(existingTaskAssignment, PREVIOUS_ELEMENT);
setPreviousElementIfApply(insertPositionNextTask, existingTaskAssignment, scoreDirector);
}
setPinned(existingTaskAssignment, scoreDirector);
scoreDirector.triggerVariableListeners();
}
use of org.kie.kogito.taskassigning.core.model.ChainElement in project kogito-apps by kiegroup.
the class AssignTaskProblemFactChange method doChange.
@Override
public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) {
User workingUser = lookupOrAddWorkingUser(user, scoreDirector, addIfNotExists);
TaskAssignment workingTaskAssignment = lookupOrPrepareTaskAssignment(taskAssignment, scoreDirector);
ChainElement insertPosition = findInsertPosition(workingUser);
TaskAssignment insertPositionNextTask = insertPosition.getNextElement();
if (taskAssignment == workingTaskAssignment) {
processNewTaskAssignment(workingTaskAssignment, insertPosition, insertPositionNextTask, scoreDirector);
} else if (insertPosition != workingTaskAssignment) {
// in cases where insertPosition == workingTaskAssignment there's nothing to do, since the workingTaskAssignment
// is already pinned and belongs to user. (see findInsertPosition)
processExistingTaskAssignment(workingTaskAssignment, insertPosition, insertPositionNextTask, scoreDirector);
}
}
use of org.kie.kogito.taskassigning.core.model.ChainElement in project kogito-apps by kiegroup.
the class ReleaseTaskProblemFactChange method doChange.
@Override
public void doChange(ScoreDirector<TaskAssigningSolution> scoreDirector) {
TaskAssignment workingTaskAssignment = scoreDirector.lookUpWorkingObjectOrReturnNull(taskAssignment);
if (workingTaskAssignment == null || workingTaskAssignment.getPreviousElement() == null) {
// or it's simply not yet assigned.
return;
}
// unlink the workingTaskAssignment from the chain.
ChainElement previousElement = workingTaskAssignment.getPreviousElement();
unlinkTaskAssignment(workingTaskAssignment, previousElement, scoreDirector);
scoreDirector.beforeVariableChanged(workingTaskAssignment, PREVIOUS_ELEMENT);
workingTaskAssignment.setPreviousElement(null);
scoreDirector.afterVariableChanged(workingTaskAssignment, PREVIOUS_ELEMENT);
if (workingTaskAssignment.isPinned()) {
scoreDirector.beforeProblemPropertyChanged(workingTaskAssignment);
workingTaskAssignment.setPinned(false);
scoreDirector.afterProblemPropertyChanged(workingTaskAssignment);
}
scoreDirector.triggerVariableListeners();
}
Aggregations