Search in sources :

Example 11 with ScheduledTask

use of com.haulmont.cuba.core.entity.ScheduledTask in project cuba by cuba-platform.

the class Scheduling method printActiveScheduledTasks.

@Override
public String printActiveScheduledTasks() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    StringBuilder sb = new StringBuilder();
    List<ScheduledTask> tasks = scheduling.getActiveTasks();
    for (ScheduledTask task : tasks) {
        sb.append(task).append(", lastStart=");
        if (task.getLastStartTime() != null) {
            sb.append(dateFormat.format(task.getLastStartTime()));
            if (BooleanUtils.isTrue(task.getSingleton()))
                sb.append(" on ").append(task.getLastStartServer());
        } else {
            sb.append("<never>");
        }
        sb.append("\n");
    }
    return sb.toString();
}
Also used : ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask) SimpleDateFormat(java.text.SimpleDateFormat)

Example 12 with ScheduledTask

use of com.haulmont.cuba.core.entity.ScheduledTask in project cuba by cuba-platform.

the class PersistenceAttributeLoadedCheckTest method testIsLoadedLogic.

@Test
public void testIsLoadedLogic() throws Exception {
    LoadContext<User> userContext = LoadContext.create(User.class).setId(userId).setView(userView);
    LoadContext<ScheduledTask> taskContext = LoadContext.create(ScheduledTask.class).setId(taskId).setView(taskView);
    User user = dataManager.load(userContext);
    ScheduledTask task = dataManager.load(taskContext);
    assertNotNull(user);
    assertNotNull(task);
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(user, "group"));
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(user, "userRoles"));
    // if attribute is not in the view - it should not be loaded
    assertTrue(!PersistenceHelper.isLoaded(user, "substitutions"));
    try {
        PersistenceHelper.isLoaded(user, "notExistingAttribute");
        Assert.fail("Should throw an exception for not existing attribute");
    } catch (Exception ignored) {
    }
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(task, "beanName"));
    // if attribute is not in the view - it should not be loaded
    assertTrue(!PersistenceHelper.isLoaded(task, "methodName"));
    // meta properties should be marked as loaded
    assertTrue(PersistenceHelper.isLoaded(task, "methodParametersString"));
    user = TestSupport.reserialize(user);
    task = TestSupport.reserialize(task);
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(user, "group"));
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(user, "userRoles"));
    // if attribute is not in the view - it should not be loaded
    assertTrue(!PersistenceHelper.isLoaded(user, "substitutions"));
    try {
        PersistenceHelper.isLoaded(user, "notExistingAttribute");
        Assert.fail("Should throw an exception for not existing attribute");
    } catch (Exception ignored) {
    }
    // if attribute is in the view - it should be loaded
    assertTrue(PersistenceHelper.isLoaded(task, "beanName"));
    // if attribute is not in the view - it should not be loaded
    assertTrue(!PersistenceHelper.isLoaded(task, "methodName"));
    // meta properties should be marked as loaded
    assertTrue(PersistenceHelper.isLoaded(task, "methodParametersString"));
}
Also used : User(com.haulmont.cuba.security.entity.User) ScheduledTask(com.haulmont.cuba.core.entity.ScheduledTask)

Aggregations

ScheduledTask (com.haulmont.cuba.core.entity.ScheduledTask)12 EntityManager (com.haulmont.cuba.core.EntityManager)3 Transaction (com.haulmont.cuba.core.Transaction)3 ScheduledExecution (com.haulmont.cuba.core.entity.ScheduledExecution)2 User (com.haulmont.cuba.security.entity.User)2 Date (java.util.Date)2 Test (org.junit.Test)2 TimeSource (com.haulmont.cuba.core.global.TimeSource)1 EditAction (com.haulmont.cuba.gui.components.actions.EditAction)1 ItemTrackingAction (com.haulmont.cuba.gui.components.actions.ItemTrackingAction)1 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)1 Group (com.haulmont.cuba.security.entity.Group)1 SimpleDateFormat (java.text.SimpleDateFormat)1 StopWatch (org.perf4j.StopWatch)1 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)1