public static void main(final String[] args) { if (args.length != 4) { System.err.println("Usage: " + RoadTrafficDataLoader.class.getSimpleName() + " <graphConfigFile> <schemaDir> <storePropsFile> <roadTrafficDataFile.csv>"); System.exit(1); } final String graphConfigFile = args[0]; final String schemaDir = args[1]; final String storePropertiesFile = args[2]; final String dataFile = args[3]; final GraphConfig config = new GraphConfig.Builder().json(new File(graphConfigFile).toPath()).build(); final Schema schema = Schema.fromJson(new File(schemaDir).toPath()); final StoreProperties storeProperties = StoreProperties.loadStoreProperties(storePropertiesFile); final Graph graph = new Graph.Builder() .config(config) .addSchemas(schema) .storeProperties(storeProperties) .build(); final User user = new User(); final RoadTrafficDataLoader dataLoader = new RoadTrafficDataLoader(graph, user); LOGGER.info("Loading data"); try { dataLoader.load(new File(dataFile)); LOGGER.info("Data has been loaded"); } catch (final Exception e) { LOGGER.info("Unable to load data: " + e.getMessage()); throw new RuntimeException("Unable to load data", e); } }
protected void runExampleNoResult(final Operation<?, Void> operation) { log("#### " + getMethodNameAsSentence(1) + "\n"); printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----")); printAsJson(operation); printOperationClass(operation); try { getGraph().execute(operation, new User("user01")); } catch (OperationException e) { throw new RuntimeException(e); } log(METHOD_DIVIDER); }
protected void runExampleNoResult(final Operation operation, final String description) { log("#### " + getMethodNameAsSentence(1) + "\n"); if (StringUtils.isNotBlank(description)) { log(description + "\n"); } printMethodJavaSnippet(); printAsJson(operation); try { getGraph().execute(operation, new User("user01")); } catch (final OperationException e) { throw new RuntimeException(e); } log(METHOD_DIVIDER); }
protected <RESULT_TYPE> RESULT_TYPE runExample(final OperationChain<RESULT_TYPE> operationChain) { log("#### " + getMethodNameAsSentence(1) + "\n"); printGraph(); printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----")); printAsJson(operationChain); final RESULT_TYPE result; try { result = getGraph().execute( operationChain, new User("user01")); } catch (OperationException e) { throw new RuntimeException(e); } logResult(result); log(METHOD_DIVIDER); return result; }
protected <RESULT_TYPE> RESULT_TYPE runExample(final Operation<?, RESULT_TYPE> operation) { log("#### " + getMethodNameAsSentence(1) + "\n"); printGraph(); printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----")); printAsJson(operation); printOperationClass(operation); final RESULT_TYPE results; try { results = getGraph().execute( operation, new User("user01")); } catch (OperationException e) { throw new RuntimeException(e); } logResult(results); log(METHOD_DIVIDER); return results; }
protected <RESULT_TYPE> RESULT_TYPE runExample( final Output<RESULT_TYPE> operation, final String description) { log("#### " + getMethodNameAsSentence(1) + "\n"); if (StringUtils.isNotBlank(description)) { log(description + "\n"); } printGraph(); printMethodJavaSnippet(); printAsJson(operation); final RESULT_TYPE results; try { results = getGraph().execute( operation, new User("user01")); } catch (final OperationException e) { throw new RuntimeException(e); } logResult(results); log(METHOD_DIVIDER); return results; }
.skipInvalidElements(skipInvalid) .build(), new Context(new User())); restart = true; } catch (final OperationException e) {
protected <RESULT_TYPE> RESULT_TYPE runExample( final OperationChain<RESULT_TYPE> operationChain, final String description) { log("#### " + getMethodNameAsSentence(1) + "\n"); if (StringUtils.isNotBlank(description)) { log(description); } printGraph(); printMethodJavaSnippet(); printAsJson(operationChain); final RESULT_TYPE result; try { result = getGraph().execute( operationChain, new User("user01")); } catch (final OperationException e) { throw new RuntimeException(e); } logResult(result); log(METHOD_DIVIDER); return result; }
graph.execute(addOpChain, new User()); } catch (final OperationException e) { throw new RuntimeException(e);
@Override public void runExamples() { try { final OperationChain<JobDetail> opChain = new OperationChain.Builder() .first(new GetAllEdges()) .then(new ExportToGafferResultCache()) .then(new GetJobDetails()) .build(); final JobDetail jobDetails = getGraph().execute(opChain, new User("user01")); jobId = jobDetails.getJobId(); } catch (final OperationException e) { throw new RuntimeException(e); } getJobResults(); }
.build(); graph.execute(operation, new User());
protected Graph createExampleGraph() { final Graph graph = new Graph.Builder() .addSchemas(StreamUtil.openStreams(getClass(), "/example/operation/schema")) .storeProperties(StreamUtil.openStream(getClass(), "/example/operation/mockaccumulostore.properties")) .build(); // Create data generator final DataGenerator dataGenerator = new DataGenerator(); // Load data into memory final List<String> data = DataUtils.loadData(StreamUtil.openStream(getClass(), "/example/operation/data.txt", true)); //add the edges to the graph using an operation chain consisting of: //generateElements - generating edges from the data (note these are directed edges) //addElements - add the edges to the graph final OperationChain addOpChain = new OperationChain.Builder() .first(new GenerateElements.Builder<String>() .generator(dataGenerator) .objects(data) .build()) .then(new AddElements()) .build(); try { graph.execute(addOpChain, new User()); } catch (OperationException e) { throw new RuntimeException(e); } return graph; }
@Override public void runExamples() { try { final OperationChain<JobDetail> opChain = new OperationChain.Builder() .first(new GetAllElements()) .then(new ExportToGafferResultCache<>()) .then(new DiscardOutput()) .then(new GetJobDetails()) .build(); final JobDetail jobDetails = getGraph().execute(opChain, new User("user01")); jobId = jobDetails.getJobId(); } catch (final OperationException e) { throw new RuntimeException(e); } getJobResults(); }
final User user = new User("user01");
final User user = new User("user01");
public CloseableIterable<Edge> run() throws OperationException { final User user = new User("user01");
public Iterable<Entity> run() throws OperationException { final User user = new User("user01");
final User user = new User("user01");
printOperationClass(operation); getGraph().execute(operation, new User("user01"));
printAsJson(operation); getGraph().execute(operation, new User("user01"));