Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class Product

    java.lang.Object
      com.knowgate.dataobjs.DBPersist
          com.knowgate.hipergate.Product

All Implemented Interfaces:
  java.io.Serializable, java.util.Map

Direct Known Subclasses:
  ProductBundle

    public class Product

extends DBPersist

Read and write products from k_products table

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`static short` | `ClassId`
`static short` | `STATUS_ACTIVE`
`static short` | `STATUS_BLOCKED`
`static short` | `STATUS_CORRUPTED`
`static short` | `STATUS_PENDING`
`static short` | `STATUS_RETIRED`

Fields inherited from class com.knowgate.dataobjs.DBPersist
`AllVals, sAuditCls, sAuditUsr, sTransactId`

Constructor Summary
`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

Method Summary
`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.

Methods inherited from class com.knowgate.dataobjs.DBPersist
`allcaps, allcaps, changelog, clear, clone, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getInteger, getIntervalPart, getItemMap, getItems, getMoney, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTableName, getTime, getTimeOfDay, getTimestamp, getUIdFromName, isEmpty, isNull, iterator, keySet, load, load, parseXML, 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, size, toLowerCase, toUpperCase, toXML, toXML, toXML, toXML, values`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Map
`equals, hashCode`

Field Detail

### ClassId

    public static final short ClassId

See Also:
  Constant Field Values

### STATUS_RETIRED

    public static final short STATUS_RETIRED

See Also:
  Constant Field Values

### STATUS_CORRUPTED

    public static final short STATUS_CORRUPTED

See Also:
  Constant Field Values

### STATUS_PENDING

    public static final short STATUS_PENDING

See Also:
  Constant Field Values

### STATUS_ACTIVE

    public static final short STATUS_ACTIVE

See Also:
  Constant Field Values

### STATUS_BLOCKED

    public static final short STATUS_BLOCKED

See Also:
  Constant Field Values

Constructor Detail

### Product

    public Product()

  Create empty Product

### Product

    public Product(java.lang.String sIdProduct)

  Create empty Product and set gu_product

  Parameters:
    `sIdProduct` - GUID for Product

### Product

    public Product(JDCConnection oConn,
                   java.lang.String sIdProduct)
            throws java.sql.SQLException

  Load Product from database

  Parameters:
    `oConn` - Database Connection
    `sIdProduct` - GUID of Product to be loaded
  Throws:
    `java.sql.SQLException`

Method Detail

### getIdFromName

    public static java.lang.String getIdFromName(java.sql.Connection oConn,
                                                 java.lang.String sProductNm,
                                                 java.lang.String sWorkAreaId)
                                          throws java.sql.SQLException

  Get product GUID given its Name (nm_product) and WorkArea (gu_owner)

  Parameters:
    `oConn` - Connection
    `sProductNm` - String Product Name (k_products.nm_product column)
    `sWorkAreaId` - String WorkArea GUID
  Returns:
    String GUID of product or null if no product with such name was found at given WorkArea
  Throws:
    `java.sql.SQLException`
  Since:
    3.0

### getIdFromName

    public static java.lang.String getIdFromName(JDCConnection oConn,
                                                 java.lang.String sProductNm,
                                                 java.lang.String sWorkAreaId)
                                          throws java.sql.SQLException

  Get product GUID given its Name (nm_product) and WorkArea (gu_owner)

  Parameters:
    `oConn` - JDCConnection
    `sProductNm` - String Product Name (k_products.nm_product column)
    `sWorkAreaId` - String WorkArea GUID
  Returns:
    String GUID of product or null if no product with such name was found at given WorkArea
  Throws:
    `java.sql.SQLException`
  Since:
    3.0

### getIdFromReference

    public static java.lang.String getIdFromReference(java.sql.Connection oConn,
                                                      java.lang.String sProductId,
                                                      java.lang.String sWorkAreaId)
                                               throws java.sql.SQLException

  Get product GUID given its Reference (id_ref) and WorkArea (gu_owner)

  Parameters:
    `oConn` - Connection
    `sProductId` - String Product Reference (k_products.id_ref column)
    `sWorkAreaId` - String WorkArea GUID (k_products.gu_owner column)
  Returns:
    String GUID of product or null if no product with such reference was found at given WorkArea
  Throws:
    `java.sql.SQLException`
  Since:
    3.0

### addOrReplaceFare

    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 tables

  Parameters:
    `oConn` - JDCConnection
    `sIdFare` - Fare Identifier
    `sTpFare` - Fare Type
    `sWorkAreaId` - GUID of WorkArea
    `dPrice` - Fare Price
    `sIdCurrency` - 3 digits numeric currency code
    `fTaxRate` - Tax Rate (10% == 0.10f)
    `bIsTaxIncluded` - true if taxes are included at pr_sale
  Returns:
    Previous sale price value for fare, or null
  Throws:
    `java.sql.SQLException`
    `java.lang.NullPointerException`
    `java.lang.IllegalStateException`
  Since:
    4.0

