com.elasticpath.service.attribute.impl
Class AttributeServiceImpl

java.lang.Object
  extended by com.elasticpath.service.impl.AbstractEpServiceImpl
      extended by com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
          extended by com.elasticpath.service.attribute.impl.AttributeServiceImpl
All Implemented Interfaces:
AttributeService, EpPersistenceService, EpService

public class AttributeServiceImpl
extends AbstractEpPersistenceServiceImpl
implements AttributeService

Default implementation for AttributeService.


Constructor Summary
AttributeServiceImpl()
           
 
Method Summary
 Attribute add(Attribute attribute)
          Adds the given attribute.
 Attribute findByKey(java.lang.String key)
          Find the attribute with the given key.
 Attribute get(long attributeUid)
          Get the attribute with the given UID.
 java.util.List getAttributeInUseUidList()
          Return a list of uids for all attributes in use, exclude the customer profile attributes.
 java.util.List getAttributesExcludeCustomerProfile()
          Returns a list of attributes exclude customer profile attribute.
 java.util.Map getAttributeTypeMap()
          Return the map for attribute type value-description.
 java.util.Map getAttributeUsageMap()
          Return the map for attribute usage value-description.
 java.util.List getCategoryAttributes()
          Return a list of category attributes.
 java.util.List getCustomerProfileAttributeInUseUidList()
          Return a list of uids for all customer profile attributes in use.
 java.util.List getCustomerProfileAttributes()
          Returns a list of customer profile attributes.
 java.util.Map getCustomerProfileAttributesMap()
          Returns a map of all system attributes.
 java.util.List getDistinctAttributeValueList(Attribute attribute, java.lang.String languageCode)
          For a given attribute, the set of distinct values currently existing for that attribute is returned.
 java.lang.Object getObject(long uid)
          Generic load method for all persistable domain models.
 java.util.List getProductAttributes()
          Return a list of attributes used for products.
 java.util.List getSkuAttributes()
          Return a list of attributes used for skus.
 boolean keyExists(Attribute attribute)
          Check whether the given attribute's key exists or not.
 boolean keyExists(java.lang.String key)
          Checks whether the given attribute key exists or not.
 java.util.List list()
          Lists all attribute stored in the database.
 Attribute load(long attributeUid)
          Load the attribute with the given UID.
 void remove(Attribute attribute)
          Delete the attribute.
 void setDistinctAttributeValueCriterion(DistinctAttributeValueCriterion distinctAttributeValueCriterion)
          Sets the generator for criteria used to query the persistence layer for distinct lists of attribute values.
 void update(Attribute attribute)
          Updates the given attribute.
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpServiceImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.service.EpPersistenceService
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from interface com.elasticpath.service.EpService
getElasticPath, setElasticPath
 

Constructor Detail

AttributeServiceImpl

public AttributeServiceImpl()
Method Detail

add

public Attribute add(Attribute attribute)
              throws DuplicateKeyException
Adds the given attribute.

Specified by:
add in interface AttributeService
Parameters:
attribute - the attribute to add
Returns:
the persisted instance of attribute
Throws:
DuplicateKeyException - - if the speicifed attribute key is already in use.

findByKey

public Attribute findByKey(java.lang.String key)
                    throws EpServiceException
Find the attribute with the given key.

Specified by:
findByKey in interface AttributeService
Parameters:
key - the attribute key.
Returns:
the attribute that matches the given key, otherwise null
Throws:
EpServiceException - - in case of any errors

get

public Attribute get(long attributeUid)
              throws EpServiceException
Get the attribute with the given UID. Return null if no matching record exists.

Specified by:
get in interface AttributeService
Parameters:
attributeUid - the attribute UID
Returns:
the attribute if UID exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getAttributeInUseUidList

public java.util.List getAttributeInUseUidList()
Return a list of uids for all attributes in use, exclude the customer profile attributes.

Specified by:
getAttributeInUseUidList in interface AttributeService
Returns:
a list of uids for all attributes in use, exclude the customer profiel attributes

getAttributesExcludeCustomerProfile

public java.util.List getAttributesExcludeCustomerProfile()
Returns a list of attributes exclude customer profile attribute.

Specified by:
getAttributesExcludeCustomerProfile in interface AttributeService
Returns:
a list of attributes exclude customer profile attribute

getAttributeTypeMap

public java.util.Map getAttributeTypeMap()
Return the map for attribute type value-description. Use stuff from AbstractAttributeTypeImpl to reduce duplication.

