HowTos - Data Management: Common

Common information about generic SalesPoint containers

Description:

Since Version 3.3, SalesPoint containers are generic. In order to use this functionality most conveniently, there are special identifiers that store the generic information. So the developer will not have to take care of casting to appropriate container types. Container types in SalesPoint are Catalogs and Stocks.

Catalogs:

Catalogs are typed by the kind of CatalogItem they will contain. The same goes for their identifiers.

        CatalogIdentifier<DataBasicCatalogItem> SimpleCatalog = new CatalogIdentifier<DataBasicCatalogItem>("SimpleCatalog");
        Catalog<DataBasicCatalogItem> simpleCatalog = new CatalogImpl<DataBasicCatalogItem>(SimpleCatalog);
		

Once they are created you can register them with the Shop and get them back with the identifier they were created with:

        Shop.getTheShop().addCatalog(simpleCatalog);
        Catalog<DataBasicCatalogItem> catalog = Shop.getTheShop().getCatalog(SimpleCatalog);
		

Stocks:

Catalogs are typed by the kind of StockItem they will contain and the kind of CatalogItem the Catalog contains that is associated with the stock. The same goes for their identifiers.

        StockIdentifier<StockItemImpl, DataBasicCatalogItem> Stock = 
                    new StockIdentifier<StockItemImpl, DataBasicCatalogItem>("CountingStock"); 
        CountingStock<StockItemImpl, DataBasicCatalogItem> stock = 
                new CountingStockImpl<StockItemImpl, DataBasicCatalogItem>(Stock, simpleCatalog);
		

Once they are created you can register them with the Shop and get them back with the identifier they were created with in a similar manner as you can do that with Catalogs.

As you can see (especially in the case of Stocks), setting these up can easily get quite extensive. Therefore it is recommended to derive your own classes from CatalogImpl, CountingStockImpl and/or StoringStockImpl and fit their generic parameters to your needs. You simply have to implement the constructor that takes the corresponding identifier and delegate it to the super constructor.


previous Data Management: StockDisplay: FormSheet next



by Thomas Ryssel