package wenrgise.workflow.core.impl;

import java.util.logging.Logger;
import wenrgise.common.exception.EnrgiseApplicationException;
import wenrgise.common.exception.EnrgiseSystemException;
import wenrgise.workflow.core.WflDocumentInfo;
import wenrgise.workflow.core.WflService;
import wenrgise.workflow.core.WflStatus;
import wenrgise.workflow.core.WorkFlow;
import wenrgise.workflow.exception.WorkFlowServiceNotFoundException;
import wenrgise.workflow.impl.WorkFlowImpl;

public class WflServiceImpl implements WflService {
  public static final Logger log = Logger.getLogger("wenrgise.workflow.utility.WorkflowPlugin");
  
  public boolean canDo(WflDocumentInfo docInfo) throws EnrgiseApplicationException, EnrgiseSystemException {
    return true;
  }
  
  public WflStatus process(WflDocumentInfo docInfo) {
    try {
      WorkFlow wfl = getWorkFlowImplementation(docInfo);
      log.severe("proc1");
      if (wfl != null) {
        log.severe("proc2");
        return wfl.start(docInfo);
      } 
      return null;
    } catch (WorkFlowServiceNotFoundException oSx) {
      return null;
    } 
  }
  
  private WorkFlow getWorkFlowImplementation(WflDocumentInfo docInfo) throws WorkFlowServiceNotFoundException {
    return (WorkFlow)new WorkFlowImpl();
  }
}
