14
14
"""
15
15
from __future__ import absolute_import
16
16
17
+ import csv
17
18
import json
18
19
19
20
from elasticsearch .exceptions import TransportError
25
26
26
27
from annotator .atoi import atoi
27
28
from annotator .annotation import Annotation
29
+ from annotator .elasticsearch import RESULTS_MAX_SIZE
28
30
29
31
store = Blueprint ('store' , __name__ )
30
32
@@ -90,7 +92,7 @@ def root():
90
92
'read' : {
91
93
'method' : 'GET' ,
92
94
'url' : url_for ('.read_annotation' ,
93
- id = ':id' ,
95
+ docid = ':id' ,
94
96
_external = True ),
95
97
'desc' : "Get an existing annotation"
96
98
},
@@ -99,7 +101,7 @@ def root():
99
101
'url' :
100
102
url_for (
101
103
'.update_annotation' ,
102
- id = ':id' ,
104
+ docid = ':id' ,
103
105
_external = True ),
104
106
'query' : {
105
107
'refresh' : {
@@ -113,7 +115,7 @@ def root():
113
115
'delete' : {
114
116
'method' : 'DELETE' ,
115
117
'url' : url_for ('.delete_annotation' ,
116
- id = ':id' ,
118
+ docid = ':id' ,
117
119
_external = True ),
118
120
'desc' : "Delete an annotation"
119
121
}
@@ -173,7 +175,7 @@ def create_annotation():
173
175
refresh = request .args .get ('refresh' ) != 'false'
174
176
annotation .save (refresh = refresh )
175
177
176
- location = url_for ('.read_annotation' , id = annotation ['id' ])
178
+ location = url_for ('.read_annotation' , docid = annotation ['id' ])
177
179
178
180
return jsonify (annotation ), 201 , {'Location' : location }
179
181
else :
@@ -182,9 +184,9 @@ def create_annotation():
182
184
183
185
184
186
# READ
185
- @store .route ('/annotations/<id >' )
186
- def read_annotation (id ):
187
- annotation = g .annotation_class .fetch (id )
187
+ @store .route ('/annotations/<docid >' )
188
+ def read_annotation (docid ):
189
+ annotation = g .annotation_class .fetch (docid )
188
190
if not annotation :
189
191
return jsonify ('Annotation not found!' , status = 404 )
190
192
@@ -196,9 +198,9 @@ def read_annotation(id):
196
198
197
199
198
200
# UPDATE
199
- @store .route ('/annotations/<id >' , methods = ['POST' , 'PUT' ])
200
- def update_annotation (id ):
201
- annotation = g .annotation_class .fetch (id )
201
+ @store .route ('/annotations/<docid >' , methods = ['POST' , 'PUT' ])
202
+ def update_annotation (docid ):
203
+ annotation = g .annotation_class .fetch (docid )
202
204
if not annotation :
203
205
return jsonify ('Annotation not found! No update performed.' ,
204
206
status = 404 )
@@ -209,7 +211,7 @@ def update_annotation(id):
209
211
210
212
if request .json is not None :
211
213
updated = _filter_input (request .json , UPDATE_FILTER_FIELDS )
212
- updated ['id' ] = id # use id from URL, regardless of what arrives in
214
+ updated ['id' ] = docid # use id from URL, regardless of what arrives in
213
215
# JSON payload
214
216
215
217
changing_permissions = (
@@ -238,9 +240,9 @@ def update_annotation(id):
238
240
239
241
240
242
# DELETE
241
- @store .route ('/annotations/<id >' , methods = ['DELETE' ])
242
- def delete_annotation (id ):
243
- annotation = g .annotation_class .fetch (id )
243
+ @store .route ('/annotations/<docid >' , methods = ['DELETE' ])
244
+ def delete_annotation (docid ):
245
+ annotation = g .annotation_class .fetch (docid )
244
246
245
247
if not annotation :
246
248
return jsonify ('Annotation not found. No delete performed.' ,
0 commit comments