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();
}
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"));
}
Aggregations