EMC Developer Network

Viewing a Query

April 2006
Contributed by - Lani Hardage-Vergeer, EMC Documentum Tech Pubs

Software Environment

FeatureTested on
Operating SystemWindows 2000 Server SP4
CompilerSun JDK 1.4.2_08
RuntimeSun JRE 1.4.2_08
DFC5.3 SP2
WDK5.3 SP2
Webtop5.3 SP2
Content Server5.3 SP1

Abstract

Have you ever wanted to see the query that is generated and used by the WDK Advanced Search or Search component? This tip describes a hidden command that captures the query generated by the simple or advanced search WDK component.

View the Query

It may be useful to capture the query that is generated by one of the 5.3 search components. You can do this by entering a control-click, shift-click, or alt-click on the Edit Search link in the search results. (The link can be found below the Search Results header as shown in the screen shot below:

Search Results

Fig - Search Results

The resulting query is retrieved from the SearchInfo class by showquery.jsp and is displayed in a separate window, as shown in the example output below:


<?xml version="1.0" encoding="UTF-8" ?> 
<SmartListDefinition>
<QueryBuilder allVersions="false" hiddenObjects="false" isDatabaseSearchRequested="
    false" maxResults="-1">
  <SourceList>
    <Source description="Global Information" name="dm_notes" serverVersion="
      5.3.0.143 SP1 sun5.Oracle" type="docbase" /> 
  </SourceList>
  <QueryScopeList /> 
 <ExpressionSet logicalOperator="AND">
    <FulltextExpression>pass-through query</FulltextExpression> 
  </ExpressionSet>
 <ResultAttributeList>
    <ResultAttribute name="object_name" /> 
    <ResultAttribute name="r_object_type" /> 
    <ResultAttribute name="r_lock_owner" /> 
    <ResultAttribute name="owner_name" /> 
    <ResultAttribute name="r_link_cnt" /> 
    <ResultAttribute name="r_is_virtual_doc" /> 
    <ResultAttribute name="r_content_size" /> 
    <ResultAttribute name="a_content_type" /> 
    <ResultAttribute name="i_is_reference" /> 
    <ResultAttribute name="r_assembled_from_id" /> 
    <ResultAttribute name="r_has_frzn_assembly" /> 
    <ResultAttribute name="a_compound_architecture" /> 
    <ResultAttribute name="i_is_replica" /> 
    <ResultAttribute name="r_policy_id" /> 
    <ResultAttribute name="score" /> 
    <ResultAttribute name="summary" /> 
    <ResultAttribute name="r_modify_date" /> 
    </ResultAttributeList>
  </QueryBuilder>
 <DisplayPreferences>
   <DisplayAttributeList>
      <DisplayAttribute name="object_name" /> 
      <DisplayAttribute name="score" /> 
      <DisplayAttribute name="summary" /> 
      <DisplayAttribute name="r_modify_date" /> 
    </DisplayAttributeList>
  </DisplayPreferences>
  <PropertyList /> 
  </SmartListDefinition>


It's interesting to look at how this support for a hidden feature is produced. The Edit Search link in searchresults_list.jsp specifies a server-side event handler:


<dmf:link name='' onclick='onClickStatus'.../>

This event handler in the SearchEx class checks the control arguments that are passed to it by calling a method outQueryDefinition:


public void onClickRevise(Control control, ArgumentList args)
{
  if (outQueryDefinition(args) == false)
  {
     //nest to the advsearch component to revise query 
  }
}

Here is how the method outQueryDefinition() calls the JSP page showquery.jsp in a new window:


private boolean outQueryDefinition(ArgumentList args)
{
  // decides whether we show the query string rather than handling the event
  // keypress arguments are appended by events.js
  String strShowQueryParams[] = new String[]{"shiftKeyPressed", "ctrlKeyPressed", "altKeyPressed"};
  boolean fShowQueryString = false;
  for (int i = 0; i < strShowQueryParams.length; i++)
  {
    String strKeyValue = args.get(strShowQueryParams[i]);
    if (strKeyValue != null && strKeyValue.equals("true") == true)
    {
       fShowQueryString = true;
       break;
    }
  }

  if (fShowQueryString)
  {
     ArgumentList argsClientEvent = new ArgumentList();
     argsClientEvent.add("queryId", getSearchInfo().getQueryId());
     setClientEvent("showQuery", argsClientEvent);
  }
  return fShowQueryString;
}

You will notice that this method sets a client event showQuery, and here is how that client event is handled by searchresults_list.jsp:


<script>
  function showQuery(strQueryId)
  {
    window.open('' + escape(strQueryId), "" + new Date().getTime(), g_strDefWinOptions);
  }
  var gRegisterShowQuery;
  if (gRegisterShowQuery != "true")
  {
    // client side event handlers
    gRegisterShowQuery = "true";
    registerClientEventHandler(null, "showQuery", showQuery);
  }
</script>