@Test public void testExecuteCypherQueryNegative() { String cypherQuery = "MATCH (n:ALM) where not exists (n.processed) with n limit 100 set n.processed=true return n"; DataEnrichmentModel model = new DataEnrichmentModel(); Boolean resultFlag = executor.executeCypherQuery(cypherQuery, model); assertFalse(resultFlag); }
public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (processedRecords > 0) { GraphResponse sprintResponse = dbHandler.executeCypherQuery(cypherQuery); JsonObject sprintResponseJson = sprintResponse.getJson(); try { processedRecords = sprintResponseJson.getAsJsonArray("results").get(0).getAsJsonObject() .getAsJsonArray("data").get(0).getAsJsonObject().getAsJsonArray("row").get(0).getAsInt(); } catch (UnsupportedOperationException | IllegalStateException | IndexOutOfBoundsException ex) { log.error(cypherQuery + " - query processing failed", ex); return Boolean.FALSE; } log.debug(" Processed " + processedRecords); recordCount = recordCount + processedRecords; } long queryExecutionEndTime = System.currentTimeMillis(); long queryProcessingTime = (queryExecutionEndTime - queryExecutionStartTime); if (dataEnrichmentModel != null) { dataEnrichmentModel.setRecordsProcessed(recordCount); dataEnrichmentModel.setQueryProcessingTime(queryProcessingTime); } } catch (InsightsCustomException e) { log.error(cypherQuery + " - query processing failed", e); return Boolean.FALSE; } return Boolean.TRUE; }
OfflineDataProcessingExecutor extends TimerTask { public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (processedRecords > 0) { GraphResponse sprintResponse = dbHandler.executeCypherQuery(cypherQuery); JsonObject sprintResponseJson = sprintResponse.getJson(); try { processedRecords = sprintResponseJson.getAsJsonArray("results").get(0).getAsJsonObject() .getAsJsonArray("data").get(0).getAsJsonObject().getAsJsonArray("row").get(0).getAsInt(); } catch (UnsupportedOperationException | IllegalStateException | IndexOutOfBoundsException ex) { log.error(cypherQuery + " - query processing failed", ex); return Boolean.FALSE; } log.debug(" Processed " + processedRecords); recordCount = recordCount + processedRecords; } long queryExecutionEndTime = System.currentTimeMillis(); long queryProcessingTime = (queryExecutionEndTime - queryExecutionStartTime); if (dataEnrichmentModel != null) { dataEnrichmentModel.setRecordsProcessed(recordCount); dataEnrichmentModel.setQueryProcessingTime(queryProcessingTime); } } catch (InsightsCustomException e) { log.error(cypherQuery + " - query processing failed", e); return Boolean.FALSE; } return Boolean.TRUE; } }
OfflineDataProcessingExecutor extends TimerTask { public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (processedRecords > 0) { GraphResponse sprintResponse = dbHandler.executeCypherQuery(cypherQuery); JsonObject sprintResponseJson = sprintResponse.getJson(); try { processedRecords = sprintResponseJson.getAsJsonArray("results").get(0).getAsJsonObject() .getAsJsonArray("data").get(0).getAsJsonObject().getAsJsonArray("row").get(0).getAsInt(); } catch (UnsupportedOperationException | IllegalStateException | IndexOutOfBoundsException ex) { log.error(cypherQuery + " - query processing failed", ex); return Boolean.FALSE; } log.debug(" Processed " + processedRecords); recordCount = recordCount + processedRecords; } long queryExecutionEndTime = System.currentTimeMillis(); long queryProcessingTime = (queryExecutionEndTime - queryExecutionStartTime); if (dataEnrichmentModel != null) { dataEnrichmentModel.setRecordsProcessed(recordCount); dataEnrichmentModel.setQueryProcessingTime(queryProcessingTime); } } catch (InsightsCustomException e) { log.error(cypherQuery + " - query processing failed", e); return Boolean.FALSE; } return Boolean.TRUE; }  }
OfflineDataProcessingExecutor extends TimerTask { public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (processedRecords > 0) { GraphResponse sprintResponse = dbHandler.executeCypherQuery(cypherQuery); JsonObject sprintResponseJson = sprintResponse.getJson(); try { processedRecords = sprintResponseJson.getAsJsonArray("results").get(0).getAsJsonObject() .getAsJsonArray("data").get(0).getAsJsonObject().getAsJsonArray("row").get(0).getAsInt(); } catch (UnsupportedOperationException | IllegalStateException | IndexOutOfBoundsException ex) { log.error(cypherQuery + " - query processing failed", ex); return Boolean.FALSE; } log.debug(" Processed " + processedRecords); recordCount = recordCount + processedRecords; } long queryExecutionEndTime = System.currentTimeMillis(); long queryProcessingTime = (queryExecutionEndTime - queryExecutionStartTime); if (dataEnrichmentModel != null) { dataEnrichmentModel.setRecordsProcessed(recordCount); dataEnrichmentModel.setQueryProcessingTime(queryProcessingTime); } } catch (InsightsCustomException e) { log.error(cypherQuery + " - query processing failed", e); return Boolean.FALSE; } return Boolean.TRUE; }  @Override void run(); int executeOfflineProcessing(); Boolean hasJsonFileExtension(String fileName); Boolean processOfflineConfiguration(File jsonFile); DataEnrichmentModel updateLastExecutionTime(DataEnrichmentModel dataEnrichmentModel); Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel); Boolean isQueryScheduledToRun(Long runSchedule, String lastRunTime, String cronSchedule); }
OfflineDataProcessingExecutor extends TimerTask { public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (processedRecords > 0) { GraphResponse sprintResponse = dbHandler.executeCypherQuery(cypherQuery); JsonObject sprintResponseJson = sprintResponse.getJson(); try { processedRecords = sprintResponseJson.getAsJsonArray("results").get(0).getAsJsonObject() .getAsJsonArray("data").get(0).getAsJsonObject().getAsJsonArray("row").get(0).getAsInt(); } catch (UnsupportedOperationException | IllegalStateException | IndexOutOfBoundsException ex) { log.error(cypherQuery + " - query processing failed", ex); return Boolean.FALSE; } log.debug(" Processed " + processedRecords); recordCount = recordCount + processedRecords; } long queryExecutionEndTime = System.currentTimeMillis(); long queryProcessingTime = (queryExecutionEndTime - queryExecutionStartTime); if (dataEnrichmentModel != null) { dataEnrichmentModel.setRecordsProcessed(recordCount); dataEnrichmentModel.setQueryProcessingTime(queryProcessingTime); } } catch (InsightsCustomException e) { log.error(cypherQuery + " - query processing failed", e); return Boolean.FALSE; } return Boolean.TRUE; }  @Override void run(); int executeOfflineProcessing(); Boolean hasJsonFileExtension(String fileName); Boolean processOfflineConfiguration(File jsonFile); DataEnrichmentModel updateLastExecutionTime(DataEnrichmentModel dataEnrichmentModel); Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel); Boolean isQueryScheduledToRun(Long runSchedule, String lastRunTime, String cronSchedule);  }