ReplicationStatus.kt 1.66 KB
Newer Older
1
package org.chronopolis.rest.models.enums
Michael Ritter's avatar
Michael Ritter committed
2

3 4 5
import com.google.common.collect.ImmutableListMultimap
import com.google.common.collect.ImmutableSet

Michael Ritter's avatar
Michael Ritter committed
6 7 8 9 10 11 12 13
enum class ReplicationStatus {
    PENDING,
    STARTED,
    TRANSFERRED,
    SUCCESS,
    ACE_REGISTERED,
    ACE_TOKEN_LOADED,
    ACE_AUDITING,
14
    REMOVED,
Michael Ritter's avatar
Michael Ritter committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

    FAILURE_ACE_AUDIT,
    FAILURE_TOKEN_STORE,
    FAILURE_TAG_MANIFEST,
    FAILURE;

    fun isFailure(): Boolean = this == FAILURE
            || this == FAILURE_ACE_AUDIT
            || this == FAILURE_TOKEN_STORE
            || this == FAILURE_TAG_MANIFEST

    fun isClientStatus(): Boolean = this == STARTED
            || this == SUCCESS
            || this == FAILURE
            || this == ACE_AUDITING
            || this == ACE_TOKEN_LOADED
            || this == ACE_REGISTERED
32
            || this == REMOVED
Michael Ritter's avatar
Michael Ritter committed
33 34 35 36

    fun isOngoing(): Boolean = !(this.isFailure() || this == SUCCESS)

    companion object {
Michael Ritter's avatar
Michael Ritter committed
37
        fun active(): Set<ReplicationStatus> = ImmutableSet.of(STARTED, TRANSFERRED,
38 39 40 41 42 43 44 45 46 47 48
                ACE_REGISTERED, ACE_AUDITING, ACE_TOKEN_LOADED)

        fun statusByGroup(): ImmutableListMultimap<String, ReplicationStatus> =
                ImmutableListMultimap.Builder<String, ReplicationStatus>()
                        .put("Inactive", PENDING)
                        .putAll("Active", active())
                        .put("Success", SUCCESS)
                        .put("Failed", FAILURE)
                        .put("Failed", FAILURE_ACE_AUDIT)
                        .put("Failed", FAILURE_TAG_MANIFEST)
                        .put("Failed", FAILURE_TOKEN_STORE)
49
                        .put("Removed", REMOVED)
50
                        .build()
Michael Ritter's avatar
Michael Ritter committed
51 52 53
    }

}