1 /*
2 * This file is part of Waarp Project (named also Waarp or GG).
3 *
4 * Copyright (c) 2019, Waarp SAS, and individual contributors by the @author
5 * tags. See the COPYRIGHT.txt in the distribution for a full listing of
6 * individual contributors.
7 *
8 * All Waarp Project is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * Waarp . If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 package org.waarp.openr66.pojo;
22
23 import com.fasterxml.jackson.annotation.JsonValue;
24 import org.waarp.common.database.data.AbstractDbData;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 public enum UpdatedInfo {
30 /**
31 * Unknown run status
32 */
33 UNKNOWN(0),
34 /**
35 * Not updated run status
36 */
37 NOTUPDATED(1),
38 /**
39 * Interrupted status (stop or cancel)
40 */
41 INTERRUPTED(2),
42 /**
43 * Updated run status meaning ready to be submitted
44 */
45 TOSUBMIT(3),
46 /**
47 * In error run status
48 */
49 INERROR(4),
50 /**
51 * Running status
52 */
53 RUNNING(5),
54 /**
55 * All done run status
56 */
57 DONE(6);
58
59 private final int id;
60
61 private static final Map<Integer, UpdatedInfo> map =
62 new HashMap<Integer, UpdatedInfo>();
63
64 static {
65 for (final UpdatedInfo updatedInfo : UpdatedInfo.values()) {
66 map.put(updatedInfo.id, updatedInfo);
67 }
68 }
69
70 UpdatedInfo(final int updatedInfo) {
71 id = updatedInfo;
72 }
73
74 public static UpdatedInfo valueOf(final int updatedInfo) {
75 if (!map.containsKey(updatedInfo)) {
76 return UNKNOWN;
77 }
78 return map.get(updatedInfo);
79 }
80
81 public final boolean equals(final AbstractDbData.UpdatedInfo legacy) {
82 return ordinal() == legacy.ordinal();
83 }
84
85 public static UpdatedInfo fromLegacy(final AbstractDbData.UpdatedInfo info) {
86 return valueOf(info.name());
87 }
88
89 public final AbstractDbData.UpdatedInfo getLegacy() {
90 return AbstractDbData.UpdatedInfo.valueOf(name());
91 }
92
93 @JsonValue
94 public final int getID() {
95 return id;
96 }
97 }