Admin/customQueries

From Omar Wiki

Jump to: navigation, search

Submitting New Ad-Hoc Queries

In order to use Ad-Hoc Queries you must first submit a new Ad-hoc query object to the registry. To do this:

  • look for:
/misc/samples/SubmitObjectsRequest_AdhocQuery.xml
  • Make a back-up of this file (just for saving the original one). You can save the backup as SubmitObjectsRequest_AdhocQuery_bak.xml
  • Open SubmitObjectsRequest_AdhocQuery.xml
  • Look for the Ad-hoc Query Element and change the lid and id to new values. For example:
<rim:AdhocQuery lid="urn:oasis:names:tc:ebxml-regrep:query:CPP_Role_Query" id="urn:oasis:names:tc:ebxml-regrep:query:CPP_Role_Query">
  • Change the Name and Description of the Query by changing the values of rim:Localized String in rim:Name and rim:Description. For example:
<rim:Name>
   <rim:LocalizedString value="CPP Role Query"/>
</rim:Name>
<rim:Description>
   <rim:LocalizedString value="Search for CPPs that specify certain Role"/>
</rim:Description>
  • Now change the QueryExpression element to the desired expression. For example:
<rim:QueryExpression queryLanguage="urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92">
     SELECT eo.* FROM ExtrinsicObject eo, Slot sl WHERE sl.value=''$Role_slot_cpp'' and eo.Id=sl.parent;
</rim:QueryExpression>

The expression may contain variables which will be introduced by the registry users when using the ad-hoc query.

IMPORTANT: When using variables such as $Variable_name remember that you MUST use two single quotes (not DOUBLE quotes, nor one single quote):

''$Variable_name''
  • Save the file
  • Send the Ad-Hoc Query to the Registry:
./build.sh loadAdhocQuery

The Ad-Hoc Query Object will be sent to the registry.

Configuring Queries to be shown by the Browser

Now you must configure the registry browser to show the new Ad-Hoc Query in the list of Ad-Hoc Queries and to show the parameters needed when it is selected:

  • Open:
/src/java/org/freebxml/omar/client/ui/common/conf/config.xml
  • Place an entry for the new query you created. For example:
 <Query>
   <AdhocQueryRef id="urn:oasis:names:tc:ebxml-regrep:query:CPP_Role_Query"/>
   <Parameter parameterName="$Role" datatype="string" defaultValue="Buyer">
     <rim:Name>
       <rim:LocalizedString charset="UTF-8" value="Role"/>
     </rim:Name>
     <rim:Description>
       <rim:LocalizedString charset="UTF-8" value="Role specified in the CPP"/>
     </rim:Description>
   </Parameter>
 </Query>

The "id" of AdhocQueryRef must be the same as the id assigned to the AdhocQuery we created by modifying SubmitObjectsRequest_AdhocQuery.xml

You create a "Parameter" element for each parameter you want to pass to the SQL Expression defined in the SubmitObjectsRequest_AdhocQuery.xml.

  • Redeploy
./build.sh deploy.restart
  • Start Browser
./build.sh run.browser
  • Select Ad-Hoc Query. The Ad-Hoc Query you submitted will appear in the list. Now you can select and use the new Ad-Hoc Query you submitted.