net.yadaframework.persistence.entity.YadaJobState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yadaweb Show documentation
Show all versions of yadaweb Show documentation
Some useful tasks for the Yada Framework
package net.yadaframework.persistence.entity;
import java.util.Locale;
import org.springframework.context.MessageSource;
import net.yadaframework.core.YadaLocalEnum;
/**
* The localized state of a YadaJob:
*
* - ACTIVE: the job is waiting to be run
* - RUNNING: the job is running
* - PAUSED: scheduling on this job has been paused (by the user) and the job should not run
* - COMPLETED: the job has completed its purpose and should not run again
* - DISABLED: the job has been disabled because of errors
*
*
*/
public enum YadaJobState implements YadaLocalEnum {
// In messages.properties:
// yada.jobstate.ACTIVE = Active
// yada.jobstate.RUNNING = Running
// yada.jobstate.PAUSED = Paused
// yada.jobstate.COMPLETED = Completed
// yada.jobstate.DISABLED = Disabled
ACTIVE("yada.jobstate.ACTIVE"),
RUNNING("yada.jobstate.RUNNING"),
PAUSED("yada.jobstate.PAUSED"),
COMPLETED("yada.jobstate.COMPLETED"),
DISABLED("yada.jobstate.DISABLED");
private String messageKey;
private YadaPersistentEnum yadaPersistentEnum;
private YadaJobState(String messageKey) {
this.messageKey = messageKey;
}
public YadaPersistentEnum toYadaPersistentEnum() {
return yadaPersistentEnum;
}
// TODO fix generics
public void setYadaPersistentEnum(YadaPersistentEnum yadaPersistentEnum) {
this.yadaPersistentEnum = yadaPersistentEnum;
}
/**
* Return the localized text for this enum
* @param messageSource
* @param locale
* @return
*/
public String toString(MessageSource messageSource, Locale locale) {
return messageSource.getMessage(messageKey, null, locale);
}
}