Use top level project task for grouped sub tasks
Instead of using the group task as the project task need to pull the top level parent. A grouped task will have as parent the group not the project. Fixes #21
This commit is contained in:
parent
89d81f8f5b
commit
64e095a841
6 changed files with 44 additions and 7 deletions
|
|
@ -243,7 +243,8 @@ public abstract class TaskElement extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProjectCode() {
|
public String getProjectCode() {
|
||||||
return getOrderElement().getOrder().getCode();
|
//then get the top level project code
|
||||||
|
return getTopMost().getOrderElement().getOrder().getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,42 @@ public class TaskElementDAOTest {
|
||||||
assertThat(child.getParent(), equalTo(reloaded));
|
assertThat(child.getParent(), equalTo(reloaded));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Transactional
|
||||||
|
public void theTopMostPropertyIsTheToplevelTask() {
|
||||||
|
TaskGroup taskGroup = createValidTaskGroup();
|
||||||
|
TaskElement taskElement = createValidTask();
|
||||||
|
taskGroup.addTaskElement(taskElement);
|
||||||
|
taskElementDAO.save(taskGroup);
|
||||||
|
|
||||||
|
TaskGroup taskGroup2 = createValidTaskGroup();
|
||||||
|
TaskElement taskElement2 = createValidTask();
|
||||||
|
taskGroup2.addTaskElement(taskElement2);
|
||||||
|
taskElementDAO.save(taskGroup2);
|
||||||
|
|
||||||
|
taskGroup.addTaskElement(taskGroup2);
|
||||||
|
taskElementDAO.save(taskGroup);
|
||||||
|
|
||||||
|
flushAndEvict(taskGroup);
|
||||||
|
flushAndEvict(taskGroup2);
|
||||||
|
|
||||||
|
TaskElement reloaded;
|
||||||
|
try {
|
||||||
|
reloaded = taskElementDAO.find(taskGroup.getId());
|
||||||
|
} catch (InstanceNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TaskElement> children = reloaded.getChildren();
|
||||||
|
|
||||||
|
for (TaskElement child : children) {
|
||||||
|
if (child instanceof TaskGroup) {
|
||||||
|
TaskElement child2 = child.getChildren().get(0);
|
||||||
|
assertThat(child2.getTopMost(), equalTo(reloaded));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public void savingGroupSavesAssociatedTaskElements() {
|
public void savingGroupSavesAssociatedTaskElements() {
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ public class SendEmailOnMilestoneReached implements IEmailNotificationJob {
|
||||||
|
|
||||||
private void sendEmailNotificationToManager(TaskElement item) {
|
private void sendEmailNotificationToManager(TaskElement item) {
|
||||||
String responsible = "";
|
String responsible = "";
|
||||||
if ( item.getParent().getOrderElement().getOrder().getResponsible() != null ) {
|
if ( item.getTopMost().getOrderElement().getOrder().getResponsible() != null ) {
|
||||||
responsible = item.getParent().getOrderElement().getOrder().getResponsible();
|
responsible = item.getTopMost().getOrderElement().getOrder().getResponsible();
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = null;
|
User user = null;
|
||||||
|
|
@ -130,7 +130,7 @@ public class SendEmailOnMilestoneReached implements IEmailNotificationJob {
|
||||||
emailNotificationModel.setUpdated(new Date());
|
emailNotificationModel.setUpdated(new Date());
|
||||||
emailNotificationModel.setResource(user.getWorker());
|
emailNotificationModel.setResource(user.getWorker());
|
||||||
emailNotificationModel.setTask(item);
|
emailNotificationModel.setTask(item);
|
||||||
emailNotificationModel.setProject(item.getParent());
|
emailNotificationModel.setProject(item.getTopMost());
|
||||||
emailNotificationModel.confirmSave();
|
emailNotificationModel.confirmSave();
|
||||||
}
|
}
|
||||||
} catch (InstanceNotFoundException e) {
|
} catch (InstanceNotFoundException e) {
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ public class SendEmailOnTaskShouldFinish implements IEmailNotificationJob {
|
||||||
emailNotificationModel.setUpdated(new Date());
|
emailNotificationModel.setUpdated(new Date());
|
||||||
emailNotificationModel.setResource(resourceItem);
|
emailNotificationModel.setResource(resourceItem);
|
||||||
emailNotificationModel.setTask(item);
|
emailNotificationModel.setTask(item);
|
||||||
emailNotificationModel.setProject(item.getParent());
|
emailNotificationModel.setProject(item.getTopMost());
|
||||||
emailNotificationModel.confirmSave();
|
emailNotificationModel.confirmSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ public class SendEmailOnTaskShouldStart implements IEmailNotificationJob {
|
||||||
emailNotificationModel.setUpdated(new Date());
|
emailNotificationModel.setUpdated(new Date());
|
||||||
emailNotificationModel.setResource(resourceItem);
|
emailNotificationModel.setResource(resourceItem);
|
||||||
emailNotificationModel.setTask(item);
|
emailNotificationModel.setTask(item);
|
||||||
emailNotificationModel.setProject(item.getParent());
|
emailNotificationModel.setProject(item.getTopMost());
|
||||||
emailNotificationModel.confirmSave();
|
emailNotificationModel.confirmSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -800,7 +800,7 @@ public class TaskPropertiesController extends GenericForwardComposer<Component>
|
||||||
|
|
||||||
emailNotificationModel.setTask(currentTaskElement.getTaskSource().getTask());
|
emailNotificationModel.setTask(currentTaskElement.getTaskSource().getTask());
|
||||||
|
|
||||||
emailNotificationModel.setProject(currentTaskElement.getParent().getTaskSource().getTask());
|
emailNotificationModel.setProject(currentTaskElement.getTopMost().getTaskSource().getTask());
|
||||||
|
|
||||||
emailNotificationModel.confirmSave();
|
emailNotificationModel.confirmSave();
|
||||||
} catch (DataIntegrityViolationException e) {
|
} catch (DataIntegrityViolationException e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue