1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.commands;
21
22 import com.tinkerpop.blueprints.Graph;
23 import com.tinkerpop.frames.FramedGraph;
24 import eu.ehri.project.core.impl.Neo4jGraphManager;
25 import eu.ehri.project.core.impl.neo4j.Neo4j2Graph;
26 import org.apache.commons.cli.CommandLine;
27
28
29
30
31 public class GenSchema extends BaseCommand {
32
33 final static String NAME = "gen-schema";
34
35 @Override
36 public String getUsage() {
37 return NAME;
38 }
39
40 @Override
41 public String getHelp() {
42 return "Drop and regenerate the (internal) graph schema and indices.";
43 }
44
45
46 @Override
47 public int execWithOptions(FramedGraph<?> graph, CommandLine cmdLine) throws Exception {
48 Graph baseGraph = graph.getBaseGraph();
49 if (baseGraph instanceof Neo4j2Graph) {
50 Neo4jGraphManager.createIndicesAndConstraints(
51 ((Neo4j2Graph) baseGraph).getRawGraph());
52 } else {
53 logger.warn("Cannot generate schema on a non-Neo4j2 graph");
54 }
55 return 0;
56 }
57 }