Interface StockAdminSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
- All Known Subinterfaces:
StockBatchAdminSession
This session creates, updates, and deletes Stocks . The data
for create and update is provided by the consumer via the form object.
OsidForms are requested for each create or update and may not be
reused.
Create and update operations differ in their usage. To create a
Stock , a StockForm is requested using
getStockFormForCreate() specifying the desired record Types or
none if no record Types are needed. The returned StockForm
will indicate that it is to be used with a create operation and can be
used to examine metdata or validate data prior to creation. Once the
StockForm is submiited to a create operation, it cannot be reused
with another create operation unless the first operation was unsuccessful.
Each StockForm corresponds to an attempted transaction.
For updates, StockForms are requested to the Stock
Id that is to be updated using getStockFormForUpdate() .
Similarly, the StockForm has metadata about the data that can be
updated and it can perform validation before submitting the update. The
StockForm can only be used once for a successful update and cannot
be reused.
The delete operations delete Stocks . To unmap a Stock
from the current Warehouse , the
StockWarehouseAssignmentSession should be used. These delete operations
attempt to remove the Stock itself thus removing it from all known
Warehouse catalogs.
This session includes an Id aliasing mechanism to assign an
external Id to an internally assigned Id.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaliasStock(Id stockId, Id aliasId) Adds anIdto aStockfor the purpose of creating compatibility.booleanTests if this user can createStocks.booleancanCreateStockWithRecordTypes(Type[] stockRecordTypes) Tests if this user can create a singleStockusing the desired record types.booleanTests if this user can deleteStocks.booleanTests if this user can manageIdaliases forStocks.booleanTests if this user can updateStocks.createStock(StockForm stockForm) Creates a newStock.voiddeleteStock(Id stockId) Deletes aStock.getStockFormForCreate(Type[] stockRecordTypes) Gets the stock form for creating new stocks.getStockFormForUpdate(Id stockId) Gets the stock form for updating an existing stock.Gets theWarehouseassociated with this session.Gets theWarehouseIdassociated with this session.voidupdateStock(StockForm stockForm) Updates an existing stock.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
getWarehouseId
Id getWarehouseId()Gets theWarehouseIdassociated with this session.- Returns:
- the
Warehouse Idassociated with this session - Compliance:
mandatory- This method must be implemented.
-
getWarehouse
Gets theWarehouseassociated with this session.- Returns:
- the warehouse
- Throws:
OperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canCreateStocks
boolean canCreateStocks()Tests if this user can createStocks. A return of true does not guarantee successful authorization. A return of false indicates that it is known creating aStockwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer create operations to an unauthorized user.- Returns:
falseifStockcreation is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
canCreateStockWithRecordTypes
Tests if this user can create a singleStockusing the desired record types. WhileInventoryManager.getStockRecordTypes()can be used to examine which records are supported, this method tests which record(s) are required for creating a specificStock. Providing an empty array tests if aStockcan be created with no records.- Parameters:
stockRecordTypes- array of stock record types- Returns:
trueifStockcreation using the specified recordTypesis supported,falseotherwise- Throws:
NullArgumentException-stockRecordTypesisnull- Compliance:
mandatory- This method must be implemented.
-
getStockFormForCreate
StockForm getStockFormForCreate(Type[] stockRecordTypes) throws OperationFailedException, PermissionDeniedException Gets the stock form for creating new stocks. A new form should be requested for each create transaction.- Parameters:
stockRecordTypes- array of stock record types- Returns:
- the stock form
- Throws:
NullArgumentException-stockRecordTypesisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException- unable to get form for requested record types- Compliance:
mandatory- This method must be implemented.
-
createStock
Stock createStock(StockForm stockForm) throws NotFoundException, OperationFailedException, PermissionDeniedException Creates a newStock.- Parameters:
stockForm- the form for thisStock- Returns:
- the new
Stock - Throws:
IllegalStateException-stockFormalready used in a create transactionInvalidArgumentException- one or more of the form elements is invalidNullArgumentException-courseId, termId, orstockFormisnullNotFoundException-stockFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-stockFormdid not originate fromgetStockFormForCreate()- Compliance:
mandatory- This method must be implemented.
-
canUpdateStocks
boolean canUpdateStocks()Tests if this user can updateStocks. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating aStockwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer update operations to an unauthorized user.- Returns:
falseifStockmodification is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
getStockFormForUpdate
StockForm getStockFormForUpdate(Id stockId) throws NotFoundException, OperationFailedException, PermissionDeniedException Gets the stock form for updating an existing stock. A new stock form should be requested for each update transaction.- Parameters:
stockId- theIdof theStock- Returns:
- the stock form
- Throws:
NotFoundException-stockIdis not foundNullArgumentException-stockIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
updateStock
Updates an existing stock.- Parameters:
stockForm- the form containing the elements to be updated- Throws:
IllegalStateException-stockFormalready used in an update transactionInvalidArgumentException- the form contains an invalid valueNullArgumentException-stockFormisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failureUnsupportedException-stockFormdid not originate fromgetStockFormForUpdate()- Compliance:
mandatory- This method must be implemented.
-
canDeleteStocks
boolean canDeleteStocks()Tests if this user can deleteStocks. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting aStockwill result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer delete operations to an unauthorized user.- Returns:
falseifStockdeletion is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
deleteStock
void deleteStock(Id stockId) throws NotFoundException, OperationFailedException, PermissionDeniedException Deletes aStock.- Parameters:
stockId- theIdof theStockto remove- Throws:
NotFoundException-stockIdnot foundNullArgumentException-stockIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
canManageStockAliases
boolean canManageStockAliases()Tests if this user can manageIdaliases forStocks. A return of true does not guarantee successful authorization. A return of false indicates that it is known changing an alias will result in aPERMISSION_DENIED. This is intended as a hint to an application that may opt not to offer alias operations to an unauthorized user.- Returns:
falseifStockaliasing is not authorized,trueotherwise- Compliance:
mandatory- This method must be implemented.
-
aliasStock
void aliasStock(Id stockId, Id aliasId) throws AlreadyExistsException, NotFoundException, OperationFailedException, PermissionDeniedException Adds anIdto aStockfor the purpose of creating compatibility. The primaryIdof theStockis determined by the provider. The newIdperforms as an alias to the primaryId. If the alias is a pointer to another stock, it is reassigned to the given stockId.- Parameters:
stockId- theIdof aStockaliasId- the aliasId- Throws:
AlreadyExistsException-aliasIdis in use as a primaryIdNotFoundException-stockIdnot foundNullArgumentException-stockIdoraliasIdisnullOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-