use of org.apache.syncope.common.lib.to.SchedTaskTO in project syncope by apache.
the class SchedTaskITCase method issueSYNCOPE660.
@Test
public void issueSYNCOPE660() {
List<JobTO> jobs = taskService.listJobs();
int old_size = jobs.size();
ImplementationTO taskJobDelegate = implementationService.read(ImplementationType.TASKJOB_DELEGATE, TestSampleJobDelegate.class.getSimpleName());
assertNotNull(taskJobDelegate);
SchedTaskTO task = new SchedTaskTO();
task.setName("issueSYNCOPE660");
task.setDescription("issueSYNCOPE660 Description");
task.setJobDelegate(taskJobDelegate.getKey());
Response response = taskService.create(TaskType.SCHEDULED, task);
task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
jobs = taskService.listJobs();
assertEquals(old_size + 1, jobs.size());
taskService.actionJob(task.getKey(), JobAction.START);
int i = 0, maxit = 50;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
jobs = taskService.listJobs().stream().filter(job -> job.isRunning()).collect(Collectors.toList());
i++;
} while (jobs.size() < 1 && i < maxit);
assertEquals(1, jobs.size());
assertEquals(task.getKey(), jobs.get(0).getRefKey());
taskService.actionJob(task.getKey(), JobAction.STOP);
i = 0;
do {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
jobs = taskService.listJobs().stream().filter(job -> job.isRunning()).collect(Collectors.toList());
i++;
} while (jobs.size() >= 1 && i < maxit);
assertTrue(jobs.isEmpty());
}
use of org.apache.syncope.common.lib.to.SchedTaskTO in project syncope by apache.
the class SchedTaskITCase method issueSYNCOPE144.
@Test
public void issueSYNCOPE144() {
ImplementationTO taskJobDelegate = implementationService.read(ImplementationType.TASKJOB_DELEGATE, TestSampleJobDelegate.class.getSimpleName());
assertNotNull(taskJobDelegate);
SchedTaskTO task = new SchedTaskTO();
task.setName("issueSYNCOPE144");
task.setDescription("issueSYNCOPE144 Description");
task.setJobDelegate(taskJobDelegate.getKey());
Response response = taskService.create(TaskType.SCHEDULED, task);
task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
assertNotNull(task);
assertEquals("issueSYNCOPE144", task.getName());
assertEquals("issueSYNCOPE144 Description", task.getDescription());
task = taskService.read(TaskType.SCHEDULED, task.getKey(), true);
assertNotNull(task);
assertEquals("issueSYNCOPE144", task.getName());
assertEquals("issueSYNCOPE144 Description", task.getDescription());
task.setName("issueSYNCOPE144_2");
task.setDescription("issueSYNCOPE144 Description_2");
response = taskService.create(TaskType.SCHEDULED, task);
task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
assertNotNull(task);
assertEquals("issueSYNCOPE144_2", task.getName());
assertEquals("issueSYNCOPE144 Description_2", task.getDescription());
}
use of org.apache.syncope.common.lib.to.SchedTaskTO in project syncope by apache.
the class SchedTaskITCase method update.
@Test
public void update() {
SchedTaskTO task = taskService.read(TaskType.SCHEDULED, SCHED_TASK_KEY, true);
assertNotNull(task);
SchedTaskTO taskMod = new SchedTaskTO();
taskMod.setKey(SCHED_TASK_KEY);
taskMod.setName(task.getName());
taskMod.setCronExpression(null);
taskService.update(TaskType.SCHEDULED, taskMod);
SchedTaskTO actual = taskService.read(TaskType.SCHEDULED, taskMod.getKey(), true);
assertNotNull(actual);
assertEquals(task.getKey(), actual.getKey());
assertNull(actual.getCronExpression());
}
use of org.apache.syncope.common.lib.to.SchedTaskTO in project syncope by apache.
the class TaskDetails method details.
public void details() {
if (input.parameterNumber() == 0) {
try {
final Map<String, String> details = new LinkedHashMap<>();
final List<TaskTO> notificationTaskTOs = taskSyncopeOperations.list(TaskType.NOTIFICATION.name());
final List<TaskTO> propagationTaskTOs = taskSyncopeOperations.list(TaskType.PROPAGATION.name());
final List<TaskTO> pushTaskTOs = taskSyncopeOperations.list(TaskType.PUSH.name());
final List<TaskTO> scheduledTaskTOs = taskSyncopeOperations.list(TaskType.SCHEDULED.name());
final List<TaskTO> pullTaskTOs = taskSyncopeOperations.list(TaskType.PULL.name());
final List<JobTO> jobTOs = taskSyncopeOperations.listJobs();
final int notificationTaskSize = notificationTaskTOs.size();
final int propagationTaskSize = propagationTaskTOs.size();
final int pushTaskSize = pushTaskTOs.size();
final int scheduledTaskSize = scheduledTaskTOs.size();
final int pullTaskSize = pullTaskTOs.size();
final int jobsSize = jobTOs.size();
long notificationNotExecuted = notificationTaskTOs.stream().filter(notificationTaskTO -> !((NotificationTaskTO) notificationTaskTO).isExecuted()).count();
long propagationNotExecuted = propagationTaskTOs.stream().filter(propagationTaskTO -> ((PropagationTaskTO) propagationTaskTO).getExecutions().isEmpty()).count();
long pushNotExecuted = pushTaskTOs.stream().filter(pushTaskTO -> ((PushTaskTO) pushTaskTO).getExecutions().isEmpty()).count();
long scheduledNotExecuted = scheduledTaskTOs.stream().filter(scheduledTaskTO -> ((SchedTaskTO) scheduledTaskTO).getExecutions().isEmpty()).count();
int pullNotExecuted = 0;
int pullFull = 0;
for (final TaskTO pullTaskTO : pullTaskTOs) {
if (((PullTaskTO) pullTaskTO).getExecutions().isEmpty()) {
pullNotExecuted++;
}
if (((PullTaskTO) pullTaskTO).getPullMode() == PullMode.FULL_RECONCILIATION) {
pullFull++;
}
}
details.put("total number", String.valueOf(notificationTaskSize + propagationTaskSize + pushTaskSize + scheduledTaskSize + pullTaskSize));
details.put("notification tasks", String.valueOf(notificationTaskSize));
details.put("notification tasks not executed", String.valueOf(notificationNotExecuted));
details.put("propagation tasks", String.valueOf(propagationTaskSize));
details.put("propagation tasks not executed", String.valueOf(propagationNotExecuted));
details.put("push tasks", String.valueOf(pushTaskSize));
details.put("push tasks not executed", String.valueOf(pushNotExecuted));
details.put("scheduled tasks", String.valueOf(scheduledTaskSize));
details.put("scheduled tasks not executed", String.valueOf(scheduledNotExecuted));
details.put("pull tasks", String.valueOf(pullTaskSize));
details.put("pull tasks not executed", String.valueOf(pullNotExecuted));
details.put("pull tasks with full reconciliation", String.valueOf(pullFull));
details.put("jobs", String.valueOf(jobsSize));
taskResultManager.printDetails(details);
} catch (final SyncopeClientException ex) {
LOG.error("Error reading details about task", ex);
taskResultManager.genericError(ex.getMessage());
} catch (final IllegalArgumentException ex) {
LOG.error("Error reading details about task", ex);
taskResultManager.typeNotValidError("task", input.firstParameter(), CommandUtils.fromEnumToArray(TaskType.class));
}
} else {
taskResultManager.commandOptionError(DETAILS_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.to.SchedTaskTO in project syncope by apache.
the class TaskDataBinderImpl method getTaskTO.
@Override
public <T extends TaskTO> T getTaskTO(final Task task, final TaskUtils taskUtils, final boolean details) {
T taskTO = taskUtils.newTaskTO();
BeanUtils.copyProperties(task, taskTO, IGNORE_TASK_PROPERTIES);
TaskExec latestExec = taskExecDAO.findLatestStarted(task);
if (latestExec == null) {
taskTO.setLatestExecStatus(StringUtils.EMPTY);
} else {
taskTO.setLatestExecStatus(latestExec.getStatus());
taskTO.setStart(latestExec.getStart());
taskTO.setEnd(latestExec.getEnd());
}
if (details) {
task.getExecs().stream().filter(execution -> execution != null).forEachOrdered(execution -> taskTO.getExecutions().add(getExecTO(execution)));
}
switch(taskUtils.getType()) {
case PROPAGATION:
PropagationTask propagationTask = (PropagationTask) task;
PropagationTaskTO propagationTaskTO = (PropagationTaskTO) taskTO;
propagationTaskTO.setAnyTypeKind(propagationTask.getAnyTypeKind());
propagationTaskTO.setEntityKey(propagationTask.getEntityKey());
propagationTaskTO.setResource(propagationTask.getResource().getKey());
propagationTaskTO.setAttributes(propagationTask.getSerializedAttributes());
break;
case SCHEDULED:
SchedTask schedTask = (SchedTask) task;
SchedTaskTO schedTaskTO = (SchedTaskTO) taskTO;
setExecTime(schedTaskTO, task);
if (schedTask.getJobDelegate() != null) {
schedTaskTO.setJobDelegate(schedTask.getJobDelegate().getKey());
}
break;
case PULL:
PullTask pullTask = (PullTask) task;
PullTaskTO pullTaskTO = (PullTaskTO) taskTO;
setExecTime(pullTaskTO, task);
pullTaskTO.setDestinationRealm(pullTask.getDestinatioRealm().getFullPath());
pullTaskTO.setResource(pullTask.getResource().getKey());
pullTaskTO.setMatchingRule(pullTask.getMatchingRule() == null ? MatchingRule.UPDATE : pullTask.getMatchingRule());
pullTaskTO.setUnmatchingRule(pullTask.getUnmatchingRule() == null ? UnmatchingRule.PROVISION : pullTask.getUnmatchingRule());
if (pullTask.getReconFilterBuilder() != null) {
pullTaskTO.setReconFilterBuilder(pullTask.getReconFilterBuilder().getKey());
}
pullTaskTO.getActions().addAll(pullTask.getActions().stream().map(Entity::getKey).collect(Collectors.toList()));
pullTask.getTemplates().forEach(template -> {
pullTaskTO.getTemplates().put(template.getAnyType().getKey(), template.get());
});
pullTaskTO.setRemediation(pullTask.isRemediation());
break;
case PUSH:
PushTask pushTask = (PushTask) task;
PushTaskTO pushTaskTO = (PushTaskTO) taskTO;
setExecTime(pushTaskTO, task);
pushTaskTO.setSourceRealm(pushTask.getSourceRealm().getFullPath());
pushTaskTO.setResource(pushTask.getResource().getKey());
pushTaskTO.setMatchingRule(pushTask.getMatchingRule() == null ? MatchingRule.LINK : pushTask.getMatchingRule());
pushTaskTO.setUnmatchingRule(pushTask.getUnmatchingRule() == null ? UnmatchingRule.ASSIGN : pushTask.getUnmatchingRule());
pushTaskTO.getActions().addAll(pushTask.getActions().stream().map(Entity::getKey).collect(Collectors.toList()));
pushTask.getFilters().forEach(filter -> {
pushTaskTO.getFilters().put(filter.getAnyType().getKey(), filter.getFIQLCond());
});
break;
case NOTIFICATION:
NotificationTask notificationTask = (NotificationTask) task;
NotificationTaskTO notificationTaskTO = (NotificationTaskTO) taskTO;
notificationTaskTO.setNotification(notificationTask.getNotification().getKey());
notificationTaskTO.setAnyTypeKind(notificationTask.getAnyTypeKind());
notificationTaskTO.setEntityKey(notificationTask.getEntityKey());
if (notificationTask.isExecuted() && StringUtils.isBlank(taskTO.getLatestExecStatus())) {
taskTO.setLatestExecStatus("[EXECUTED]");
}
break;
default:
}
return taskTO;
}
Aggregations