Modeling Management Center object definitions
In the Management Center, a business object represents
an entity that is stored on the WebSphere Commerce Server. The objects
that are 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 must change to support it. In this lesson,
you remodel the Recipes tool objects for extended sites.
About this task
To support extended sites, the object definitions are different from other tutorials in the Recipes tool scenario. The object definitions for extended sites must support specific rules and specifications. When a user logs in to the asset store itself, the objects are local and there are no inherited objects; the asset store does not inherit. The same object can be local if you are logged in to the asset store; the object becomes an inherited object when you log in to the extended site. For more information, see Management Center modeling guidelines for extended sites.
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 on.
- 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 in the following table are only an example for the
Recipes tool scenario. You can make your own design decisions for
other customizations.
Action | Logged in to local store (access only to local store) | Logged in to local store (access to both local and asset store) | Logged in to 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 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. For the asset store, the product must come from the asset store. Similar to merchandising associations. | Create a 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 recipe 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 |
- If a user who has access to only the asset store is logged in to the asset store, only the recipes that belong to the asset store are listed.
- If a user who has access to only the local store is logged in to the local store, the recipes that belong to the asset store and the local store are listed.
- If a user who has access to both the local store and the asset store are logged in to the local store, the recipes that belong 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.
- Recipe is the primary object.
ChildRecipe
is aParentReference
Object. It represents the relationship of Recipe and Recipe collection.RecipeNode
is a node in an explorer tree view.RecipeNode
is anOrganizationalObject
.
- The Management Center must be able to distinguish local Recipes from inherited Recipes. To do so, two object definitions are required. This requirement holds true for all object definitions that are inherited for your asset store.
- The full primary object definition code is contained in the following
file:
- RecipePrimaryObjectDefinition.lzx
- RecipePrimaryObjectDefinition.def
- the
baseDefinition
- a base definition
BaseRecipeCollection
,RecipeCollection
, andInheritedRecipeCollection
. 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 theRecipeCollection
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 theBaseRecipe
. Think of this definition as an abstract class. The inherited recipe is only one recipe that is created in the asset store. An inherited recipe cannot be created in the local store. The object definition is marked ascreatable="false"
or with nocreatable
attribute. The Management Center framework does not allow you to create objects of this type. - Only
RecipeCollection
object is creatable, and it defineswcfCreateService
. - The RecipePrimaryObjectDefinition.lzx file
includes
wcfRegisterObjectDefinition
instances. All primary object-related definitions should be registered. All base object definitions must be registered. For more information, see wcfRegisterObjectDefinition.
<!-- 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 theRecipeCollection
object definition. TheBaseRecipeCollection
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 theBaseRecipeCollection
. Think of this definition as an abstract class. The inherited recipe collection can be created only in the asset store. An inherited recipe cannot be created in the local store. The object definition is marked ascreatable="false"
or with nocreatable
attribute. The Management Center framework does not allow you to create objects of this type. - Only the
RecipeCollection
object is creatable, and it definesCreateService
.
- Reference objects also must 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.
<!-- 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>
- Only the base definition needs
- 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>