use of org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo in project jbpm by kiegroup.
the class DefaultExecutionErrorStorage method store.
@Override
public ExecutionError store(ExecutionError error) {
if (!isActive()) {
return error;
}
return call((EntityManager em) -> {
ExecutionErrorInfo errorEntity = new ExecutionErrorInfo(error.getErrorId(), error.getType(), error.getDeploymentId(), error.getProcessInstanceId(), error.getProcessId(), error.getActivityId(), error.getActivityName(), error.getJobId(), error.getErrorMessage(), error.getError(), error.getErrorDate(), error.getInitActivityId());
em.persist(errorEntity);
return error;
});
}
use of org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo in project jbpm by kiegroup.
the class AutoAckErrorCommand method execute.
@Override
public ExecutionResults execute(CommandContext ctx) throws Exception {
ExecutionResults executionResults = new ExecutionResults();
String emfName = (String) ctx.getData("EmfName");
if (emfName == null) {
emfName = "org.jbpm.domain";
}
String singleRun = (String) ctx.getData("SingleRun");
if ("true".equalsIgnoreCase(singleRun)) {
// disable rescheduling
this.nextScheduleTimeAdd = -1;
}
String nextRun = (String) ctx.getData("NextRun");
if (nextRun != null) {
nextScheduleTimeAdd = DateTimeUtils.parseDateAsDuration(nextRun);
}
// get hold of persistence and create instance of audit service
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(emfName);
EntityManager em = emf.createEntityManager();
try {
List<ExecutionErrorInfo> errorsToAck = findErrorsToAck(em);
logger.debug("Found {} jobs that can be auto ack", errorsToAck.size());
errorsToAck.forEach(error -> {
AbstractRuntimeManager manager = (AbstractRuntimeManager) RuntimeManagerRegistry.get().getManager(error.getDeploymentId());
if (manager != null) {
ExecutionErrorManager errorManager = manager.getExecutionErrorManager();
errorManager.getStorage().acknowledge("SYSTEM", error.getErrorId());
logger.debug("Error {} has been auto acknowledged by system based on {}", error.getErrorId(), getAckRule());
} else {
logger.warn("Unable to ack error {} due missing runtime manager for '{}'", error.getErrorId(), error.getDeploymentId());
}
});
} finally {
em.close();
}
return executionResults;
}
Aggregations