use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.
the class IncidentsTest method testFindFailure2.
@Test
public void testFindFailure2() {
final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Immutables.<IncidentTree>nil())))));
assertFalse(Incidents.findFailure(r));
}
use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.
the class AbstractIncidentService method getIncidentsOfJob.
@Override
public IncidentTree getIncidentsOfJob(long jobId, boolean cascade) throws NotFoundException, IncidentServiceException {
List<Incident> incidents = getIncidentsOfJob(jobId);
List<IncidentTree> childIncidents = new ArrayList<IncidentTree>();
try {
Job job = getServiceRegistry().getJob(jobId);
if (cascade && !"START_WORKFLOW".equals(job.getOperation())) {
childIncidents = getChildIncidents(jobId);
} else if (cascade && "START_WORKFLOW".equals(job.getOperation())) {
for (WorkflowOperationInstance operation : getWorkflowService().getWorkflowById(jobId).getOperations()) {
if (operation.getState().equals(OperationState.INSTANTIATED))
continue;
IncidentTree operationResult = getIncidentsOfJob(operation.getId(), true);
if (hasIncidents(Collections.list(operationResult)))
childIncidents.add(operationResult);
}
}
return new IncidentTreeImpl(incidents, childIncidents);
} catch (NotFoundException ignore) {
// Workflow deleted
return new IncidentTreeImpl(incidents, childIncidents);
} catch (Exception e) {
logger.error("Error loading child jobs of {}: {}", jobId);
throw new IncidentServiceException(e);
}
}
use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.
the class IncidentsTest method testFindFailure3.
@Test
public void testFindFailure3() {
final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.FAILURE), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Immutables.<IncidentTree>nil())))));
assertTrue(Incidents.findFailure(r));
}
use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.
the class IncidentsTest method testFindFailure1.
@Test
public void testFindFailure1() {
final IncidentTree r = new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Immutables.<IncidentTree>list(new IncidentTreeImpl(Immutables.list(mkIncident(Severity.WARNING), mkIncident(Severity.FAILURE)), Immutables.<IncidentTree>nil())))));
assertTrue(Incidents.findFailure(r));
}
use of org.opencastproject.job.api.IncidentTreeImpl in project opencast by opencast.
the class AbstractIncidentService method getChildIncidents.
private List<IncidentTree> getChildIncidents(long jobId) throws NotFoundException, ServiceRegistryException, IncidentServiceException {
List<Job> childJobs = getServiceRegistry().getChildJobs(jobId);
List<IncidentTree> incidentResults = new ArrayList<IncidentTree>();
for (Job childJob : childJobs) {
if (childJob.getParentJobId() != jobId)
continue;
List<Incident> incidentsForJob = getIncidentsOfJob(childJob.getId());
IncidentTree incidentTree = new IncidentTreeImpl(incidentsForJob, getChildIncidents(childJob.getId()));
if (hasIncidents(Collections.list(incidentTree)))
incidentResults.add(incidentTree);
}
return incidentResults;
}
Aggregations