/
object.vm
1978 lines (1838 loc) · 81.8 KB
/
object.vm
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
##
## Copyright (c) 2007 Glencoe Software Inc. All rights reserved.
## Use is subject to license terms supplied in LICENSE.txt
##
##
## SETUP
##
#set($ofilter = "${type.table}_owner_filter")
#set($gfilter = "${type.table}_group_filter")
#set($efilter = "${type.table}_event_filter")
#set($pfilter = "${type.table}_perms_filter")
## See #1679, #2142 and various others
#set($cascadeEjb = "javax.persistence.CascadeType.DETACH,")
#set($cascadeEjb = "$cascadeEjb javax.persistence.CascadeType.MERGE,")
#set($cascadeEjb = "$cascadeEjb javax.persistence.CascadeType.PERSIST,")
#set($cascadeEjb = "$cascadeEjb javax.persistence.CascadeType.REFRESH")
#set($cascadeHib = "org.hibernate.annotations.CascadeType.LOCK,")
#set($cascadeHib = "$cascadeHib org.hibernate.annotations.CascadeType.MERGE,")
#set($cascadeHib = "$cascadeHib org.hibernate.annotations.CascadeType.PERSIST,")
#set($cascadeHib = "$cascadeHib org.hibernate.annotations.CascadeType.REPLICATE,")
#set($cascadeHib = "$cascadeHib org.hibernate.annotations.CascadeType.REFRESH,")
#set($cascadeHib = "$cascadeHib org.hibernate.annotations.CascadeType.SAVE_UPDATE")
#set($errorIfUnloaded = "if (! _loaded ) errorIfUnloaded();" )
##
##
##
##
/*
* This file was generated by dsl/resources/ome/dsl/object.vm
*
* Copyright (c) 2007 Glencoe Software Inc. All rights reserved.
* Use is subject to license terms supplied in LICENSE.txt
*
*/
package ${type.package};
#if($type.isEnum)
import java.util.Arrays;
#end
import ome.conditions.*;
import ome.model.*;
#if(!$type.superclass && !$type.global)
/**
* These filter definitions are used by the security system
* to eliminate non-readable objects from queries. The regular
* user does not need to worry about them, as they will be
* injected directly into the SQL (not HQL)
*/
@org.hibernate.annotations.FilterDefs({
@org.hibernate.annotations.FilterDef(name="${ofilter}",
parameters=@org.hibernate.annotations.ParamDef( name="ownerId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${gfilter}",
parameters=@org.hibernate.annotations.ParamDef( name="groupId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${efilter}",
parameters=@org.hibernate.annotations.ParamDef( name="eventId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${pfilter}",
parameters=@org.hibernate.annotations.ParamDef( name="permsStr", type="java.lang.String" ))#foreach( $prop in $type.classProperties )#if($prop.one2Many),
@org.hibernate.annotations.FilterDef(name="${ofilter}_${prop.nameUpper}",
parameters=@org.hibernate.annotations.ParamDef( name="ownerId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${gfilter}_${prop.nameUpper}",
parameters=@org.hibernate.annotations.ParamDef( name="groupId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${efilter}_${prop.nameUpper}",
parameters=@org.hibernate.annotations.ParamDef( name="eventId", type="java.lang.Long" )),
@org.hibernate.annotations.FilterDef(name="${pfilter}_${prop.nameUpper}",
parameters=@org.hibernate.annotations.ParamDef( name="permsStr", type="java.lang.String" ))
#end
#end
})
##if(!$type.superclass && !$type.global)
@org.hibernate.annotations.Filters({
// See the comments on filters above
@org.hibernate.annotations.Filter(name="${ofilter}", condition=":ownerId = owner_id"),
@org.hibernate.annotations.Filter(name="${gfilter}", condition=":groupId = group_id"),
@org.hibernate.annotations.Filter(name="${efilter}", condition=":eventId = event_id"),
@org.hibernate.annotations.Filter(name="${pfilter}", condition=":permsStr = permissions"),
@org.hibernate.annotations.Filter(name="OneGroupSecurityFilter"),
@org.hibernate.annotations.Filter(name="AllGroupsSecurityFilter"),
#if($type.id.equals("ome.model.acquisition.Detector"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT detector.id FROM detector*, image* WHERE " +
"detector.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.DetectorSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT detectorsettings.id FROM detectorsettings*, detector*, image* WHERE " +
"detectorsettings.detector = detector.id AND detector.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.Dichroic"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT dichroic.id FROM dichroic*, image* WHERE " +
"dichroic.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.Filter"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filter.id FROM filter*, image* WHERE " +
"filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.FilterSet"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filterset.id FROM filterset*, image* WHERE " +
"filterset.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.FilterSetEmissionFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM filtersetemissionfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.FilterSetExcitationFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM filtersetexcitationfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.ImagingEnvironment"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT imagingenvironment FROM image* WHERE " +
"id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.Instrument"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT instrument FROM image* WHERE " +
"id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.LightPath"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT logicalchannel.lightpath FROM logicalchannel*, channel*, pixels* WHERE " +
"logicalchannel.id = channel.logicalchannel AND channel.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.LightPathEmissionFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM lightpathemissionfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.LightPathExcitationFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM lightpathexcitationfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.LightSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT lightsettings.id FROM lightsettings*, logicalchannel*, channel*, pixels* WHERE " +
"lightsettings.id = logicalchannel.lightsourcesettings AND logicalchannel.id = channel.logicalchannel AND channel.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.LightSource"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT lightsource.id FROM lightsource*, image* WHERE " +
"lightsource.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.Microscope"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT instrument.microscope FROM instrument*, image* WHERE " +
"instrument.id = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.Objective"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT objective.id FROM objective*, image* WHERE " +
"objective.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.ObjectiveSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT objectivesettings FROM image* WHERE " +
"id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.OTF"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT otf.id FROM otf*, image* WHERE " +
"otf.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.StageLabel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT stagelabel FROM image* WHERE " +
"id IN (:images)))")
#elseif($type.id.equals("ome.model.acquisition.TransmittanceRange"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filter.transmittancerange FROM filter*, image* WHERE " +
"filter.instrument = image.instrument AND image.id IN (:images)))")
#elseif($type.id.equals("ome.model.core.Channel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.id FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.core.Image"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (:images))")
#elseif($type.id.equals("ome.model.core.LogicalChannel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.logicalchannel FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.core.OriginalFile"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT pofm.parent FROM pixelsoriginalfilemap AS pofm*, pixels* WHERE " +
"pofm.child = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.core.Pixels"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"image IN (:images))")
#elseif($type.id.equals("ome.model.core.PixelsOriginalFileMap"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT pofm.id FROM pixelsoriginalfilemap AS pofm*, pixels* WHERE " +
"pofm.child = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.core.PlaneInfo"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT planeinfo.id FROM planeinfo*, pixels* WHERE " +
"planeinfo.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.ChannelBinding"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channelbinding.id FROM channelbinding*, renderingdef*, pixels* WHERE " +
"channelbinding.renderingdef = renderingdef.id AND renderingdef.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.CodomainMapContext"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT codomainmapcontext.id FROM channelbinding*, codomainmapcontext*, renderingdef*, pixels* WHERE " +
"codomainmapcontext.channelbinding = channelbinding.id AND channelbinding.renderingdef = renderingdef.id AND " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.ProjectionDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT projectiondef.id FROM projectiondef*, renderingdef*, pixels* WHERE " +
"projectiondef.renderingdef = renderingdef.id AND renderingdef.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.QuantumDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT renderingdef.quantization FROM renderingdef*, pixels* WHERE " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.RenderingDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT renderingdef.id FROM renderingdef*, pixels* WHERE " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.display.Thumbnail"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT thumbnail.id FROM thumbnail*, pixels* WHERE " +
"thumbnail.pixels = pixels.id AND pixels.image IN (:images)))")
#elseif($type.id.equals("ome.model.stats.StatsInfo"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.statsinfo FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))")
#else
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0)")
#end
})
#elseif($type.id.equals("ome.model.meta.Session"))
@org.hibernate.annotations.FilterDefs({
@org.hibernate.annotations.FilterDef(name="owner_or_admin",
parameters={
@org.hibernate.annotations.ParamDef( name="current_user", type="java.lang.Long" ),
@org.hibernate.annotations.ParamDef( name="is_admin", type="java.lang.Integer" )})
})
@org.hibernate.annotations.Filters({
@org.hibernate.annotations.Filter(name="owner_or_admin", condition="(1 = :is_admin or owner = :current_user)"),
@org.hibernate.annotations.Filter(name="LightAdminPrivilegesSecurityFilter",
condition="(COALESCE(sudoer, owner) = :real_owner OR 'ReadSession' IN (:privileges))")
})
#elseif($type.id.equals("ome.model.meta.Node"))
@org.hibernate.annotations.FilterDefs({
@org.hibernate.annotations.FilterDef(name="owner_or_admin",
parameters={
@org.hibernate.annotations.ParamDef( name="current_user", type="java.lang.Long" ),
@org.hibernate.annotations.ParamDef( name="is_admin", type="java.lang.Integer" )})
})
@org.hibernate.annotations.Filters({
@org.hibernate.annotations.Filter(name="owner_or_admin", condition="(1 = :is_admin)")
})
#end
@javax.persistence.Entity
##
## Determine inheritance type
##
###############################################################
#if($type.superclass)
## JOINED SUBCLASS
#set($superId = ${type.typeToColumn($type.superclass)} )
#if(!$type.discriminator)
@javax.persistence.PrimaryKeyJoinColumn(name="${superId}_id")
@javax.persistence.Table(name = "${type.tableName()}")
#set($fkvalue = "FK${type.table}_${superId}_id_${superId}")
#set($fkvalue = "${type.fk($fkvalue)}")
@org.hibernate.annotations.ForeignKey(name="${fkvalue}")
#else
## SINGLETABLE SUBCLASS
@javax.persistence.DiscriminatorValue("${type.discriminator}")
#end
#else##########################################################
## TOP OF HIERARCHY
@javax.persistence.Table(name = "${type.tableName()}", uniqueConstraints = {
#set( $comma = "0" )
#foreach($cols in $type.uniqueConstraints)
#if( $comma == "" )#set( $comma = ",")#end
#if( $comma == "0" )#set( $comma = "" )#end
$comma @javax.persistence.UniqueConstraint(columnNames={$cols})
#set( $comma = "," )
#end
})
@org.hibernate.annotations.Entity( selectBeforeUpdate = true )
#if(!$type.discriminator)
## ...OF JOINED TABLES
@javax.persistence.Inheritance(strategy=javax.persistence.InheritanceType.JOINED)
#else
## ... IN A SINGLE TABLE
@javax.persistence.Inheritance(strategy=javax.persistence.InheritanceType.SINGLE_TABLE)
@javax.persistence.DiscriminatorValue("${type.discriminator}")
@javax.persistence.DiscriminatorColumn(
name="discriminator", discriminatorType=javax.persistence.DiscriminatorType.STRING
)
#end
@org.hibernate.annotations.GenericGenerator(name = "seq_${type.table}",
strategy = "ome.util.TableIdGenerator",
parameters = {
@org.hibernate.annotations.Parameter(name = "table_name", value = "seq_table"),
@org.hibernate.annotations.Parameter(name = "segment_value", value = "seq_${type.sequenceName}"),
@org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled"),
@org.hibernate.annotations.Parameter(name = "increment_size", value = "50")
})
#end############################################################
#if(!$type.abstract)
@org.hibernate.search.annotations.Indexed(index="FullText")
#end
@org.hibernate.search.annotations.ClassBridge(
name="details",
impl = ome.util.DetailsFieldBridge.class,
index=org.hibernate.search.annotations.Index.UN_TOKENIZED,
store=org.hibernate.search.annotations.Store.NO
)
#if("" != $type.check)
@org.hibernate.annotations.Check(constraints="${type.check}")
#end
#if($type.deprecated)
@Deprecated
#end
public #if($type.abstract)abstract#end class ${type.shortname}
#if($type.superclass)extends $type.superclass #end
implements java.io.Serializable, IObject
#if($type.global), IGlobal#end#if(!$type.immutable), IMutable#end
#if($type.isEnum), IEnum#end
#if($type.isAnnotationLink), IAnnotationLink#elseif($type.isLink), ILink#end
#if($type.annotated), IAnnotated#end
{
/* These values are defined in dsl/resources/ome/dsl/object.vm:
* -------------------------------------------------------------
* Explanation of serialVersionUID ex 0000000 03 00 00 01 03 01 L;
* 1-7 : currently unused
* 8-9 : major part (3.x.x)
* 10-11 : minor part (x.0.x)
* 12-13 : patch part (x.x.0)
* 14-15 : release type (B)
* 16-17 : release number (3)
* 18-19 : increment per delta // any changes to the dsl or mapping files
*/
private static final long serialVersionUID = 0000000030000020302L;
#if($type.isEnum && !$type.shortname.startsWith("Units"))
#foreach($prop in $type.properties)
#if($prop.class.name == "ome.dsl.EntryField")
#set($enumSymbol = ${prop.name.replaceAll("-","_").replaceAll("([a-z])([A-Z])", "$1_$2").toUpperCase().replaceAll("[^A-Z0-9_]","")})
#if($prop.deprecated)
@Deprecated
#end
public static final String VALUE_${enumSymbol} = "${prop.name}";
#end
#end
#end
#if(!$type.global)
/*
* Constants naming filters used by the OMERO
* security system.
*/
public static final String OWNER_FILTER = "${ofilter}";
public static final String GROUP_FILTER = "${gfilter}";
public static final String EVENT_FILTER = "${efilter}";
public static final String PERMS_FILTER = "${pfilter}";
#end
public ${type.shortname} () {
this(null, true);
}
protected ${type.shortname} (Long id) {
this(id, true);
}
/**
* Main constructor.
*/
public ${type.shortname} (Long id, boolean loaded) {
#if($type.superclass)
super(id, loaded);
#else
setId(id);
if (loaded) {
getDetails().setContext(this);
} else {
if (this.id == null) {
throw new ApiUsageException("Id cannot be null for a proxy");
}
unload();
}
#end
}
#if($type.isEnum)
public ${type.shortname} (String value) {
this(null, true);
setValue(value);
}
#end
## (1) Check if needed
#if($type.requiredSingleProperties.size() > 0 && !$type.isEnum)
public ${type.shortname}(
##
## Add ctor arguments, with a comma if not the first
##
#set($comma = "")
#foreach($prop in $type.requiredSingleProperties)$comma${prop.fieldType} _${prop.name}#set($comma = ",")#end
) {
this(null, true);
#foreach($prop in $type.requiredSingleProperties)
set${prop.nameCapped}(_${prop.name});
#end
}
#end## END ctorWithRequiredNeeded
#if(!${type.superclass})
public static final String ID = "${type.id}_id";
protected Long id;
/**
* The DB unique identifier for this object. You are not responsible for
* setting the id; however, it can be useful for creating "unloaded"
* versions of your objects.
*
* Each top-level entity contains an id field of type long.
* For all objects returned from the server, this value will
* be non-null, which doesn't necessarily hold for the other
* fields.
*/
@javax.persistence.Id
@javax.persistence.GeneratedValue(
strategy=javax.persistence.GenerationType.SEQUENCE,
generator="seq_${type.table}")
@org.hibernate.search.annotations.DocumentId
@Override
public Long getId() {
return this.id;
}
@Override
public void setId(Long id) {
this.id = id;
}
#end
/*
* INTERFACE-BASED
* Several properties are defined by whether or not
* the OME definition has certain interfaces.
*/
#if(!${type.immutable} && !${type.superclass})
public static final String VERSION = "${type.id}_version";
protected Integer version = 0;
/**
* This version number is controlled by the database for optimisitic
* locking.
*/
@javax.persistence.Column(name="version")
// @javax.persistence.Version
//TODO mark off #118 if this succeeds, otherwise, completely remove versions and test updateEvent
@Override
public Integer getVersion() {
$errorIfUnloaded
return this.version;
}
@Override
public void setVersion(Integer version) {
$errorIfUnloaded
this.version = version;
}
#end
/*
* PROPERTIES
* All properties which follow are straightforward
* and can be understood using only the Hibernate
* documentation.
*/
#foreach($prop in $type.classProperties)#######################################EACH
##
## Now we iterate through each of the properties and based on the type we
## generate the appropriate methods.
##
##
## SETUP
##
## Property to be used only within the property loop which is guaranteed to be reset
## This is used only for one-to-many (collection-valued) relationships
## If this is a link, cascadeHibCollection will be reset to all-delete-orphan
#set( $cascadeHibCollection = ${cascadeHib} )
##
#if( $prop.isLink )
#set( $LinkType = ${prop.type} )
#set( $Link = ${prop.shortType} )
#if($prop.class.name == "ome.dsl.ChildLink" )
#set( $order = "this, addition" )
#set( $next = "parent" )
#set( $other = "child" )
#set( $cascadeHibCollection = "org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN" )
#elseif($prop.class.name == "ome.dsl.ParentLink")
#set( $order = "addition, this" )
#set( $next = "child" )
#set( $other = "parent" )
#set( $cascadeHibCollection = "org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN" )
#end
#elseif($prop.ordered)
#set( $cascadeHibCollection = "org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN" )
#end
##
#if($prop.deprecated)
@Deprecated
#end
protected ${prop.fieldType} ${prop.name} = ${prop.fieldInitializer};
#if($prop.name == "details") #############################################TYPE
/**
* The details of this object correspond to low-level system
* information. Owner, permissions, Details is always guaranteed
* to be non-null, unless the user actively nulls it.
*
* Every entity also contains a Detail reference, which doesn't
* refer to a separate table but rather to a collection of fields
* collected into a Hibernate "component" which is embedded in the
* object.
*
* HQL queries which refer to the Details component cannot directly
* fetch the entity like this:
*
* select o from Object join fetch o.details
*
* but rather each field of the Details instance must be explicitly
* joined:
*
* select o from Object join fetch o.details.owner
*
* It should also be noted that not all types have all the fields
* which are present on Details. For example,
*
* select e from Experimenter e join fetch e.details.owner
*
* will fail. Experimenter has no owner, for obvious reasons.
*
* Note: subclasses of this class will return a subclass of
* the {@link ome.model.internal.Details} type.
*/
@javax.persistence.Embedded
@org.hibernate.annotations.Target(Details.class)
@Override
public ome.model.internal.Details getDetails() {
$errorIfUnloaded
return this.details;
}
## /**
## * Use the {@link ome.model.internal.Details#copy(ome.model.internal.Details})}
## * or {@link ome.model.internal.Details#shallowCopy(ome.model.internal.Details)}
## * methods to set the {@link Details} instance instead.
## */
protected void setDetails(ome.model.internal.Details details) {
$errorIfUnloaded
this.details = (Details) details;
}
#elseif($prop.class.name == "ome.dsl.MapField")#############################TYPE
##
## MapFields are collections of primitives which can be stored in a single
## row/field of some model object.
##
#if($prop.deprecated)
@Deprecated
#end
public void set${prop.nameCapped}(${prop.fieldType} map) {
this.${prop.name} = map;
}
@javax.persistence.ElementCollection(fetch = javax.persistence.FetchType.EAGER)
@javax.persistence.OrderColumn(name="index")
@javax.persistence.CollectionTable(name="${type.tableName()}_${prop.name}",
joinColumns = @javax.persistence.JoinColumn(name="${type.tableName()}_id"))
@javax.persistence.Column(name="${prop.name}", nullable=false)
@org.hibernate.annotations.ForeignKey(name="FK${type.tableName()}_${prop.name}_map")
#if($prop.deprecated)
@Deprecated
#end
public ${prop.fieldType} get${prop.nameCapped}() {
return this.${prop.name};
}
#elseif($prop.class.name == "ome.dsl.EntryField")#############################TYPE
##
## EntryFields are handled by ome/dsl/data.vm, since each of the entries isn't
## a real property but rather an enum value for the database. However, they
## are not even returned by $type.classProperties only $type.properties
##
#elseif($prop.one2Many)###################################################TYPE
##
##
#if(!$prop.actualTarget.global)
/*
* Filter names which are used by the security system to turn on filters
* for this particular collection.
*/
#if($prop.deprecated)
@Deprecated
#end
public static final String OWNER_FILTER_${prop.nameUpper} = "${ofilter}_${prop.nameUpper}";
#if($prop.deprecated)
@Deprecated
#end
public static final String GROUP_FILTER_${prop.nameUpper} = "${gfilter}_${prop.nameUpper}";
#if($prop.deprecated)
@Deprecated
#end
public static final String EVENT_FILTER_${prop.nameUpper} = "${efilter}_${prop.nameUpper}";
#if($prop.deprecated)
@Deprecated
#end
public static final String PERMS_FILTER_${prop.nameUpper} = "${pfilter}_${prop.nameUpper}";
#end
/**
* returns ${prop.name} . You should not modify this collection unless you
* know what you are doing. Use the iterate method instead.
*
##
#if($prop.ordered)
* one-to-many List ${type.id}.${prop.name} (${prop.type})
* Values are indexed by the column "index" on ${prop.type}
*/
@javax.persistence.JoinColumn(name="${type.inverse($prop)}", nullable=false)
@javax.persistence.OneToMany(fetch=javax.persistence.FetchType.LAZY, cascade={${cascadeEjb}})
@org.hibernate.annotations.IndexColumn(name="${prop.inverse}_index", nullable=false)
#else
* one-to-many Set ${type.id}.${prop.name} (${prop.type})
*/
@javax.persistence.OneToMany(mappedBy="${prop.inverse}", fetch=javax.persistence.FetchType.LAZY, cascade={${cascadeEjb}})
#end
@org.hibernate.annotations.Cascade({${cascadeHibCollection}})
##
##
#if(!$prop.actualTarget.global)
@org.hibernate.annotations.Filters({
@org.hibernate.annotations.Filter(name="OneGroupSecurityFilter"),
@org.hibernate.annotations.Filter(name="AllGroupsSecurityFilter"),
#if($prop.type.equals("ome.model.acquisition.Detector"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT detector.id FROM detector*, image* WHERE " +
"detector.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.DetectorSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT detectorsettings.id FROM detectorsettings*, detector*, image* WHERE " +
"detectorsettings.detector = detector.id AND detector.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.Dichroic"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT dichroic.id FROM dichroic*, image* WHERE " +
"dichroic.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.Filter"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filter.id FROM filter*, image* WHERE " +
"filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.FilterSet"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filterset.id FROM filterset*, image* WHERE " +
"filterset.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.FilterSetEmissionFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM filtersetemissionfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.FilterSetExcitationFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM filtersetexcitationfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.ImagingEnvironment"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT imagingenvironment FROM image* WHERE " +
"id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.Instrument"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT instrument FROM image* WHERE " +
"id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.LightPath"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT logicalchannel.lightpath FROM logicalchannel*, channel*, pixels* WHERE " +
"logicalchannel.id = channel.logicalchannel AND channel.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.LightPathEmissionFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM lightpathemissionfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.LightPathExcitationFilterLink"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT link.id FROM lightpathexcitationfilterlink AS link*, filter*, image* WHERE " +
"link.child = filter.id AND filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.LightSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT lightsettings.id FROM lightsettings*, logicalchannel*, channel*, pixels* WHERE " +
"lightsettings.id = logicalchannel.lightsourcesettings AND logicalchannel.id = channel.logicalchannel AND channel.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.LightSource"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT lightsource.id FROM lightsource*, image* WHERE " +
"lightsource.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.Microscope"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT instrument.microscope FROM instrument*, image* WHERE " +
"instrument.id = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.Objective"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT objective.id FROM objective*, image* WHERE " +
"objective.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.ObjectiveSettings"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT objectivesettings FROM image* WHERE " +
"id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.OTF"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT otf.id FROM otf*, image* WHERE " +
"otf.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.StageLabel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT stagelabel FROM image* WHERE " +
"id IN (:images)))"),
#elseif($prop.type.equals("ome.model.acquisition.TransmittanceRange"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT filter.transmittancerange FROM filter*, image* WHERE " +
"filter.instrument = image.instrument AND image.id IN (:images)))"),
#elseif($prop.type.equals("ome.model.core.Channel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.id FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.core.Image"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (:images))"),
#elseif($prop.type.equals("ome.model.core.LogicalChannel"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.logicalchannel FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.core.OriginalFile"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT pofm.parent FROM pixelsoriginalfilemap AS pofm*, pixels* WHERE " +
"pofm.child = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.core.Pixels"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"image IN (:images))"),
#elseif($prop.type.equals("ome.model.core.PixelsOriginalFileMap"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT pofm.id FROM pixelsoriginalfilemap AS pofm*, pixels* WHERE " +
"pofm.child = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.core.PlaneInfo"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT planeinfo.id FROM planeinfo*, pixels* WHERE " +
"planeinfo.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.ChannelBinding"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channelbinding.id FROM channelbinding*, renderingdef*, pixels* WHERE " +
"channelbinding.renderingdef = renderingdef.id AND renderingdef.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.CodomainMapContext"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT codomainmapcontext.id FROM channelbinding*, codomainmapcontext*, renderingdef*, pixels* WHERE " +
"codomainmapcontext.channelbinding = channelbinding.id AND channelbinding.renderingdef = renderingdef.id AND " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.ProjectionDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT projectiondef.id FROM projectiondef*, renderingdef*, pixels* WHERE " +
"projectiondef.renderingdef = renderingdef.id AND renderingdef.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.QuantumDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT renderingdef.quantization FROM renderingdef*, pixels* WHERE " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.RenderingDef"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT renderingdef.id FROM renderingdef*, pixels* WHERE " +
"renderingdef.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.display.Thumbnail"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT thumbnail.id FROM thumbnail*, pixels* WHERE " +
"thumbnail.pixels = pixels.id AND pixels.image IN (:images)))"),
#elseif($prop.type.equals("ome.model.stats.StatsInfo"))
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0 OR " +
"id IN (SELECT channel.statsinfo FROM channel*, pixels* WHERE " +
"channel.pixels = pixels.id AND pixels.image IN (:images)))"),
#else
@org.hibernate.annotations.Filter(name="SharingSecurityFilter", condition="(:is_admin = 1 OR :is_share = 0)"),
#end
@org.hibernate.annotations.Filter(name=OWNER_FILTER_${prop.nameUpper}, condition=":ownerId = owner_id"),
@org.hibernate.annotations.Filter(name=GROUP_FILTER_${prop.nameUpper}, condition=":groupId = group_id"),
@org.hibernate.annotations.Filter(name=EVENT_FILTER_${prop.nameUpper}, condition=":eventId = event_id"),
@org.hibernate.annotations.Filter(name=PERMS_FILTER_${prop.nameUpper}, condition=":permsStr = permissions")
})
#end
#if($prop.deprecated)
@Deprecated
#end
protected ${prop.fieldType} get${prop.nameCapped}() {
$errorIfUnloaded
return this.${prop.name};
}
/**
* setter for ${prop.name} should be avoided. Does not fulfill normal semantics.
*/
#if($prop.deprecated)
@Deprecated
#end
protected void set${prop.nameCapped}(${prop.fieldType} ${prop.name}) {
$errorIfUnloaded
this.${prop.name} = ${prop.name};
}
##
## A one-to-many property represents a set that is contained by this entity.
## These methods represent our handling of Hibernate's "inverse" sets
## which do not act as expected with regards to getters & setters.
##
## To prevent users from making mistakes like not properly setting both
## sides of a relationship, these fields are hidden, and only accessible via
## the following methods. Methods fall into several categories:
## (A) general
## (B) list-only
## (C) link-based
##
## (A) General one-to-many code
## ----------------------------
##
/**
* returns the size of ${prop.name}. If less than zero, the Set was null.
*/
#if($prop.deprecated)
@Deprecated
#end
public int sizeOf${prop.nameCapped}() {
$errorIfUnloaded
return this.${prop.name} == null ? -1 : this.${prop.name}.size();
}
/**
* should be used rather than accessing the ${prop.name} set directly.
* This method will never return null, but rather will return an instance
* of {@link ome.util.EmptyIterator}. To test for a null collection,
* see of {@link #sizeOf${prop.nameCapped}()} is less than zero.
*/
#if($prop.deprecated)
@Deprecated
#end
public java.util.Iterator<${prop.type}> iterate${prop.nameCapped}() {
$errorIfUnloaded
if ( get${prop.nameCapped}() == null ) {
return new ome.util.EmptyIterator<${prop.type}>();
}
return get${prop.nameCapped}().iterator(); // TODO should this be direct access
}
/**
* Returns an unmodifiable collection-view
*/
#if($prop.deprecated)
@Deprecated
#end
public java.util.Collection<${prop.type}> unmodifiable${prop.nameCapped}() {
$errorIfUnloaded
if ( get${prop.nameCapped}() == null ) {
return java.util.Collections.emptyList();
}
return java.util.Collections.unmodifiableCollection( get${prop.nameCapped}() );
}
/**
* takes a CBlock and calls the block once for each ${prop.type} while
* collecting the results. If <code>block == null</code>, then the
* iterator values themselves are collected. This method uses
* {@link #iterate${prop.nameCapped}} internally and so will return a value
* even if the underlying collection is null.
*/
@SuppressWarnings("unchecked")
#if($prop.deprecated)
@Deprecated
#end
public <E> java.util.List<E> collect${prop.nameCapped}(ome.util.CBlock<E> block) {
$errorIfUnloaded
java.util.List<E> result = new java.util.ArrayList<E>();
java.util.Iterator<${prop.type}> it = iterate${prop.nameCapped}();
while ( it.hasNext() ) {
IObject obj = (IObject) it.next();
if ( block != null ) {
result.add( block.call( obj ) );
} else {
result.add( (E) obj );
}
}
return result;
}
/**
* use instead of set${prop.nameCapped} . Makes the necessary
* call on ${prop.type} as well.
*/
#if($prop.deprecated)
@Deprecated
#end
public void add${prop.fieldName}(${prop.type} target) {
$errorIfUnloaded
if (get${prop.nameCapped}() == null) {
throwNullCollectionException("${prop.nameCapped}");
}
get${prop.nameCapped}().add( target );
## Copied to add${prop.shortType}Set(elements)
## Copied to set${prop.shortType}(index, element)
// If this relationship is not ordered, then we will
// "attempt" the setting even if it is loaded.
if (target != null) {
#if(${prop.ordered})
if (target.isLoaded()) {
#end
target.set${prop.inverseCapped} ( this );
#if(${prop.ordered})
}
#end
}
}
/**
* use like add${prop.shortType}.
*/
#if($prop.deprecated)
@Deprecated
#end
public void add${prop.fieldName}Set(java.util.Collection<${prop.type}> targets) {
$errorIfUnloaded
if (get${prop.nameCapped}() == null) {
throwNullCollectionException("${prop.nameCapped}");
}
get${prop.nameCapped}().addAll( targets );
java.util.Iterator<${prop.type}> it = targets.iterator();
while ( it.hasNext() ) {
${prop.type} target = it.next();
## Copied from add${prop.shortType}(target)
// If this relationship is not ordered, then we will
// "attempt" the setting even if it is loaded.
if (target != null) {
#if(${prop.ordered})
if (target.isLoaded()) {
#end
target.set${prop.inverseCapped} ( this );
#if(${prop.ordered})
}
#end
}
}
}
/**
* removes a single element from this set and makes the inverse call on ${prop.type}
*/
#if($prop.deprecated)
@Deprecated
#end
public void remove${prop.fieldName}(${prop.type} target) {
$errorIfUnloaded
if (get${prop.nameCapped}() == null) {
throwNullCollectionException("${prop.nameCapped}");
}
get${prop.nameCapped}().remove( target );
#if(${prop.ordered})
if (target.isLoaded()) {
#end
target.set${prop.inverseCapped} ( null );
#if(${prop.ordered})
}
#end
}
/**
* use like remove${prop.shortType}
*/
#if($prop.deprecated)
@Deprecated
#end
public void remove${prop.fieldName}Set(java.util.Collection<${prop.type}> targets ) {
$errorIfUnloaded
if (get${prop.nameCapped}() == null) {
throwNullCollectionException("${prop.nameCapped}");
}
get${prop.nameCapped}().removeAll( targets );
java.util.Iterator<${prop.type}> it = targets.iterator();
while ( it.hasNext() ) {
${prop.type} target = it.next();
#if(${prop.ordered})
if (target.isLoaded()) {
#end
target.set${prop.inverseCapped} ( null );
#if(${prop.ordered})
}
#end
}
}
##
## The following methods are overwritten separately by the link code (C) below
## and therefore are omitted here if this is a link property.
##