Understanding > WebSphere Commerce and service-oriented architecture (SOA) > Data service layer > Data service layer query processing

Commerce Feature Pack


Access profiles

It is very common, especially when building Web applications, to require a different level of detail on various web pages for the same object. For example, on a product list page, only minimal information about each product is needed, while on a product detail page, more information is required. To accommodate the varying needs for different levels of knowledge about an object, clients can use access profiles to convey the intent of their requests.

Access profiles are keys that allow you to change the amount and type of response data being returned by a particular XPath expression. The access profile is used to choose the SQL statement from the Query template file that retrieves data. You must always specify the access profile. For example, the following query specifies the IBM_Admin_Details access profile:

IBM_Admin_ prefixes all services intended to be used by admin/CMC based services calls in Feature Pack 4. Access profiles which do not follow the new naming conventions continue to function correctly, as compatibility is maintained with earlier versions. IBM recommends, however, that they are followed for existing access profiles, and when making changes to future access profiles. See Access profile naming conventions for more information.

{_wcf.ap=IBM_Admin_Details}/CatalogGroup[Name='MyCatalogGroupName']

There are two ways to use the access profile to scope your response data:

  1. Define a XPATH_TO_SQL_STATEMENT block in the query template file. The template name is the XPath_key+Access_profile, where XPath_key is the key generated from an XPath query and Access_Profile is the name of the access profile. The access profile together with the XPath key is used to locate the necessary query template in the template file.

  2. Define the access profile in the PROFILE section of the query template file, and define one or more SQL templates under the ASSOCIATON_SQL_STATEMENT section. When the DSL is called with this access profile, the associated SQL is run. Use this method to structure a query to retrieve a set of objects, then use the associated SQL, to retrieve information about those objects. For information about configuring access profiles, see Query template file.

Access profile extensions

You can extend an access profile, including WebSphere Commerce default access profiles.

An example of the syntax in your custom query template file is:

BEGIN_SYMBOL_DEFINITIONS
  COLS:CATENTRY=CATENTRY:* 
  COLS:XWARRANTY=XWARRANTY:*
END_SYMBOL_DEFINITIONS

BEGIN_ASSOCIATION_SQL_STATEMENT
  name=MyAssociatedQuery
  base_table=CATENTRY
  sql=
       SELECT CATENTRY.$COLS:CATENTRY$,
                XWARRANTY.$COLS:XWARRANTY$
       FROM
            CATENTRY 
                   LEFT OUTER JOIN XWARRANTY ON 
                     (CATENTRY.CATENTRY_ID = XWARRANTY.CATENTRY_ID)
             WHERE
                   CATENTRY.CATENTRY_ID IN ($ENTITY_PKS$) 
END_ASSOCIATION_SQL_STATEMENT

BEGIN_PROFILE
  name=MyProfile
  extends = IBM_Admin_Summary
  associated_sql_statement=MyAssociatedQuery
BEGIN_ENTITY
In the example, the access profile MyProfile is extending IBM_Admin_Summary, a default WebSphere Commerce access profile. A new associated SQL statement block, MyAssociatedQuery, is also defined. This SQL statement must be in the same query template file as the new access profile.

When selecting a subset of columns from the extension table (or any table associated with the base table), always select the primary key of the custom table and the foreign key to the base table. If not, WAS is incapable of building the relationship between the base table object and the extension table object.

Restriction:

Related concepts

Data service layer

Query template file

Related tasks

Create a query

Create an access profile for an existing XPath expression

Extending a default WebSphere Commerce query

Generating your XPath key using the wcs_xpathkey utility

Related reference

SQL parameters

Query template file tags

Data service layer naming conventions

WebSphere Commerce extended XPath notation

Last updated: 25 November 2009