use of uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator15 in project Gaffer by gchq.
the class LoadAndQuery15 method run.
public CloseableIterable<?> run() throws OperationException {
// [user] Create a user
// ---------------------------------------------------------
final User user = new User("user01");
// ---------------------------------------------------------
// [graph] create a graph using our schema and store properties
// ---------------------------------------------------------
final Graph graph = new Graph.Builder().addSchemas(getSchemas()).storeProperties(getStoreProperties()).build();
// ---------------------------------------------------------
// [add] add the edges to the graph
// ---------------------------------------------------------
final OperationChain addOpChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().generator(new DataGenerator15()).objects(DataUtils.loadData(getData())).build()).then(new AddElements()).build();
graph.execute(addOpChain, user);
// ---------------------------------------------------------
// [job] create an operation chain to be executed as a job
// ---------------------------------------------------------
final OperationChain<CloseableIterable<Edge>> job = new OperationChain.Builder().first(new GetEdges.Builder<EntitySeed>().addSeed(new EntitySeed("1")).build()).build();
// ---------------------------------------------------------
// [execute job] execute the job
// ---------------------------------------------------------
final JobDetail initialJobDetail = graph.executeJob(job, user);
final String jobId = initialJobDetail.getJobId();
// ---------------------------------------------------------
log("JOB_DETAIL_START", initialJobDetail.toString());
waitUntilJobHashFinished(user, graph, initialJobDetail);
// [job details] Get the job details
// ---------------------------------------------------------
final JobDetail jobDetail = graph.execute(new GetJobDetails.Builder().jobId(jobId).build(), user);
// ---------------------------------------------------------
log("JOB_DETAIL_FINISH", jobDetail.toString());
// [all job details] Get all job details
// ---------------------------------------------------------
final CloseableIterable<JobDetail> jobDetails = graph.execute(new GetAllJobDetails(), user);
// ---------------------------------------------------------
for (final JobDetail detail : jobDetails) {
log("ALL_JOB_DETAILS", detail.toString());
}
// [get job results] Get the job results
// ---------------------------------------------------------
final CloseableIterable<?> jobResults = graph.execute(new GetJobResults.Builder().jobId(jobId).build(), user);
// ---------------------------------------------------------
for (final Object result : jobResults) {
log("JOB_RESULTS", result.toString());
}
return jobResults;
}
Aggregations