forked from nulpunt/nulpunt
/
schema.go
135 lines (119 loc) · 5.27 KB
/
schema.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// DB-types.go
// This file contains the definitive mapping between Go structs and Mongo document field names.
// It's called schema in relational parlance.
package main
import (
"labix.org/v2/mgo/bson"
"time"
)
// Account holds information about an account.
// It should not keep data in-memory, but rather write to db directly.
// This type should just be a good wrapper for db read/write functionality
type Account struct {
ID bson.ObjectId `bson:"_id"`
Username string `bson:"username"`
Admin bool `bson:"admin"`
Color string `bson:"color"` // read out what was created in AccountDetail (at signup)
}
// Account Details for password authentication.
type AccountDetail struct {
ID bson.ObjectId `bson:"_id"`
Username string `bson:"username"`
Email string `bson:"email"`
Color string `bson:"color"` // Set up here, read out from the db in Account
Hash []byte `bson:"hash"`
Salt []byte `bson:"salt"`
N int `bson:"n"` // Parameters for the PBKDF2 hashing.
R int `bson:"r"` // Parameters for the PBKDF2 hashing.
P int `bson:"p"` // Parameters for the PBKDF2 hashing.
Remarks string `bson:"remarks"` // field for admin remarks about accounts.
}
// type Profile holds the profile properties
type Profile struct {
ID bson.ObjectId `bson:"_id"`
Username string `bson:"username"`
Tags []string `bson:"tags"` // contains tag.Tag
PublicName string `bson:"publicName"`
Website string `bson:"website"`
Bio string `bson:"bio"`
Location string `bson:"location"`
}
// type Bookmark holds the users preferred documents
type Bookmark struct {
ID bson.ObjectId `bson:"_id"`
Username string `bson:"username"`
DocumentIDs []bson.ObjectId `bson:"documentIds"`
}
// type Document holds the document properties
type Document struct {
ID bson.ObjectId `bson:"_id"`
UploaderUsername string `bson:"uploaderUsername"`
UploadFilename string `bson:"uploadFilename"` // original PDF filename.
UploadGridFilename string `bson:"uploadGridFilename"` // Filename into GridFS
UploadDate time.Time `bson:"uploadDate"`
Language string `bson:"language"`
PageCount int `bson:"pageCount"`
AnalyseState string `bson:"analyseState"`
Title string `bson:"title"`
Summary string `bson:"summary"`
Category string `bson:"category"`
Tags []string `bson:"tags"` // contains tag.Tag
FOIRequester string `bson:"foiRequester"`
FOIARequest string `bson:"foiaRequest"`
OriginalDate time.Time `bson:"orginalDate"`
Source string `bson:"source"`
Country string `bson:"country"`
Published bool `bson:"published"`
Score float32 `bson:"score"`
}
// type Tag hold the document classification tags
// Note: tags have an ObjectId, these are not for referencing in other collections.
// Just insert the tag-string into other collections where needed.
// Tag: The tag as seen on the site.
type Tag struct {
ID bson.ObjectId `bson:"_id"`
Tag string `bson:"tag"`
}
type Page struct {
ID bson.ObjectId `bson:"_id"`
DocumentID bson.ObjectId `bson:"documentId"` // refers to `documents._id`)
PageNumber uint `bson:"pageNumber"` // page number
Lines [][]PageChar `bson:"lines"`
Text string `bson:"text"` // the text in the same order as the lines-attribute, use for search/sharing. Contains ocr-errors
HighresWidth int `bson:"highresWidth"`
HighresHeight int `bson:"highresHeight"`
}
type PageChar struct {
X1 float32 `bson:"x1"` // in percentage relative to the image
Y1 float32 `bson:"y1"` // in percentage relative to the image
X2 float32 `bson:"x2"` // in percentage relative to the image
Y2 float32 `bson:"y2"` // in percentage relative to the image
C string `bson:"c"`
}
// type Annotation hold the document annotations
type Annotation struct {
ID bson.ObjectId `bson:"_id"`
DocumentID bson.ObjectId `bson:"documentId"` // to which document belong these annotations.
AnnotatorUsername string `bson:"annotatorUsername"`
Color string `bson:"color"`
CreateDate time.Time `bson:"createDate"`
AnnotationText string `bson:"annotationText"`
Locations []Location `bson:"locations"`
CropId bson.ObjectId `bson:"cropId"` // ID in GridFS of the cropped image
Comments []Comment `bson:"comments"`
}
type Location struct {
PageNumber int `bson:"pageNumber"`
X1 float32 `bson:"x1"` // in percentage relative to the image
Y1 float32 `bson:"y1"` // in percentage relative to the image
X2 float32 `bson:"x2"` // in percentage relative to the image
Y2 float32 `bson:"y2"` // in percentage relative to the image
}
type Comment struct {
ID bson.ObjectId `bson:"_id"`
CommenterUsername string `bson:"commenterUsername"`
Color string `bson:"color"`
CreateDate time.Time `bson:"createDate"`
CommentText string `bson:"commentText"`
Comments []Comment `bson:"comments"`
}