1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.courseoffering.service.util;
18
19 import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
20 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
21
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26
27
28
29
30
31
32 public class AoStateTransitionRefSolution {
33
34 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_DRAFT = {
35 {TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.NO},
36 {TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.NO},
37 {TransitionGridYesNoEnum.INVALID, TransitionGridYesNoEnum.INVALID, TransitionGridYesNoEnum.INVALID} };
38
39 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_OPEN = AO_STATE_SOC_DRAFT;
40 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_LOCKED = AO_STATE_SOC_DRAFT;
41 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_FINAL_EDITS = AO_STATE_SOC_DRAFT;
42
43 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_PUBLISHING = {
44 {TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES},
45 {TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES},
46 {TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES, TransitionGridYesNoEnum.YES} };
47 public static final TransitionGridYesNoEnum [][] AO_STATE_SOC_PUBLISHED = AO_STATE_SOC_PUBLISHING;
48 public static Map<String, TransitionGridYesNoEnum [][]> SOC_STATE_TO_AO_TRANSITION;
49 static {
50 SOC_STATE_TO_AO_TRANSITION = new HashMap<String, TransitionGridYesNoEnum [][]>();
51 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.DRAFT_SOC_STATE_KEY, AO_STATE_SOC_DRAFT);
52 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.OPEN_SOC_STATE_KEY, AO_STATE_SOC_OPEN);
53 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.LOCKED_SOC_STATE_KEY, AO_STATE_SOC_LOCKED);
54 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.FINALEDITS_SOC_STATE_KEY, AO_STATE_SOC_FINAL_EDITS);
55 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.PUBLISHING_SOC_STATE_KEY, AO_STATE_SOC_PUBLISHING);
56 SOC_STATE_TO_AO_TRANSITION.put(CourseOfferingSetServiceConstants.PUBLISHED_SOC_STATE_KEY, AO_STATE_SOC_PUBLISHED);
57 }
58
59 public static final List<String> AO_STATES_ORDERED;
60 static {
61 AO_STATES_ORDERED = new ArrayList<String>();
62 AO_STATES_ORDERED.add(LuiServiceConstants.LUI_AO_STATE_DRAFT_KEY);
63 AO_STATES_ORDERED.add(LuiServiceConstants.LUI_AO_STATE_APPROVED_KEY);
64
65 AO_STATES_ORDERED.add(LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY);
66 }
67
68 public static PseudoUnitTestStateTransitionGrid getReferenceGridForState(String socState) {
69 final TransitionGridYesNoEnum[][] stateTransition = SOC_STATE_TO_AO_TRANSITION.get(socState);
70 List<String> values = new ArrayList<String>();
71 values.add(TransitionGridYesNoEnum.YES.getName());
72 values.add(TransitionGridYesNoEnum.NO.getName());
73 values.add(TransitionGridYesNoEnum.INVALID.getName());
74 PseudoUnitTestStateTransitionGrid grid = new PseudoUnitTestStateTransitionGrid(AoStateTransitionRefSolution.AO_STATES_ORDERED, values, "ao");
75 grid.setSocStateKey(socState);
76 for (int from = 0; from < stateTransition.length; from++) {
77 for (int to = 0; to < stateTransition.length; to++) {
78 grid.setTransition(AFUTTypeEnum.EXPECTED, from, to, stateTransition[from][to].getName());
79 }
80 }
81 return grid;
82 }
83 }