| .. | .. |
|---|
| 28 | 28 | |
|---|
| 29 | 29 | import org.apache.logging.log4j.LogManager; |
|---|
| 30 | 30 | import org.apache.logging.log4j.Logger; |
|---|
| 31 | +import org.hibernate.annotations.Type; |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 33 | 34 | import com.fasterxml.jackson.annotation.JsonIgnore; |
|---|
| .. | .. |
|---|
| 75 | 76 | @JoinColumn(name = "cancelled_by") |
|---|
| 76 | 77 | private User cancelledBy; |
|---|
| 77 | 78 | |
|---|
| 79 | + @Type(type = "net.curisit.securis.db.common.LicenseStatusType") |
|---|
| 78 | 80 | private LicenseStatus status; |
|---|
| 79 | 81 | |
|---|
| 80 | 82 | @Column(name = "full_name") |
|---|
| .. | .. |
|---|
| 316 | 318 | |
|---|
| 317 | 319 | public static class Status { |
|---|
| 318 | 320 | |
|---|
| 319 | | - private static final Map<Integer, List<Integer>> transitions = Utils.createMap( // |
|---|
| 321 | + private static final Map<Integer, List<LicenseStatus>> transitions = Utils.createMap( // |
|---|
| 320 | 322 | Action.REQUEST, Arrays.asList(LicenseStatus.CREATED, LicenseStatus.REQUESTED), // |
|---|
| 321 | 323 | Action.ACTIVATION, Arrays.asList(LicenseStatus.REQUESTED, LicenseStatus.PRE_ACTIVE, LicenseStatus.EXPIRED), // |
|---|
| 322 | 324 | Action.SEND, Arrays.asList(LicenseStatus.ACTIVE, LicenseStatus.PRE_ACTIVE), // |
|---|
| .. | .. |
|---|
| 335 | 337 | * @return |
|---|
| 336 | 338 | */ |
|---|
| 337 | 339 | public static boolean isActionValid(Integer action, LicenseStatus currentStatus) { |
|---|
| 338 | | - List<Integer> validStatuses = transitions.get(action); |
|---|
| 339 | | - |
|---|
| 340 | + List<LicenseStatus> validStatuses = transitions.get(action); |
|---|
| 341 | + LOG.info("Action {} is valid ? => {} current: {} OK? {}", action, validStatuses, currentStatus, validStatuses.contains(currentStatus)); |
|---|
| 340 | 342 | return validStatuses != null && validStatuses.contains(currentStatus); |
|---|
| 341 | 343 | } |
|---|
| 342 | 344 | } |
|---|