# Testing Federated Query Wizard:

***Federated Query Use case***- Users can create DCQL (Distributed caBIG
Query Language) queries using the query tool in the portal. Two major
query types can be created

-   Aggregate Queries -- Queries to aggregate similar data from multiple
    services

-   Distributed Join type Queries- Queries that will have distributed
    joins across multiple services on the grid.

Use case also includes service Discovery enhancements. Users can
discover distributed join possibilities and created queries that will be
executed against the caGrid Distributed Query Service

## Implementation 

The portal uses a Federated Query Proessor (FQP) grid service to execute
DCQL queries.

We have two sample services "**Model1Svc**" and "**Model2Svc"** that are
deployed in the dev tier and advertising to the QA index. These services
are specially designed to test the DCQL use case. The URL's for the two
services are as below

<http://137.187.182.144:18090/wsrf-model1/services/cagrid/Model1Svc>

<http://137.187.182.144:18090/wsrf-model2/services/cagrid/Model2Svc>

**Note**: The above test data services cannot be reached from outside
the NCI firewall, so we have to use a FQP service that can reach these
services. You will need to install an alternate FQP service that is
inside the NCI firewall and can reach the above test data services. By
default the Portal is configuered for the production FQP service. We can
override this behaviour, by specifying a property in the
build-nci_qa.properties, as shown below

*fqp.service.url=https://qa.nci.nih.gov/wsrf/services/cagrid/FederatedQueryProcessor*

and then run

*ant --Dtarget.env=nci_qa liferay:deploy-portlets*

*(These steps should have already been done).*

## Test Plan for Federated Query 

Following sequence of events can be used to test DCQL with these test
service

1.  Select Services from the top menu

2.  Select **Search** from the **Discovery** Portlet

3.  Enter '**Model1Svc'** in the keyword filed. Select Name as the
    criteria to search on. Press search

4.  Model1Svc should be displayed in the result

5.  Select "**Query**" link in the result table. This will update the
    "Data Service Query" Portlet, with the name of the classes from
    Model1Svc. The screen should look like this

![](media/image1.png){width="5.990972222222222in"
height="1.7027777777777777in"}

6.  Select "Gene" class to query on. Your screen should look like

![](media/image2.png){width="6.00625in" height="1.6368055555555556in"}

7.  Select "**Add Criterion**" in the "**Data Service Query"** portlet

8.  This will load some criterions to chose from. It should also load
    "**Gene**" from "**Model2Svc**" as one of the critirions.

9.  Select "Gene" class from "Model2Svc". This will expand the node for
    "Gene". The screen should look like

![](media/image3.png){width="4.028472222222222in"
height="4.513194444444444in"}

10. In the Join table (as shown above). Select Values for both the
    "Local Attribute" and "Foreign Attribute" as "symbol".

11. Click on the hyperlink "name ". This will take you to the next
    screen (below)

![](media/image4.png){width="5.581944444444445in"
height="2.058333333333333in"}

12. Once you fill in the value (as shown above), click update and you
    will be taken to the next screen (below)

![](media/image5.png){width="4.302777777777778in" height="2.08125in"}

13. You will see that the Query type has changed to "DCQL Query" . Click
    on "Export to XML" to see the DCQL query. The following screen will
    show the query as XML in a text area. Ensure that the query looks
    correct (URL's, join condition is "symbol" as selected in step 10).
    Click "Submit Query" to execute the query

14. The Results tab should have the query executed successfully.

15. The History tab should also have the DCQL query listed.