Tutorials > Management Center > Add a Recipes tool to the Management Center

< Previous | Next >


Define primary objects

As part of creating a custom tool for the Management Center, define an OpenLaszlo library class or a definition file for the primary objects.

A primary object definition describes a top level business object that exists as its own entity independent of other objects. They are different from other object definition types due to the fact that primary objects can be found using a search service and can be referenced by other primary objects.

Two primary objects are defined in this lesson: Recipe and Recipe Collection.


Procedure

  1. Complete one of the following steps:

    • In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > mycompany > recipe > objectDefinitions.

    • In the Enterprise Explorer view, expand LOBTools > WebContent > config > mycompany > recipe > objectDefinitions.

  2. Right-click the objectDefinitions folder and select Import. Expand General and select File system.

  3. Click Next, then click Browse and navigate to:

    Option Description
    TutorialSource\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code

    1. Select the RecipePrimaryObjectDefinition.lzx file.

    2. Click Finish to import the file.
    TutorialSource\LOBTools\WebContent\config\mycompany\recipe\objectDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code

    1. Select the RecipePrimaryObjectDefinition.def file.

    2. Click Finish to import the file.

  4. Open one of the following files and examine the contents:

    • RecipePrimaryObjectDefinition.lzx (primary object class file)

    • RecipePrimaryObjectDefinition.def (primary object definition file)

    A primary object named Recipe is defined in these files.

    The following code samples show the primary object defined in each of these files:

    Option Description
    RecipePrimaryObjectDefinition.lzx

    <class name="recRecipePrimaryObjectDefinition" extends="wcfPrimaryObjectDefinition"
                    objectType="Recipe"
                    creatable="true"
                    displayName="${extRecipeResources.recipe_DisplayName.string}"
                    displayNameProperty="name"
                    idProperty="recipeId"
                    newDisplayName="${extRecipeResources.recipe_NewDisplayName.string}"
                    propertiesClass="recRecipeProperties"
                    icon="recipeIcon"
                    headerIcon="recipeHeaderIcon"  
                    >                    
                    
           
    <!-- Multiple GetChildrenService -->
           
    <wcfGetChildrenService url="/cmc/GetRecipeChildren-Ingredients" objectTypes="RecipeIngredients">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="recipeId" propertyName="recipeId"/>
           
    </wcfGetChildrenService>       
           
    <wcfGetChildrenService url="/cmc/GetRecipeChildren-Instruction" objectTypes="RecipeInstruction">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="recipeId" propertyName="recipeId"/>
           
    </wcfGetChildrenService>      
           
    <wcfGetChildrenService url="/cmc/GetRecipeChildren-Association" objectTypes="RecipeAssociation">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="recipeId" propertyName="recipeId"/>
           
    </wcfGetChildrenService>
                            
           
    <!-- Create Service -->
           
    <wcfCreateService sendDefaultLanguageProperties="true" url="/cmc/CreateRecipe">
                   
    <wcfServiceParam name="storeId"/>
                   
    <wcfServiceParam name="defaultLanguageId" parameterName="languageId" />
           
    </wcfCreateService>        
            
           
    <!-- Update Service -->
           
    <wcfUpdateService sendDefaultLanguageProperties="true" url="/cmc/UpdateRecipe">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="defaultLanguageId" parameterName="languageId" />
                   
    <wcfServiceParam name="recipeId" propertyName="recipeId" />
           
    </wcfUpdateService>
            
           
    <!-- Delete Service -->
           
    <wcfDeleteService url="/cmc/DeleteRecipe">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="recipeId" propertyName="recipeId" />
           
    </wcfDeleteService>       
                                                                          
           
    <!-- Refresh Service -->
           
    <wcfRefreshService url="/cmc/GetRecipeByRecipeId">
           
    <wcfServiceParam name="storeId" />
           
    <wcfServiceParam name="recipeId" propertyName="recipeId" />
           
    </wcfRefreshService>
    
           
    <!-- Property Definition -->
           
    <wcfPropertyDefinition displayName="${extRecipeResources.recipeTime_DisplayName.string}"  
                    propertyName="time" type="number" />
           
    <wcfPropertyDefinition displayName="${extRecipeResources.difficultyLevel_DisplayName.string}" 
                    propertyName="difficulty">
                           
    <wcfPropertyValue displayName="easy" value="easy"/>
                           
    <wcfPropertyValue displayName="medium" value="normal"/>
                           
    <wcfPropertyValue displayName="difficult" value="difficult"/>                                 
           
    </wcfPropertyDefinition>  
                                                    
           
    <!-- All child and reference objects need to be initialized so that the parent-child and reference relationship can be built.   -->
           
    <recRecipeDescriptionDefinition/>
           
    <recRecipeCollectionReference/>
           
    <recRecipeIngredientsDefinition/>
           
    <recRecipeInstructionDefinition/>
           
    <recRecipeAssociationDefinition/>
                    
    </class>
    

    RecipePrimaryObjectDefinition.def

    <PrimaryObjectDefinition definitionName="Recipe"
            objectType="Recipe"
            creatable="true"
            displayName="${extRecipeResources.recipe_DisplayName}"
            displayNameProperty="name"
            idProperty="recipeId"
            newDisplayName="${extRecipeResources.recipe_NewDisplayName}"
            propertiesDefinitionName="recRecipeProperties"
            icon="recipeIcon"
            headerIcon="recipeHeaderIcon">
    
        <!-- Multiple GetChildrenService -->
        <GetChildrenService url="/cmc/GetRecipeChildren-Ingredients"
            objectTypes="RecipeIngredients">
            <ServiceParam name="storeId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
           
    </GetChildrenService>
        <GetChildrenService url="/cmc/GetRecipeChildren-Instruction"
            objectTypes="RecipeInstruction">
            <ServiceParam name="storeId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
        </GetChildrenService>      
        <GetChildrenService url="/cmc/GetRecipeChildren-Association"
            objectTypes="RecipeAssociation">
            <ServiceParam name="storeId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
        </GetChildrenService>
    
        <!-- Create Service -->
        <CreateService sendDefaultLanguageProperties="true" url="/cmc/CreateRecipe">
            <ServiceParam name="storeId"/>
            <ServiceParam name="defaultLanguageId" parameterName="languageId"/>
        </CreateService>
    
        <!-- Update Service -->
        <UpdateService sendDefaultLanguageProperties="true" url="/cmc/UpdateRecipe">
            <ServiceParam name="storeId"/>
            <ServiceParam name="defaultLanguageId" parameterName="languageId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
        </UpdateService>
    
        <!-- Delete Service -->
        <DeleteService url="/cmc/DeleteRecipe">
            <ServiceParam name="storeId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
           
    </DeleteService>
                                                                
        <!-- Refresh Service -->
        <RefreshService url="/cmc/GetRecipeByRecipeId">
            <ServiceParam name="storeId"/>
            <ServiceParam name="recipeId" propertyName="recipeId"/>
        </RefreshService>
    
           
    <!-- Property Definition -->
           
    <PropertyDefinition displayName="${extRecipeResources.recipeTime_DisplayName}"
                    propertyName="time" type="number"/>
           
    <PropertyDefinition
            displayName=
                "${extRecipeResources.difficultyLevel_DisplayName}"
            propertyName="difficulty">
            <PropertyValue displayName="easy" value="easy"/>
            <PropertyValue displayName="medium" value="normal"/>
            <PropertyValue displayName="difficult" value="difficult"/>
           
    </PropertyDefinition>
    
        <!--
            All child and reference objects need to be initialized so that the
            parent-child and reference relationship can be built.
        -->
           
    <ChildObjectDefinition baseDefinitionName="recRecipeDescriptionDefinition"/>
           
    <ChildObjectDefinition baseDefinitionName="recRecipeIngredientsDefinition"/>
           
    <ReferenceObjectDefinition baseDefinitionName="recRecipeIngredientsReference"/>
           
    <ChildObjectDefinition baseDefinitionName="recRecipeInstructionDefinition"/>
           
    <ReferenceObjectDefinition baseDefinitionName="recRecipeAssociationDefinition"/>
    </PrimaryObjectDefinition>
    

    As described in the lesson Model the Recipe noun to Management Center object definitions, the primary object Recipe has four child objects:

    • description

    • ingredients

    • instructions

    • tools association

    Recipe also has one parent reference object: ChildRecipe. All child and reference objects need to be retrieved by separate wcfGetChildrenService services, except for description. The description is retrieved in the Recipe get service. All of the services have been defined in Tutorial: Creating the Project BOD service module, and are mapped to the URL in the lesson: Retrive Management Center objects by transforming Nouns into XML.

  5. Define the primary object, RecipeCollection, within one of the following files:

    Option Description
    RecipePrimaryObjectDefinition.lzx (primary object class file) The following sample code shows the primary object definition for RecipeCollection:

    <class name="recRecipeCollectionPrimaryObjectDefinition" extends="wcfPrimaryObjectDefinition"
                    creatable="true"
                    idProperty="collectionId"
                    objectType="RecipeCollection"
                    displayName="${extRecipeResources.recipeCollection_DisplayName.string}"
                    displayNameProperty="collectionName"  
                    newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName.string}"
                    propertiesClass="recCollectionProperties" 
                    >                            
                    
           
    <!-- Create Service -->
           
    <wcfCreateService sendDefaultLanguageProperties="true" url="/cmc/CreateRecipeCollection">
                   
    <wcfServiceParam name="storeId"/>
                   
    <wcfServiceParam name="defaultLanguageId" parameterName="languageId"/> 
           
    </wcfCreateService>
            
           
    <!-- Update Service -->
           
    <wcfUpdateService sendDefaultLanguageProperties="true" url="/cmc/UpdateRecipeCollection">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="defaultLanguageId" parameterName="languageId" />
                   
    <wcfServiceParam name="collectionId" propertyName="collectionId" />
           
    </wcfUpdateService>
            
           
    <!-- Delete Service -->
           
    <wcfDeleteService url="/cmc/DeleteRecipeCollection">
                   
    <wcfServiceParam name="storeId" />
                   
    <wcfServiceParam name="collectionId" propertyName="collectionId"/>
           
    </wcfDeleteService>               
            
           
    <!-- GetChildren Service -->      
             1 
    <wcfGetChildrenService url="/cmc/GetRecipesByCollection" objectTypes="ChildRecipe">
                   
    <wcfServiceParam name="collectionId" propertyName="collectionId"/>
                   
    <wcfServiceParam name="storeId" />
           
    </wcfGetChildrenService>          
           
    <!-- Refresh Service -->
           
    <wcfRefreshService url="/cmc/GetRecipeCollectionById">
             
    <wcfServiceParam name="storeId" />
             
    <wcfServiceParam name="collectionId" propertyName="collectionId" />
           
    </wcfRefreshService>
    
             2 
    <recRecipeNavigationList/>                                                
            
           
    <!-- Include all children object definition-->
           
    <recRecipeCollectionDescription/>                 
            
           
    <!-- Define the reference relationship with Recipe -->
             3 
    <recRecipeReferencesCollection/>    
    </class>
    

     1  wcfGetChildrenService

    Gets all the recipes under the recipe collection as child objects of it. The service is defined in Tutorial: Creating the Project BOD service module and is mapped to the URL in the lesson: Retrive Management Center objects by transforming Nouns into XML.

     2  recRecipeNavigationList

    An instance of wcfNavigationListDefinition used to list the recipes in the grid view after clicking a recipe collection in the navigation tree. It is defined in RecipeGrid.lzx in the lesson: Define views for a Management Center object.

     3  recRecipeReferencesCollection

    An instance of wcfParentReferenceObjectDefinition defined in RecipeCommonObjectDefinition.lzx. It is used to build the parent-child relationship between the recipe collection and recipe.
    RecipePrimaryObjectDefinition.def (primary object definition file) The following sample code shows the primary object definition for RecipeCollection:

    <PrimaryObjectDefinition definitionName="RecipeCollection"
            creatable="true"
            idProperty="collectionId"
            objectType="RecipeCollection"
            displayName="${extRecipeResources.recipeCollection_DisplayName}"
            displayNameProperty="collectionName"
            newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName}"
            propertiesDefinitionName="recCollectionProperties">
    
        <!-- Create Service -->
        <CreateService sendDefaultLanguageProperties="true"
            url="/cmc/CreateRecipeCollection">
            <ServiceParam name="storeId"/>
            <ServiceParam name="defaultLanguageId" parameterName="languageId"/> 
           
    </CreateService>
    
           
    <!-- Update Service -->
        <UpdateService sendDefaultLanguageProperties="true"
            url="/cmc/UpdateRecipeCollection">
            <ServiceParam name="storeId"/>
            <ServiceParam name="defaultLanguageId" parameterName="languageId"/>
            <ServiceParam name="collectionId" propertyName="collectionId"/>
        </UpdateService>
    
        <!-- Delete Service -->
        <DeleteService url="/cmc/DeleteRecipeCollection">
            <ServiceParam name="storeId"/>
            <ServiceParam name="collectionId" propertyName="collectionId"/>
        </DeleteService>
    
        <!-- GetChildren Service -->
         1 
    <GetChildrenService url="/cmc/GetRecipesByCollection"
            objectTypes="ChildRecipe">
            <ServiceParam name="collectionId" propertyName="collectionId"/>
            <wServiceParam name="storeId"/>
        </GetChildrenService>
        <!-- Refresh Service -->
        <RefreshService url="/cmc/GetRecipeCollectionById">
            <wcfServiceParam name="storeId"/>
            <wcfServiceParam name="collectionId" propertyName="collectionId"/>
        </RefreshService>
    
     2 
    <NavigationListDefinition baseDefinitionName="recRecipeNavigationList"/>
    
        <!-- Include all children object definition-->
        <ChildObjectDefinition baseDefinitionName="recRecipeCollectionDescription"/>
    
        <!-- Define the reference relationship with Recipe -->
        <ParentReferenceObjectDefinition
         3  baseDefinitionName="recRecipeReferencesCollection"/>
    </PrimaryObjectDefinition>
    

     1  GetChildrenService

    Gets all the recipes under the recipe collection as child objects of it. The service is defined in Tutorial: Creating the Project BOD service module and is mapped to the URL in the lesson: Retrive Management Center objects by transforming Nouns into XML.

     2  recRecipeNavigationList

    An instance of wcfNavigationListDefinition used to list the recipes in the grid view after clicking a recipe collection in the navigation tree. It is defined in RecipeGrid.def in the lesson: Define views for a Management Center object.

     3  recRecipeReferencesCollection

    An instance of wcfParentReferenceObjectDefinition defined in RecipeCommonObjectDefinition.def. It is used to build the parent-child relationship between the recipe collection and recipe.

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

< Previous | Next >


+

Search Tips   |   Advanced Search