Specified by:
getAttributeTypeMap in interface AttributeService
Returns:
the map for attribute type value-description

getAttributeUsageMap

public java.util.Map getAttributeUsageMap()
Return the map for attribute usage value-description.

Specified by:
getAttributeUsageMap in interface AttributeService
Returns:
the map for attribute usage value-description

getCategoryAttributes

public java.util.List getCategoryAttributes()
Return a list of category attributes.

Specified by:
getCategoryAttributes in interface AttributeService
Returns:
a list of category attributes.

getCustomerProfileAttributeInUseUidList

public java.util.List getCustomerProfileAttributeInUseUidList()
Return a list of uids for all customer profile attributes in use.

Specified by:
getCustomerProfileAttributeInUseUidList in interface AttributeService
Returns:
a list of uids for all customer profile attributes in use

getCustomerProfileAttributes

public java.util.List getCustomerProfileAttributes()
Returns a list of customer profile attributes.

Specified by:
getCustomerProfileAttributes in interface AttributeService
Returns:
a list of customer profile attributes

getCustomerProfileAttributesMap

public java.util.Map getCustomerProfileAttributesMap()
Returns a map of all system attributes.

Specified by:
getCustomerProfileAttributesMap in interface AttributeService
Returns:
a map of all system attributes

getDistinctAttributeValueList

public java.util.List getDistinctAttributeValueList(Attribute attribute,
                                                    java.lang.String languageCode)
For a given attribute, the set of distinct values currently existing for that attribute is returned.

Specified by:
getDistinctAttributeValueList in interface AttributeService
Parameters:
attribute - the attribute for which the distinct attribute values are to be returned
languageCode - the lower case code of the language for which attributes are to be returned.
Returns:
a List of matching AttributeValues

getObject

public java.lang.Object getObject(long uid)
                           throws EpServiceException
Generic load method for all persistable domain models.

Specified by:
getObject in interface EpPersistenceService
Parameters:
uid - the persisted instance uid
Returns:
the persisted instance if exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getProductAttributes

public java.util.List getProductAttributes()
Return a list of attributes used for products.

Specified by:
getProductAttributes in interface AttributeService
Returns:
a list of products attributes.

getSkuAttributes

public java.util.List getSkuAttributes()
Return a list of attributes used for skus.

Specified by:
getSkuAttributes in interface AttributeService
Returns:
a list of sku attributes.

keyExists

public boolean keyExists(Attribute attribute)
                  throws EpServiceException
Check whether the given attribute's key exists or not.

Specified by:
keyExists in interface AttributeService
Parameters:
attribute - the attribute to check
Returns:
true if a different attribute with the given attribute's key exists
Throws:
EpServiceException - - in case of any errors

keyExists

public boolean keyExists(java.lang.String key)
                  throws EpServiceException
Checks whether the given attribute key exists or not.

Specified by:
keyExists in interface AttributeService
Parameters:
key - the attribute key.
Returns:
true if the given key exists.
Throws:
EpServiceException - - in case of any errors

list

public java.util.List list()
                    throws EpServiceException
Lists all attribute stored in the database.

Specified by:
list in interface AttributeService
Returns:
a list of attribute
Throws:
EpServiceException - - in case of any errors

load

public Attribute load(long attributeUid)
               throws EpServiceException
Load the attribute with the given UID. Throw an unrecoverable exception if there is no matching database row.

Specified by:
load in interface AttributeService
Parameters:
attributeUid - the attribute UID
Returns:
the attribute if UID exists, otherwise null
Throws:
EpServiceException - - in case of any errors

remove

public void remove(Attribute attribute)
            throws EpServiceException
Delete the attribute.

Specified by:
remove in interface AttributeService
Parameters:
attribute - the attribute to remove
Throws:
EpServiceException - - in case of any errors

setDistinctAttributeValueCriterion

public void setDistinctAttributeValueCriterion(DistinctAttributeValueCriterion distinctAttributeValueCriterion)
Sets the generator for criteria used to query the persistence layer for distinct lists of attribute values.

Specified by:
setDistinctAttributeValueCriterion in interface AttributeService
Parameters:
distinctAttributeValueCriterion - the DistinctAttributeValueCriterion

update

public void update(Attribute attribute)
            throws DuplicateKeyException
Updates the given attribute.

Specified by:
update in interface AttributeService
Parameters:
attribute - the attribute to update
Throws:
DuplicateKeyException - - if the speicifed attribute key is already in use.