ItEr19S08CUCreacionProxectoPlanificacionItEr18S08: Adding remove method to TaskElementService.

This commit is contained in:
Óscar González Fernández 2009-07-23 19:37:19 +02:00 committed by Javier Moran Rua
parent b2a096b5af
commit 33132466a3
5 changed files with 50 additions and 0 deletions

View file

@ -17,4 +17,6 @@ public interface ITaskElementService {
void convertToScheduleAndSave(Order order);
void remove(TaskElement taskElement);
}

View file

@ -97,4 +97,14 @@ public class TaskElementService implements ITaskElementService {
}
}
@Override
@Transactional
public void remove(TaskElement taskElement) {
try {
taskElementDao.remove(taskElement.getId());
} catch (InstanceNotFoundException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -303,4 +303,31 @@ public class TaskElementServiceTest {
assertThat(orderElement.getTaskElements().iterator().next(),
equalTo(fromDB));
}
@Test
public void aTaskCanBeRemoved() {
Task task = createValidTask();
taskElementService.save(task);
flushAndEvict(task);
taskElementService.remove(task);
sessionFactory.getCurrentSession().flush();
assertNull(sessionFactory.getCurrentSession().get(TaskElement.class,
task.getId()));
}
@Test
public void aTaskGroupCanBeRemoved() {
TaskGroup taskGroup = createValidTaskGroup();
Task task = createValidTask();
taskGroup.addTaskElement(task);
taskElementService.save(taskGroup);
flushAndEvict(taskGroup);
taskElementService.remove(taskGroup);
sessionFactory.getCurrentSession().flush();
assertNull(sessionFactory.getCurrentSession().get(TaskGroup.class,
taskGroup.getId()));
assertNull(sessionFactory.getCurrentSession().get(TaskElement.class,
task.getId()));
}
}

View file

@ -44,4 +44,8 @@ public class ContextRelativeToOtherComponent<T> implements IContext<T> {
context.remove(domainObject);
}
public void replace(T oldDomainObject, T newDomainObject) {
context.replace(oldDomainObject, newDomainObject);
};
}

View file

@ -1,6 +1,7 @@
package org.zkoss.ganttz.extensions;
import org.zkoss.ganttz.adapters.PlannerConfiguration;
import org.zkoss.ganttz.data.Position;
import org.zkoss.ganttz.data.Task;
import org.zkoss.zk.ui.Component;
@ -43,10 +44,16 @@ public class ContextWithPlannerTask<T> implements IContextWithPlannerTask<T> {
return context.getRelativeTo();
}
@Override
public void replace(T oldDomainObject, T newDomainObject) {
context.replace(oldDomainObject, newDomainObject);
}
@Override
public Task getTask() {
return task;
}
}