Tutorials > Management Center > Support extended sites in the Recipes tool

< Previous | Next >


Model Management Center object definitions

In the Management Center, a business object represents an entity that is stored on the WebSphere Commerce Server. The objects created to build the Recipe tool were defined in the previous tutorial. For extended sites, the inherited object concept is introduced, and the object definitions need to change to support it. In this lesson, we will remodel the Recipes tool objects for extended sites.

To support extended sites, the object definitions are different from other tutorials in the Recipes tool scenario. The object definitions for extended sites needs to support specific rules and specifications. When a user logs into the asset store itself, the objects are local and there are no inherited objects; the asset store does not inherit. The same object could be local if you are logged into the asset store, but becomes an inherited object if you log into the extended site. See Management Center modeling guidelines for extended sites for more information.

In an extended sites model, objects fall into one of the two following categories:

Local objects

Objects belonging to the current store that the business user is logged into.

Inherited objects

Objects that are owned by a parent asset store.

Permission to act on an object depends on where you are logged in and the kind of store access that you have. The permitted actions are a design decision and depend on how you want it to behave. The following table illustrates the design for the extended site relationship within the Recipes tool. The rules to define the extended site relationships are flexible, the assumptions made in the chart below are only an example for the Recipes tool scenario. You can make your own design decisions for other customizations.

Action Logged into local store (access only to local store) Logged into local store (access to both local and asset store) Logged into asset store
List Recipes Show recipes from the local and asset store. Show recipes from the local and asset store. Show recipes from the asset store.
Update Recipe Update local store recipes. Update local and asset store recipes. Update asset store recipes.
Update/Delete Usage Associations for a Recipe Update/Delete Usage Associations for a Recipe from the local store. Update/Delete Usage Associations for a Recipe from the local + asset store. Update/Delete Usage Associations for a Recipe from the asset store
Create a new Usage Association for a Recipe You can create a new usage association for any recipe. The usage association is owned by the local store. The products can come from both stores. You can create a new usage association for any recipe. The usage association is owned by the local store or asset store. In the case of the asset store, the product has to come from the asset store. Similar to merchandising associations. Create a new Usage Association for a Recipe from the asset store.
Create a Recipe instruction for a Recipe from the asset store If the recipe belongs to the local store, you can add new instruction in the local store If the recipe belongs in the parent store, you cannot add instruction in the local store. If the recipe belongs to the local store, you can add new instructions in the local store. If the recipe belongs in the parent store, you cannot add instructions in the local store. If the recipe belongs to the local store, you can add new instructions in the local store. If the recipe belongs in the parent store, you cannot add a Recipe instruction. Recipes and its instructions must all belong to the same store.
Update Recipe Instruction local local + asset asset
Delete Recipe Instruction local local + asset asset
Create an Ingredient for a Recipe If the recipe belongs to the local store, you can add new ingredient in the local store. If the recipe belongs in the parent store, you cannot add ingredients. local + asset asset
Update/Delete Ingredient local local + asset asset
List Ingredient-CatEntry Association local local + asset asset
Delete Ingredient-CatEntry Associations local local + asset asset
Create Integredient-CatEntry associations local local + asset asset
Assign Recipe to Recipe Collection local local + asset asset

The way to read the chart for the first action is listed as an example here:

  1. If a user who only has access to the asset store is logged into the asset store, only the recipes belonging to the asset store are listed.

  2. If a user who only has access to the local store is logged into the local store, the recipes belonging to the asset store and the local store are listed.

  3. If a user who has access to both the local store and the asset store are logged into the local store, the recipes belonging to the asset store and the local store are listed.

The following diagram is a UML representation of the user interface object model for the extended sites Recipes tool.


