Search in sources :

Example 1 with SoftDelete_Project

use of com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Project in project cuba by cuba-platform.

the class SoftDeleteNotFoundDeletedTest method setUp.

@Before
public void setUp() throws Exception {
    dataManager = AppBeans.get(DataManager.class);
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        SoftDelete_Service service = new SoftDelete_Service();
        serviceId = service.getId();
        service.setName("service");
        service.setCode("serviceCode");
        em.persist(service);
        SoftDelete_Task task = new SoftDelete_Task();
        taskId = task.getId();
        task.setMessage("message");
        task.setService(service);
        em.persist(task);
        SoftDelete_TaskValue taskValue = new SoftDelete_TaskValue();
        taskValueId = taskValue.getId();
        taskValue.setTask(task);
        em.persist(taskValue);
        SoftDelete_Project project = new SoftDelete_Project();
        projectId = project.getId();
        project.setName("project");
        project.setAValue(taskValue);
        project.setTask(task);
        em.persist(project);
        tx.commitRetaining();
        em = cont.persistence().getEntityManager();
        task = em.find(SoftDelete_Task.class, taskId);
        em.remove(task);
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : SoftDelete_Task(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Task) EntityManager(com.haulmont.cuba.core.EntityManager) SoftDelete_Service(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Service) SoftDelete_TaskValue(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_TaskValue) Transaction(com.haulmont.cuba.core.Transaction) DataManager(com.haulmont.cuba.core.global.DataManager) SoftDelete_Project(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Project)

Example 2 with SoftDelete_Project

use of com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Project in project cuba by cuba-platform.

the class SoftDeleteNotFoundDeletedTest method testLoadDeletedObject.

@Test
public void testLoadDeletedObject() {
    View taskView_Message = new View(SoftDelete_Task.class).addProperty("message");
    View taskView_Service = new View(SoftDelete_Task.class).addProperty("service", new View(SoftDelete_Service.class).addProperty("code"));
    View taskValueView = new View(SoftDelete_TaskValue.class).addProperty("task", taskView_Message);
    View projectView = new View(SoftDelete_Project.class).addProperty("name").addProperty("aValue", taskValueView).addProperty("task", taskView_Service);
    LoadContext<SoftDelete_Project> loadContext = new LoadContext<>(SoftDelete_Project.class).setView(projectView).setId(projectId);
    SoftDelete_Project project = dataManager.load(loadContext);
    Assert.assertNotNull(project);
    Assert.assertNotNull(project.getTask());
    Assert.assertTrue(project.getTask().isDeleted());
}
Also used : SoftDelete_Task(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Task) SoftDelete_TaskValue(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_TaskValue) LoadContext(com.haulmont.cuba.core.global.LoadContext) SoftDelete_Project(com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Project) View(com.haulmont.cuba.core.global.View)

Aggregations

SoftDelete_Project (com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Project)2 SoftDelete_Task (com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Task)2 SoftDelete_TaskValue (com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_TaskValue)2 EntityManager (com.haulmont.cuba.core.EntityManager)1 Transaction (com.haulmont.cuba.core.Transaction)1 DataManager (com.haulmont.cuba.core.global.DataManager)1 LoadContext (com.haulmont.cuba.core.global.LoadContext)1 View (com.haulmont.cuba.core.global.View)1 SoftDelete_Service (com.haulmont.cuba.testmodel.softdelete_notfounddeleted.SoftDelete_Service)1