@Override public void contextInitialized( ServletContextEvent event ) { WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext( event .getServletContext() ); StartupRoutineExecutor startupRoutineExecutor = (StartupRoutineExecutor) applicationContext .getBean( StartupRoutineExecutor.ID ); try { startupRoutineExecutor.execute(); } catch ( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); throw new RuntimeException( "Failed to run startup routines: " + ex.getMessage(), ex ); } }
private ImportSummary handleImportError( JobConfiguration jobId, Throwable ex ) { log.error( DebugUtils.getStackTrace( ex ) ); notifier.notify( jobId, NotificationLevel.ERROR, "Process failed: " + ex.getMessage(), true ); return new ImportSummary( ImportStatus.ERROR, "The import process failed: " + ex.getMessage() ); }
/** * Evaluates validation rules for a single organisation unit. This is the * central method in validation rule evaluation. */ @Override @Transactional public void run() { try { runInternal(); } catch ( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); throw ex; } }
@Override public List<RuleEffect> evaluate( ProgramInstance programInstance ) { List<RuleEffect> ruleEffects = new ArrayList<>(); try { ruleEffects = programRuleEngine.evaluateEnrollment( programInstance ); } catch( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); log.error( DebugUtils.getStackTrace( ex.getCause() ) ); } for ( RuleEffect effect : ruleEffects ) { ruleActionImplementers.stream().filter( i -> i.accept( effect.ruleAction() ) ).forEach( i -> { log.info( String.format( "Invoking action implementer: %s", i.getClass().getSimpleName() ) ); i.implement( effect, programInstance ); } ); } return ruleEffects; }
@Override public List<RuleEffect> evaluate( ProgramStageInstance programStageInstance ) { List<RuleEffect> ruleEffects = new ArrayList<>(); try { ruleEffects = programRuleEngine.evaluateEvent( programStageInstance ); } catch( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); log.error( DebugUtils.getStackTrace( ex.getCause() ) ); } for ( RuleEffect effect : ruleEffects ) { ruleActionImplementers.stream().filter( i -> i.accept( effect.ruleAction() ) ).forEach( i -> { log.info( String.format( "Invoking action implementer: %s", i.getClass().getSimpleName() ) ); i.implement( effect, programStageInstance ); } ); } return ruleEffects; } }
/** * Return string value of boolean output. False will be returned in case * of wrongly created expression * * @param expression to be evaluated. * @return string value of boolean true/false. */ @Nonnull @Override public String evaluate( @Nonnull String expression ) { String result = ""; try { result = ExpressionUtils.evaluate( expression ).toString(); } catch ( JexlException je ) { result = "false"; log.debug( DebugUtils.getStackTrace( je.getCause() ) ); } return result; } }
@Override @Transactional public ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions, JobConfiguration id ) { try { in = StreamUtils.wrapAndCheckCompressionFormat( in ); return saveDataValueSetInternal( in, importOptions, id ); } catch ( IOException ex ) { log.warn( "Import failed: " + DebugUtils.getStackTrace( ex ) ); return new ImportSummary( ImportStatus.ERROR, "ADX import failed" ); } }
private void internalExecuteJobConfiguration( JobConfiguration jobConfiguration ) { JobInstance jobInstance = new DefaultJobInstance(); ListenableFuture<?> future = jobExecutor.submitListenable( () -> { try { jobInstance.execute( jobConfiguration, this, messageService, leaderManager ); } catch ( Exception e ) { log.error( DebugUtils.getStackTrace( e ) ); } } ); currentTasks.put( jobConfiguration.getUid(), future ); log.info( "Scheduler initiated execution of job: " + jobConfiguration ); }
@Override public ImportSummary saveDataValueSetPdf( InputStream in, ImportOptions importOptions, JobConfiguration id ) { try { DataValueSet dataValueSet = PdfDataEntryFormUtil.getDataValueSet( in ); return saveDataValueSet( importOptions, id, dataValueSet ); } catch ( RuntimeException ex ) { log.error( DebugUtils.getStackTrace( ex ) ); notifier.clear( id ).notify( id, ERROR, "Process failed: " + ex.getMessage(), true ); return new ImportSummary( ImportStatus.ERROR, "The import process failed: " + ex.getMessage() ); } }
@Override public ImportSummary saveDataValueSetJson( InputStream in, ImportOptions importOptions, JobConfiguration id ) { try { in = StreamUtils.wrapAndCheckCompressionFormat( in ); DataValueSet dataValueSet = DefaultRenderService.getJsonMapper().readValue( in, DataValueSet.class ); return saveDataValueSet( importOptions, id, dataValueSet ); } catch ( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); notifier.notify( id, ERROR, "Process failed: " + ex.getMessage(), true ); return new ImportSummary( ImportStatus.ERROR, "The import process failed: " + ex.getMessage() ); } }
@Override public int sendSystemErrorNotification( String subject, Throwable t ) { String title = (String) systemSettingManager.getSystemSetting( SettingKey.APPLICATION_TITLE ); String baseUrl = (String) systemSettingManager.getSystemSetting( SettingKey.INSTANCE_BASE_URL ); String text = new StringBuilder() .append( subject + LN + LN ) .append( "System title: " + title + LN ) .append( "Base URL: " + baseUrl + LN ) .append( "Time: " + new DateTime().toString() + LN ) .append( "Message: " + t.getMessage() + LN + LN ) .append( "Cause: " + DebugUtils.getStackTrace( t.getCause() ) ).toString(); MessageConversationParams params = new MessageConversationParams.Builder() .withRecipients( getFeedbackRecipients() ) .withSubject( subject ) .withText( text ) .withMessageType( MessageType.SYSTEM ).build(); return sendMessage( params ); }
log.error( DebugUtils.getStackTrace( e ) ); log.error( DebugUtils.getStackTrace( e.getCause() ) );
@Override public ImportSummary saveDataValueSet( InputStream in, ImportOptions importOptions, JobConfiguration id ) { try { in = StreamUtils.wrapAndCheckCompressionFormat( in ); DataValueSet dataValueSet = new StreamingXmlDataValueSet( XMLFactory.getXMLReader( in ) ); return saveDataValueSet( importOptions, id, dataValueSet ); } catch ( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); notifier.notify( id, ERROR, "Process failed: " + ex.getMessage(), true ); return new ImportSummary( ImportStatus.ERROR, "The import process failed: " + ex.getMessage() ); } }
@Override public ImportSummary saveDataValueSetCsv( InputStream in, ImportOptions importOptions, JobConfiguration id ) { try { in = StreamUtils.wrapAndCheckCompressionFormat( in ); DataValueSet dataValueSet = new StreamingCsvDataValueSet( new CsvReader( in, Charset.forName( "UTF-8" ) ) ); return saveDataValueSet( importOptions, id, dataValueSet ); } catch ( Exception ex ) { log.error( DebugUtils.getStackTrace( ex ) ); notifier.clear( id ).notify( id, ERROR, "Process failed: " + ex.getMessage(), true ); return new ImportSummary( ImportStatus.ERROR, "The import process failed: " + ex.getMessage() ); } }
log.error( DebugUtils.getStackTrace( e ) ); log.error( DebugUtils.getStackTrace( e.getCause() ) );
DebugUtils.getStackTrace( e );
@Override public void scheduleJobWithStartTime( JobConfiguration jobConfiguration, Date startTime ) { if ( ifJobInSystemStop( jobConfiguration.getUid() ) ) { JobInstance jobInstance = new DefaultJobInstance(); if ( jobConfiguration.getUid() != null && !futures.containsKey( jobConfiguration.getUid() ) ) { ScheduledFuture<?> future = jobScheduler .schedule( () -> { try { jobInstance.execute( jobConfiguration, this, messageService, leaderManager ); } catch ( Exception e ) { log.error( DebugUtils.getStackTrace( e ) ); } }, startTime ); futures.put( jobConfiguration.getUid(), future ); log.info( "Scheduled job: " + jobConfiguration ); } } }
@Override public PredictionSummary predictTask( Date startDate, Date endDate, List<String> predictors, List<String> predictorGroups, JobConfiguration jobId ) { PredictionSummary predictionSummary; try { notifier.notify( jobId, NotificationLevel.INFO, "Making predictions", false ); predictionSummary = predictInternal( startDate, endDate, predictors, predictorGroups ); notifier.update( jobId, NotificationLevel.INFO, "Prediction done", true ) .addJobSummary( jobId, predictionSummary, PredictionSummary.class ); } catch ( RuntimeException ex ) { log.error( DebugUtils.getStackTrace( ex ) ); predictionSummary = new PredictionSummary( PredictionStatus.ERROR, "Predictions failed: " + ex.getMessage() ); notifier.update( jobId, ERROR, predictionSummary.getDescription(), true ); } return predictionSummary; }
@Override public void scheduleJob( JobConfiguration jobConfiguration ) { if ( ifJobInSystemStop( jobConfiguration.getUid() ) ) { JobInstance jobInstance = new DefaultJobInstance(); if ( jobConfiguration.getUid() != null && !futures.containsKey( jobConfiguration.getUid() ) ) { ScheduledFuture<?> future = jobScheduler .schedule( () -> { try { jobInstance.execute( jobConfiguration, this, messageService, leaderManager ); } catch ( Exception e ) { log.error( DebugUtils.getStackTrace( e ) ); } }, new CronTrigger( jobConfiguration.getCronExpression() ) ); futures.put( jobConfiguration.getUid(), future ); log.info( "Scheduled job: " + jobConfiguration ); } } }
log.error( DebugUtils.getStackTrace( ex ) ); log.error( DebugUtils.getStackTrace( ex.getCause() ) );