Procedure

  1. Import the object definition files:

    1. In WebSphere Commerce Developer, select File > Import.

    2. In the Import window, expand General and select File System, then click Next.

    3. Set the From directory to:

      • TutorialEsiteSourceCode\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\objectDefinitions

      • TutorialEsiteSourceCode\LOBTools\WebContent\config\mycompany\recipe\objectDefinitions

      Set the Into folder to:

      • workspace_dir\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\objectDefinitions

      • workspace_dir\LOBTools\WebContent\config\mycompany\recipe\objectDefinitions

    4. Click Finish.

    Notes:

    1. The Management Center must be able to distinguish local Recipes from inherited Recipes.

      To do so, two object definitions are required. This holds true for all object definitions that are inherited for your asset store.

    2. The full primary object definition code is contained in the following file:

      • RecipePrimaryObjectDefinition.lzx

      • RecipePrimaryObjectDefinition.def

      According to Management Center modeling guidelines for extended sites , duplicate all the primary business object definitions and introduce:

      • the baseDefinition

      • a base definition

      The following code samples contain fragments of the object RecipeCollection. Compared with the definition in Define primary objects, there are three related object type definitions, BaseRecipeCollection, RecipeCollection, and InheritedRecipeCollection. The primary object Recipe also has three related definitions.

      <!-- this is the base object definition from which all recipe objects will inherit -->
      <class name="
      recBaseRecipeCollectionPrimaryObjectDefinition"
      extends="wcfPrimaryObjectDefinition"
                      isBaseDefinition="true" 
                      creatable="false"
                      idProperty="collectionId"
                      objectType="BaseRecipeCollection"
                      objectGroups="RecipeCollectionGroup"
                     
      displayName="${extRecipeResources.recipeCollection_DisplayName.string}"
                      displayNameProperty="collectionName"    
                     
      newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName.string}"
                      propertiesClass="recCollectionProperties" 
                      searchType="FindRecipeCollections">             
                                  
                      ......
      </class>
      
      <!-- this object definition represents the local Recipe object -->
      <class name="
      recRecipeCollectionPrimaryObjectDefinition"
      extends="wcfPrimaryObjectDefinition"
                      idProperty="collectionId"
                      objectType="RecipeCollection"
                      
      baseType="BaseRecipeCollection"
                     
      displayName="${extRecipeResources.recipeCollection_DisplayName.string}"
                      displayNameProperty="collectionName"  
                     
      newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName.string}"
                      creatable="true"
                      icon="catalogIcon"
                      headerIcon="catalogHeaderIcon" >   
                     
      <wcfCreateService
      sendDefaultLanguageProperties="true"
      url="/cmc/CreateRecipeCollection">
                     
      <wcfServiceParam name="storeId"/>
                     
      <wcfServiceParam name="defaultLanguageId"
      parameterName="languageId"/>
                     
      </wcfCreateService>       
                      ......                                             
          
      </class>  
      
      <!-- this object definition defines Recipe objects that are inherited from the asset store -->
      <class name="
      recInheritedRecipeCollectionPrimaryObjectDefinition"
      extends="wcfPrimaryObjectDefinition"
                      idProperty="collectionId"
                      objectType="InheritedRecipeCollection" 
                      
      baseType="BaseRecipeCollection"
                      creatable="false"
                      icon="inheritedProductIcon"
                      headerIcon="inheritedProductHeaderIcon"       
                      compatibleObjectTypes="RecipeCollection">       
                                                
                      ......
      </class>  
      

      In the preceding code fragments:

      • The wcfCreateService is only defined in the RecipeCollection object definition. The base Recipe object definition is used only as a way of creating a common ancestor for all recipe object types. The Recipe tool never creates instances of the BaseRecipe. Think of this as an abstract class. The inherited recipe is only one recipe created in the asset store. An inherited recipe cannot be created in the local store. The object definition is marked as creatable="false" or with no creatable attribute (the default value is false) so that the Management Center framework will not allow you to create objects of this type.

      • Only RecipeCollection object is creatable, and it defines wcfCreateService.

      • The RecipePrimaryObjectDefinition.lzx file includes wcfRegisterObjectDefinition instances. All primary object related definitions should be registered. All base object definitions must be registered. See wcfRegisterObjectDefinition for more information.


      <!-- This is the base recipe collection object definition. The RecipeCollection and InheritedRecipeCollection object definitions inherit from this definition.-->
      <PrimaryObjectDefinition definitionName="BaseRecipeCollection"
          displayName="${extRecipeResources.recipeCollection_DisplayName}"
          displayNameProperty="collectionName"
          idProperty="collectionId"
          isBaseDefinition="true"
          newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName}"
          objectGroups="RecipeCollectionGroup"
          objectType="BaseRecipeCollection"
          propertiesDefinitionName="recCollectionProperties"
          searchType="FindRecipeCollections">                
                  ......
      </PrimaryObjectDefinition>
      
      <!-- this object definition represents the local Recipe Collection object -->
      <PrimaryObjectDefinition baseDefinitionName="BaseRecipeCollection"
          creatable="true"
          definitionName="RecipeCollection"
          displayName="${extRecipeResources.recipeCollection_DisplayName}"
          displayNameProperty="collectionName"
          headerIcon="catalogHeaderIcon"
          icon="catalogIcon"
          idProperty="collectionId"
          newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName}"
          objectType="RecipeCollection">
          <CreateService sendDefaultLanguageProperties="true"
              url="/cmc/CreateRecipeCollection">
              <ServiceParam name="storeId"/>
              <ServiceParam name="defaultLanguageId" parameterName="languageId"/>
          </CreateService>
      </PrimaryObjectDefinition>
      
      <!-- This object definition defines Recipe Collection objects that are inherited from the asset store -->
      <PrimaryObjectDefinition baseDefinitionName="BaseRecipeCollection"
          compatibleObjectTypes="RecipeCollection"
          definitionName="InheritedRecipeCollection"
          headerIcon="inheritedProductHeaderIcon"
          icon="inheritedProductIcon"
          idProperty="collectionId"
          objectType="InheritedRecipeCollection">    
          <ParentReferenceObjectDefinition baseDefinitionName="recInheritedChildRecipe"/>
      </PrimaryObjectDefinition>
      

      In the preceding code fragments:

      • The CreateService is only defined in the RecipeCollection object definition. The BaseRecipeCollection object definition is used only as a way of creating a common ancestor for all recipe collection object types. The Recipe tool never creates instances of the BaseRecipeCollection. Think of this as an abstract class. The inherited recipe collection can only be created in the asset store. An inherited recipe cannot be created in the local store. The object definition is marked as creatable="false" or with no creatable attribute (the default value is false) so that the Management Center framework will not allow you to create objects of this type.

      • Only the RecipeCollection object is creatable, and it defines CreateService.

    3. Reference objects also need to be redefined. An example can be seen in the following sample code; this code is similar to the code for primary objects, with the following differences:

      • Only the base definition needs wcfRegisterObjectDefinition.

      • The wcfCreateService is defined in the base object.

      Users with the correct authority can create inherited reference objects. The inherited reference object also needs the create service.

      <!-- this is the base RecipeAssociationDefinition -->
      <wcfRegisterObjectDefinition objectType="BaseRecipeAssociation"
          objectDefinitionClass="recBaseRecipeAssociationDefinition" />
      <class name="recBaseRecipeAssociationDefinition"
          extends="wcfReferenceObjectDefinition" isBaseDefinition="true"
          objectType="BaseRecipeAssociation" copyProtected="true"
          objectGroups="RecipeAssociationReferenceGroup"
          idProperty="associationId" allowDuplicates="false">
          <wcfCreateService url="/cmc/CreateRecipeAssociation"
              sendAll="false">
              <wcfServiceParam name="storeId">
                  <wcfEnablementCondition conditionId="objectTypeCondition"
                      negate="true" checkObjectDefinition="true" propertyName="objectType"
                      enablementValue="InheritedRecipeAssociation" />
              </wcfServiceParam>
              <wcfServiceParam name="objectStoreId" parameterName="storeId"
                  propertyName="objectStoreId" parentProperty="true">
                  <wcfEnablementCondition conditionId="objectTypeCondition"
                      checkObjectDefinition="true" propertyName="objectType"
                      enablementValue="InheritedRecipeAssociation" />
              </wcfServiceParam>
              <wcfServiceParam name="catentryId" objectPath="CatalogEntry"
                  propertyName="catentryId" />
              <wcfServiceParam name="recipeId" parentProperty="true" />
          </wcfCreateService>
          ......
      </class>
      <!-- RecipeAssociation definition. this object definition represents the local RecipeAssociation object -->
      <class name="recRecipeAssociationDefinition"
          extends="wcfReferenceObjectDefinition" objectType="RecipeAssociation"
          baseType="BaseRecipeAssociation"
          referencedTypes="Product,InheritedProduct">
          <wcfTrueEnablementCondition />
      </class>
      <!--  Inherited  RecipeAssociation definition. this object definition defines RecipeAssociation objects that are inherited from the asset store -->
      <class name="recInheritedRecipeAssociationDefinition"
          extends="wcfReferenceObjectDefinition"
          objectType="InheritedRecipeAssociation"
          baseType="BaseRecipeAssociation" referencedType="InheritedProduct">
      </class>
      


      <!-- This is the base recipe association object definition -->    
      <ReferenceObjectDefinition allowDuplicates="false"
          copyProtected="true"
          definitionName="BaseRecipeAssociation"
          idProperty="associationId"
          isBaseDefinition="true"
          objectGroups="RecipeAssociationReferenceGroup"
          objectType="BaseRecipeAssociation">
          <CreateService sendAll="false" url="/cmc/CreateRecipeAssociation">
              <ServiceParam name="storeId">
                  <EnablementCondition checkObjectDefinition="true"
                      conditionId="objectTypeCondition"
                      enablementValue="InheritedRecipeAssociation"
                      negate="true" propertyName="objectType"/>
              </ServiceParam>
              <ServiceParam name="objectStoreId" parameterName="storeId"
                  parentProperty="true" propertyName="objectStoreId">
                  <EnablementCondition checkObjectDefinition="true�?
                      conditionId="objectTypeCondition"
                      enablementValue="InheritedRecipeAssociation"
                      propertyName="objectType"/>
              </ServiceParam>
              <ServiceParam name="catentryId" objectPath="CatalogEntry"
                  propertyName="catentryId"/>
              <ServiceParam name="recipeId" parentProperty="true"/>
          </CreateService>
          .......           
      </ReferenceObjectDefinition>
      <!-- RecipeAssociation definition. this object definition represents the local RecipeAssociation object -->    
      <ReferenceObjectDefinition baseDefinitionName="BaseRecipeAssociation"
          definitionName="recRecipeAssociationDefinition"
          objectType="RecipeAssociation"
          referencedTypes="Product,InheritedProduct">           
          <TrueEnablementCondition/>          
      </ReferenceObjectDefinition>
      <!--  Inherited  RecipeAssociation definition. this object definition defines RecipeAssociation objects that are inherited from the asset store -->
      <ReferenceObjectDefinition baseDefinitionName="BaseRecipeAssociation"
          definitionName="recInheritedRecipeAssociationDefinition"
          objectType="InheritedRecipeAssociation" referencedType="InheritedProduct">
      </ReferenceObjectDefinition>
      

    4. Add the new Inherited object type into the Top object definition. The following code samples show how to add the inherited object type into the Top object definition:

      File Code sample
      RecipeTopObjectDefinition.lzx

        
      <class
      name="recUnassignedRecipeOrganizationalObjectDefinition"
                      extends="wcfOrganizationalObjectDefinition" 
                      objectType="UnassignedRecipeNode"             
                     
      displayName="${extRecipeResources.recipeNotInCollection_DisplayName.string}"
                      organizedObjectTypes="Recipe, InheritedRecipe">
                      ......
                     
      </class>
                     
      <class
      name="recRecipeCollectionOrganizationalObjectDefinition"
                      extends="wcfOrganizationalObjectDefinition" 
                      objectType="RecipeCollectionNode"
                      organizedObjectTypes="RecipeCollection, InheritedRecipeCollection" 
                     
      displayName="${extRecipeResources.recipeCollection_TreeNode.string}">
                      
                     
      <!-- Get children service to retrieve all recipe
      collections -->
                     
      <wcfGetChildrenService
      url="/cmc/GetRecipeCollections" objectTypes="RecipeCollection, InheritedRecipeCollection">       
                             
      <wcfServiceParam name="storeId"/>    
                
                     
      </wcfGetChildrenService>
                              ......
                     
      </class>
      

      RecipeTopObjectDefinition.def

      <OrganizationalObjectDefinition definitionName="UnassignedRecipeNode"
          displayName="${extRecipeResources.recipeNotInCollection_DisplayName}"
          objectType="UnassignedRecipeNode"
          organizedObjectTypes="Recipe,InheritedRecipe">
          ......              
      </OrganizationalObjectDefinition>
          
      <OrganizationalObjectDefinition definitionName="RecipeCollectionNode"
          displayName="${extRecipeResources.recipeCollection_TreeNode}"
          objectType="RecipeCollectionNode"
          organizedObjectTypes="RecipeCollection,InheritedRecipeCollection">
              
          <!-- Get children service to retrieve all recipe collections -->
          <GetChildrenService objectTypes="RecipeCollection,InheritedRecipeCollection"
              url="/cmc/GetRecipeCollections">
              <ServiceParam name="storeId"/>        
              <ServiceParam name="defaultLanguageId"/>    
          </GetChildrenService>
          ......
      </OrganizationalObjectDefinition>
      

  2. You have new object definitions to represent the inherited versions of the user interface objects. Add those new object definitions to the business object editor. The following code samples contain the modified version of the business object editor with the necessary object definition instances. Copy this code to the following location:

    • workspace_dir\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\RecipeManagementToolDefinition.lzx

    • workspace_dir\LOBTools\WebContent\config\mycompany\recipe\RecipeManagementToolDefinition.def

    Option Description
    RecipeManagementToolDefinition.lzx

    <library>
        <class name="recRecipeManagement" extends="wcfBusinessObjectEditor" 
        helpLink="" displayName="${extRecipeResources.recipe_DisplayName.string}"
        browseUtilityFilterTypes="Recipes,MasterCategories,SalesCategories"
        explorerFilterTypes="Recipes">            
            <!-- Context value for the master catalog id -->
           
    <wcfContextValue parameterName="masterCatalogId"/>
            <catCatalogInitService/>        
            <!-- Filter definitions -->
            <wcfObjectTypeFilter filterType="Recipes"  displayName="Recipes" isDefault="true"
                objectTypes="RecipeCollectionNode,UnassignedRecipeNode,RecipeCollection,InheritedRecipeCollection" />            
            <catMasterCatalogGroupsFilter />
            <catSalesCatalogGroupsFilter />                
            <!-- Recipe Top Objects -->
            <recRecipeTopObjectDefinition/>            
           
    <!-- Recipe Organizational Objects -->
               <recUnassignedRecipeOrganizationalObjectDefinition/>
           
    <recRecipeCollectionOrganizationalObjectDefinition/>
           
    <!-- Recipe Primary Objects -->
            <recRecipeCollectionPrimaryObjectDefinition/>
             <recRecipePrimaryObjectDefinition/>          
             <recInheritedRecipeCollectionPrimaryObjectDefinition/>     
             <recInheritedRecipePrimaryObjectDefinition/>     
             <!-- search definitions -->
             <recFindRecipesSearchDefinition/>             
            <recFindRecipeCollectionsSearchDefinition/>         
        </class>        
    </library>
    

    RecipeManagementToolDefinition.def

    <Definitions>
        <BusinessObjectEditor
            browseUtilityFilterTypes="Recipes,MasterCategories,SalesCategories"
            definitionName="recRecipeManagement"
            displayName="${extRecipeResources.recipe_DisplayName}"
            explorerFilterTypes="Recipes" helpLink="">
            <!-- Context value for the master catalog id -->
            <ContextValue parameterName="masterCatalogId"/>
            <InitService baseDefinitionName="catCatalogInitService"/>
            <!-- Filter definitions -->
            <ObjectTypeFilter displayName="Recipes" filterType="Recipes"
                isDefault="true"
        objectTypes="RecipeCollectionNode,UnassignedRecipeNode,RecipeCollection,InheritedRecipeCollection"/>
            <ObjectTypeFilter baseDefinitionName="catMasterCatalogGroupsFilter"/>
            <ObjectTypeFilter baseDefinitionName="catSalesCatalogGroupsFilter"/>
            <!-- Recipe Top Objects -->
            <TopObjectDefinition baseDefinitionName="recRecipeTopObjectDefinition"/>
            <!-- Recipe Organizational Objects -->
               <OrganizationalObjectDefinition
                baseDefinitionName="UnassignedRecipeNode"/>
            <OrganizationalObjectDefinition
                baseDefinitionName="RecipeCollectionNode"/>
            <!-- Recipe Primary Objects -->
            <PrimaryObjectDefinition baseDefinitionName="RecipeCollection"/>
             <PrimaryObjectDefinition baseDefinitionName="Recipe"/>
             <PrimaryObjectDefinition baseDefinitionName="InheritedRecipeCollection"/>
             <PrimaryObjectDefinition baseDefinitionName="InheritedRecipe"/>
             <!-- search definitions -->
             <SearchDefinition baseDefinitionName="FindRecipes"/>    
            <SearchDefinition baseDefinitionName="FindRecipeCollections"/>
        </BusinessObjectEditor>
    </Definitions>
    

  3. Right-click the LOBTools project and select Build OpenLaszlo Project.

< Previous | Next >


+

Search Tips   |   Advanced Search