Sunday, July 14, 2013

USERS in WebSphere Commerce

USERS in WebSphere Commerce

If you are working in WCS, you might have heard about registered users, guest users and generic users. Do you the difference between these users’ types?

Generic User:
When a customer accesses the website to browse the home pages and other product pages without signing in, the user will be assigned as a generic user. Normally in WCS, the user id -1002 refers to the generic user. This user id will be shared across the entire application. This approach minimizes the resource usage in WCS as the same context can be used for multiple users.

Guest User:
When the user adds an item to cart or do some activity which requires a unique identity the user will be converted to a guest user. A guest user will be assigned with a unique member id. Based on the business model and the access policies defined, a guest user will have more privileges in the site rather than a generic user.
The registrationType present in USERS table for both guest and generic user will be “G”. But in WCS by default, a generic user cannot purchase an item through the website. He should register with the site to place an order in the system. A guest user can place order in the site, if guest checkout is enabled in the system.

Registered User:
If the guest user registers to the site, the user will get converted to a registered user, and any assets that the guest user owned will be migrated to the registered user. As part of registration process, the user has to provide a unique user name and password. This will create a profile for the user and will create an entry in USERS table with profile type ‘R’. This username will be always tied up with the member id which is created during registration. Based on the customization implemented, user can store his personal, address and payment details in his profile. Also it will provide additional functionality to the user such as order history, checkout later, personalization, reminder emails etc.

The term “registered user” not only refers the customers who signin to purchase the items, but includes the site administrators, customer care representatives etc. But the registration type present in USERS table will be different for these users.  For eg. The user type of a site administrator will be ‘A’ where as for an administrator, it will be ‘S’. Based on the configuration and customization, the functionalities provided to each of these users may differ. 


How to identify different users from USERS table:



Member Id
Registration Type
Description
-1002
G
The user is a generic user
<any member id>
G
The user is a guest user
<any member id>
R
Registered customer
<any member id>
S
Site Administrator
<any member id>
A
Administrator





Wednesday, July 10, 2013

SWT Code -FileDialog,DirectoryDialog and multi-lined text field

Search for files with specified extension

Learn  how to use FileDialog,DirectoryDialog and multi-lined text field in SWT using Grid layout



/*
 *  program to get the file with specified extension.
 *
 * Description: If we gave directory path and extension of file , we will be able to select files with that specified extension
 */
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class FileSearchForExtension {
       Display display = new Display();
       Shell shell = new Shell(display);
       Text text;
       String selectedDir;
       Label label;
       Text text1, fileNameText;
       String fileFilterPath = "";
       StringBuilder sb = new StringBuilder("");

       public FileSearchForExtension() {
              init();
              shell.pack();
              shell.setSize(450, 300); // setting size of the shell
              shell.open();

              while (!shell.isDisposed()) {
                     if (!display.readAndDispatch()) {
                           display.sleep();
                     }
              }
              display.dispose();
       }

       private void init() {
              shell.setText("File Searcher for Extension");
              GridLayout gridLayout = new GridLayout();
              gridLayout.numColumns = 2;
              gridLayout.makeColumnsEqualWidth = true;
              shell.setLayout(gridLayout);
              GridData data = new GridData(GridData.FILL_BOTH);

              // UI design 
              // Directory selection button and text box

              Button button = new Button(shell, SWT.PUSH);
              button.setText("Select a directory");
              text = new Text(shell, SWT.NONE);
              text.setLayoutData(data);

              // Enter extension manually
              label = new Label(shell, SWT.BORDER | SWT.WRAP);
              label.setText("Enter the extension to search");
              text1 = new Text(shell, SWT.NONE);
              text1.setLayoutData(data);

              // Multiple/single file name selection button and text box

              Button buttonSelectFile = new Button(shell, SWT.PUSH);
              buttonSelectFile.setText("Select a file/multiple files names");
              fileNameText = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP
                           | SWT.V_SCROLL);
              fileNameText.setLayoutData(data);

              Button buttonClear = new Button(shell, SWT.PUSH);
              buttonClear.setText("clear fileds");
              GridData gridData = new GridData();
              gridData.horizontalAlignment = GridData.CENTER;
              gridData.horizontalSpan = 2;
              buttonClear.setLayoutData(gridData);

              // Adding listner for directory selection using directory dialog
              button.addListener(SWT.Selection, new Listener() {
                     public void handleEvent(Event event) {
                           DirectoryDialog directoryDialog = new DirectoryDialog(shell);

                           directoryDialog.setFilterPath(selectedDir);
                           directoryDialog
                                         .setMessage("Please select a directory and click OK");

                           String dir = directoryDialog.open();
                           if (dir != null) {
                                  text.setText(dir);
                                  text.setEditable(true);
                                  selectedDir = dir;
                           }
                     }
              });

              // adding listener to file names selection using file dialog
              buttonSelectFile.addListener(SWT.Selection, new Listener() {
                     public void handleEvent(Event event) {
                           FileDialog fileDialog = new FileDialog(shell, SWT.MULTI);

                           fileDialog.setFilterPath(text.getText());
                           String extension = text1.getText();
                           fileDialog
                                         .setFilterExtensions(new String[] { "*." + extension });

                           String firstFile = fileDialog.open();

                           if (firstFile != null) {
                                  fileFilterPath = fileDialog.getFilterPath();
                                  String[] selectedFiles = fileDialog.getFileNames();

                                  for (int i = 0; i < selectedFiles.length; i++) {
                                         sb.append(selectedFiles[i] + "\n");
                                  }
                                  fileNameText.setText(sb.toString());
                           }
                     }
              });

              // Adding listener to the clear button
              buttonClear.addListener(SWT.Selection, new Listener() {
                     public void handleEvent(Event event) {
                           text.setText("");
                           text1.setText("");
                           fileNameText.setText("");
                           sb.setLength(0);
                     }
              });

       }

       public static void main(String[] args) {
              new FileSearchForExtension();
       }
}

