/
TRLUtil.java
1191 lines (968 loc) · 54.3 KB
/
TRLUtil.java
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) 2020 Bird Software Solutions Ltd
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Neil Mackenzie - initial API and implementation
*******************************************************************************/
package org.eclipse.efbt.cocamo.trl.component.translator.util;
import java.util.Iterator;
import org.eclipse.efbt.cocamo.core.model.functions.AggregateFunction;
import org.eclipse.efbt.cocamo.core.model.functions.BasicFunction;
import org.eclipse.efbt.cocamo.core.model.functions.BooleanFunction;
import org.eclipse.efbt.cocamo.core.model.functions.FunctionsFactory;
import org.eclipse.efbt.cocamo.lineage.model.lineagefunctions.CubeColumn;
import org.eclipse.efbt.cocamo.lineage.model.lineagefunctions.LineagefunctionsFactory;
import org.eclipse.efbt.cocamo.lineage.model.lineagefunctions.MemberParameter;
import org.eclipse.efbt.cocamo.lineage.model.lineagefunctions.SpeculativeCubeColumnParameter;
import org.eclipse.efbt.cocamo.trl.component.translator.impl.AttributeLineageUtilImpl;
import org.eclipse.efbt.cocamo.smcubes.model.core.DOMAIN;
import org.eclipse.efbt.cocamo.smcubes.model.core.MEMBER;
import org.eclipse.efbt.cocamo.smcubes.model.core.VARIABLE;
import org.eclipse.efbt.cocamo.smcubes.model.data_definition.COMBINATION;
import org.eclipse.efbt.cocamo.smcubes.model.data_definition.COMBINATION_ITEM;
import org.eclipse.efbt.cocamo.smcubes.model.data_definition.CUBE;
import org.eclipse.efbt.cocamo.smcubes.model.data_definition.CUBE_STRUCTURE;
import org.eclipse.efbt.cocamo.smcubes.model.data_definition.CUBE_STRUCTURE_ITEM;
import org.eclipse.efbt.cocamo.smcubes.model.efbt_data_definition.CubeModule;
import org.eclipse.efbt.cocamo.smcubes.model.efbt_data_definition.MemberModule;
import org.eclipse.efbt.cocamo.smcubes.model.reports.ReportCell;
import org.eclipse.efbt.cocamo.smcubes.model.smcubes_model.SmcubesModel;
import org.eclipse.efbt.cocamo.core.model.functionality_module.LeafFunctionalityModule;
import org.eclipse.efbt.cocamo.trl.model.domain_model_mapping.DomainMappingModule;
import org.eclipse.efbt.cocamo.trl.model.domain_model_mapping.LeafModuleToReportCellViewModule;
import org.eclipse.efbt.cocamo.trl.model.transformation.DataSetTransformation;
import org.eclipse.efbt.cocamo.trl.model.transformation.VersionedComponentsSet;
import org.eclipse.efbt.cocamo.trl.model.transformation.VersionedCubeSchemaModule;
import org.eclipse.efbt.cocamo.trl.model.transformation.VersionedFunctionalModuleLogic;
import org.eclipse.efbt.cocamo.trl.model.trl_report_cell_views.ReportCellView;
import org.eclipse.efbt.cocamo.trl.model.trl_report_cell_views.ReportCellViewModule;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.AggregateEnrichmentView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.BaseViewIncorporatingDeltas;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.CopyView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.DeltaAccumulation;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.EnrichmentView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.FilterByConditionView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.JoinView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.SQLView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.UnionView;
import org.eclipse.efbt.cocamo.trl.model.trl_sql_views.VersionedSQLViewsModule;
import org.eclipse.efbt.cocamo.lineage.model.cube_transformation_logic.CubeTransformationLogic;
import org.eclipse.efbt.cocamo.lineage.model.cube_transformation_logic.Cube_transformation_logicFactory;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.BaseViewIncorporatingDeltasRowFunction;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.DeltaAccumulationRowFunction;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.FilterAndGroupToOneRowCreationApproach;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.FilterRowCreationApproach;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.GroupByRowCreationApproach;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.OneToOneRowCreationApproach;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.RowCreationApproachForCube;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.RowJoinFunction;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.UnionRowCreationApproach;
import org.eclipse.efbt.cocamo.lineage.model.row_transformation_logic.impl.Row_transformation_logicFactoryImpl;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.AggregateColumnFunction;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.BasicColumnFunction;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.ColumnFunction;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.ColumnFunctionGroup;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.Column_transformation_logicFactory;
import org.eclipse.efbt.cocamo.lineage.model.column_transformation_logic.StandardBasicColumnFunction;
import org.eclipse.efbt.cocamo.lineage.model.cube_schema.CubeSchema;
import org.eclipse.efbt.cocamo.lineage.model.cubes.DerivedCube;
import org.eclipse.efbt.cocamo.lineage.model.cubes.FreeBirdToolsCube;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* @author Neil Mackenzie
*
*/
public class TRLUtil {
/**
* Create a CubeTransformationLogic object form an SQLView.
*
* @param view
* @param functionalModuleLogicList
* @param cubeSchemaModuleList
* @param specialFunctions
* @return
*/
public static CubeTransformationLogic translateViewToFunctionalRowLogic(SQLView view,
EList<VersionedFunctionalModuleLogic> functionalModuleLogicList,
EList<VersionedCubeSchemaModule> cubeSchemaModuleList,
SpecialFunctionSpecs specialFunctions) {
CubeTransformationLogic cubeTransformationLogic = Cube_transformation_logicFactory.eINSTANCE.createCubeTransformationLogic();
ColumnFunctionGroup cfg = Column_transformation_logicFactory.eINSTANCE.createColumnFunctionGroup();
cubeTransformationLogic .setColumnFunctionGroup(cfg);
// columns created by row function
FreeBirdToolsCube derivedCube = view.getCube();
setFunctionalCubeLogic(view, cubeTransformationLogic ,
specialFunctions, functionalModuleLogicList, cubeSchemaModuleList);
if (view instanceof EnrichmentView) {
EList<BasicColumnFunction> calculatedColumns = ((EnrichmentView) view).getFunctions();
Iterator<BasicColumnFunction> calculatedColumnsIter = calculatedColumns.iterator();
while (calculatedColumnsIter.hasNext()) {
BasicColumnFunction calculatedColumn = calculatedColumnsIter.next();
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().
add(EcoreUtil.copy(calculatedColumn));
}
}
if (view instanceof AggregateEnrichmentView) {
EList<AggregateColumnFunction> calculatedColumns =
((AggregateEnrichmentView) view).getFunctions();
Iterator<AggregateColumnFunction> calculatedColumnsIter = calculatedColumns.iterator();
while (calculatedColumnsIter.hasNext()) {
AggregateColumnFunction calculatedColumn = calculatedColumnsIter.next();
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().
add(EcoreUtil.copy(calculatedColumn));
}
}
if ((view instanceof EnrichmentView) ||
(view instanceof CopyView) ||
(view instanceof FilterByConditionView)) {
// now for each column that is actually available in the source cube
// create a calculatedColumn using the specialCopycolumn Function.
// first create the CopyClumn FunctionSpec
EList<SQLView> dependantViews = getTheDependantViews(view, functionalModuleLogicList);
EList<CubeSchema> dependantSourceTables = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
Iterator<CubeSchema> dependantSourceTablesIter = dependantSourceTables.iterator();
while (dependantViewsIter.hasNext()) {
SQLView dependantView = dependantViewsIter.next();
EList<CubeColumn> columns =
getColumnsFromSQLView(dependantView, functionalModuleLogicList,
cubeSchemaModuleList, specialFunctions);
Iterator<CubeColumn> columnIter = columns.iterator();
while (columnIter.hasNext()) {
CubeColumn column = columnIter.next();
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + column.getVariable().getVariable_id());
calculatedColumn.setVariable(column.getVariable());
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column.getVariable());
columnParameter.setCube(dependantView.getCube());
function.getParameters().add(columnParameter);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
}
while (dependantSourceTablesIter.hasNext()) {
CubeSchema dependantSchema = dependantSourceTablesIter.next();
EList<VARIABLE> columns = Util.getVariablesFromBIRDCube(dependantSchema.getCube());
Iterator<VARIABLE> columnIter = columns.iterator();
while (columnIter.hasNext()) {
VARIABLE column = columnIter.next();
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + column.getVariable_id());
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column);
columnParameter.setCube(dependantSchema.getBaseCube());
function.getParameters().add(columnParameter);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
}
}
if (view instanceof AggregateEnrichmentView) {
EList<SQLView> dependantViews = getTheDependantViews(view, functionalModuleLogicList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
AggregateEnrichmentView aggView = (AggregateEnrichmentView) view;
while (dependantViewsIter.hasNext()) {
SQLView dependantView = dependantViewsIter.next();
// get the aggregates, and the groupbys
EList<VARIABLE> groupByColumnnTypedItems =
((AggregateEnrichmentView) view).getGroupByClause()
.getGroupByColumns();
// from these columns make the calculatedColumns
Iterator<VARIABLE> groupByColumnnTypedItemsIter = groupByColumnnTypedItems.iterator();
while (groupByColumnnTypedItemsIter.hasNext()) {
VARIABLE column = groupByColumnnTypedItemsIter.next();
AggregateColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE
.createAggregateColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + column.getVariable_id());
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
AggregateFunction function = FunctionsFactory.eINSTANCE.createAggregateFunction();
function.setFunctionSpec(specialFunctions.firstColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column);
columnParameter.setCube(dependantView.getCube());
function.getParameters().add(columnParameter);
calculatedColumn.setAggregateFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
}
EList<CubeSchema> dependantSourceCubes = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<CubeSchema> dependantSourceCubesIter = dependantSourceCubes.iterator();
while (dependantSourceCubesIter.hasNext()) {
CubeSchema dependantSchema = dependantSourceCubesIter.next();
// get the aggregates, and the groupbys
EList<VARIABLE> groupByColumnnTypedItems =
((AggregateEnrichmentView) view).getGroupByClause()
.getGroupByColumns();
// from these columns make the calculatedColumns
Iterator<VARIABLE> groupByColumnnTypedItemsIter = groupByColumnnTypedItems.iterator();
while (groupByColumnnTypedItemsIter.hasNext()) {
VARIABLE column = groupByColumnnTypedItemsIter.next();
AggregateColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE
.createAggregateColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + column.getVariable_id());
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
AggregateFunction function = FunctionsFactory.eINSTANCE.createAggregateFunction();
function.setFunctionSpec(specialFunctions.firstColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column);
columnParameter.setCube(dependantSchema.getBaseCube());
function.getParameters().add(columnParameter);
calculatedColumn.setAggregateFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
}
}
if (view instanceof JoinView) {
EList<SQLView> dependantViews = getTheDependantViews(view, functionalModuleLogicList);
EList<CubeSchema> dependantSourceCubes = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
Iterator<CubeSchema> dependantSourceCubesIter = dependantSourceCubes.iterator();
while (dependantViewsIter.hasNext()) {
SQLView dependantView = dependantViewsIter.next();
EList<CubeColumn> columns =
getColumnsFromSQLView(dependantView, functionalModuleLogicList,
cubeSchemaModuleList, specialFunctions);
Iterator<CubeColumn> columnIter = columns.iterator();
while (columnIter.hasNext()) {
CubeColumn column = columnIter.next();
// need to check if this is one of the ignored or replaced columns.
// we could possible do this by reusing the replace function on the main view
VARIABLE replacedColumn = ReplaceColumnUtil.replaceColumn((JoinView) view, dependantView,
column.getVariable());
if (replacedColumn != null) {
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + replacedColumn.getVariable_id());
calculatedColumn.setVariable(replacedColumn);
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column.getVariable());
columnParameter.setCube(dependantView.getCube());
function.getParameters().add(columnParameter);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().
getColumnFunctions().add(calculatedColumn);
}
}
}
while (dependantSourceCubesIter.hasNext()) {
CubeSchema dependantSchema = dependantSourceCubesIter.next();
EList<VARIABLE> columns = Util.getColumnsFromCubeSchema(dependantSchema);
Iterator<VARIABLE> columnIter = columns.iterator();
while (columnIter.hasNext()) {
VARIABLE column = columnIter.next();
VARIABLE replacedColumn =
ReplaceColumnUtil.replaceColumn((JoinView) view, dependantSchema.getBaseCube(),
column);
if (replacedColumn != null) {
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + replacedColumn.getVariable_id());
calculatedColumn.setVariable(replacedColumn);
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(column);
columnParameter.setCube(dependantSchema.getBaseCube());
function.getParameters().add(columnParameter);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
}
}
}
if (view instanceof UnionView) {
// now for each column that is actually available in the source cube
// create a calculatedColumn using the specialCopycolumn Function.
// first create the CopyClumn FunctionSpec
// we should complain if they are not all compatible cubes.
// then just use the first one, for structure, and then create a
// calculated column for each field,
// however the we should have a parameter for each dependent cube
EList<SQLView> dependantViews = getTheDependantViews(view, functionalModuleLogicList);
EList<CubeSchema> dependantSourceCubes = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
Iterator<CubeSchema> dependantSourceTablesIter = dependantSourceCubes.iterator();
boolean first = true;
while (dependantViewsIter.hasNext()) {
SQLView dependantView = dependantViewsIter.next();
if (first) {
EList<CubeColumn> theColumns =
getColumnsFromSQLView(dependantView, functionalModuleLogicList,
cubeSchemaModuleList, specialFunctions);
Iterator<CubeColumn> columnIter = theColumns.iterator();
while (columnIter.hasNext()) {
CubeColumn column = columnIter.next();
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + column.getVariable().getVariable_id());
calculatedColumn.setVariable(column.getVariable());
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns =
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions()
.iterator();
while (theCalculatedColumns.hasNext()) {
// for each calculated column we need to add a dependant column with this table
StandardBasicColumnFunction theCalculatedColumn =
(StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantView.getCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
}
while (dependantSourceTablesIter.hasNext()) {
CubeSchema dependantSchema = dependantSourceTablesIter.next();
if (first) {
EList<VARIABLE> theColumns = Util.getColumnsFromCubeSchema(dependantSchema);
Iterator<VARIABLE> columnIter = theColumns.iterator();
while (columnIter.hasNext()) {
VARIABLE column = columnIter.next();
StandardBasicColumnFunction calculatedColumn =
Column_transformation_logicFactory.eINSTANCE
.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(
view.getCube().getName() + ":" + column.getVariable_id());
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
BasicFunction function = FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns =
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions()
.iterator();
while (theCalculatedColumns.hasNext()) {
// for each calculated column we need to add a dependant column with this cube
StandardBasicColumnFunction theCalculatedColumn =
(StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantSchema.getBaseCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
}
}
if (view instanceof ReportCellView) {
// we want the groupbycolumns and the agregate column...
// we just make a plain assumption that the source is a groupby transformation.
EList<SQLView> dependantViews = getTheDependantViews(view, functionalModuleLogicList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
ReportCellView dpView = (ReportCellView) view;
while (dependantViewsIter.hasNext()) {
SQLView dependantView = dependantViewsIter.next();
VARIABLE measure = getMeasure(dpView);
AggregateColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE
.createAggregateColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +
":" + measure.getVariable_id());
calculatedColumn.setVariable(measure);
calculatedColumn.setCube(view.getCube());
AggregateFunction function = FunctionsFactory.eINSTANCE.createAggregateFunction();
function.setFunctionSpec(specialFunctions.sumColumnSpec);
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(measure);
columnParameter.setCube(dependantView.getCube());
function.getParameters().add(columnParameter);
calculatedColumn.setAggregateFunction(function);
cubeTransformationLogic .getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
Iterator<COMBINATION_ITEM> dimensions = getDimensionValues(dpView);
while (dimensions.hasNext()) {
COMBINATION_ITEM dimensionVal = dimensions.next();
VARIABLE dimension = dimensionVal.getVariable_id();
AggregateColumnFunction calculatedColumnForDimension =
Column_transformation_logicFactory.eINSTANCE
.createAggregateColumnFunction();
calculatedColumnForDimension.setColumnID(view.getCube().getName() +
":" + dimension.getVariable_id());
calculatedColumnForDimension.setVariable(dimension);
calculatedColumnForDimension.setCube(view.getCube());
AggregateFunction functionForDimension =
FunctionsFactory.eINSTANCE.createAggregateFunction();
functionForDimension.setFunctionSpec(specialFunctions.firstColumnSpec);
calculatedColumnForDimension.setAggregateFunction(functionForDimension);
SpeculativeCubeColumnParameter dimensionColumnParameter = LineagefunctionsFactory.eINSTANCE
.createSpeculativeCubeColumnParameter();
dimensionColumnParameter.setColumn(dimension);
dimensionColumnParameter.setCube(dependantView.getCube());
functionForDimension.getParameters().add(dimensionColumnParameter);
cubeTransformationLogic .getColumnFunctionGroup().
getColumnFunctions().add(calculatedColumnForDimension);
}
}
}
if(view instanceof DeltaAccumulation)
{
EList<CubeSchema> dependantSourceTables = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<CubeSchema> dependantSourceTablesIter = dependantSourceTables.iterator();
boolean first = true;
EList<SQLView> dependantViews = getTheDependantViews(view,functionalModuleLogicList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
/**while (dependantViewsIter.hasNext())
{
SQLView dependantView = dependantViewsIter.next();
if (first)
{
EList<CubeColumn> theColumns = getColumnsFromSQLView(dependantView, functionalModuleLogicList,cubeSchemaModuleList, specialFunctions);
Iterator<CubeColumn> columnIter = theColumns.iterator();
while(columnIter.hasNext())
{
CubeColumn column = columnIter.next();
StandardBasicColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getCube_name() +":" + column.getVariable().getVariable_id() );
calculatedColumn.setVariable(column.getVariable());
calculatedColumn.setCube(view.getCube());
BasicFunction function= FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns = cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().iterator();
while (theCalculatedColumns.hasNext())
{
//for each calculated column we need to add a dependant column with this table
StandardBasicColumnFunction theCalculatedColumn = (StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = FunctionsFactory.eINSTANCE.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantView.getCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
}**/
while (dependantSourceTablesIter.hasNext())
{
CubeSchema dependantSchema= dependantSourceTablesIter.next();
if (first)
{
EList<VARIABLE> theColumns = Util.getColumnsFromCubeSchema(dependantSchema);
Iterator<VARIABLE> columnIter = theColumns.iterator();
while(columnIter.hasNext())
{
VARIABLE column = columnIter.next();
StandardBasicColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +":" + column.getVariable_id() );
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
BasicFunction function= FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns = cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().iterator();
while (theCalculatedColumns.hasNext())
{
//for each calculated column we need to add a dependant column with this table
StandardBasicColumnFunction theCalculatedColumn = (StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantSchema.getBaseCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
}
}
if(view instanceof BaseViewIncorporatingDeltas)
{
EList<CubeSchema> dependantSourceTables = getAnySourceCubes(view, cubeSchemaModuleList);
Iterator<CubeSchema> dependantSourceTablesIter = dependantSourceTables.iterator();
boolean first = true;
EList<SQLView> dependantViews = getTheDependantViews(view,functionalModuleLogicList);
Iterator<SQLView> dependantViewsIter = dependantViews.iterator();
/**while (dependantViewsIter.hasNext())
{
SQLView dependantView = dependantViewsIter.next();
if (first)
{
EList<CubeColumn> theColumns = getColumnsFromSQLView(dependantView, functionalModuleLogicList,cubeSchemaModuleList, specialFunctions);
Iterator<CubeColumn> columnIter = theColumns.iterator();
while(columnIter.hasNext())
{
CubeColumn column = columnIter.next();
StandardBasicColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getCube_name() +":" + column.getVariable().getVariable_id() );
calculatedColumn.setVariable(column.getVariable());
calculatedColumn.setCube(view.getCube());
BasicFunction function= FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns = cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().iterator();
while (theCalculatedColumns.hasNext())
{
//for each calculated column we need to add a dependant column with this table
StandardBasicColumnFunction theCalculatedColumn = (StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = FunctionsFactory.eINSTANCE.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantView.getCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
} */
while (dependantSourceTablesIter.hasNext())
{
CubeSchema dependantSchema= dependantSourceTablesIter.next();
if (first)
{
EList<VARIABLE> theColumns = Util.getColumnsFromCubeSchema(dependantSchema);
Iterator<VARIABLE> columnIter = theColumns.iterator();
while(columnIter.hasNext())
{
VARIABLE column = columnIter.next();
StandardBasicColumnFunction calculatedColumn = Column_transformation_logicFactory.eINSTANCE.createStandardBasicColumnFunction();
calculatedColumn.setColumnID(view.getCube().getName() +":" + column.getVariable_id() );
calculatedColumn.setVariable(column);
calculatedColumn.setCube(view.getCube());
BasicFunction function= FunctionsFactory.eINSTANCE.createBasicFunction();
function.setFunctionSpec(specialFunctions.copyColumnSpec);
calculatedColumn.setBasicFunction(function);
cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().add(calculatedColumn);
}
first = false;
}
Iterator<ColumnFunction> theCalculatedColumns = cubeTransformationLogic.getColumnFunctionGroup().getColumnFunctions().iterator();
while (theCalculatedColumns.hasNext())
{
//for each calculated column we need to add a dependant column with this table
StandardBasicColumnFunction theCalculatedColumn = (StandardBasicColumnFunction) theCalculatedColumns.next();
SpeculativeCubeColumnParameter columnParameter = LineagefunctionsFactory.eINSTANCE.createSpeculativeCubeColumnParameter();
columnParameter.setColumn(theCalculatedColumn.getVariable());
columnParameter.setCube(dependantSchema.getBaseCube());
theCalculatedColumn.getBasicFunction().getParameters().add(columnParameter);
}
}
}
return cubeTransformationLogic ;
}
/**
* Set the RowCreationApproachForCube of a cubeTransformationLogic .
*
* @param view
* @param cubeTransformationLogic
* @param specialFunctions
* @param functionalModuleLogicList
* @param cubeSchemaModuleList
*/
private static void setFunctionalCubeLogic(SQLView view, CubeTransformationLogic cubeTransformationLogic ,
SpecialFunctionSpecs specialFunctions, EList<VersionedFunctionalModuleLogic> functionalModuleLogicList,
EList<VersionedCubeSchemaModule> cubeSchemaModuleList) {
if ((view instanceof CopyView) || (view instanceof EnrichmentView)) {
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
OneToOneRowCreationApproach oneToOneRowCreationApproach = Row_transformation_logicFactoryImpl.eINSTANCE
.createOneToOneRowCreationApproach();
rowCreationApproachForCube.setRowCreationApproach(oneToOneRowCreationApproach);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
if (view instanceof FilterByConditionView) {
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
FilterRowCreationApproach rowFilterFunction = Row_transformation_logicFactoryImpl.eINSTANCE.createFilterRowCreationApproach();
rowFilterFunction
.setFilterFunction(EcoreUtil.copy(((FilterByConditionView) view).getWhereClause().getFunction()));
rowCreationApproachForCube.setRowCreationApproach(rowFilterFunction);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
if (view instanceof JoinView) {
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
RowJoinFunction rowJoinFunction = Row_transformation_logicFactoryImpl.eINSTANCE.createRowJoinFunction();
rowJoinFunction.setJoinFunction(EcoreUtil.copy((((JoinView) view).getWhereClause().getFunction())));
rowCreationApproachForCube.setRowCreationApproach(rowJoinFunction);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
if (view instanceof AggregateEnrichmentView) {
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
GroupByRowCreationApproach groupByFunction = Row_transformation_logicFactoryImpl.eINSTANCE.createGroupByRowCreationApproach();
groupByFunction.getGroupByColumns()
.addAll((((AggregateEnrichmentView) view).getGroupByClause().getGroupByColumns()));
rowCreationApproachForCube.setRowCreationApproach(groupByFunction);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
if (view instanceof ReportCellView) {
// get the dependent view
SQLView dependantView = getTheDependantViews(view, functionalModuleLogicList).get(0);
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
FilterAndGroupToOneRowCreationApproach rowFilterAndGroupFunction = Row_transformation_logicFactoryImpl.eINSTANCE
.createFilterAndGroupToOneRowCreationApproach();
BooleanFunction bf = FunctionsFactory.eINSTANCE.createBooleanFunction();
// this is a hack to make it work for 1 dimension, we need
// to change to make it work for multiple dimensions
Iterator<COMBINATION_ITEM> dimensionValues = getDimensionValues((ReportCellView) view);
while (dimensionValues.hasNext()) {
COMBINATION_ITEM dimValue = dimensionValues.next();
rowFilterAndGroupFunction.getGroupByVariables().add(dimValue.getVariable_id());
BooleanFunction bf2 = FunctionsFactory.eINSTANCE.createBooleanFunction();
bf2.setFunctionSpec(specialFunctions.equalsSpec);
SpeculativeCubeColumnParameter param = LineagefunctionsFactory.eINSTANCE.createSpeculativeCubeColumnParameter();
param.setColumn(dimValue.getVariable_id());
param.setCube(dependantView.getCube());
bf2.getParameters().add(param);
MemberParameter memberparam = LineagefunctionsFactory.eINSTANCE.createMemberParameter();
memberparam.setParam(dimValue.getMember_id());
bf2.getParameters().add(memberparam);
rowFilterAndGroupFunction.setFilterFunction(bf2);
}
rowCreationApproachForCube.setRowCreationApproach(rowFilterAndGroupFunction);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
if(view instanceof DeltaAccumulation )
{
RowCreationApproachForCube tableLogic = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
DeltaAccumulationRowFunction rowDAFunction = Row_transformation_logicFactoryImpl.eINSTANCE.createDeltaAccumulationRowFunction();
rowDAFunction.setUltimateCubeSource(((DeltaAccumulation)view).getUltimateSourceCube());
tableLogic.setRowCreationApproach(rowDAFunction);
tableLogic.setCube(view.getCube());
tableLogic.setUltimateCubeSource(((DeltaAccumulation)view).getUltimateSourceCube());
tableLogic.setName(view.getName());
cubeTransformationLogic.setRowCreationApproachForCube(tableLogic);
}
if(view instanceof BaseViewIncorporatingDeltas )
{
RowCreationApproachForCube tableLogic = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
BaseViewIncorporatingDeltasRowFunction rowbvFunction = Row_transformation_logicFactoryImpl.eINSTANCE.createBaseViewIncorporatingDeltasRowFunction();
rowbvFunction.setUltimateCubeSource(((BaseViewIncorporatingDeltas)view).getUltimateSourceCube());
tableLogic.setRowCreationApproach(rowbvFunction);
tableLogic.setCube(view.getCube());
tableLogic.setUltimateCubeSource(((BaseViewIncorporatingDeltas)view).getUltimateSourceCube());
tableLogic.setName(view.getName());
cubeTransformationLogic.setRowCreationApproachForCube(tableLogic);
}
if (view instanceof UnionView) {
RowCreationApproachForCube rowCreationApproachForCube = Row_transformation_logicFactoryImpl.eINSTANCE.createRowCreationApproachForCube();
UnionRowCreationApproach urf = Row_transformation_logicFactoryImpl.eINSTANCE.createUnionRowCreationApproach();
rowCreationApproachForCube.setRowCreationApproach(urf);
rowCreationApproachForCube.setCube(view.getCube());
rowCreationApproachForCube.setName(view.getName());
cubeTransformationLogic .setRowCreationApproachForCube(rowCreationApproachForCube);
}
}
/**
* Return the columns associated with an SQLView.
* @param view
* @param functionalModuleLogicList
* @param cubeSchemaModuleList
* @param specialFunctions
* @return
*/
public static EList<CubeColumn> getColumnsFromSQLView(SQLView view,
EList<VersionedFunctionalModuleLogic> functionalModuleLogicList,
EList<VersionedCubeSchemaModule> cubeSchemaModuleList, SpecialFunctionSpecs specialFunctions) {
CubeTransformationLogic rowLogic = translateViewToFunctionalRowLogic(view, functionalModuleLogicList,
cubeSchemaModuleList, specialFunctions);
return AttributeLineageUtilImpl.getColumnsFromFunctionalRowLogic(rowLogic);
}
/**
* Return the Views dependant upon a view
* @param view
* @param functionalModuleLogicList
* @return
*/
public static EList<SQLView> getTheDependantViews(SQLView view,
EList<VersionedFunctionalModuleLogic> functionalModuleLogicList) {
BasicEList<SQLView> dependantViews = new BasicEList<SQLView>();
EList<FreeBirdToolsCube> dependantCubes = ((DerivedCube) (view.getCube())).getSourceCubes();
Iterator<FreeBirdToolsCube> dependantCubesIter = dependantCubes.iterator();
while (dependantCubesIter.hasNext()) {
FreeBirdToolsCube dtd = dependantCubesIter.next();
EList<SQLView> viewList = getAllViews(functionalModuleLogicList);
Iterator<SQLView> iter = viewList.iterator();
FreeBirdToolsCube cube = null;
while (iter.hasNext()) {
SQLView tableDefinitionItem = iter.next();
cube = tableDefinitionItem.getCube();
if (cube.equals(dtd)) {
dependantViews.add((SQLView) tableDefinitionItem);
}
}
}
return dependantViews;
}
/**
* et all the SQLViews associated with a list of VersionedFunctionalModuleLogics
* @param functionalModuleLogicList
* @return
*/
private static EList<SQLView> getAllViews(EList<VersionedFunctionalModuleLogic> functionalModuleLogicList) {
EList<SQLView> returnList = new BasicEList<SQLView>();
for (Iterator iterator = functionalModuleLogicList.iterator(); iterator.hasNext();) {
VersionedFunctionalModuleLogic dataSetTransformationModule = (VersionedFunctionalModuleLogic) iterator
.next();
EList<SQLView> views = ((VersionedSQLViewsModule) dataSetTransformationModule).getSqlViews();
for (Iterator iterator2 = views.iterator(); iterator2.hasNext();) {
SQLView sqlView = (SQLView) iterator2.next();
returnList.add(sqlView);
}
}
return returnList;
}
/**
* Get source cubes of a view in the context of a list of cubeSchemaModules.
* @param view
* @param cubeSchemaModules
* @return
*/
public static EList<CubeSchema> getAnySourceCubes(SQLView view,
EList<VersionedCubeSchemaModule> cubeSchemaModules) {
BasicEList<CubeSchema> dependantSourceCube = new BasicEList<CubeSchema>();
CubeSchema dependantSchema = null;
EList<FreeBirdToolsCube> sourceCubeList = ((DerivedCube) view.getCube()).getSourceCubes();
Iterator<FreeBirdToolsCube> dependantCubesIter = sourceCubeList.iterator();
EList<CubeSchema> cubeSchemas = Util.getSchemas(cubeSchemaModules);
while (dependantCubesIter.hasNext()) {
FreeBirdToolsCube dtd = dependantCubesIter.next();
// loop through the context and get any views which are linked to the cube.
Iterator<CubeSchema> iter = cubeSchemas.iterator();
FreeBirdToolsCube hlItem = null;
while (iter.hasNext()) {
CubeSchema tableDefinitionItem = iter.next();
hlItem = ((CubeSchema) tableDefinitionItem).getBaseCube();
if (hlItem.equals(dtd)) {
dependantSourceCube.add((CubeSchema) tableDefinitionItem);
}
}
}
return dependantSourceCube;
}
/**
* Returns the SMCubesModel
* @param o
* @return
*/
public static SmcubesModel getSmcubesModelContainingObject(EObject o) {
return (SmcubesModel) o.eContainer().eContainer();
}
public static EList<CUBE_STRUCTURE_ITEM> getCubeStructureItemsFromDefaultBIRDModel(CubeSchema schema)
{
CUBE cube = schema.getCube();
SmcubesModel birdModel = getSmcubesModelContainingObject(cube);
EList<CubeModule> cubeModules = birdModel.getCubes();
CUBE_STRUCTURE cubeStructure = cube.getCube_structure_id();
EList<CUBE_STRUCTURE_ITEM> returnlist = new BasicEList<CUBE_STRUCTURE_ITEM>();
for (Iterator iterator = cubeModules.iterator(); iterator.hasNext();) {
CubeModule cubeModule = (CubeModule) iterator.next();
EList<CUBE_STRUCTURE_ITEM> items = cubeModule.getCubeStructureItems();
for (Iterator iterator2 = items.iterator(); iterator2.hasNext();) {
CUBE_STRUCTURE_ITEM cube_STRUCTURE_ITEM = (CUBE_STRUCTURE_ITEM) iterator2.next();
if(cube_STRUCTURE_ITEM.getCube_structure_id().equals(cubeStructure))
{
returnlist.add(cube_STRUCTURE_ITEM);
}
}
}
return returnlist;
}
/**
* Return the associated reportCellView for a reportCell in the context of a componentSet.
* @param reportCell
* @param componentSet