### getFareForDate

    public java.math.BigDecimal getFareForDate(JDCConnection oConn,
                                               java.sql.Date dtWhen)
                                        throws java.sql.SQLException

  Get first fare found valid for a given date

  Parameters:
    `oConn` - JDCConnection
    `dtWhen` - Date
  Returns:
    BigDecimal
  Throws:
    `java.sql.SQLException`

### getFare

    public java.math.BigDecimal getFare(JDCConnection oConn,
                                        java.lang.String sIdFare)
                                 throws java.sql.SQLException

  Get a given fare price for a product

  Parameters:
    `oConn` - JDCConnection
    `sIdFare` - String Identifier of fare to wich price is going to be retrived
  Returns:
    BigDecimal Product price for the fare or null if fare does not exist.
  Throws:
    `java.sql.SQLException`
  Since:
    v2.2

### getFares

    public DBSubset getFares(JDCConnection oConn)
                      throws java.sql.SQLException

  Get product fares

  Parameters:
    `oConn` - JDCConnection
  Returns:
    DBSubset with the following columns

    id_fare | pr_sale | id_currencypct_tax_rate | is_tax_included | dt_start | dt_end | tp_fare

  Throws:
    `java.sql.SQLException`

### getFaresOfType

    public DBSubset getFaresOfType(JDCConnection oConn,
                                   java.lang.String sType)
                            throws java.sql.SQLException

  Get product fares of a given type

  Parameters:
    `oConn` - JDCConnection
  Returns:
    DBSubset with the following columns

    id_fare | pr_sale | id_currencypct_tax_rate | is_tax_included | dt_start | dt_end | tp_fare

  Throws:
    `java.sql.SQLException`

### getFaresOfType

    public DBSubset getFaresOfType(JDCConnection oConn,
                                   java.lang.String sType,
                                   java.sql.Date dtWhen)
                            throws java.sql.SQLException

  Get product fares of a given type valid for the specified date

  Parameters:
    `oConn` - JDCConnection
  Returns:
    DBSubset with the following columns

    id_fare | pr_sale | id_currencypct_tax_rate | is_tax_included | dt_start | dt_end | tp_fare

  Throws:
    `java.sql.SQLException`

### getImages

    public DBSubset getImages(JDCConnection oConn)
                       throws java.sql.SQLException

  Get Images associated to this Product

  Parameters:
    `oConn` - Database Connection
  Returns:
    A DBSubset with all columns from k_images table for images with gu_product field is equal to this Product GUID.
  Throws:
    `java.sql.SQLException`
  See Also:
    `Image`

### getLocations

    public DBSubset getLocations(JDCConnection oConn)
                          throws java.sql.SQLException,
                                 java.lang.NullPointerException

  Get Product Locations

  Location semantics depend upon what Product is used for.
  - For Downloadable Products, ProductLocations represent mirror download URLs.
  - For Versioned Products, ProductLocations represent different versions of the same File.
  - For Compound Products, ProductLocations represent parts of the Product each one being a File.
  - For Physical Products, ProductLocations represent stock of Product at different warehouses.

  Parameters:
    `oConn` - Database Connection
  Returns:
    A DBSubset with all columns from k_prod_locats for ProductLocations with gu_product is equal to this Product GUID.
  Throws:
    `java.sql.SQLException`
    `java.lang.NullPointerException` - if gu_product property is not set for this object

### getFirstLocation

    public 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.

  Parameters:
    `oConn` - Database Connection
  Returns:
    ProductLocation or null if no ProductLocation is found at k_prod_locats with gu_product equal to this Product GUID.
  Throws:
    `java.sql.SQLException`

### store

    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.
  If dt_modified is null then it is assigned to current system date.
  If dt_uploaded is null then it is assigned to current system date.
  If is_compound is null then it is assigned to 0.
  If id_status is null then it is assigned to 1.

  Overrides:
    `store` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    boolean true if register was stored for the first time, false if register already existed.
  Throws:
    `java.sql.SQLException`

### delete

    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.

  Overrides:
    `delete` in class `DBPersist`
  Parameters:
    `oConn` - Database Connection
  Returns:
    true if register was successfully erased, false if not.
  Throws:
    `java.sql.SQLException`

### eraseLocations

    public int eraseLocations(JDCConnection oConn)
                       throws java.sql.SQLException,
                              java.lang.NullPointerException

  Delete ProductLocations including disk files.

  Parameters:
    `oConn` - Database Connection
  Throws:
    `java.sql.SQLException`
    `java.lang.NullPointerException` - if gu_product property is not set for this object
  See Also:
    `ProductLocation.delete(JDCConnection)`

### addToCategory

    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.
  If Product already belongs to Category no error is raised.

  Parameters:
    `oConn` - Database Connection
    `idCategory` - GUID of Category
    `iOdPosition` - 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.
  Throws:
    `java.sql.SQLException` - if there was another Product with the same name (k_products.nm_product) already present at idCategory

