package com.k_int.ca.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.k_int.aggregator.harvest.dto.HarvestInstructionDTO;
import com.k_int.aggregator.harvest.service.OAIHarvestService;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;


public  class DisplayHarvestInstructionAction extends ActionSupport {
  private static final long serialVersionUID = 1L;
  private HarvestInstructionDTO instruction = new HarvestInstructionDTO();
  private long instructionId;
  private OAIHarvestService service;
 
  private static Log log = LogFactory.getLog(DisplayHarvestInstructionAction.class);
 
  public void setOaiService(OAIHarvestService service)
  {
    this.service = service;
  }
  //Test comment
  
  public String execute() throws Exception {
    log.debug("Display single Harvest Instruction action");  
    
    if (instructionId > 0 )
    	instruction = service.getHarvestInstruction(instructionId);
    else
    	log.debug("instructionID = " + instructionId);
    
    log.debug("instruction.providerCode  = " + instruction.getProviderCode());
    return Action.SUCCESS;
  }
  
  
  public void setInstructionId(String instructionId) {
    if (instructionId!=null && !"".equals(instructionId))
    try
    {
      this.instructionId = Long.parseLong(instructionId);
    }
    catch (Exception e){}
    
    
	log.debug("instructionId = " + this.instructionId);

  }
  
  public HarvestInstructionDTO getInstruction(){
	    return instruction;
  }

  
}
  