Defining top and organizational objects in the explorer view
In this lesson, you define the top object definition and the organization
object definition in the Management Center explorer view.
About this task
A top object definition is an organizational object definition that describes the root object for an instance of the BusinessObjectEditor class. This root object is the starting point for populating the navigation tree. As shown in the preceding screen capture, there are another two organizational objects under the top object, Recipe By Collections, and Unassigned Recipes.
Business objects have relationships and can be
modeled in UML to review and determine the correct model. The business object relations are modeled
according to the noun in service module. The following UML diagram describes the Recipes tool:
- Recipe and Recipe Collection
- These collections are 2 primary objects in recipe tool that represent 2 main concepts in this tool. ChildRecipe is parent reference object, which is used to build parent-child relationship between them. They are in 1 to n relationship, which means one recipe collection can have multiple recipes, while one recipe can belong to only one recipe collection. It is same as the relationship between Catalog group and Catalog.
- RecipeDescription, Ingredients, RecipeInstruction, and RecipeAssociation
- These objects are four child objects of the Recipe primary object. These objects represent the recipe description, the ingredients of a recipe, the instructions to complete a recipe, and the tools that are used in a recipe. Ingredients and RecipeInstruction have their own description as child objects. RecipeAssociation builds a reference relationship with CatalogEntry. Ingredients also build a reference relationship with CatalogEntry.
- RecipeCollection
- RecipeCollection has only one child object, RecipeCollection Description.
- RecipeCollectionTopObject, UnassignedRecipeNode, RecipeCollectionNode
- These objects are either organization objects or top objects, which are used to build the navigation tree in the Recipes tool. RecipeCollectionTopObject is the top object for the tool. It is the root node of the navigation tree in the UI and is not visible. Its role is to return the first level of nodes in the tree by using GetChildrenServices. It does not have a server-side representation. UnassignedRecipeNode is an organizational object and does not have a server-side representation. This object is meant as a way of categorizing the recipes. The UnassignedRecipeNodeobject groups all recipes that are not part of collection. RecipeCollectionNode is also an organizational object and does not have a server-side representation. This object is meant as a way of categorizing the recipes. The RecipeCollectionNode object groups all recipes by collection. This object 's GetChildrenServices return RecipeCollection objects.
Term that is used in UI | Term that is used in DB schema/Noun |
---|---|
Recipe | Project |
Recipe description | ProjectDescription |
Ingredients | ProjectMaterial |
DescriptionOfIngredient | ProjectMaterialDesc |
RecipeInstruction | ProjInstr |
RecipeInstructionDescription | ProjInstrDesc |
RecipeCollection | ProjectCollection |
RecipeCollectionDescription | ProjectCollectionDesc |
Procedure
- In the Enterprise Explorer view, expand .
- Within this directory, create a subdirectory that is named objectDefinitions.
- Right-click the objectDefinitions folder and select Import. Expand General and select File system.
-
Click Next, then click Browse to the following
directory:
TutorialSource\LOBTools\WebContent\WEB-INF\src\xml\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you extracted the Tutorial sample source code
- Select the RecipeTopObjectDefinition.xml object definition file within this directory. Click Finish to import the file.
-
Open the RecipeTopObjectDefinition.xml top object definition file and
examine the contents of the file.
A top object that is named recRecipeTopObjectdefinition is defined in these files. The following code samples show the top object definition.
<Definitions> 1<TopObjectDefinition definitionName="cmc/recipe/RecipeTopObjectDefinition"> <!-- Initialize the Instants of the OrganizationalObject--> <Xml name="template"> <object objectType="UnassignedRecipeNode"/> <object objectType="RecipeCollectionNode"/> </Xml> <GetChildrenService url="/cmc/GetMasterCatalogObject"> <ServiceParam name="storeId"/> </GetChildrenService> <!--- Retrieves the {@link catSalesCatalogPrimaryObjectDefinition Sales Catalog} child objects. --> <GetChildrenService url="/cmc/GetSalesCatalogs"> <ServiceParam name="storeId"/> <ServiceParam name="defaultLanguageId"/> </GetChildrenService> </TopObjectDefinition> </Definitions>
- 1 RecipeTopObjectDefinition
- Rrepresents the whole navigation tree of the recipe tool. The tree has two kinds of
organizational objects as the second layer nodes: unassigned recipes and collection managed recipes.
You need to add these two kinds of organizational objects under this top object in the data set by
defining the object with the corresponding object type.This top object definition has child objects that are only organizational objects. There is no need to invoke a service on the WebSphere Commerce server to get these children, because these organizational objects do not have a server side representation. A template is created that contains the XML representation of these child objects. When the top object is created, the template causes the Management Center framework to create the child objects that are within the template. It has two GetChildrenService elements to retrieve the data from the master catalog and sales catalog, which is used to load the catalog objects into the utility panel.Note: Only one top object definition can be declared for each instance of the BusinessObjectEditor class.
The RecipeTopObjectDefinition.xml file also includes object definitions for two organization objects, one for Unassigned Recipes, the other for Recipe By Collections. The following code snippets show these definitions- Unassigned Recipes:
<OrganizationalObjectDefinition 1definitionName="cmc/recipe/UnassignedRecipeNode" displayName="${ExtRecipeResources.recipeNotInCollection_DisplayName}" objectType="UnassignedRecipeNode" organizedObjectTypes="Recipe"> <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/> <!-- Get children service to retrieve all unassigned recipes --> 2<GetChildrenService url="/cmc/GetUnassignedRecipes"> <ServiceParam name="storeId"/> </GetChildrenService> <!-- Include the list view definition to display the children objects--> <NavigationListDefinition baseDefinition="cmc/recipe/UnassignedRecipeNavigationList"/> <!-- Filter out the Recipes with Parents --> <UnassignedObjectFilter/> </OrganizationalObjectDefinition>
- 1
UnassignedRecipeNode
- Represents a node in a navigation tree that contains the recipes that are not assigned to recipe collections.
- 2
/cmc/GetUnassignedRecipes
- Gets all the unassigned recipes in the system. This service is already defined in the
prerequisite tutorial and is mapped to the URL
"/cmc/GetUnassignedRecipes"
in another lesson.
- 1
- Recipe By Collections:
3<OrganizationalObjectDefinition definitionName="cmc/recipe/RecipeCollectionNode" displayName="${ExtRecipeResources.recipeCollection_TreeNode}" objectType="RecipeCollectionNode" organizedObjectTypes="RecipeCollection"> <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/> <!-- Get children service to retrieve all recipe collections --> 4<GetChildrenService objectTypes="RecipeCollection" url="/cmc/GetRecipeCollections"> <ServiceParam name="storeId"/> </GetChildrenService> <!-- Define the list view definition to display the children objects--> <NavigationListDefinition displayName="${ExtRecipeResources.recipeCollection_DisplayName}" listDefinition="cmc/recipe/CollectionList" listTitle="${ExtRecipeResources.recipeCollection_DisplayName}" name="recCollectionNavigationList" toolbarIcon="listToolbarIcon"/> </OrganizationalObjectDefinition>
- 3 RecipeCollectionNode
- Represents the node Recipe by Collection on the navigation tree. Its child nodes are all the recipe collections in the system.
- 4
/cmc/GetRecipeCollections
- Gets all the recipe collections in the system. This service is already defined in the
prerequisite tutorial and is mapped to the URL
"/cmc/GetRecipeCollections"
in another lesson.