Wednesday, July 3, 2013

Catalog subsystem

What is Catalog subsystem ?

Catalog subsystem is a component of WebSphere Commerce Server that provides online catalog navigation, partitioning, categorization, and associations. It contain all logic and data relevant to an online catalog and associations or relationships among them.
Online catalog consists of the goods and services you offer for sale.
Online catalogs can differ greatly from store to store, depending on the type and amount of merchandise.

For a catalog for purchase we need many things:

1      Prices, Product data, such as descriptions and images of your merchandise.
2.    Categories, as most, but not all catalogs divide merchandise into categories, to facilitate navigation for   customers.
3.       A display method for what you are selling.

The online Catalog can be a catalog groups (or categories) or a catalog entries.

Catalog entries

A catalog entry is a product displayed in the store's online catalog for purchasing from the store.

Catalog entries can be a single item (atomic) or composed of several other catalog entries (composite).

Atomic Catalog entries 

A single orderable item.
An orderable item is called a SKU. Atomic item is a SKU.
A fully resolved package is a atomic

 Composite catalog entries:
 A catalog entry represents unresolved products, packages, or bundles that may need additional information before becoming atomic entities.
An example is resolving a product into an item through SKU resolution, performed by the ResolveSkuCmd task command.
If necessary, you can create new CatalogEntry type objects that do not fit into one of the existing ProductItemPackageBundle, or DynamicKit models. 
  
A catalog entry can be a product, item, package, bundle, or dynamic kit.

Item and product

Flat screen T.V (Product)
        
--  T.V screen size 12 inch(item)
--  T.V screen size 15 inch(item)
--  T.V screen size 20 inch(item)
--  T.V screen size 24 inch(item)
 ….

Item
Product
tangible unit of merchandise that has a specific name, part number, and price.
a group of items that exhibit the same attributes
Item is having specific attribute value.
A 15 inch hammer with a wooden handle (part number 15) is an item. It is having specific attribute value.
handle type : Wooden
Size: 15 inch
Items related to a particular product exhibit the same set of attributes.
E.g:
Hammer is a product , it’s attributes are "handle type" and "size".
All the items are coming under one product.
each item should be associated to one product in WebSphere Commerce Accelerator
User can purchase an item.
An item is orderable(SKU)
A product cannot be purchased

Packages and bundles

Packages and bundles are groupings of catalog entries used for promotional purposes.

Package
Bundle
a package is an atomic collection of catalog entries
A bundle is a collection of catalog entries that allow customers to buy multiple items with one click
Packages can be unresolved or fully resolved.

A bundle can be a grouping of items, or a combination of products, items, and fully resolved packages.
A fully resolved package is comparable to an item, with its own price, and can be added to a shopping cart. unresolved packages must first be transformed into fully resolved packages before adding to shopping cart.
The Package will be considered as a single item , after adding to shopping cart. We will not be able to decompose, modify or remove individual items from that package.
When adding to shopping cart , the each items of bundles will be decomposed into separate orderable SKUs that are added individually to the shopping cart.
We can modify or remove each item from cart according to our choice.
a computer package:  contain a specific central processing unit, monitor, and hard drive that cannot be sold separately.

Computer bundle:
a computer bundle might be composed of a central processing unit, a monitor, a hard drive, and a CD-ROM drive.
Once the bundle is added to shopping cart, user can remove or modify items( processing unit, a monitor, a hard drive, and a CD-ROM drive).





Example:
A Computer consist of  CPU, monitor and hard drive etc.
Computer product can be displayed as package or bundle according to their business.(according to the sales how they want to display online).

If business is selling it has package , we will get it as a single item with CPU, monitor and hard drive.

If it is selling as bundle , after adding to shopping cart customer can  remove or modify item  , i.e we customer can individually buy a monitor or cpu or hard drive.

Dynamic Kit and Static kit

Dynamic Kit
Static kit
dynamic kit is a type of catalog entry which can be dynamically configured by the customer. This configuration (or grouping) of products is based on the customer's requirements and is sold as a single unit.
static kit is a group of products that are ordered as a unit. The information about the products contained in a static kit is predefined and controlled within WebSphere Commerce.
Adding a dynamic kit to an order is similar to adding a package. Like a package, the individual components of a dynamic kit cannot be modified and the entire configuration must be fulfilled as a whole. However, you may change the dynamic kit components by reconfiguring it using an external product configurator.

The individual components within the order cannot be modified and must be fulfilled together. A static kit will backorder if any of its components are unavailable.