-
Notifications
You must be signed in to change notification settings - Fork 24
/
MetadataRetrieve.template
474 lines (436 loc) · 15.3 KB
/
MetadataRetrieve.template
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
{% def indexes_string(indexes) %}${", ".join(map(lambda x: lang.index_string(x),indexes))}{% end %}\
\
{% def index_string(name) %}\
{% choose %}\
{% when name[:2].isupper()%}int ${name}Index{% end %}\
{% otherwise %}int ${name[:1].lower()}${name[1:]}Index{% end %}\
{% end %}\
{% end %}\
\
{% def getter(parent, obj, prop, indexes) %}\
{% choose %}\
{% when len(indexes) > 0 and prop.maxOccurs > 1 %}\
{% if debug %}\
// MARKER [A-GET]
{% end debug %}\
/**
* Get the ${prop.name} property of ${o.name}.
*
{% for param in indexes %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @param ${lang.index_signature(prop.name, 0, 0)['argname']} ${prop.name} index.
* @return the ${prop.name} property.
*/
${prop.metadataStoreRetType} get{% if is_multi_path[o.name] %}${parent}{% end %}${obj.name}{% if not prop.hasBaseAttribute %}${prop.name}{% end %}(${indexes_string(indexes)}, ${index_string(prop.name)});\
{% end %}\
{% when len(indexes) > 0 %}\
{% if debug %}\
// MARKER [B-GET]
{% end debug %}\
/**
* Get the ${prop.name} property of ${o.name}.
*
{% for param in indexes %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @return the ${prop.name} property.
*/
${prop.metadataStoreRetType} get{% if is_multi_path[o.name] %}${parent}{% end %}${obj.name}{% if not prop.hasBaseAttribute %}${prop.name}{% end %}(${indexes_string(indexes)});\
{% end %}\
{% otherwise %}\
{% if debug %}\
// MARKER [C-GET]
{% end debug %}\
/**
* Get the ${prop.name} property of ${o.name}.
*
* @return the ${prop.name} property.
*/
${prop.metadataStoreRetType} get{% if is_multi_path[o.name] %}${parent}{% end %}${obj.name}{% if not prop.hasBaseAttribute %}${prop.name}{% end %}();\
{% end %}\
{% end %}\
{% end %}\
\
{% python
def is_abstract(name):
o = model.getObjectByName(name)
if o is not None and \
(o.isAbstract):
return True
return False
def sorted_properties(o):
return sorted(o.properties.values() + o.baseObjectProperties, lambda x, y: cmp(x.name, y.name))
%}\
\
\
/*
* #%L
* OME-XML Java library for working with OME-XML metadata structures.
* %%
* Copyright (C) 2006 - 2016 Open Microscopy Environment:
* - Massachusetts Institute of Technology
* - National Institutes of Health
* - University of Dundee
* - Board of Regents of the University of Wisconsin-Madison
* - Glencoe Software, Inc.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of any organization.
* #L%
*/
/*-----------------------------------------------------------------------------
*
* THIS IS AUTOMATICALLY GENERATED CODE. DO NOT MODIFY.
*
*-----------------------------------------------------------------------------
*/
package ${lang.metadata_package};
import java.util.List;
import ${lang.omexml_model_package}.*;
import ${lang.omexml_model_enums_package}.*;
import ${lang.omexml_model_package}.primitives.*;
import ${lang.units_package}.quantity.Angle;
import ${lang.units_package}.quantity.ElectricPotential;
import ${lang.units_package}.quantity.Frequency;
import ${lang.units_package}.quantity.Length;
import ${lang.units_package}.quantity.Power;
import ${lang.units_package}.quantity.Pressure;
import ${lang.units_package}.quantity.Temperature;
import ${lang.units_package}.quantity.${lang.typeToUnitsType("UnitsTime")};
import ${lang.units_package}.unit.Unit;
/**
* A proxy whose responsibility it is to extract biological image data from a
* particular storage medium.
*
* <p>The <code>MetadataRetrieve</code> interface encompasses the metadata
* that any specific storage medium (file, relational database, etc.) should be
* expected to access from its backing data model.
*
* <p>The <code>MetadataRetrieve</code> interface goes hand in hand with the
* <code>MetadataStore</code> interface. Essentially,
* <code>MetadataRetrieve</code> provides the "getter" methods for a storage
* medium, and <code>MetadataStore</code> provides the "setter" methods.
*
* <p>Since it often makes sense for a storage medium to implement both
* interfaces, there is also an {@link IMetadata} interface encompassing
* both <code>MetadataStore</code> and <code>MetadataRetrieve</code>, which
* reduces the need to cast between object types.
*
* <p>See {@link ${lang.omexml_metadata_package}.OMEXMLMetadata} for an example
* implementation.
*
* @author Melissa Linkert linkert at wisc.edu
* @author Curtis Rueden ctrueden at wisc.edu
*/
public interface MetadataRetrieve extends BaseMetadata {
// -- Entity counting (manual definitions) --
/**
* Get the number of links to a BooleanAnnotation.
*
* This method returns the number of references to the
* specified BooleanAnnotation held by all model objects.
*
* @param booleanAnnotationIndex the BooleanAnnotation index.
* @return the number of BooleanAnnotation links.
*/
int getBooleanAnnotationAnnotationCount(int booleanAnnotationIndex);
/**
* Get the number of links to a CommentAnnotation.
*
* This method returns the number of references to the
* specified CommentAnnotation held by all model objects.
*
* @param commentAnnotationIndex the CommentAnnotation index.
* @return the number of CommentAnnotation links.
*/
int getCommentAnnotationAnnotationCount(int commentAnnotationIndex);
/**
* Get the number of links to a DoubleAnnotation.
*
* This method returns the number of references to the
* specified DoubleAnnotation held by all model objects.
*
* @param doubleAnnotationIndex the DoubleAnnotation index.
* @return the number of DoubleAnnotation links.
*/
int getDoubleAnnotationAnnotationCount(int doubleAnnotationIndex);
/**
* Get the number of links to a FileAnnotation.
*
* This method returns the number of references to the
* specified FileAnnotation held by all model objects.
*
* @param fileAnnotationIndex the FileAnnotation index.
* @return the number of FileAnnotation links.
*/
int getFileAnnotationAnnotationCount(int fileAnnotationIndex);
/**
* Get the number of links to a ListAnnotation.
*
* This method returns the number of references to the
* specified ListAnnotation held by all model objects.
*
* @param listAnnotationIndex the ListAnnotation index.
* @return the number of ListAnnotation links.
*/
int getListAnnotationAnnotationCount(int listAnnotationIndex);
/**
* Get the number of links to a LongAnnotation.
*
* This method returns the number of references to the
* specified LongAnnotation held by all model objects.
*
* @param longAnnotationIndex the LongAnnotation index.
* @return the number of LongAnnotation links.
*/
int getLongAnnotationAnnotationCount(int longAnnotationIndex);
/**
* Get the number of links to a MapAnnotation.
*
* This method returns the number of references to the
* specified MapAnnotation held by all model objects.
*
* @param mapAnnotationIndex the MapAnnotation index.
* @return the number of MapAnnotation links.
*/
int getMapAnnotationAnnotationCount(int mapAnnotationIndex);
/**
* Get the number of links to a TagAnnotation.
*
* This method returns the number of references to the
* specified TagAnnotation held by all model objects.
*
* @param tagAnnotationIndex the TagAnnotation index.
* @return the number of TagAnnotation links.
*/
int getTagAnnotationAnnotationCount(int tagAnnotationIndex);
/**
* Get the number of links to a TermAnnotation.
*
* This method returns the number of references to the
* specified TermAnnotation held by all model objects.
*
* @param termAnnotationIndex the TermAnnotation index.
* @return the number of TermAnnotation links.
*/
int getTermAnnotationAnnotationCount(int termAnnotationIndex);
/**
* Get the number of links to a TimestampAnnotation.
*
* This method returns the number of references to the
* specified TimestampAnnotation held by all model objects.
*
* @param timestampAnnotationIndex the TimestampAnnotation index.
* @return the number of TimestampAnnotation links.
*/
int getTimestampAnnotationAnnotationCount(int timestampAnnotationIndex);
/**
* Get the number of links to an XMLAnnotation.
*
* This method returns the number of references to the
* specified XMLAnnotation held by all model objects.
*
* @param xmlAnnotationIndex the XMLAnnotation index.
* @return the number of XMLAnnotation links.
*/
int getXMLAnnotationAnnotationCount(int xmlAnnotationIndex);
{% for abstractClass in model.opts.lang.getSubstitutionTypes() %}\
{% for k, v in indexes[abstractClass].items() %}\
/**
* Get the type of a ${abstractClass}.
*
{% for param in v %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @return the ${abstractClass} type.
*/
String get${abstractClass}Type(${indexes_string(v)});
/**
* Get the number of ${abstractClass} elements{% if is_multi_path[abstractClass] %} in ${k}{% end %}.
*
{% for param in v[:-1] %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @return the number of ${abstractClass} elements.
*/
int get{% if is_multi_path[abstractClass] %}${k}{% end %}${abstractClass}Count(${indexes_string(v[:-1])});
{% end %}\
{% end %}\
{% for o in sorted(model.objects.values(), lambda x, y: cmp(x.name, y.name)) %}\
{% if o.name not in fu.METADATA_OBJECT_IGNORE %}\
{% if o.langBaseType != 'Object' %}\
{% if debug %}\
// Element's text data
// ${repr(indexes[o.name])}
{% end debug %}\
/**
* Get the text value of ${o.name}.
*
{% for param in indexes[o.topLevelName].items()[0][1] %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @return the text value.
*/
${o.langBaseType} get${o.topLevelName}Value(${indexes_string(indexes[o.topLevelName].items()[0][1])});
{% end %}\
// -- Entity counting (code generated definitions) --
{% if (parents[o.name] is not None and not o.isAbstract) or o.isConcreteSubstitution %}
{% if debug %}\
// ${o.name} entity counting
{% end debug %}\
{% for k, v in indexes[o.topLevelName].items() %}\
{% if fu.max_occurs_under_parent(model, k, o.name) > 1 and (k not in fu.METADATA_COUNT_IGNORE or o.type not in fu.METADATA_COUNT_IGNORE[k]) %}\
/**
* Get the number of ${o.name} elements{% if is_multi_path[o.name] %} in ${k}{% end %}.
*
{% for param in v[:-1] %}\
* @param ${param['argname']} the ${param['type']} index.
{% end for %}\
* @return the number of ${o.name} elements.
*/
int get{% if is_multi_path[o.name] %}${k}{% end %}${o.name}Count(${indexes_string(v[:-1])});
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
// -- Entity retrieval (manual definitions) --
/**
* Get the values from a MapAnnotation.
*
* @param mapAnnotationIndex the MapAnnotation index.
* @return the MapAnnotation values.
*/
List<MapPair> getMapAnnotationValue(int mapAnnotationIndex);
/**
* Get the MapAnnotation values from a GenericExcitationSource.
*
* @param instrumentIndex the Instrument index.
* @param lightSourceIndex the LightSource index.
* @return the MapAnnotation values.
*/
List<MapPair> getGenericExcitationSourceMap(int instrumentIndex, int lightSourceIndex);
/**
* Get the MapAnnotation values from a ImagingEnvironment.
*
* @param imageIndex the Image index.
* @return the MapAnnotation values.
*/
List<MapPair> getImagingEnvironmentMap(int imageIndex);
/**
* Get the UUID associated with this collection of metadata.
*
* @return the UUID.
*/
/** Gets the UUID associated with this collection of metadata. */
String getUUID();
// -- Entity retrieval (code generated definitions) --
{% for o in sorted(model.objects.values(), lambda x, y: cmp(x.name, y.name)) %}\
{% if o.name not in fu.METADATA_OBJECT_IGNORE %}\
{% if (parents[o.name] is not None and not o.isAbstract) or o.isConcreteSubstitution %}
{% if debug %}\
// MARKER [EEE]
//
// ${o.name} property storage
//
// ${repr(parents[o.name])}
// Is multi path? ${is_multi_path[o.name]}
{% end debug %}\
{% choose %}\
{% when o.isReference %}\
{% for prop in sorted(o.properties.values() + o.baseObjectProperties, lambda x, y: cmp(x.name, y.name)) %}\
{% if debug %}\
// ${prop.minOccurs}:${prop.maxOccurs}
// Is multi path? ${is_multi_path[o.name]}
// Ignoring ${prop.name} property of reference ${o.name}
{% end debug %}\
{% end %}\
{% end %}\
{% otherwise %}\
\
{% for k, v in indexes[o.topLevelName].items() %}\
{% if is_abstract(k) %}\
{% for prop in sorted_properties(model.getObjectByName(k)) %}\
{% choose %}\
{% when not prop.isPrimitive and prop.isChoice %}\
{% if debug %}\
// MARKER [CCC]
// Ignoring ${prop.name} of parent abstract type
{% end debug %}\
{% end %}\
{% otherwise %}\
{% for parent_k, parent_v in indexes[k].items() %}\
{% if debug %}\
// MARKER [DDD]
{% end debug %}\
{% if not prop.isBackReference and not prop.isUnitsEnumeration %}\
{% if debug %}\
// MARKER [AAA] - isUnitsEnumeration ${prop.isUnitsEnumeration}
{% end debug %}\
// ${prop.name} accessor from parent ${k}
${getter(k, o, prop, v)}
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
\
{% for prop in sorted(o.properties.values() + o.baseObjectProperties, lambda x, y: cmp(x.name, y.name)) %}\
{% choose %}\
{% when prop.isBackReference %}\
{% if debug %}\
// Ignoring ${prop.name} back reference
{% end debug %}\
{% end %}\
{% when not prop.isReference and not prop.isAttribute and prop.isComplex() and (not prop.name in fu.COMPLEX_OVERRIDE) %}\
{% if debug %}\
// Ignoring ${prop.name} element, complex property
{% end debug %}\
{% end %}\
{% when prop.isUnitsEnumeration %}\
{% if debug %}\
// MARKER [FFF]
// Ignoring ${prop.name} element, unit enumeration property
{% end debug %}\
{% end %}\
{% otherwise %}\
{% for k, v in indexes[o.topLevelName].items() %}\
{% if debug %}\
// MARKER [BBB]
{% end debug %}\
${getter(k, o, prop, v)}
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
{% end %}\
}