-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (42 loc) · 941 Bytes
/
main.go
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
package main
import (
"log"
"gopkg.in/yaml.v2"
"io/ioutil"
"importer"
"os"
)
func main() {
loadYaml("config.yml", &importer.AppConfig)
loadYaml("emotions.yml", &importer.AppEmotions)
if importer.GetNeo4jConnection() == nil {
os.Exit(1)
}
createConstraints()
importer.ImportData()
}
func loadYaml(file string, container interface{}) {
yamlData, err := ioutil.ReadFile(file)
if err != nil {
log.Fatalf("Cannot load file %s: %s", file, err)
}
err = yaml.Unmarshal(yamlData, container)
if err != nil {
log.Fatalf("Cannot parse YAML: %s", err)
}
}
func createConstraints() {
constrains := map[string]string{
"Track": "id",
"Tag": "name",
"Artist": "id",
"Album": "id",
"Emotion": "name",
}
for label, id := range constrains {
_, err := importer.GetNeo4jConnection().CreateUniqueConstraint(label, id)
if err != nil {
log.Printf("Cannot create constraint %s (%s): %s", label, id, err)
}
}
}