-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeoLoader.groovy
More file actions
101 lines (89 loc) · 3.14 KB
/
NeoLoader.groovy
File metadata and controls
101 lines (89 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Groovy CLI script that creates a Neo4j Graph representation of an LDAP Source.
* The resulting Graph contains 2 types of nodes:
* - Users
* - Groups
*
* The relationships between the nodes can me modelled as follows:
* - User --[MEMBER_OF] --> Group
* - Group --[CHILD_OF] --> Group
* - Group --[USED_WITH] --> Group
*
* The latter relationship ("USED_WITH") additionally holds a 'weight' attribute, which simply counts the number
* of times the related groups have been used together.
*
* To run:
* =======
* groovy -cp <path/to>/LdapGraphLoader.jar:runtime/* NeoLoader.groovy
* e.g.,
* groovy -Djava.util.logging.config.file=resources/logging.properties -cp build/libs/LdapGraphLoader-0.0.1-SNAPSHOT.jar:runtime/* NeoLoader.groovy
*
* 3Edges - March 2015
* Created by ababeanu on 2015-03-10.
*/
import com.threeedges.analyzer.neoloader.LoaderProcessor
import com.threeedges.analyzer.neoloader.config.LdapConfiguration;
import com.threeedges.analyzer.neoloader.config.NeoConfiguration;
import groovy.cli.commons.*;
// Command Line Builder
def cli = new CliBuilder(usage:'NeoLoader.groovy [-l <ldap Config File>] [-n <neo4j config file>] [-h]', width:80 );
// CLI options
cli.with {
h longOpt: 'help', ('Show Usage Information')
l longOpt: 'ldap-cfg-file', args: 1, argName: 'LDAP Config File', 'Configuration file that holds the LDAP connectivity config.'
n longOpt: 'neo4j-cfg-file', args: 1, argName: 'Neo4J Config File', 'Configuration file that holds the Neo4J connectivity config.'
}
def options = cli.parse(args)
if (options.h) {
// Help: usage
cli.usage()
return
}
def LdapCfg;
def NeoCfg;
/*
Load LDAP Config
*/
if ( options.l ) {
try {
LdapCfg = new LdapConfiguration((String) options.l);
} catch (FileNotFoundException fnf) {
System.err.println('The provided LDAP Config File name is invalid, please try again.');
return;
}
System.out.println 'Using LDAP Config: ' + options.l + '...';
} else {
// Use default config file
try {
LdapCfg = new LdapConfiguration();
} catch (FileNotFoundException fnf) {
System.err.println('No LDAP Config File name provided and can\'t find the default one. Please supply a valid configuration file and try again.');
return;
}
System.out.println 'Using default LDAP Config ...';
}
/*
Load NEO4J Config
*/
if ( options.n ) {
try {
NeoCfg = new NeoConfiguration((String) options.n);
} catch (FileNotFoundException fnf) {
System.err.println('The provided Neo4J Config File name is invalid, please try again.');
return;
}
System.out.println 'Using Neo4J Config: ' + options.n + '...';
} else {
// Use default config file
try {
NeoCfg = new NeoConfiguration();
} catch (FileNotFoundException fnf) {
System.err.println('No Neo4J Config File name provided and can\'t find the default one. Please supply a valid configuration file and try again.');
return;
}
System.out.println 'Using default Neo4J Config ...';
}
// Trigger Loader Processor
// TODO
def Loader = new LoaderProcessor(LdapCfg, NeoCfg);
Loader.orchestrateLoad();