public class Product extends DBPersist
Modifier and Type | Field and Description |
---|---|
static short |
ClassId |
static short |
STATUS_ACTIVE |
static short |
STATUS_BLOCKED |
static short |
STATUS_CORRUPTED |
static short |
STATUS_PENDING |
static short |
STATUS_RETIRED |
Constructor and Description |
---|
Product()
Create empty Product
|
Product(JDCConnection oConn,
java.lang.String sIdProduct)
Load Product from database
|
Product(java.lang.String sIdProduct)
Create empty Product and set gu_product
|
Modifier and Type | Method and Description |
---|---|
java.math.BigDecimal |
addOrReplaceFare(JDCConnection oConn,
java.lang.String sIdFare,
java.lang.String sTpFare,
java.lang.String sWorkAreaId,
java.math.BigDecimal dPrice,
java.lang.String sIdCurrency,
float fTaxRate,
boolean bIsTaxIncluded,
java.sql.Date dtStart,
java.sql.Date dtEnd)
Add or replace a Product Fare
This method modifies both k_prod_fares and k_prod_fares_lookup tables
|
int |
addToCategory(JDCConnection oConn,
java.lang.String idCategory,
int iOdPosition)
Add Product to Category
Insert Product GUID into table k_x_cat_objs.
|
void |
checkIn(JDCConnection oConn,
java.lang.String sUserId)
Check user permissions and set gu_blockedby column of k_products to null
|
void |
checkOut(JDCConnection oConn,
java.lang.String sUserId)
Check user permissions and set the given user GUID at gu_blockedby column of k_products
|
boolean |
delete(JDCConnection oConn)
Delete Product
Images and Productlocations are deleted first, including disk files.
|
int |
eraseLocations(JDCConnection oConn)
Delete ProductLocations including disk files.
|
DBSubset |
getCategories(JDCConnection oConn)
Get all categories to which this Products belongs
|
java.lang.String |
getCategoryId(JDCConnection oConn)
Get GUID of the first Category to which this Products belongs
|
java.math.BigDecimal |
getFare(JDCConnection oConn,
java.lang.String sIdFare)
Get a given fare price for a product
|
java.math.BigDecimal |
getFareForDate(JDCConnection oConn,
java.sql.Date dtWhen)
Get first fare found valid for a given date
|
DBSubset |
getFares(JDCConnection oConn)
Get product fares
|
DBSubset |
getFaresOfType(JDCConnection oConn,
java.lang.String sType)
Get product fares of a given type
|
DBSubset |
getFaresOfType(JDCConnection oConn,
java.lang.String sType,
java.sql.Date dtWhen)
Get product fares of a given type valid for the specified date
|
ProductLocation |
getFirstLocation(JDCConnection oConn)
Get First ProductLocation for this Product.
|
static java.lang.String |
getIdFromName(java.sql.Connection oConn,
java.lang.String sProductNm,
java.lang.String sWorkAreaId)
Get product GUID given its Name (nm_product) and WorkArea (gu_owner)
|
static java.lang.String |
getIdFromName(JDCConnection oConn,
java.lang.String sProductNm,
java.lang.String sWorkAreaId)
Get product GUID given its Name (nm_product) and WorkArea (gu_owner)
|
static java.lang.String |
getIdFromReference(java.sql.Connection oConn,
java.lang.String sProductId,
java.lang.String sWorkAreaId)
Get product GUID given its Reference (id_ref) and WorkArea (gu_owner)
|
DBSubset |
getImages(JDCConnection oConn)
Get Images associated to this Product
|
DBSubset |
getLocations(JDCConnection oConn)
Get Product Locations
Location semantics depend upon what Product is used for.
|
java.lang.Integer |
getPosition(JDCConnection oConn,
java.lang.String sCategoryId)
get position of Product inside a Category.
|
Shop |
getShop(JDCConnection oConn)
Get the Shop to which this product belongs
|
java.lang.String |
getShopId(JDCConnection oConn)
Get the GUID of the Shop to which this product belongs
|
int |
removeFromCategory(JDCConnection oConn,
java.lang.String idCategory)
Remove product from Category
|
java.math.BigDecimal |
salePrice(java.util.Date dtForDate)
Get Sale Price for a given date.
|
boolean |
store(JDCConnection oConn)
Store Product
If no gu_product is provided, this method will automatically add a new row to k_prod_attr table for the newly created product
If gu_product is null then a new GUID is automatically assigned.
|
allcaps, allcaps, clear, clone, columns, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getIntArray, getInteger, getIntegerArray, getIntervalPart, getItemMap, getItems, getMoney, getPrimaryKey, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTime, getTimeOfDay, getTimestamp, isEmpty, isNull, iterator, keySet, load, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, setPrimaryKey, size, toLowerCase, toUpperCase, toXML, toXML, toXML, values
public static final short ClassId
public static final short STATUS_RETIRED
public static final short STATUS_CORRUPTED
public static final short STATUS_PENDING
public static final short STATUS_ACTIVE
public static final short STATUS_BLOCKED
public Product()
public Product(java.lang.String sIdProduct)
sIdProduct
- GUID for Productpublic Product(JDCConnection oConn, java.lang.String sIdProduct) throws java.sql.SQLException
oConn
- Database ConnectionsIdProduct
- GUID of Product to be loadedjava.sql.SQLException
public static java.lang.String getIdFromName(java.sql.Connection oConn, java.lang.String sProductNm, java.lang.String sWorkAreaId) throws java.sql.SQLException
oConn
- ConnectionsProductNm
- String Product Name (k_products.nm_product column)sWorkAreaId
- String WorkArea GUIDjava.sql.SQLException
public static java.lang.String getIdFromName(JDCConnection oConn, java.lang.String sProductNm, java.lang.String sWorkAreaId) throws java.sql.SQLException
oConn
- JDCConnectionsProductNm
- String Product Name (k_products.nm_product column)sWorkAreaId
- String WorkArea GUIDjava.sql.SQLException
public static java.lang.String getIdFromReference(java.sql.Connection oConn, java.lang.String sProductId, java.lang.String sWorkAreaId) throws java.sql.SQLException
oConn
- ConnectionsProductId
- String Product Reference (k_products.id_ref column)sWorkAreaId
- String WorkArea GUID (k_products.gu_owner column)java.sql.SQLException
public java.math.BigDecimal addOrReplaceFare(JDCConnection oConn, java.lang.String sIdFare, java.lang.String sTpFare, java.lang.String sWorkAreaId, java.math.BigDecimal dPrice, java.lang.String sIdCurrency, float fTaxRate, boolean bIsTaxIncluded, java.sql.Date dtStart, java.sql.Date dtEnd) throws java.sql.SQLException, java.lang.NullPointerException, java.lang.IllegalStateException
Add or replace a Product Fare
This method modifies both k_prod_fares and k_prod_fares_lookup tablesoConn
- JDCConnectionsIdFare
- Fare IdentifiersTpFare
- Fare TypesWorkAreaId
- GUID of WorkAreadPrice
- Fare PricesIdCurrency
- 3 digits numeric currency codefTaxRate
- Tax Rate (10% == 0.10f)bIsTaxIncluded
- true if taxes are included at pr_salejava.sql.SQLException
java.lang.NullPointerException
java.lang.IllegalStateException
public java.math.BigDecimal getFareForDate(JDCConnection oConn, java.sql.Date dtWhen) throws java.sql.SQLException
oConn
- JDCConnectiondtWhen
- Datejava.sql.SQLException
public java.math.BigDecimal getFare(JDCConnection oConn, java.lang.String sIdFare) throws java.sql.SQLException
oConn
- JDCConnectionsIdFare
- String Identifier of fare to wich price is going to be retrivedjava.sql.SQLException
public DBSubset getFares(JDCConnection oConn) throws java.sql.SQLException
oConn
- JDCConnectionid_fare | pr_sale | id_currency | pct_tax_rateis_tax_included | dt_start | dt_end | tp_fare |
java.sql.SQLException
public DBSubset getFaresOfType(JDCConnection oConn, java.lang.String sType) throws java.sql.SQLException
oConn
- JDCConnectionid_fare | pr_sale | id_currency | pct_tax_rateis_tax_included | dt_start | dt_end | tp_fare |
java.sql.SQLException
public DBSubset getFaresOfType(JDCConnection oConn, java.lang.String sType, java.sql.Date dtWhen) throws java.sql.SQLException
oConn
- JDCConnectionid_fare | pr_sale | id_currency | pct_tax_rateis_tax_included | dt_start | dt_end | tp_fare |
java.sql.SQLException
public DBSubset getImages(JDCConnection oConn) throws java.sql.SQLException
oConn
- Database Connectionjava.sql.SQLException
Image
public DBSubset getLocations(JDCConnection oConn) throws java.sql.SQLException, java.lang.NullPointerException
Get Product Locations
Location semantics depend upon what Product is used for.oConn
- Database Connectionjava.sql.SQLException
java.lang.NullPointerException
- if gu_product property is not set for this objectpublic ProductLocation getFirstLocation(JDCConnection oConn) throws java.sql.SQLException
Get First ProductLocation for this Product.
First ProductLocation is that one find in the first place when querying to the database. Thus there is no particular criteria for what is a first ProductLocation. This method is particularly usefull when retrieving the ProductLocation for products that always have a single Productlocation.oConn
- Database Connectionjava.sql.SQLException
public boolean store(JDCConnection oConn) throws java.sql.SQLException
Store Product
If no gu_product is provided, this method will automatically add a new row to k_prod_attr table for the newly created product If gu_product is null then a new GUID is automatically assigned.public boolean delete(JDCConnection oConn) throws java.sql.SQLException
Delete Product
Images and Productlocations are deleted first, including disk files. Then k_sp_del_product storedprocedure is called.public int eraseLocations(JDCConnection oConn) throws java.sql.SQLException, java.lang.NullPointerException
Delete ProductLocations including disk files.
oConn
- Database Connectionjava.sql.SQLException
java.lang.NullPointerException
- if gu_product property is not set for this objectProductLocation.delete(JDCConnection)
public int addToCategory(JDCConnection oConn, java.lang.String idCategory, int iOdPosition) throws java.sql.SQLException
Add Product to Category
Insert Product GUID into table k_x_cat_objs.oConn
- Database ConnectionidCategory
- GUID of CategoryiOdPosition
- Position of Product into Category.
Positions of products inside categories do not need to be unique,
this value is only used for ordering product when displaying them.java.sql.SQLException
- if there was another Product with the same name (k_products.nm_product) already present at idCategorypublic int removeFromCategory(JDCConnection oConn, java.lang.String idCategory) throws java.sql.SQLException
oConn
- Database ConenctionidCategory
- Category GUIDjava.sql.SQLException
public java.lang.Integer getPosition(JDCConnection oConn, java.lang.String sCategoryId) throws java.sql.SQLException
oConn
- Database ConenctionsCategoryId
- Category GUIDjava.sql.SQLException
public DBSubset getCategories(JDCConnection oConn) throws java.sql.SQLException
JDCConnection
- java.sql.SQLException
public java.lang.String getCategoryId(JDCConnection oConn) throws java.sql.SQLException
JDCConnection
- java.sql.SQLException
public java.lang.String getShopId(JDCConnection oConn) throws java.sql.SQLException, java.lang.IllegalStateException
Connection
- java.sql.SQLException
java.lang.IllegalStateException
public Shop getShop(JDCConnection oConn) throws java.sql.SQLException
JDCConnection
- java.sql.SQLException
public java.math.BigDecimal salePrice(java.util.Date dtForDate)
Get Sale Price for a given date.
This method takes into account pr_sale, pr_list, dt_start and dt_end fields.dtForDate
- Date for testing List or Sale Price.public void checkIn(JDCConnection oConn, java.lang.String sUserId) throws java.sql.SQLException, java.lang.IllegalStateException
JDCConnection
- sUserId
- GUID of user requesting check-outjava.lang.SecurityException
- if user does not have modify permission over any category containing this productjava.lang.IllegalStateException
- if product is already checked out by another userjava.sql.SQLException
public void checkOut(JDCConnection oConn, java.lang.String sUserId) throws java.lang.SecurityException, java.sql.SQLException, java.lang.IllegalStateException
JDCConnection
- sUserId
- GUID of user requesting check-outjava.lang.SecurityException
- if user does not have modify permission over any category containing this productjava.lang.IllegalStateException
- if product is already checked out by another userjava.sql.SQLException