-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathannotation.py
More file actions
91 lines (74 loc) · 2.84 KB
/
Copy pathannotation.py
File metadata and controls
91 lines (74 loc) · 2.84 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Glencoe Software, Inc. All rights reserved.
#
# This software is distributed under the terms described by the LICENCE file
# you can find at the root of the distribution bundle.
# If the file is missing please request a copy by contacting
# jason@glencoesoftware.com.
#
from ... import SCHEMA_VERSION
from .. import Encoder
from omero.model import Annotation
class Annotation201501Encoder(Encoder):
'''
Annotation
BasicAnnotation
BooleanAnnotation
BooleanAnnotationI
NumericAnnotation
DoubleAnnotation
DoubleAnnotationI
LongAnnotation
LongAnnotationI
TermAnnotation
TermAnnotationI
TimestampAnnotation
TimestampAnnotationI
ListAnnotation
ListAnnotationI
MapAnnotation
MapAnnotationI
TextAnnotation
CommentAnnotation
CommentAnnotationI
TagAnnotation
TagAnnotationI
XmlAnnotation
XmlAnnotationI
TypeAnnotation
FileAnnotation
FileAnnotationI
'''
TYPE = 'http://www.openmicroscopy.org/Schemas/SA/2015-01#Annotation'
def encode(self, obj, include_context=None):
v = super(Annotation201501Encoder, self).encode(obj, include_context)
self.set_if_not_none(v, 'Description', obj.description)
self.set_if_not_none(v, 'Namespace', obj.ns)
return v
class Annotation201606Encoder(Annotation201501Encoder):
TYPE = 'http://www.openmicroscopy.org/Schemas/OME/2016-06#Annotation'
class Annotatable201501Encoder(Encoder):
TYPE = 'http://www.openmicroscopy.org/Schemas/SA/2015-01#AnnotationRef'
def encode(self, obj, include_context=None):
v = super(Annotatable201501Encoder, self).encode(obj, include_context)
if obj.isAnnotationLinksLoaded() and obj.sizeOfAnnotationLinks() > 0:
annotations = list()
for annotation_link in obj.copyAnnotationLinks():
annotation = annotation_link.child
annotation_encoder = self.ctx.get_encoder(annotation.__class__)
annotations.append(
annotation_encoder.encode(annotation, False)
)
v['Annotations'] = annotations
return v
class Annotatable201606Encoder(Annotatable201501Encoder):
TYPE = 'http://www.openmicroscopy.org/Schemas/OME/2016-06#AnnotationRef'
if SCHEMA_VERSION == '2015-01':
encoder = (Annotation, Annotation201501Encoder)
AnnotatableEncoder = Annotatable201501Encoder
elif SCHEMA_VERSION == '2016-06':
encoder = (Annotation, Annotation201606Encoder)
AnnotatableEncoder = Annotatable201606Encoder
AnnotationEncoder = encoder[1]