Defining search

In this lesson, you create a search definition XML file to include the search definitions for each Recipe object type.

Procedure

  1. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > xml > mycompany > recipe.
  2. Within this directory, create a subdirectory that is named searchDefinitions.
  3. Right-click the searchDefinitions folder and select Import. Expand General and select File system.
  4. Click Next, then click Browse to the following directory:

    TutorialSource\LOBTools\WebContent\WEB-INF\src\xml\mycompany\recipe\searchDefinitions, where TutorialSource is the location where you extracted the Tutorial sample source code

  5. Select the FindRecipesSearchDefinition.xml search definition files within this directory. Click Finish to import the file.
  6. Open the file within your workspace to examine the contents:
    The following sample code shows two search definitions within the file, one for the Recipe object and the other for the Recipe Collection.
    <Definitions>    
      ...
    1<SearchDefinition definitionName="cmc/recipe/FindRecipes" 
        displayName="${ExtRecipeResources.findRecipesSearchDefinition_DisplayName}" 
        isDefault="true" 
    2listDefinition="cmc/recipe/RecipeSearchGrid" 
    3searchType="FindRecipes">
        <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/>
    4<SearchService name="FindRecipes" url="/cmc/FindRecipes">
          <ServiceParam name="storeId"/>			
        </SearchService>
      </SearchDefinition>
      
      <SearchDefinition definitionName="cmc/recipe/FindRecipeCollections" 
        displayName="${ExtRecipeResources.findRecipeCollectionsSearchDefinition_DisplayName}" 
        isDefault="false" listDefinition="cmc/recipe/CollectionGrid" searchType="FindRecipeCollections">
        <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/>
        <SearchService name="FindRecipeCollections" url="/cmc/FindRecipeCollections">
          <ServiceParam name="storeId"/>			
        </SearchService>
      </SearchDefinition>
    
    </Definitions>
    1 FindRecipes
    Used to define the search on recipes.
    2 listDefinitionName
    Sets the search results list grid.
    3 searchType
    Must be consistent with the searchType attribute of the corresponding primary object definition.
    4 SearchService
    Sets the search service to be called to run the query. The query is mapped to the URL "/cmc/FindRecipes" in the lesson: Retrieving Management Center objects by transforming Nouns into XML.
  7. After you define the search definition, you need to map the search type to the primary object.
    1. Expand LOBTools > WebContent > WEB-INF > src > xml > mycompany > recipe > objectDefinitions
    2. Open the RecipePrimaryObjectDefinition.xml file for editing
    3. Find the Recipe and RecipeCollection object definitions and the searchType attribute for these object definitions.
      The following code samples show the searchType attribute for the Recipe and RecipeCollection object definitions, in boldface. Update the value for the searchType attribute if it is not defined correctly.
      
      <PrimaryObjectDefinition creatable="true" definitionName="cmc/recipe/Recipe" 
        displayName="${ExtRecipeResources.recipe_DisplayName}" displayNameProperty="name" 
        headerIcon="productHeaderIcon" icon="productIcon" idProperty="recipeId" 
        newDisplayName="${ExtRecipeResources.recipe_NewDisplayName}" objectType="Recipe" 
        propertiesDefinition="cmc/recipe/RecipeProperties" searchType="FindRecipes">
        <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/>
      
        <GetChildrenService objectTypes="RecipeIngredients" url="/cmc/GetRecipeChildren-Ingredients">
          <ServiceParam name="storeId"/>
          <ServiceParam name="recipeId" propertyName="recipeId"/>
        </GetChildrenService>
      
      </PrimaryObjectDefinition>
      
      <PrimaryObjectDefinition creatable="true" definitionName="cmc/recipe/RecipeCollection"
        displayName="${ExtRecipeResources.recipeCollection_DisplayName}" displayNameProperty="collectionName" 
        headerIcon="catalogHeaderIcon" icon="catalogIcon" idProperty="collectionId" 
        newDisplayName="${ExtRecipeResources.recipeCollection_NewDisplayName}" objectType="RecipeCollection"
        propertiesDefinition="cmc/recipe/CollectionProperties" searchType="FindRecipeCollections">
        <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/>				
      
        <CreateService sendDefaultLanguageProperties="true" url="/cmc/CreateRecipeCollection">
          <ServiceParam name="storeId"/>
          <ServiceParam name="defaultLanguageId" parameterName="languageId"/> 
        </CreateService>
      
        <UpdateService sendDefaultLanguageProperties="true" url="/cmc/UpdateRecipeCollection">
          <ServiceParam name="storeId"/>
          <ServiceParam name="defaultLanguageId" parameterName="languageId"/>
          <ServiceParam name="collectionId" propertyName="collectionId"/>
        </UpdateService>
      
      </PrimaryObjectDefinition>