/*
* GSAItemEntryActionImpl
*
* 07/09/2003
*
* Copyright:
* Licensed Materials - Property of IBM
* "Restricted Materials of IBM"
* 5724-AEF
* (C) Copyright IBM Corp. 2003.
*
* %W% %E%
*/
package com.ibm.retail.AEF.action;
import com.ibm.retail.AEF.automation.*;
import com.ibm.retail.AEF.util.*;
import com.ibm.retail.si.util.*;
import com.ibm.retail.si.Copyright;
import com.ibm.retail.AEF.thread.*;
import com.ibm.retail.AEF.data.*;
import com.ibm.retail.AEF.session.*;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* GSAItemEntryActionImpl is a class which the POSAutomationProvider uses to
* add items to the current transaction on the POS application.
*
*/
public class GSAItemEntryActionImpl extends GSAActionImpl
{
static String copyright()
{ return com.ibm.retail.si.Copyright.IBM_COPYRIGHT_SHORT;}
private static AEFPerfTrace perfTrace = AEFPerfTrace.getInstance();
/**
* Constructor
*
* @param request The ActionRequest which contains a HashMap of arguments.
* @exception AEFException
*/
public GSAItemEntryActionImpl(ActionRequest request) throws AEFException
{
super(request);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.GSAItemEntryActionImpl().");
log.trace(tempAEFMessage);
}
if (request.getArguments()instanceof ItemIdentifier)
{
itemID = (ItemIdentifier)(request.getArguments());
}
else
{
itemID = (ItemIdentifier)(request.getArguments().get("id"));
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.GSAItemEntryActionImpl().");
log.trace(tempAEFMessage);
}
}
/**
* Perform the action represented by the ActionRequest and return an ActionResult.
*
*
* @return Object An ArrayList of the items.
* @exception AEFException
* Among the possible AEFException error codes are:
*
AEFConst.INVALID_ARGUMENT, AEFConst.INVALID_ITEM_IDENTIFIER_TYPE
*
Common Errors
*/
public Object performAction() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.performAction().");
log.trace(tempAEFMessage);
}
super.performAction(); // Call super to perform any common processing and clear any errors before we start.
Object retVal = null;
try
{
if (log.isDebugEnabled())
{
tempAEFMessage.setMessage("GSAItemEntryActionImpl.performAction started for item: " + itemID);
log.debug(tempAEFMessage);
}
int seqResult = -1;
detector = ((DetectorAccess)(SessionContext.getSession())).getLineItemDetector();
//Check to make sure that GSA is in a state that is valid for item entry.
String currentState = getCurrentState();
if (currentState.equals(State.getState("ITEMENTRY")) || currentState.equals(State.getState("ENTER_TENDER_AMOUNT")))
{
// Figure out what type of Item is this and call the correct method.
String itemCodeType = itemID.getItemCodeType();
if (itemCodeType.equals(AEFConst.SCAN_LABEL))
{
sendItemEntrySequence();
}
else if (itemCodeType.equals(AEFConst.SKU))
{
sendSKUItemEntrySequence();
}
else if (itemCodeType.equals(AEFConst.VELOCITY))
{
sendItemEntrySequence();
}
else if (itemCodeType.equals(AEFConst.KEYED_LABEL))
{
sendItemEntrySequence();
}
else if (itemCodeType.equals(AEFConst.DEPT))
{
sendDepartmentItemEntrySequence();
}
else
{
throw new AEFException(AEFConst.INVALID_ARGUMENT,
AEFConst.INVALID_ITEM_IDENTIFIER_TYPE,
"GSAItemEntryActionImpl.performAction(): The Item Identifier Type of " + itemCodeType + " is not valid in GSA.");
}
// Wait until an item is returned or an exception is thrown.
retVal = waitForItem();
}
else
{
// Not in valid state for item entry.
throw new AEFException(AEFConst.APPLICATION_NOT_IN_PROPER_STATE,
0,
"GSAItemEntryActionImpl.performAction(): POS application not in the proper state to perform item entry.\n Application is in state " + currentState + ".");
}
}
catch (AEFException e)
{
tempAEFMessage.setMessage("There was an AEF exception thrown in performAction of GSAItemEntryActionImpl-.");
log.error(tempAEFMessage, e);
throw e;
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.performAction().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* Sends the Department key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendDepartmentItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendDepartmentItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
String department = itemID.getDepartment();
// Send the void sequence if this item is a void.
if (voidItem)
{
sendVoidSequence();
}
// Send the return sequence if this item is a return.
if (returnItem)
{
sendReturnSequence();
}
// See if the item is taxable.
sendNonTaxSequence();
// Send Department.
if (department != null)
{
args.clear();
args.put("%0", department);
args.put("SEQUENCE_ID", "department");
Condition[] goodConditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ENTER_CLASS_STOCK")),
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ENTER_STOCK")),
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending department key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-department",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Department Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
// Lets make sure that we are in the right state after the error helper.
if (retVal >= 0)
{
takeActionBasedOnState();
}
}
else
{
department = "";
sendClassItemEntrySequence();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendDepartmentItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the class key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendClassItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendClassItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
lock = new ConditionLock();
String itemClass = itemID.getItemClass();
// Send Class.
if (itemClass != null)
{
args.clear();
args.put("%0", itemClass);
args.put("SEQUENCE_ID", "class");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ENTER_STOCK")),
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending class key sequence to application.");
}
// Send the key sequence to GSA.
retVal = lock.performActionAndWait("wait-after-send-class",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Class Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
// Lets make sure that we are in the right state after the error helper.
if (retVal >= 0)
{
takeActionBasedOnState();
}
}
else
{
itemClass = "";
sendStockItemEntrySequence();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendClassItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the stock key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendStockItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendStockItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
lock = new ConditionLock();
String itemStock = itemID.getItemCode();
// Send Stock Number.
if (itemStock == null)
{
itemStock = "";
}
args.clear();
args.put("%0", itemStock);
args.put("SEQUENCE_ID", "stock");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending Stock key sequence to application.");
}
// Send the key sequence to GSA.
retVal = lock.performActionAndWait("wait-after-stock-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Stock Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
// Lets make sure that we are in the right state after the error helper.
if (retVal >= 0)
{
takeActionBasedOnState();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendStockItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the Amount key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendAmountItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendAmountItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
lock = new ConditionLock();
String itemAmount = itemID.getPrice();
// Send Amount.
if (itemAmount == null)
{
itemAmount = "";
}
args.clear();
args.put("%0", itemAmount);
args.put("SEQUENCE_ID", "amount");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending Amount key sequence to application.");
}
// Send the key sequence to GSA.
retVal = lock.performActionAndWait("wait-after-amount-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Amount Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendAmountItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the Item code key sequence for item entry.
*
* @exception AEFException
*/
public void sendItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
String itemCode = itemID.getItemCode();
// Send the void sequence if this item is a void.
if (voidItem)
{
sendVoidSequence();
}
// Send the return sequence if this item is a return.
if (returnItem)
{
sendReturnSequence();
}
// See if the non-tax key needs to be sent.
sendNonTaxSequence();
// See if the quantity needs to be sent.
sendQuantityFirstSequence();
// Send Item Code.
if (itemCode == null)
{
itemCode = "";
}
args.clear();
args.put("%0", itemCode);
if (itemID.isNonMerchandise())
{
args.put("SEQUENCE_ID", "nonmerchadise");
}
else
{
args.put("SEQUENCE_ID", "item");
}
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending Item key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-item-code-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
// Lets make sure that we are in the right state after the error helper.
if (retVal >= 0)
{
takeActionBasedOnState();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the Non-Tax key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendNonTaxSequence() throws AEFException
{
/* Taxes not supported for now
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendNonTaxSequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
boolean itemIsTaxable = itemID.isTaxable();
// If the item is taxable, do nothing else send the key sequence.
if (itemIsTaxable == false)
{
args.clear();
args.put("SEQUENCE_ID", "nontax");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ITEMENTRY"))
};
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending Non-Tax key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-non-tax-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Non-Tax Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendNonTaxSequence().");
log.trace(tempAEFMessage);
}
*/
}
/**
* Sends the SKU key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendSKUItemEntrySequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendSKUItemEntrySequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
String sku = itemID.getItemCode();
// Send the void sequence if this item is a void.
if (voidItem)
{
sendVoidSequence();
}
// Send the return sequence if this item is a return.
if (returnItem)
{
sendReturnSequence();
}
// See if the item is taxable.
sendNonTaxSequence();
// Send the SKU.
if (sku == null)
{
sku = "";
}
args.clear();
args.put("%0", sku);
args.put("SEQUENCE_ID", "sku");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(TransactionStatusProperties.CATEGORY, TransactionStatusProperties.ITEM_SALE_IN_PROGRESS, "true")
};
// Save any current item instance number so we are sure to only get an item created after this key sequence is sent.
instanceNumber = detector.getInstanceNumber();
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending SKU key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-SKU",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send SKU Item Entry Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
// Lets make sure that we are in the right state after the error helper.
if (retVal >= 0)
{
takeActionBasedOnState();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendSKUItemEntrySequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the Quantity key sequence for item entry where the Quantity precedes the item.
*
*
* @exception AEFException
*/
public void sendQuantityFirstSequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendQuantityFirstSequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
int itemQuantityValue = 1;
String itemQuantity = itemID.getQuantity();
// Send Quantity only if it is not 1.
if (itemQuantity == null)
{
itemQuantity = "1";
}
else
{
itemQuantityValue = Integer.valueOf(itemQuantity).intValue();
}
if (itemQuantityValue != 1)
{
args.clear();
args.put("%0", itemQuantity);
args.put("SEQUENCE_ID", "quantity");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ITEMENTRY"))
};
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending Quantity key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-quantity-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send quantity Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendQuantityFirstSequence().");
log.trace(tempAEFMessage);
}
}
/**
* Sends the Void key sequence for item entry.
*
*
* @exception AEFException
*/
public void sendVoidSequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.sendVoidSequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
args.clear();
args.put("SEQUENCE_ID", "void");
theKeySequenceAction = (AEFAction)(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ITEMENTRY")),
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("ENTER_TENDER_AMOUNT"))
};
// Report performance data.
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE, sessionID, "addItem", ">>>Sending void key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-void-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Void Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendVoidSequence().");
log.trace(tempAEFMessage);
}
}
/**
* Waits for the item object after the item is sold.
*
*
* @return Object (ArrayList) An array of LineItems created by the action.
* @exception AEFException
*/
public Object waitForItem() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.waitForItem().");
log.trace(tempAEFMessage);
}
Object retVal = null;
// Successfully got to item entry. Wait for the array of LineItems to be created.
ObjectDetectorLock objLock = new ObjectDetectorLock();
retVal = objLock.waitForNewObject("wait-for-item-array",detector, instanceNumber, getTimeout());
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE,
sessionID,
"addItem",
"<<>>Sending return key sequence to application.");
}
// Send the key sequence to GSA.
lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-after-return-send",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Return Sequence Error", itemID);
retVal = errorHandler.handleError(lock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.sendReturnSequence().");
log.trace(tempAEFMessage);
}
}
/**
* Perform the action needed based on the current state.
*
*
* @exception AEFException
*/
public void takeActionBasedOnState() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter GSAItemEntryActionImpl.takeActionBasedOnState().");
log.trace(tempAEFMessage);
}
String currentState = getCurrentState();
if (currentState.equals(State.getState("ENTER_CLASS_STOCK")))
{
sendClassItemEntrySequence();
}
else if (currentState.equals(State.getState("ENTER_STOCK")))
{
sendStockItemEntrySequence();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit GSAItemEntryActionImpl.takeActionBasedOnState().");
log.trace(tempAEFMessage);
}
}
// Instance and Class Variables
protected boolean voidItem = false; // Set to true by GSAItemVoidActionImpl.
protected boolean returnItem = false; // Set to true by GSAItemReturnActionImpl.
protected AEFAction theKeySequenceAction = null;
protected ItemIdentifier itemID = null;
protected ConditionLock lock = null;
protected ObjectDetector detector = null;
protected int instanceNumber = 0;
private static Log log = LogFactory.getLog(GSAItemEntryActionImpl.class);
}