### removeFromCategory

    public int removeFromCategory(JDCConnection oConn,
                                  java.lang.String idCategory)
                           throws java.sql.SQLException

  Remove product from Category

  Parameters:
    `oConn` - Database Conenction
    `idCategory` - Category GUID
  Throws:
    `java.sql.SQLException`

### getPosition

    public java.lang.Integer getPosition(JDCConnection oConn,
                                         java.lang.String sCategoryId)
                                  throws java.sql.SQLException

  get position of Product inside a Category.

  Parameters:
    `oConn` - Database Conenction
    `sCategoryId` - Category GUID
  Returns:
    Product Position or null if this Product was not found inside specified Category.
  Throws:
    `java.sql.SQLException`

### getCategories

    public DBSubset getCategories(JDCConnection oConn)
                           throws java.sql.SQLException

  Get all categories to which this Products belongs

  Parameters:
    `JDCConnection` -
  Returns:
    A DBSubset with a single column gu_category
  Throws:
    `java.sql.SQLException`
  Since:
    4.0

### getCategoryId

    public java.lang.String getCategoryId(JDCConnection oConn)
                                   throws java.sql.SQLException

  Get GUID of the first Category to which this Products belongs

  Parameters:
    `JDCConnection` -
  Returns:
    Category GUID
  Throws:
    `java.sql.SQLException`
  Since:
    4.0

### getShopId

    public java.lang.String getShopId(JDCConnection oConn)
                               throws java.sql.SQLException,
                                      java.lang.IllegalStateException

  Get the GUID of the Shop to which this product belongs

  Parameters:
    `Connection` -
  Returns:
    GUID of Shop or null if no Shop is found for this Product
  Throws:
    `java.sql.SQLException`
    `java.lang.IllegalStateException`
  Since:
    4.0

### getShop

    public Shop getShop(JDCConnection oConn)
                 throws java.sql.SQLException

  Get the Shop to which this product belongs

  Parameters:
    `JDCConnection` -
  Returns:
    Shop object or null if no Shop is found for this Product
  Throws:
    `java.sql.SQLException`
  Since:
    4.0

### salePrice

    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.
  There are two possible prices, list price or sale (bargain) price.
  Sale price is returned if it exists at database and given date is between dt_start and dt_end.
  Otherwise List price is returned.
  This method does not take into account any information from k_prod_fares table.
  Product Price is taken from k_products table following these rules:
  - if dt_start AND dt_end are NULL then pr_list price is assigned.
  - if dt_start is NULL AND dt_end is NOT NULL AND pr_sale is NULL then pr_list is assigned.
  - if dt_start is NULL AND dt_end is NOT NULL AND pr_sale is NOT NULL AND dtForDate is less than or equal to dt_end then pr_sale is assigned.
  - if dt_start is NULL AND dt_end is NOT NULL AND pr_sale is NOT NULL AND dtForDate is greater than dt_end then pr_list is assigned.
  - if dt_start is NOT NULL AND dt_end is NULL AND pr_sale is NULL then pr_list is assigned.
  - if dt_start is NOT NULL AND dt_end is NULL AND pr_sale is NOT NULL AND dtForDate is greater than or equal to dt_start then pr_sale is assigned.
  - if dt_start is NOT NULL AND dt_end is NULL AND pr_sale is NOT NULL AND dtForDate is less than dt_start then pr_list is assigned.
  - if dt_start AND dt_end are NOT NULL AND pr_sale IS NULL then pr_list price is assigned.
  - if dt_start AND dt_end are NOT NULL AND pr_sale IS NOT NULL AND dtForDate is greater than or equal to dt_start AND dtForDate is less than or equal to dt_end then pr_sale is assigned.
  - if dt_start AND dt_end are NOT NULL AND pr_sale IS NOT NULL AND dtForDate is less than dt_start OR dtForDate is greater than dt_end then pr_sale is assigned.

  Parameters:
    `dtForDate` - Date for testing List or Sale Price.
  Returns:
    Price for selling the Product at a given Date.

### checkIn

    public void checkIn(JDCConnection oConn,
                        java.lang.String sUserId)
                 throws java.sql.SQLException,
                        java.lang.IllegalStateException

  Check user permissions and set gu_blockedby column of k_products to null

  Parameters:
    `JDCConnection` -
    `sUserId` - GUID of user requesting check-out
  Throws:
    `java.lang.SecurityException` - if user does not have modify permission over any category containing this product
    `java.lang.IllegalStateException` - if product is already checked out by another user
    `java.sql.SQLException`
  Since:
    4.0

### checkOut

    public void checkOut(JDCConnection oConn,
                         java.lang.String sUserId)
                  throws java.lang.SecurityException,
                         java.sql.SQLException,
                         java.lang.IllegalStateException

  Check user permissions and set the given user GUID at gu_blockedby column of k_products

  Parameters:
    `JDCConnection` -
    `sUserId` - GUID of user requesting check-out
  Throws:
    `java.lang.SecurityException` - if user does not have modify permission over any category containing this product
    `java.lang.IllegalStateException` - if product is already checked out by another user
    `java.sql.SQLException`
  Since:
    4.0

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD