Sample Custom State

A simple custom state, named SampleState, formats the current date.

You can modify the date format in the properties-context.xml file. The formatted date is stored in an output variable.

import java.text.Format;   
import java.text.SimpleDateFormat;   
import java.util.Date;       
import org.slf4j.Logger;   
import org.slf4j.LoggerFactory;       
import com.sybase365.mobiliser.brand.dao.DBException;   
import com.sybase365.mobiliser.brand.jpa.SmappState;   
import com.sybase365.mobiliser.brand.plugins.api.smapp.SmappStateProcessingAction;   
import com.sybase365.mobiliser.brand.plugins.api.smapp.SmappStateProcessingContext;   
import com.sybase365.mobiliser.brand.plugins.smapp.controls.Attribute;   
import com.sybase365.mobiliser.brand.plugins.smapp.controls.OutputAttribute;   
import com.sybase365.mobiliser.brand.plugins.smapp.state.SmappStatePlugin;   
import com.sybase365.mobiliser.brand.processing.exceptions.MwizProcessingException;       

public class SampleState  extends SmappStatePlugin {           
  private static final Logger LOG = 
  protected static final OutputAttribute outDate = 
                       new OutputAttribute("DATE", "Current Date");
  private static Attribute[] stateAttr;              
  private String country = "";           
  public void setCountry(String value) {        
    LOG.debug("Country = " + value);    = value;       

  static {        
    stateAttr = new Attribute[] {outDate};       

  private static long STATE_ID = 600000L;           

  public String getStateNotes() {        
    return "A sample state. When executed, it returns the current \n"             
         + " date in the format of the configured country.\n\n"             
         + "Use the following follow up states:\n"             
         + "- OK: date and time in the output variable.\n"             
         + "- FAIL: If an error occurs during processing.\n";       

  public boolean supportsFailTransition() {        
    return true;       

  protected Attribute[] getStateAttributes() {        
    return stateAttr.clone();       

  public String getRevisionString() {        
    return "1.0.0";       

  public long getStateId() {        
    return STATE_ID;       

  public String getStateName() {        
    return "Example - Get Date";      

  protected SmappState processStateLogic(
                              SmappStateProcessingContext context,
                              SmappStateProcessingAction action)
            throws MwizProcessingException, DBException {     

    Format formatter = new SimpleDateFormat("MM dd yyyy");                
    if (!country.equalsIgnoreCase("US"))          
      formatter = new SimpleDateFormat("dd MM yyyy");               

    outDate.setValue(formatter.format(new Date()));        
    return continueOk();