Date endDate=context.getNextFireTime();
SourceBean request = null;
SourceBean resp = null;
EMFErrorHandler errorHandler = null;
try {
request = new SourceBean("");
resp = new SourceBean("");
} catch (SourceBeanException e1) {
e1.printStackTrace();
}
RequestContainer reqContainer = new RequestContainer();
ResponseContainer resContainer = new ResponseContainer();
reqContainer.setServiceRequest(request);
resContainer.setServiceResponse(resp);
DefaultRequestContext defaultRequestContext = new DefaultRequestContext(
reqContainer, resContainer);
resContainer.setErrorHandler(new EMFErrorHandler());
RequestContainer.setRequestContainer(reqContainer);
ResponseContainer.setResponseContainer(resContainer);
Locale locale = new Locale("it","IT","");
SessionContainer session = new SessionContainer(true);
reqContainer.setSessionContainer(session);
SessionContainer permSession = session.getPermanentContainer();
IEngUserProfile profile =UserProfile.createSchedulerUserProfile();
permSession.setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
errorHandler = defaultRequestContext.getErrorHandler();
reqContainer.setAttribute("model_node_instance", modelInstanceId);
reqContainer.setAttribute("start_date", beginDate);
reqContainer.setAttribute("end_date", endDate);
reqContainer.setAttribute("cascade", cascade);
reqContainer.setAttribute("recalculate_anyway", "true");
SpagoBIKpiInternalEngine engine = new SpagoBIKpiInternalEngine();
try {
engine.execute(reqContainer, resp);
} catch (EMFUserError e) {
logger.error("Error during engine execution", e);
errorHandler.addError(e);
} catch (Exception e) {
logger.error("Error while engine execution", e);
errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR,
100));
}
} catch (Throwable e) {
logger.error("Error while executiong KpiEngineJob", e);