刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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
package jnpf.dmsService.support;
 
import java.util.Optional;
 
/**
 * Converts the persisted JNPF flow state into an idempotent number action.
 */
public final class DmsWenjianBianhaoFlowStateResolver {
 
    public static final int TO_BE_SUBMIT = 0;
    public static final int RUNNING = 1;
    public static final int PASSED = 2;
    public static final int REJECTED = 3;
    public static final int CANCELLED = 4;
    public static final int PAUSED = 5;
    public static final int REVOKING = 6;
    public static final int REVOKED = 7;
    public static final int BACKED = 8;
    public static final int RECALLED = 9;
    public static final int EXCEPTION = 10;
 
    private DmsWenjianBianhaoFlowStateResolver() {
    }
 
    public static Optional<Action> resolve(Integer flowState) {
        if (flowState == null) {
            return Optional.empty();
        }
        switch (flowState) {
            case TO_BE_SUBMIT:
            case RECALLED:
                return Optional.of(Action.RESTORE_DRAFT);
            case RUNNING:
                return Optional.of(Action.FREEZE_SNAPSHOT);
            case PASSED:
                return Optional.of(Action.ISSUE_NUMBER);
            case REJECTED:
                return Optional.of(Action.REJECT);
            case CANCELLED:
                return Optional.of(Action.CANCEL);
            case PAUSED:
            case REVOKING:
            case BACKED:
                return Optional.of(Action.HOLD);
            case REVOKED:
                return Optional.of(Action.REVOKE);
            case EXCEPTION:
                return Optional.of(Action.ERROR);
            default:
                return Optional.empty();
        }
    }
 
    public enum Action {
        RESTORE_DRAFT,
        FREEZE_SNAPSHOT,
        ISSUE_NUMBER,
        REJECT,
        CANCEL,
        HOLD,
        REVOKE,
        ERROR
    }
}