Skip to main content
summaryrefslogtreecommitdiffstats
blob: a12c7d875bb00556e8c6c7b048a8b6c344ab5d59 (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.artifact;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import org.eclipse.nebula.widgets.xviewer.XViewerCells;
import org.eclipse.osee.ats.artifact.ATSLog.LogType;
import org.eclipse.osee.ats.artifact.TeamWorkFlowArtifact.DefaultTeamState;
import org.eclipse.osee.ats.editor.SMAEditor;
import org.eclipse.osee.ats.editor.stateItem.AtsStateItems;
import org.eclipse.osee.ats.editor.stateItem.IAtsStateItem;
import org.eclipse.osee.ats.internal.AtsPlugin;
import org.eclipse.osee.ats.util.AtsArtifactTypes;
import org.eclipse.osee.ats.util.AtsNotifyUsers;
import org.eclipse.osee.ats.util.AtsRelationTypes;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.util.DeadlineManager;
import org.eclipse.osee.ats.util.Overview;
import org.eclipse.osee.ats.util.Overview.PreviewStyle;
import org.eclipse.osee.ats.util.StateManager;
import org.eclipse.osee.ats.util.widgets.ReviewManager;
import org.eclipse.osee.ats.workflow.ATSXWidgetOptionResolver;
import org.eclipse.osee.ats.workflow.AtsWorkPage;
import org.eclipse.osee.ats.workflow.item.AtsStatePercentCompleteWeightRule;
import org.eclipse.osee.ats.workflow.item.AtsWorkDefinitions;
import org.eclipse.osee.ats.world.IWorldViewArtifact;
import org.eclipse.osee.framework.access.AccessControlManager;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.SystemUser;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.IRelationEnumeration;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactFactory;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.ui.plugin.util.Result;
import org.eclipse.osee.framework.ui.skynet.FrameworkArtifactImageProvider;
import org.eclipse.osee.framework.ui.skynet.group.IGroupExplorerProvider;
import org.eclipse.osee.framework.ui.skynet.notify.OseeNotificationManager;
import org.eclipse.osee.framework.ui.skynet.util.ChangeType;
import org.eclipse.osee.framework.ui.skynet.util.email.EmailGroup;
import org.eclipse.osee.framework.ui.skynet.widgets.XDate;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkFlowDefinition;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkFlowDefinitionFactory;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkItemDefinition;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkPageDefinition;
import org.eclipse.osee.framework.ui.skynet.widgets.workflow.WorkRuleDefinition;
import org.eclipse.swt.graphics.Image;

/**
 * @author Donald G. Dunne
 */
public abstract class StateMachineArtifact extends ATSArtifact implements IGroupExplorerProvider, IWorldViewArtifact, ISubscribableArtifact, IFavoriteableArtifact {

   private final Set<IRelationEnumeration> atsWorldRelations = new HashSet<IRelationEnumeration>();
   private Collection<User> preSaveStateAssignees;
   private User preSaveOriginator;
   public static double DEFAULT_HOURS_PER_WORK_DAY = 8;
   protected WorkFlowDefinition workFlowDefinition;
   protected Artifact parent;
   protected StateMachineArtifact parentSma;
   protected TeamWorkFlowArtifact parentTeamArt;
   protected ActionArtifact parentAction;
   private Collection<User> transitionAssignees;
   private static String SEPERATOR = ";  ";
   private StateManager stateMgr;
   private DeadlineManager deadlineMgr;
   private SMAEditor editor;
   private ATSLog atsLog;
   private ATSNote atsNote;
   private static final AtsStateItems stateItems = new AtsStateItems();
   private boolean inTransition = false;
   public static enum TransitionOption {
      None, Persist,
      // Override check whether workflow allows transition to state
      OverrideTransitionValidityCheck,
      // Allows transition to occur with UnAssigned, OseeSystem or Guest
      OverrideAssigneeCheck
   };

   public StateMachineArtifact(ArtifactFactory parentFactory, String guid, String humanReadableId, Branch branch, ArtifactType artifactType) throws OseeDataStoreException {
      super(parentFactory, guid, humanReadableId, branch, artifactType);
   }

   @Override
   public void onBirth() throws OseeCoreException {
      super.onBirth();
      setSoleAttributeValue(ATSAttributes.CURRENT_STATE_ATTRIBUTE.getStoreName(), "");
   }

   @Override
   public void onInitializationComplete() {
      super.onInitializationComplete();
      initializeSMA();
   }

   @Override
   public void reloadAttributesAndRelations() throws OseeCoreException {
      super.reloadAttributesAndRelations();
      initializeSMA();
   }

   protected void initializeSMA() {
      initalizePreSaveCache();
   }

   public void initalizePreSaveCache() {
      try {
         deadlineMgr = new DeadlineManager(this);
         stateMgr = new StateManager(this);
         atsLog = new ATSLog(this);
         atsNote = new ATSNote(this);
         preSaveStateAssignees = getStateMgr().getAssignees();
         if (getOriginator() == null) {
            preSaveOriginator = UserManager.getUser();
         } else {
            preSaveOriginator = getOriginator();
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
      }
   }

   public boolean hasAtsWorldChildren() throws OseeCoreException {
      for (IRelationEnumeration iRelationEnumeration : atsWorldRelations) {
         if (getRelatedArtifactsCount(iRelationEnumeration) > 0) {
            return true;
         }
      }
      return false;
   }

   public String getHelpContext() {
      return "atsWorkflowEditorWorkflowTab";
   }

   public String getArtifactSuperTypeName() {
      return getArtifactTypeName();
   }

   @Override
   public Date getWorldViewDeadlineDate() throws OseeCoreException {
      return null;
   }

   @Override
   public String getWorldViewDeadlineDateStr() throws OseeCoreException {
      return "";
   }

   @Override
   public String getWorldViewDescription() throws OseeCoreException {
      return "";
   }

   @Override
   public String getWorldViewImplementer() throws OseeCoreException {
      return Artifacts.toString("; ", getImplementers());
   }

   public Collection<User> getImplementersByState(String stateName) throws OseeCoreException {
      if (isCancelled()) {
         return Arrays.asList(getLog().getCancelledLogItem().getUser());
      }
      Collection<User> users = new HashSet<User>(getStateMgr().getAssignees(stateName));
      LogItem item = getLog().getCompletedLogItem();
      if (item != null) {
         users.add(item.getUser());
      }
      return users;
   }

   public Collection<User> getImplementers() throws OseeCoreException {
      return Collections.emptyList();
   }

   @Override
   public String getWorldViewTeam() throws OseeCoreException {
      return null;
   }

   @Override
   public String getWorldViewGroups() throws OseeCoreException {
      return Artifacts.toString("; ", getRelatedArtifacts(CoreRelationTypes.Universal_Grouping__Group));
   }

   @Override
   public String getWorldViewGoals() throws OseeCoreException {
      return Artifacts.toString("; ", getRelatedArtifacts(AtsRelationTypes.Goal_Goal));
   }

   @Override
   public double getWorldViewWeeklyBenefit() throws OseeCoreException {
      return 0;
   }

   @Override
   public void onAttributePersist(SkynetTransaction transaction) throws OseeCoreException {
      // Since multiple ways exist to change the assignees, notification is performed on the persist
      if (isDeleted()) {
         return;
      }
      try {
         notifyNewAssigneesAndReset();
         notifyOriginatorAndReset();
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
      }
   }

   /**
    * Override to apply different algorithm to current section expansion.
    *
    * @param page
    * @return true if section should be expanded
    * @throws OseeCoreException
    */
   public boolean isCurrentSectionExpanded(String stateName) throws OseeCoreException {
      return getStateMgr().getCurrentStateName().equals(stateName);
   }

   public void notifyNewAssigneesAndReset() throws OseeCoreException {
      if (preSaveStateAssignees == null) {
         preSaveStateAssignees = getStateMgr().getAssignees();
         return;
      }
      Set<User> newAssignees = new HashSet<User>();
      for (User user : getStateMgr().getAssignees()) {
         if (!preSaveStateAssignees.contains(user)) {
            newAssignees.add(user);
         }
      }
      preSaveStateAssignees = getStateMgr().getAssignees();
      if (newAssignees.isEmpty()) {
         return;
      }
      try {
         // These will be processed upon save
         AtsNotifyUsers.getInstance().notify(this, newAssignees, AtsNotifyUsers.NotifyType.Assigned);
      } catch (OseeCoreException ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
      }
   }

   public void notifyOriginatorAndReset() throws OseeCoreException {
      if (preSaveOriginator != null && getOriginator() != null && !getOriginator().equals(preSaveOriginator)) {
         AtsNotifyUsers.getInstance().notify(this, AtsNotifyUsers.NotifyType.Originator);
      }
      preSaveOriginator = getOriginator();
   }

   public boolean isValidationRequired() throws OseeCoreException {
      return false;
   }

   public abstract Set<User> getPrivilegedUsers() throws OseeCoreException;

   public String getDescription() {
      return "";
   }

   public ArrayList<EmailGroup> getEmailableGroups() throws OseeCoreException {
      ArrayList<EmailGroup> groupNames = new ArrayList<EmailGroup>();
      ArrayList<String> emails = new ArrayList<String>();
      emails.add(getOriginator().getEmail());
      groupNames.add(new EmailGroup("Originator", emails));
      if (getStateMgr().getAssignees().size() > 0) {
         emails = new ArrayList<String>();
         for (User u : getStateMgr().getAssignees()) {
            emails.add(u.getEmail());
         }
         groupNames.add(new EmailGroup("Assignees", emails));
      }
      return groupNames;
   }

   public StateMachineArtifact getParentSMA() throws OseeCoreException {
      return parentSma;
   }

   public ActionArtifact getParentActionArtifact() throws OseeCoreException {
      return parentAction;
   }

   public TeamWorkFlowArtifact getParentTeamWorkflow() throws OseeCoreException {
      return parentTeamArt;
   }

   public String getPreviewHtml() throws OseeCoreException {
      return getPreviewHtml(PreviewStyle.NONE);
   }

   public String getPreviewHtml(PreviewStyle... styles) throws OseeCoreException {
      Overview o = new Overview();
      o.addHeader(this, styles);
      o.addFooter(this, styles);
      return o.getPage();
   }

   public boolean isUnCancellable() {
      try {
         LogItem item = getLog().getStateEvent(LogType.StateCancelled);
         if (item == null) {
            throw new OseeArgumentException("No Cancelled Event");
         }
         for (WorkPageDefinition toWorkPageDefinition : getWorkFlowDefinition().getToPages(getWorkPageDefinition())) {
            if (toWorkPageDefinition.getPageName().equals(item.getState())) {
               return true;
            }
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
      }
      return false;
   }

   public boolean isTaskable() throws OseeCoreException {
      if (isCompleted() || isCancelled()) {
         return false;
      }
      return true;
   }

   public boolean showTaskTab() throws OseeCoreException {
      return isTaskable();
   }

   public String getEditorTitle() throws OseeCoreException {
      return getWorldViewType() + ": " + getName();
   }

   public String getWorldViewActionableItems() throws OseeCoreException {
      return "";
   }

   /**
    * Registers relation as part of the parent/child hierarchy in ATS World
    */
   public void registerAtsWorldRelation(AtsRelationTypes side) {
      atsWorldRelations.add(side);
   }

   public Image getAssigneeImage() throws OseeCoreException {
      if (isDeleted()) {
         return null;
      }
      return FrameworkArtifactImageProvider.getUserImage(getStateMgr().getAssignees());
   }

   public WorkFlowDefinition getWorkFlowDefinition() throws OseeCoreException {
      if (workFlowDefinition == null) {
         try {
            workFlowDefinition = WorkFlowDefinitionFactory.getWorkFlowDefinition(this);
         } catch (Exception ex) {
            OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
         }
      }
      return workFlowDefinition;
   }

   public void addSubscribed(User user, SkynetTransaction transaction) throws OseeCoreException {
      if (!getRelatedArtifacts(AtsRelationTypes.SubscribedUser_User).contains(user)) {
         addRelation(AtsRelationTypes.SubscribedUser_User, user);
         persist(transaction);
      }

   }

   public void removeSubscribed(User user, SkynetTransaction transaction) throws OseeCoreException {
      deleteRelation(AtsRelationTypes.SubscribedUser_User, user);
      persist(transaction);
   }

   public boolean isSubscribed(User user) throws OseeCoreException {
      return getRelatedArtifacts(AtsRelationTypes.SubscribedUser_User).contains(user);
   }

   public ArrayList<User> getSubscribed() throws OseeCoreException {
      ArrayList<User> arts = new ArrayList<User>();
      for (Artifact art : getRelatedArtifacts(AtsRelationTypes.SubscribedUser_User)) {
         arts.add((User) art);
      }
      return arts;
   }

   public void addFavorite(User user, SkynetTransaction transaction) throws OseeCoreException {
      if (!getRelatedArtifacts(AtsRelationTypes.FavoriteUser_User).contains(user)) {
         addRelation(AtsRelationTypes.FavoriteUser_User, user);
         persist(transaction);
      }
   }

   public void removeFavorite(User user, SkynetTransaction transaction) throws OseeCoreException {
      deleteRelation(AtsRelationTypes.FavoriteUser_User, user);
      persist(transaction);
   }

   public boolean isFavorite(User user) throws OseeCoreException {
      return getRelatedArtifacts(AtsRelationTypes.FavoriteUser_User).contains(user);
   }

   public ArrayList<User> getFavorites() throws OseeCoreException {
      ArrayList<User> arts = new ArrayList<User>();
      for (Artifact art : getRelatedArtifacts(AtsRelationTypes.FavoriteUser_User)) {
         arts.add((User) art);
      }
      return arts;
   }

   public boolean amISubscribed() {
      try {
         return isSubscribed(UserManager.getUser());
      } catch (OseeCoreException ex) {
         return false;
      }
   }

   public boolean amIFavorite() {
      try {
         return isFavorite(UserManager.getUser());
      } catch (OseeCoreException ex) {
         return false;
      }
   }

   @Override
   public void atsDelete(Set<Artifact> deleteArts, Map<Artifact, Object> allRelated) throws OseeCoreException {
      SMAEditor.close(Collections.singleton(this), true);
      super.atsDelete(deleteArts, allRelated);
   }

   public String getWorldViewType() throws OseeCoreException {
      return getArtifactTypeName();
   }

   public String getWorldViewTitle() throws OseeCoreException {
      return getName();
   }

   public String getWorldViewState() throws OseeCoreException {
      return getStateMgr().getCurrentStateName();
   }

   public String implementersStr = null;

   public String getWorldViewActivePoc() throws OseeCoreException {
      if (isCancelledOrCompleted()) {
         if (implementersStr == null) {
            if (getImplementers().size() > 0) {
               implementersStr = "(" + Artifacts.toString("; ", getImplementers()) + ")";
            }
         }
         return implementersStr;
      }
      return Artifacts.toString("; ", getStateMgr().getAssignees());
   }

   public String getWorldViewCreatedDateStr() throws OseeCoreException {
      if (getWorldViewCreatedDate() == null) {
         return XViewerCells.getCellExceptionString("No creation date");
      }
      return new XDate(getWorldViewCreatedDate()).getMMDDYYHHMM();
   }

   public String getWorldViewCompletedDateStr() throws OseeCoreException {
      if (isCompleted()) {
         if (getWorldViewCompletedDate() == null) {
            OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "Completed with no date => " + getHumanReadableId());
            return XViewerCells.getCellExceptionString("Completed with no date.");
         }
         return new XDate(getWorldViewCompletedDate()).getMMDDYYHHMM();
      }
      return "";
   }

   public String getWorldViewCancelledDateStr() throws OseeCoreException {
      if (isCancelled()) {
         if (getWorldViewCancelledDate() == null) {
            OseeLog.log(AtsPlugin.class, Level.SEVERE, "Cancelled with no date => " + getHumanReadableId());
            return XViewerCells.getCellExceptionString("Cancelled with no date.");
         }
         return new XDate(getWorldViewCancelledDate()).getMMDDYYHHMM();
      }
      return "";
   }

   public Date getWorldViewCreatedDate() throws OseeCoreException {
      return getLog().getCreationDate();
   }

   public String getWorldViewOriginator() throws OseeCoreException {
      return getOriginator().getName();
   }

   public String getWorldViewID() throws OseeCoreException {
      return getHumanReadableId();
   }

   public String getWorldViewLegacyPCR() throws OseeCoreException {
      if (isAttributeTypeValid(ATSAttributes.LEGACY_PCR_ID_ATTRIBUTE.getStoreName())) {
         return getSoleAttributeValue(ATSAttributes.LEGACY_PCR_ID_ATTRIBUTE.getStoreName(), "");
      }
      return "";
   }

   public Date getWorldViewCompletedDate() throws OseeCoreException {
      LogItem item = getLog().getCompletedLogItem();
      if (item != null) {
         return item.getDate();
      }
      return null;
   }

   public Date getWorldViewCancelledDate() throws OseeCoreException {
      LogItem item = getLog().getCancelledLogItem();
      if (item != null) {
         return item.getDate();
      }
      return null;
   }

   public abstract VersionArtifact getWorldViewTargetedVersion() throws OseeCoreException;

   public ChangeType getWorldViewChangeType() throws OseeCoreException {
      return ChangeType.None;
   }

   public String getWorldViewChangeTypeStr() throws OseeCoreException {
      if (getWorldViewChangeType() == null || getWorldViewChangeType() == ChangeType.None) {
         return "";
      } else {
         return getWorldViewChangeType().name();
      }
   }

   public double getEstimatedHoursFromArtifact() throws OseeCoreException {
      if (isAttributeTypeValid(ATSAttributes.ESTIMATED_HOURS_ATTRIBUTE.getStoreName())) {
         return getSoleAttributeValue(ATSAttributes.ESTIMATED_HOURS_ATTRIBUTE.getStoreName(), 0.0);
      }
      return 0;
   }

   public double getEstimatedHoursFromTasks(String relatedToState) throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return 0;
      }
      return ((TaskableStateMachineArtifact) this).getEstimatedHoursFromTasks(relatedToState);
   }

   public double getEstimatedHoursFromTasks() throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return 0;
      }
      return ((TaskableStateMachineArtifact) this).getEstimatedHoursFromTasks();
   }

   public double getEstimatedHoursFromReviews() throws OseeCoreException {
      if (isTeamWorkflow()) {
         return ReviewManager.getEstimatedHours((TeamWorkFlowArtifact) this);
      }
      return 0;
   }

   public double getEstimatedHoursFromReviews(String relatedToState) throws OseeCoreException {
      if (isTeamWorkflow()) {
         return ReviewManager.getEstimatedHours((TeamWorkFlowArtifact) this, relatedToState);
      }
      return 0;
   }

   public double getEstimatedHoursTotal(String relatedToState) throws OseeCoreException {
      return getEstimatedHoursFromArtifact() + getEstimatedHoursFromTasks(relatedToState) + getEstimatedHoursFromReviews(relatedToState);
   }

   public double getEstimatedHoursTotal() throws OseeCoreException {
      return getEstimatedHoursFromArtifact() + getEstimatedHoursFromTasks() + getEstimatedHoursFromReviews();
   }

   public double getWorldViewEstimatedHours() throws OseeCoreException {
      return getEstimatedHoursTotal();
   }

   public String getWorldViewUserCommunity() throws OseeCoreException {
      return "";
   }

   public String getWorldViewPriority() throws OseeCoreException {
      return "";
   }

   public String getWorldViewResolution() throws OseeCoreException {
      return getAttributesToString(ATSAttributes.RESOLUTION_ATTRIBUTE.getStoreName());
   }

   public double getRemainHoursFromArtifact() throws OseeCoreException {
      if (isCompleted() || isCancelled()) {
         return 0;
      }
      double est = getSoleAttributeValue(ATSAttributes.ESTIMATED_HOURS_ATTRIBUTE.getStoreName(), 0.0);
      if (est == 0) {
         return getEstimatedHoursFromArtifact();
      }
      double remain = est - est * getPercentCompleteSMATotal() / 100.0;
      return remain;
   }

   public double getRemainHoursTotal() throws OseeCoreException {
      return getRemainHoursFromArtifact() + getRemainFromTasks() + getRemainFromReviews();
   }

   public double getRemainFromTasks() throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return 0;
      }
      return ((TaskableStateMachineArtifact) this).getRemainHoursFromTasks();
   }

   public double getRemainFromReviews() throws OseeCoreException {
      if (isTeamWorkflow()) {
         return ReviewManager.getRemainHours((TeamWorkFlowArtifact) this);
      }
      return 0;
   }

   @Override
   public double getWorldViewRemainHours() throws OseeCoreException {
      return getRemainHoursTotal();
   }

   public Result isWorldViewRemainHoursValid() throws OseeCoreException {
      if (!isAttributeTypeValid(ATSAttributes.ESTIMATED_HOURS_ATTRIBUTE.getStoreName())) {
         return Result.TrueResult;
      }
      try {
         Double value = getSoleAttributeValue(ATSAttributes.ESTIMATED_HOURS_ATTRIBUTE.getStoreName(), null);
         if (isCancelled()) {
            return Result.TrueResult;
         }
         if (value == null) {
            return new Result("Estimated Hours not set.");
         }
         return Result.TrueResult;
      } catch (Exception ex) {
         return new Result(
               ex.getClass().getName() + ": " + ex.getLocalizedMessage() + "\n\n" + Lib.exceptionToString(ex));
      }
   }

   public Result isWorldViewManDaysNeededValid() throws OseeCoreException {
      Result result = isWorldViewRemainHoursValid();
      if (result.isFalse()) {
         return result;
      }
      if (getManHrsPerDayPreference() == 0) {
         return new Result("Man Day Hours Preference is not set.");
      }

      return Result.TrueResult;
   }

   public double getWorldViewManDaysNeeded() throws OseeCoreException {
      double hrsRemain = getWorldViewRemainHours();
      double manDaysNeeded = 0;
      if (hrsRemain != 0) {
         manDaysNeeded = hrsRemain / getManHrsPerDayPreference();
      }
      return manDaysNeeded;
   }

   public double getManHrsPerDayPreference() throws OseeCoreException {
      return DEFAULT_HOURS_PER_WORK_DAY;
   }

   public double getWorldViewAnnualCostAvoidance() throws OseeCoreException {
      return 0;
   }

   public Result isWorldViewAnnualCostAvoidanceValid() throws OseeCoreException {
      if (isAttributeTypeValid(ATSAttributes.WEEKLY_BENEFIT_ATTRIBUTE.getStoreName())) {
         return Result.TrueResult;
      }
      Result result = isWorldViewRemainHoursValid();
      if (result.isFalse()) {
         return result;
      }
      String value = null;
      try {
         value = getSoleAttributeValue(ATSAttributes.WEEKLY_BENEFIT_ATTRIBUTE.getStoreName(), "");
         if (value == null || value.equals("")) {
            return new Result("Weekly Benefit Hours not set.");
         }
         double val = new Float(value).doubleValue();
         if (val == 0) {
            return new Result("Weekly Benefit Hours not set.");
         }
      } catch (NumberFormatException ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "HRID " + getHumanReadableId(), ex);
         return new Result("Weekly Benefit value is invalid double \"" + value + "\"");
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "HRID " + getHumanReadableId(), ex);
         return new Result("Exception calculating cost avoidance.  See log for details.");
      }
      return Result.TrueResult;
   }

   public String getWorldViewNotes() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.SMA_NOTE_ATTRIBUTE.getStoreName(), "");
   }

   @Override
   public String getWorldViewWorkPackage() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.WORK_PACKAGE_ATTRIBUTE.getStoreName(), "");
   }

   public String getWorldViewPoint() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.POINTS_ATTRIBUTE.getStoreName(), "");
   }

   public String getWorldViewNumeric1() throws OseeCoreException {
      return AtsUtil.doubleToI18nString(getSoleAttributeValue(ATSAttributes.NUMERIC1_ATTRIBUTE.getStoreName(), 0.0),
            true);
   }

   public String getWorldViewNumeric2() throws OseeCoreException {
      return AtsUtil.doubleToI18nString(getSoleAttributeValue(ATSAttributes.NUMERIC2_ATTRIBUTE.getStoreName(), 0.0),
            true);
   }

   public String getWorldViewGoalOrderVote() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.GOAL_ORDER_VOTE_ATTRIBUTE.getStoreName(), "");
   }

   public String getWorldViewCategory() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.CATEGORY_ATTRIBUTE.getStoreName(), "");
   }

   public String getWorldViewCategory2() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.CATEGORY2_ATTRIBUTE.getStoreName(), "");
   }

   public String getWorldViewCategory3() throws OseeCoreException {
      return getSoleAttributeValue(ATSAttributes.CATEGORY3_ATTRIBUTE.getStoreName(), "");
   }

   public int getWorldViewStatePercentComplete() throws OseeCoreException {
      return getPercentCompleteSMAStateTotal(getStateMgr().getCurrentStateName());
   }

   public String getWorldViewNumberOfTasks() throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return "";
      }
      int num = ((TaskableStateMachineArtifact) this).getTaskArtifacts().size();
      if (num == 0) {
         return "";
      }
      return String.valueOf(num);
   }

   public String getWorldViewRelatedToState() throws OseeCoreException {
      return "";
   }

   @Override
   public String getWorldViewTargetedVersionStr() throws OseeCoreException {
      if (getWorldViewTargetedVersion() == null) {
         return "";
      }
      return getWorldViewTargetedVersion().toString();
   }

   /**
    * Return true if this artifact, it's ATS relations and any of the other side artifacts are dirty
    *
    * @return true if any object in SMA tree is dirty
    */
   public Result isSMAEditorDirty() {
      try {
         Set<Artifact> artifacts = new HashSet<Artifact>();
         getSmaArtifactsOneLevel(this, artifacts);
         for (Artifact artifact : artifacts) {
            if (artifact.isDirty()) {
               return new Result(true, String.format("Artifact [%s][%s] is dirty", artifact.getHumanReadableId(),
                     artifact));
            }
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "Can't save artifact " + getHumanReadableId(), ex);
      }
      return Result.FalseResult;
   }

   public void saveSMA(SkynetTransaction transaction) {
      try {
         Set<Artifact> artifacts = new HashSet<Artifact>();
         getSmaArtifactsOneLevel(this, artifacts);
         for (Artifact artifact : artifacts) {
            artifact.persist(transaction);
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "Can't save artifact " + getHumanReadableId(), ex);
      }
   }

   public void revertSMA() {
      try {
         Set<Artifact> artifacts = new HashSet<Artifact>();
         getSmaArtifactsOneLevel(this, artifacts);
         for (Artifact artifact : artifacts) {
            artifact.reloadAttributesAndRelations();
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, "Can't revert artifact " + getHumanReadableId(), ex);
      }
   }

   public void getSmaArtifactsOneLevel(StateMachineArtifact smaArtifact, Set<Artifact> artifacts) throws OseeCoreException {
      artifacts.add(smaArtifact);
   }

   @Override
   public Date getWorldViewEstimatedReleaseDate() throws OseeCoreException {
      Date date = getSoleAttributeValue(ATSAttributes.ESTIMATED_RELEASE_DATE_ATTRIBUTE.getStoreName(), null);
      Date parentDate = null;
      if (getParentSMA() != null) {
         parentDate = getParentSMA().getWorldViewEstimatedReleaseDate();
      }
      if (date == null && parentDate != null) {
         return parentDate;
      }
      return date;
   }

   @Override
   public Date getWorldViewEstimatedCompletionDate() throws OseeCoreException {
      Date date = getSoleAttributeValue(ATSAttributes.ESTIMATED_COMPLETION_DATE_ATTRIBUTE.getStoreName(), null);
      if (date != null) {
         return date;
      }
      if (getParentSMA() != null) {
         Date parentDate = getParentSMA().getWorldViewEstimatedCompletionDate();
         if (parentDate != null) {
            return parentDate;
         }
      }
      date = getWorldViewEstimatedReleaseDate();
      if (date != null) {
         return date;
      }
      return null;
   }

   public String getWorldViewEstimatedReleaseDateStr() throws OseeCoreException {
      if (getWorldViewEstimatedReleaseDate() == null) {
         return "";
      }
      return new XDate(getWorldViewEstimatedReleaseDate()).getMMDDYYHHMM();
   }

   public String getWorldViewEstimatedCompletionDateStr() throws OseeCoreException {
      if (getWorldViewEstimatedCompletionDate() == null) {
         return "";
      }
      return new XDate(getWorldViewEstimatedCompletionDate()).getMMDDYYHHMM();
   }

   public abstract Date getWorldViewReleaseDate() throws OseeCoreException;

   public String getWorldViewReleaseDateStr() throws OseeCoreException {
      if (getWorldViewReleaseDate() == null) {
         return "";
      }
      return new XDate(getWorldViewReleaseDate()).getMMDDYYHHMM();
   }

   /**
    * Called at the end of a transition just before transaction manager persist. SMAs can override to perform tasks due
    * to transition.
    *
    * @throws Exception
    */
   public void transitioned(WorkPageDefinition fromPage, WorkPageDefinition toPage, Collection<User> toAssignees, boolean persist, SkynetTransaction transaction) throws OseeCoreException {
   }

   public String getHyperName() {
      return getName();
   }

   public String getHyperType() {
      try {
         return getArtifactTypeName();
      } catch (Exception ex) {
         return ex.getLocalizedMessage();
      }
   }

   public String getHyperState() {
      try {
         return getStateMgr().getCurrentStateName();
      } catch (OseeCoreException ex) {
         OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
      }
      return "";
   }

   public String getHyperAssignee() {
      try {
         return Artifacts.toString("; ", getStateMgr().getAssignees());
      } catch (OseeCoreException ex) {
         OseeLog.log(AtsPlugin.class, Level.SEVERE, ex);
      }
      return "";
   }

   public Image getHyperAssigneeImage() throws OseeCoreException {
      return getAssigneeImage();
   }

   public Artifact getHyperArtifact() {
      return this;
   }

   public String getWorldViewDecision() throws OseeCoreException {
      return "";
   }

   public Artifact getParentAtsArtifact() throws OseeCoreException {
      return getParentSMA();
   }

   public String getWorldViewValidationRequiredStr() throws OseeCoreException {
      if (isAttributeTypeValid(ATSAttributes.VALIDATION_REQUIRED_ATTRIBUTE.getStoreName())) {
         return String.valueOf(getSoleAttributeValue(ATSAttributes.VALIDATION_REQUIRED_ATTRIBUTE.getStoreName(), false));
      }
      return "";
   }

   public Result isWorldViewDeadlineAlerting() throws OseeCoreException {
      return Result.FalseResult;
   }

   public int getWorldViewPercentRework() throws OseeCoreException {
      return 0;
   }

   public String getWorldViewPercentReworkStr() throws OseeCoreException {
      int reWork = getWorldViewPercentRework();
      if (reWork == 0) {
         return "";
      }
      return String.valueOf(reWork);
   }

   public static Set<IArtifactType> getAllSMAType() throws OseeCoreException {
      Set<IArtifactType> artTypeNames = TeamWorkflowExtensions.getInstance().getAllTeamWorkflowArtifactTypes();
      artTypeNames.add(AtsArtifactTypes.Task);
      artTypeNames.add(AtsArtifactTypes.DecisionReview);
      artTypeNames.add(AtsArtifactTypes.PeerToPeerReview);
      return artTypeNames;
   }

   public static List<Artifact> getAllSMATypeArtifacts() throws OseeCoreException {
      List<Artifact> result = new ArrayList<Artifact>();
      for (IArtifactType artType : getAllSMAType()) {
         result.addAll(ArtifactQuery.getArtifactListFromType(artType, AtsUtil.getAtsBranch()));
      }
      return result;
   }

   public static List<TeamWorkFlowArtifact> getAllTeamWorkflowArtifacts() throws OseeCoreException {
      List<TeamWorkFlowArtifact> result = new ArrayList<TeamWorkFlowArtifact>();
      for (IArtifactType artType : TeamWorkflowExtensions.getInstance().getAllTeamWorkflowArtifactTypes()) {
         List<TeamWorkFlowArtifact> teamArts =
               org.eclipse.osee.framework.jdk.core.util.Collections.castAll(ArtifactQuery.getArtifactListFromType(
                     artType, AtsUtil.getAtsBranch()));
         result.addAll(teamArts);
      }
      return result;
   }

   public String getWorldViewBranchStatus() throws OseeCoreException {
      return "";
   }

   public String getWorldViewReviewAuthor() throws OseeCoreException {
      return "";
   }

   public String getWorldViewReviewDecider() throws OseeCoreException {
      return "";
   }

   public String getWorldViewReviewModerator() throws OseeCoreException {
      return "";
   }

   public String getWorldViewReviewReviewer() throws OseeCoreException {
      return "";
   }

   /**
    * Return hours spent working ONLY the SMA stateName (not children SMAs)
    */
   public double getHoursSpentSMAState(String stateName) throws OseeCoreException {
      return getStateMgr().getHoursSpent(stateName);
   }

   /**
    * Return hours spent working ONLY on tasks related to stateName
    */
   public double getHoursSpentSMAStateTasks(String stateName) throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return 0;
      }
      return ((TaskableStateMachineArtifact) this).getHoursSpentFromTasks(stateName);
   }

   /**
    * Return hours spent working ONLY on reviews related to stateName
    */
   public double getHoursSpentSMAStateReviews(String stateName) throws OseeCoreException {
      if (isTeamWorkflow()) {
         return ReviewManager.getHoursSpent((TeamWorkFlowArtifact) this, stateName);
      }
      return 0;
   }

   /**
    * Return hours spent working on all things (including children SMAs) related to stateName
    */
   public double getHoursSpentSMAStateTotal(String stateName) throws OseeCoreException {
      return getHoursSpentSMAState(stateName) + getHoursSpentSMAStateTasks(stateName) + getHoursSpentSMAStateReviews(stateName);
   }

   @Override
   public double getWorldViewHoursSpentStateTotal() throws OseeCoreException {
      return getHoursSpentSMAStateTotal(getStateMgr().getCurrentStateName());
   }

   /**
    * Return hours spent working on all things (including children SMAs) for this SMA
    */
   public double getHoursSpentSMATotal() throws OseeCoreException {
      double hours = 0.0;
      for (String stateName : getStateMgr().getVisitedStateNames()) {
         hours += getHoursSpentSMAStateTotal(stateName);
      }
      return hours;
   }

   /**
    * Return Percent Complete working ONLY the SMA stateName (not children SMAs)
    */
   public int getPercentCompleteSMAState(String stateName) throws OseeCoreException {
      return getStateMgr().getPercentComplete(stateName);
   }

   /**
    * Return Percent Complete ONLY on tasks related to stateName. Total Percent / # Tasks
    */
   public int getPercentCompleteSMAStateTasks(String stateName) throws OseeCoreException {
      if (!(this instanceof TaskableStateMachineArtifact)) {
         return 0;
      }
      return ((TaskableStateMachineArtifact) this).getPercentCompleteFromTasks(stateName);
   }

   /**
    * Return Percent Complete ONLY on reviews related to stateName. Total Percent / # Reviews
    */
   public int getPercentCompleteSMAStateReviews(String stateName) throws OseeCoreException {
      if (isTeamWorkflow()) {
         return ReviewManager.getPercentComplete((TeamWorkFlowArtifact) this, stateName);
      }
      return 0;
   }

   /**
    * Return Percent Complete on all things (including children SMAs) related to stateName. Total Percent for state,
    * tasks and reviews / 1 + # Tasks + # Reviews
    */
   public int getPercentCompleteSMAStateTotal(String stateName) throws OseeCoreException {
      return getStateMetricsData(stateName).getResultingPercent();
   }

   /**
    * Return Percent Complete on all things (including children SMAs) for this SMA<br>
    * <br>
    * percent = all state's percents / number of states (minus completed/cancelled)
    */
   public int getPercentCompleteSMATotal() throws OseeCoreException {
      if (isCancelledOrCompleted()) {
         return 100;
      }
      Map<String, Double> stateToWeightMap = getStatePercentCompleteWeight();
      if (stateToWeightMap.size() > 0) {
         // Calculate total percent using configured weighting
         int percent = 0;
         for (String stateName : getWorkFlowDefinition().getPageNames()) {
            if (!stateName.equals(DefaultTeamState.Completed.name()) && !stateName.equals(DefaultTeamState.Cancelled.name())) {
               Double weight = stateToWeightMap.get(stateName);
               if (weight == null) {
                  weight = 0.0;
               }
               percent += weight * getPercentCompleteSMAStateTotal(stateName);
            }
         }
         return percent;
      } else {
         int percent = 0;
         int numStates = 0;
         for (String stateName : getWorkFlowDefinition().getPageNames()) {
            if (!stateName.equals(DefaultTeamState.Completed.name()) && !stateName.equals(DefaultTeamState.Cancelled.name())) {
               percent += getPercentCompleteSMAStateTotal(stateName);
               numStates++;
            }
         }
         if (numStates == 0) {
            return 0;
         }
         return percent / numStates;
      }
   }

   // Cache stateToWeight mapping
   private Map<String, Double> stateToWeight = null;

   public Map<String, Double> getStatePercentCompleteWeight() throws OseeCoreException {
      if (stateToWeight == null) {
         stateToWeight = new HashMap<String, Double>();
         Collection<WorkRuleDefinition> workRuleDefs = getWorkRulesStartsWith(AtsStatePercentCompleteWeightRule.ID);
         // Log error if multiple of same rule found, but keep going
         if (workRuleDefs.size() > 1) {
            OseeLog.log(
                  AtsPlugin.class,
                  Level.SEVERE,
                  "Team Definition has multiple rules of type " + AtsStatePercentCompleteWeightRule.ID + ".  Only 1 allowed.  Defaulting to first found.");
         }
         if (workRuleDefs.size() == 1) {
            stateToWeight = AtsStatePercentCompleteWeightRule.getStateWeightMap(workRuleDefs.iterator().next());
         }
      }
      return stateToWeight;
   }

   private StateMetricsData getStateMetricsData(String stateName) throws OseeCoreException {
      // Add percent and bump objects 1 for state percent
      int percent = getPercentCompleteSMAState(stateName);
      int numObjects = 1; // the state itself is one object

      // Add percent for each task and bump objects for each task
      if (this instanceof TaskableStateMachineArtifact) {
         Collection<TaskArtifact> tasks = ((TaskableStateMachineArtifact) this).getTaskArtifacts(stateName);
         for (TaskArtifact taskArt : tasks) {
            percent += taskArt.getPercentCompleteSMATotal();
         }
         numObjects += tasks.size();
      }

      // Add percent for each review and bump objects for each review
      if (isTeamWorkflow()) {
         Collection<ReviewSMArtifact> reviews = ReviewManager.getReviews((TeamWorkFlowArtifact) this, stateName);
         for (ReviewSMArtifact reviewArt : reviews) {
            percent += reviewArt.getPercentCompleteSMATotal();
         }
         numObjects += reviews.size();
      }

      return new StateMetricsData(percent, numObjects);
   }

   private static class StateMetricsData {
      public int numObjects = 0;
      public int percent = 0;

      public StateMetricsData(int percent, int numObjects) {
         this.numObjects = numObjects;
         this.percent = percent;
      }

      public int getResultingPercent() {
         return percent / numObjects;
      }

      @Override
      public String toString() {
         return "Percent: " + getResultingPercent() + "  NumObjs: " + numObjects + "  Total Percent: " + percent;
      }
   }

   @Override
   public double getWorldViewHoursSpentState() throws OseeCoreException {
      return getHoursSpentSMAState(getStateMgr().getCurrentStateName());
   }

   @Override
   public double getWorldViewHoursSpentStateReview() throws OseeCoreException {
      return getHoursSpentSMAStateReviews(getStateMgr().getCurrentStateName());
   }

   @Override
   public double getWorldViewHoursSpentStateTask() throws OseeCoreException {
      return getHoursSpentSMAStateTasks(getStateMgr().getCurrentStateName());
   }

   @Override
   public double getWorldViewHoursSpentTotal() throws OseeCoreException {
      return getHoursSpentSMATotal();
   }

   @Override
   public int getWorldViewPercentCompleteState() throws OseeCoreException {
      return getPercentCompleteSMAState(getStateMgr().getCurrentStateName());
   }

   @Override
   public int getWorldViewPercentCompleteStateReview() throws OseeCoreException {
      return getPercentCompleteSMAStateReviews(getStateMgr().getCurrentStateName());
   }

   @Override
   public int getWorldViewPercentCompleteStateTask() throws OseeCoreException {
      return getPercentCompleteSMAStateTasks(getStateMgr().getCurrentStateName());
   }

   @Override
   public int getWorldViewPercentCompleteTotal() throws OseeCoreException {
      return getPercentCompleteSMATotal();
   }

   public Set<IRelationEnumeration> getAtsWorldRelations() {
      return atsWorldRelations;
   }

   public String getWorldViewLastUpdated() throws OseeCoreException {
      return XDate.getDateStr(getLastModified(), XDate.MMDDYYHHMM);
   }

   public String getWorldViewLastStatused() throws OseeCoreException {
      return XDate.getDateStr(getLog().getLastStatusedDate(), XDate.MMDDYYHHMM);
   }

   public String getWorldViewSWEnhancement() throws OseeCoreException {
      return "";
   }

   public String getWorldViewNumberOfReviewIssueDefects() throws OseeCoreException {
      return "";
   }

   public String getWorldViewNumberOfReviewMajorDefects() throws OseeCoreException {
      return "";
   }

   public String getWorldViewNumberOfReviewMinorDefects() throws OseeCoreException {
      return "";
   }

   public String getWorldViewActionsIntiatingWorkflow() throws OseeCoreException {
      return getParentActionArtifact().getWorldViewActionsIntiatingWorkflow();
   }

   @Override
   public String getWorldViewDaysInCurrentState() throws OseeCoreException {
      double timeInCurrState = getStateMgr().getTimeInState();
      if (timeInCurrState == 0) {
         return "0.0";
      }
      return AtsUtil.doubleToI18nString(timeInCurrState / XDate.MILLISECONDS_IN_A_DAY);
   }

   @Override
   public String getWorldViewParentState() throws OseeCoreException {
      if (getParentSMA() != null) {
         return getParentSMA().getStateMgr().getCurrentStateName();
      }
      return "";
   }

   public String getGroupExplorerName() throws OseeCoreException {
      return String.format("[%s] %s", getStateMgr().getCurrentStateName(), getName());
   }

   @Override
   public String getWorldViewOriginatingWorkflowStr() throws OseeCoreException {
      return getParentActionArtifact().getWorldViewOriginatingWorkflowStr();
   }

   @Override
   public Collection<TeamWorkFlowArtifact> getWorldViewOriginatingWorkflows() throws OseeCoreException {
      return getParentActionArtifact().getWorldViewOriginatingWorkflows();
   }

   public String getWorldViewNumberOfTasksRemaining() throws OseeCoreException {
      return "";
   }

   public void closeEditors(boolean save) throws OseeStateException {
      SMAEditor.close(java.util.Collections.singleton(this), save);
   }

   public ATSLog getLog() {
      return atsLog;
   }

   public ATSNote getNotes() {
      return atsNote;
   }

   public Result getUserInputNeeded() {
      return Result.FalseResult;
   }

   public WorkPageDefinition getWorkPageDefinition() throws OseeCoreException {
      if (getStateMgr().getCurrentStateName() == null) {
         return null;
      }
      return getWorkFlowDefinition().getWorkPageDefinitionByName(getStateMgr().getCurrentStateName());
   }

   public WorkPageDefinition getWorkPageDefinitionByName(String name) throws OseeCoreException {
      return getWorkFlowDefinition().getWorkPageDefinitionByName(name);
   }

   public WorkPageDefinition getWorkPageDefinitionById(String id) throws OseeCoreException {
      return getWorkFlowDefinition().getWorkPageDefinitionById(id);
   }

   public boolean isHistoricalVersion() throws OseeStateException {
      return isHistorical();
   }

   public List<WorkPageDefinition> getToWorkPages() throws OseeCoreException {
      return getWorkFlowDefinition().getToPages(getWorkPageDefinition());
   }

   public List<WorkPageDefinition> getReturnPages() throws OseeCoreException {
      return getWorkFlowDefinition().getReturnPages(getWorkPageDefinition());
   }

   public boolean isReturnPage(WorkPageDefinition workPageDefinition) throws OseeCoreException {
      return getWorkFlowDefinition().isReturnPage(getWorkPageDefinition(), workPageDefinition);
   }

   public boolean isAccessControlWrite() throws OseeCoreException {
      return AccessControlManager.hasPermission(this, PermissionEnum.WRITE);
   }

   public User getOriginator() throws OseeCoreException {
      return atsLog.getOriginator();
   }

   public void setOriginator(User user) throws OseeCoreException {
      atsLog.addLog(LogType.Originated, "", "Changed by " + UserManager.getUser().getName(), user);
   }

   /**
    * @return true if this is a TeamWorkflow and it uses versions
    * @throws OseeStateException
    */
   public boolean isTeamUsesVersions() throws OseeStateException {
      if (!isTeamWorkflow()) {
         return false;
      }
      try {
         return ((TeamWorkFlowArtifact) this).getTeamDefinition().isTeamUsesVersions();
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE, ex);
         return false;
      }
   }

   /**
    * Return true if sma is TeamWorkflowArtifact and it's TeamDefinitionArtifact has rule set
    *
    * @param ruleId
    * @return if has rule
    * @throws OseeCoreException
    * @throws
    */
   public boolean teamDefHasWorkRule(String ruleId) throws OseeCoreException {
      if (!isTeamWorkflow()) {
         return false;
      }
      try {
         return ((TeamWorkFlowArtifact) this).getTeamDefinition().hasWorkRule(ruleId);
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
         return false;
      }
   }

   public boolean workPageHasWorkRule(String ruleId) throws OseeCoreException {
      return getWorkPageDefinition().hasWorkRule(AtsWorkDefinitions.RuleWorkItemId.atsRequireTargetedVersion.name());
   }

   public Collection<WorkRuleDefinition> getWorkRulesStartsWith(String ruleId) throws OseeCoreException {
      Set<WorkRuleDefinition> workRules = new HashSet<WorkRuleDefinition>();
      if (ruleId == null || ruleId.equals("")) {
         return workRules;
      }
      if (isTeamWorkflow()) {
         // Get rules from team definition
         workRules.addAll(((TeamWorkFlowArtifact) this).getTeamDefinition().getWorkRulesStartsWith(ruleId));
      }
      // Get work rules from workflow
      WorkFlowDefinition workFlowDefinition = getWorkFlowDefinition();
      if (workFlowDefinition != null) {
         // Get rules from workflow definitions
         workRules.addAll(getWorkFlowDefinition().getWorkRulesStartsWith(ruleId));
      }
      // Add work rules from page
      for (WorkItemDefinition wid : getWorkPageDefinition().getWorkItems(false)) {
         if (!wid.getId().equals("") && wid.getId().startsWith(ruleId)) {
            workRules.add((WorkRuleDefinition) wid);
         }
      }
      return workRules;
   }

   /**
    * @return true if this is a TeamWorkflow and the version it's been targeted for has been released
    */
   public boolean isReleased() {
      try {
         VersionArtifact verArt = getTargetedForVersion();
         if (verArt != null) {
            return verArt.isReleased();
         }
      } catch (Exception ex) {
         // Do Nothing
      }
      return false;
   }

   public boolean isVersionLocked() {
      try {
         VersionArtifact verArt = getTargetedForVersion();
         if (verArt != null) {
            return verArt.isVersionLocked();
         }
      } catch (Exception ex) {
         // Do Nothing
      }
      return false;
   }

   public VersionArtifact getTargetedForVersion() throws OseeCoreException {
      return getWorldViewTargetedVersion();
   }

   public boolean isCompleted() throws OseeCoreException {
      return stateMgr.getCurrentStateName().equals(DefaultTeamState.Completed.name());
   }

   public boolean isCancelled() throws OseeCoreException {
      return stateMgr.getCurrentStateName().equals(DefaultTeamState.Cancelled.name());
   }

   public boolean isCancelledOrCompleted() throws OseeCoreException {
      return isCompleted() || isCancelled();
   }

   public boolean isCurrentState(String stateName) throws OseeCoreException {
      return stateName.equals(stateMgr.getCurrentStateName());
   }

   public void setTransitionAssignees(Collection<User> assignees) throws OseeCoreException {
      if (assignees.contains(UserManager.getUser(SystemUser.OseeSystem)) || assignees.contains(UserManager.getUser(SystemUser.Guest))) {
         throw new OseeArgumentException("Can not assign workflow to OseeSystem or Guest");
      }
      if (assignees.size() > 1 && assignees.contains(UserManager.getUser(SystemUser.UnAssigned))) {
         throw new OseeArgumentException("Can not assign to user and UnAssigned");
      }
      transitionAssignees = assignees;
   }

   public boolean isAssigneeMe() throws OseeCoreException {
      return stateMgr.getAssignees().contains(UserManager.getUser());
   }

   public Collection<User> getTransitionAssignees() throws OseeCoreException {
      if (transitionAssignees != null) {
         if (transitionAssignees.size() > 0 && transitionAssignees.contains(UserManager.getUser(SystemUser.UnAssigned))) {
            transitionAssignees.remove(UserManager.getUser(SystemUser.UnAssigned));
         }
         if (transitionAssignees.size() > 0) {
            return transitionAssignees;
         }
      }
      return stateMgr.getAssignees();
   }

   public String getTransitionAssigneesStr() throws OseeCoreException {
      StringBuffer sb = new StringBuffer();
      for (User u : getTransitionAssignees()) {
         sb.append(u.getName() + SEPERATOR);
      }
      return sb.toString().replaceFirst(SEPERATOR + "$", "");
   }

   public Result transitionToCancelled(String reason, SkynetTransaction transaction, TransitionOption... transitionOption) {
      Result result =
            transition(DefaultTeamState.Cancelled.name(), Arrays.asList(new User[] {}), reason, transaction,
                  transitionOption);
      return result;
   }

   public Result transitionToCompleted(String reason, SkynetTransaction transaction, TransitionOption... transitionOption) {
      Result result =
            transition(DefaultTeamState.Completed.name(), Arrays.asList(new User[] {}), reason, transaction,
                  transitionOption);
      return result;
   }

   public Result isTransitionValid(final String toStateName, final Collection<User> toAssignees, TransitionOption... transitionOption) throws OseeCoreException {
      boolean overrideTransitionCheck =
            org.eclipse.osee.framework.jdk.core.util.Collections.getAggregate(transitionOption).contains(
                  TransitionOption.OverrideTransitionValidityCheck);
      boolean overrideAssigneeCheck =
            org.eclipse.osee.framework.jdk.core.util.Collections.getAggregate(transitionOption).contains(
                  TransitionOption.OverrideAssigneeCheck);
      // Validate assignees
      if (!overrideAssigneeCheck && (getStateMgr().getAssignees().contains(UserManager.getUser(SystemUser.OseeSystem)) || getStateMgr().getAssignees().contains(
            UserManager.getUser(SystemUser.Guest)) || getStateMgr().getAssignees().contains(
            UserManager.getUser(SystemUser.UnAssigned)))) {
         return new Result("Can not transition with \"Guest\", \"UnAssigned\" or \"OseeSystem\" user as assignee.");
      }

      // Validate toState name
      final WorkPageDefinition fromWorkPageDefinition = getWorkPageDefinition();
      final WorkPageDefinition toWorkPageDefinition = getWorkPageDefinitionByName(toStateName);
      if (toWorkPageDefinition == null) {
         return new Result("Invalid toState \"" + toStateName + "\"");
      }

      // Validate transition from fromPage to toPage
      if (!overrideTransitionCheck && !getWorkFlowDefinition().getToPages(fromWorkPageDefinition).contains(
            toWorkPageDefinition)) {
         String errStr =
               "Not configured to transition to \"" + toStateName + "\" from \"" + fromWorkPageDefinition.getPageName() + "\"";
         OseeLog.log(AtsPlugin.class, Level.SEVERE, errStr);
         return new Result(errStr);
      }
      // Don't transition with existing working branch
      if (toStateName.equals(DefaultTeamState.Cancelled.name()) && isTeamWorkflow() && ((TeamWorkFlowArtifact) this).getBranchMgr().isWorkingBranchInWork()) {
         return new Result("Working Branch exists.  Please delete working branch before cancelling.");
      }

      // Don't transition with uncommitted branch if this is a commit state
      if (AtsWorkDefinitions.isAllowCommitBranch(getWorkPageDefinition()) && isTeamWorkflow() && ((TeamWorkFlowArtifact) this).getBranchMgr().isWorkingBranchInWork()) {
         return new Result("Working Branch exists.  Please commit or delete working branch before transition.");
      }

      // Check extension points for valid transition
      List<IAtsStateItem> atsStateItems = stateItems.getStateItems(fromWorkPageDefinition.getId());
      for (IAtsStateItem item : atsStateItems) {
         Result result = item.transitioning(this, fromWorkPageDefinition.getPageName(), toStateName, toAssignees);
         if (result.isFalse()) {
            return result;
         }
      }
      for (IAtsStateItem item : atsStateItems) {
         Result result = item.transitioning(this, fromWorkPageDefinition.getPageName(), toStateName, toAssignees);
         if (result.isFalse()) {
            return result;
         }
      }
      return Result.TrueResult;
   }

   public Result transition(String toStateName, User toAssignee, SkynetTransaction transaction, TransitionOption... transitionOption) {
      List<User> users = new ArrayList<User>();
      if (toAssignee != null && !toStateName.equals(DefaultTeamState.Completed.name()) && !toStateName.equals(DefaultTeamState.Cancelled.name())) {
         users.add(toAssignee);
      }
      return transition(toStateName, users, transaction, transitionOption);
   }

   public boolean isTargetedVersionable() throws OseeCoreException {
      if (!isTeamWorkflow()) {
         return false;
      }
      return ((TeamWorkFlowArtifact) this).getTeamDefinition().getTeamDefinitionHoldingVersions() != null && ((TeamWorkFlowArtifact) this).getTeamDefinition().getTeamDefinitionHoldingVersions().isTeamUsesVersions();
   }

   public Result transition(String toStateName, Collection<User> toAssignees, SkynetTransaction transaction, TransitionOption... transitionOption) {
      return transition(toStateName, toAssignees, null, transaction, transitionOption);
   }

   private Result transition(final String toStateName, final Collection<User> toAssignees, final String completeOrCancelReason, SkynetTransaction transaction, TransitionOption... transitionOption) {
      try {
         final boolean persist =
               org.eclipse.osee.framework.jdk.core.util.Collections.getAggregate(transitionOption).contains(
                     TransitionOption.Persist);

         Result result = isTransitionValid(toStateName, toAssignees, transitionOption);
         if (result.isFalse()) {
            return result;
         }

         final WorkPageDefinition fromWorkPageDefinition = getWorkPageDefinition();
         final WorkPageDefinition toWorkPageDefinition = getWorkPageDefinitionByName(toStateName);

         transitionHelper(toAssignees, persist, fromWorkPageDefinition, toWorkPageDefinition, toStateName,
               completeOrCancelReason, transaction);
         if (persist) {
            OseeNotificationManager.getInstance().sendNotifications();
         }
      } catch (Exception ex) {
         OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
         return new Result("Transaction failed " + ex.getLocalizedMessage());
      }
      return Result.TrueResult;
   }

   private void transitionHelper(Collection<User> toAssignees, boolean persist, WorkPageDefinition fromPage, WorkPageDefinition toPage, String toStateName, String completeOrCancelReason, SkynetTransaction transaction) throws OseeCoreException {
      // Log transition
      if (toPage.isCancelledPage()) {
         atsLog.addLog(LogType.StateCancelled, stateMgr.getCurrentStateName(), completeOrCancelReason);
      } else {
         atsLog.addLog(LogType.StateComplete, stateMgr.getCurrentStateName(),
               (completeOrCancelReason != null ? completeOrCancelReason : ""));
      }
      atsLog.addLog(LogType.StateEntered, toStateName, "");

      stateMgr.transitionHelper(toAssignees, persist, fromPage, toPage, toStateName, completeOrCancelReason);

      if (isValidationRequired() && isTeamWorkflow()) {
         ReviewManager.createValidateReview((TeamWorkFlowArtifact) this, false, transaction);
      }

      AtsNotifyUsers.getInstance().notify(this, AtsNotifyUsers.NotifyType.Subscribed,
            AtsNotifyUsers.NotifyType.Completed, AtsNotifyUsers.NotifyType.Completed);

      // Persist
      if (persist) {
         persist(transaction);
      }

      transitioned(fromPage, toPage, toAssignees, true, transaction);

      // Notify extension points of transition
      for (IAtsStateItem item : stateItems.getStateItems(fromPage.getId())) {
         item.transitioned(this, fromPage.getPageName(), toStateName, toAssignees, transaction);
      }
      for (IAtsStateItem item : stateItems.getStateItems(toPage.getId())) {
         item.transitioned(this, fromPage.getPageName(), toStateName, toAssignees, transaction);
      }
   }

   public SMAEditor getEditor() {
      return editor;
   }

   public void setEditor(SMAEditor editor) {
      this.editor = editor;
   }

   public AtsStateItems getStateItems() {
      return stateItems;
   }

   public boolean isInTransition() {
      return inTransition;
   }

   public void setInTransition(boolean inTransition) {
      this.inTransition = inTransition;
   }

   public DeadlineManager getDeadlineMgr() {
      return deadlineMgr;
   }

   public StateManager getStateMgr() {
      return stateMgr;
   }

   public boolean isTeamWorkflow() {
      return this instanceof TeamWorkFlowArtifact;
   }

   public boolean isTask() throws OseeStateException {
      return this instanceof TaskArtifact;
   }

   public String getWorldViewGoalOrder() throws OseeCoreException {
      return GoalArtifact.getGoalOrder(this);
   }

   public AtsWorkPage getCurrentAtsWorkPage() throws OseeCoreException {
      for (AtsWorkPage atsWorkPage : getAtsWorkPages()) {
         if (isCurrentState(atsWorkPage.getName())) {
            return atsWorkPage;
         }
      }
      return null;
   }

   public List<AtsWorkPage> getAtsWorkPages() throws OseeCoreException {
      List<AtsWorkPage> atsWorkPages = new ArrayList<AtsWorkPage>();
      for (WorkPageDefinition workPageDefinition : getWorkFlowDefinition().getPagesOrdered()) {
         try {
            AtsWorkPage atsWorkPage =
                  new AtsWorkPage(getWorkFlowDefinition(), workPageDefinition, null,
                        ATSXWidgetOptionResolver.getInstance());
            atsWorkPages.add(atsWorkPage);
         } catch (Exception ex) {
            OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE, ex);
         }
      }
      return atsWorkPages;
   }

   /**
    * Assigned or computed Id that will show at the top of the editor
    */
   public String getPcrId() throws OseeCoreException {
      return "";
   }

   public Map<String, String> getSMADetails() throws OseeCoreException {
      Map<String, String> details = Artifacts.getDetailsKeyValues(this);
      details.put("Workflow Definition", getWorkFlowDefinition().getName());
      if (getParentActionArtifact() != null) {
         details.put("Action Id", getParentActionArtifact().getHumanReadableId());
      }
      if (!(this instanceof TeamWorkFlowArtifact) && getParentTeamWorkflow() != null) {
         details.put("Parent Team Workflow Id", getParentTeamWorkflow().getHumanReadableId());
      }
      return details;
   }

   protected void addPriviledgedUsersUpTeamDefinitionTree(TeamDefinitionArtifact tda, Set<User> users) throws OseeCoreException {
      users.addAll(tda.getLeads());
      users.addAll(tda.getPrivilegedMembers());

      // Walk up tree to get other editors
      if (tda.getParent() != null && tda.getParent() instanceof TeamDefinitionArtifact) {
         addPriviledgedUsersUpTeamDefinitionTree((TeamDefinitionArtifact) tda.getParent(), users);
      }
   }

}

Back to the top