Part Nine: Invoke COPPA PO Service
Desired Application Functionality
Discover the COPPA PO analytical Services
- Open a web browser and visit http://portal.training.cagrid.org/web/guest/tools/service-discovery

- Under catalog search type coreservices and press enter
- Select CoreServices (1.2) @ CBIIT
- You will see the service's properties including it's URL
Invoke an Analytical Service
Analytical services cannot be invoked via the caGrid Portal. We will use the jar files to programmatically invoke a service operations.
Example Application Flow
- Discover the Coppa PO analytical Service.
- Create required ISO21090
- Call the Analytical Service
Creating Client Functionality
Now, we will implement the new data service query in our client application.
Step 1: Update XML files to resolve required jars
Update ivysettings.xml
- Open antfiles/ivy/ivysettings.xml
- After
<!-- Last, use the caGrid 1.4 repository --> <url name="remote-caGrid-ivy-resolver-1.4" cache="cache"> <ivy pattern="http://software.cagrid.org/repository-1.4/[organisation]/[module]/ivy-[revision].xml"/> <artifact pattern="http://software.cagrid.org/repository-1.4/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/> <artifact pattern="http://software.cagrid.org/repository-1.4/[organisation]/[module]/[revision]/[artifact].[ext]"/> </url>
Add
<!-- COPPA repository --> <url name="ncicb-ivy-repo" m2compatible="false"> <ivy pattern="https://ncisvn.nci.nih.gov/svn/cbiit-ivy-repo/trunk/[organisation]/[module]/[revision]/ivy.xml" /> <artifact pattern="https://ncisvn.nci.nih.gov/svn/cbiit-ivy-repo/trunk/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <!-- And finally, the CBIIT BDA / commonlibrary repository --> <url name="remote-cbiit-bda-commonlibrary-resolver" cache="cache"> <ivy pattern="http://gforge.nci.nih.gov/svnroot/commonlibrary/trunk/ivy-repo/[organisation]/[module]/[revision]/ivy.xml"/> <artifact pattern="http://gforge.nci.nih.gov/svnroot/commonlibrary/trunk/ivy-repo/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/> <artifact pattern="http://gforge.nci.nih.gov/svnroot/commonlibrary/trunk/ivy-repo/[organisation]/[module]/[revision]/[artifact].[ext]"/> </url>
Update ivy.xml
- Open ivy.xml
- After
<!-- Grid Grouper Dependencies --> <dependency rev="${repository.version}" org="caGrid" name="gridgrouper" conf="default->client,common,stubs"/> <dependency rev="1.1" org="internet2" name="grouper" conf="default->default"/> <dependency rev="0.2.1" org="internet2" name="subject" conf="default->default"/>
Add
<!-- COPPA Service Dependencies --> <!-- ISO data type Dependencies --> <dependency org="javax.xml.bind" name="jaxb-api" rev="2.1" conf="default->*"/> <dependency org="javax.xml.bind" name="jaxb-impl" rev="2.1.4" conf="default->*"/> <dependency org="javax.xml.bind" name="jaxb-xjc" rev="2.1.4" conf="default->*"/> <dependency org="gov.nih.nci.iso-datatypes" name="iso-datatypes" rev="2.0.1" conf="default->*" transitive="false"/> <dependency org="gov.nih.nci.iso-datatypes" name="iso-datatypes-extensions" rev="2.0.1" conf="default->*" transitive="false"/> <dependency org="javax.activation" name="activation" rev="1.1" conf="default->*"/> <dependency org="stax" name="stax-api" rev="1.0-2" conf="default->*"/> <!-- COPPA PO Service Dependencies --> <dependency rev="3.2" org="gov.nih.nci.coppa.po" name="CoreServices-client" transitive="false" /> <dependency rev="3.2" org="gov.nih.nci.coppa.po" name="CoreServices-common" transitive="false" /> <dependency rev="3.2" org="gov.nih.nci.coppa.po" name="CoreServices-stubs" transitive="false" /> <dependency rev="3.2.0-SNAPSHOT" org="gov.nih.nci.coppa.po" name="po-services-client" transitive="false" /> <dependency rev="1.3.5" org="gov.nih.nci.coppa" name="coppa-commons" transitive="false" />
Build the Application
- Build the project
> cd GRID_CLIENT_HOME > ant all
- Fix all compilation errors.
Import Jars into the Project
- Right-click on the caGridClient project in the Eclipse Package Explorer.
- Select the Properties entry at the bottom of the list.
- Select Java Build Path, then Libraries.
- Select the lib entry and click the Edit button.
- Click User Libraries
- Click Add Jars
- Navigate to the newly added jars in caGridClient/lib and add them to the lib user library.
- In the Preferences dialog, click OK.
- In the Add Library dialog, click Finish.
Step 2: Invoke an Analytical Service
Create the CoppaPO Class
- In the Eclipse Package Explorer right-click the src/org.cagrid.client package and select New->Class
- Set the class name as CoppaPO and click Finish.
- Add imports
import gov.nih.nci.coppa.po.ClinicalResearchStaff; import gov.nih.nci.coppa.po.HealthCareFacility; import gov.nih.nci.coppa.po.HealthCareProvider; import gov.nih.nci.coppa.po.IdentifiedOrganization; import gov.nih.nci.coppa.po.IdentifiedPerson; import gov.nih.nci.coppa.po.Organization; import gov.nih.nci.coppa.po.OrganizationalContact; import gov.nih.nci.coppa.po.OversightCommittee; import gov.nih.nci.coppa.po.Patient; import gov.nih.nci.coppa.po.Person; import gov.nih.nci.coppa.po.ResearchOrganization; import gov.nih.nci.coppa.services.business.business.client.BusinessClient; import gov.nih.nci.coppa.services.client.ClientUtils; import gov.nih.nci.coppa.services.entities.organization.client.OrganizationClient; import gov.nih.nci.coppa.services.entities.person.client.PersonClient; import gov.nih.nci.coppa.services.structuralroles.clinicalresearchstaff.client.ClinicalResearchStaffClient; import gov.nih.nci.coppa.services.structuralroles.healthcarefacility.client.HealthCareFacilityClient; import gov.nih.nci.coppa.services.structuralroles.healthcareprovider.client.HealthCareProviderClient; import gov.nih.nci.coppa.services.structuralroles.identifiedorganization.client.IdentifiedOrganizationClient; import gov.nih.nci.coppa.services.structuralroles.identifiedperson.client.IdentifiedPersonClient; import gov.nih.nci.coppa.services.structuralroles.organizationalcontact.client.OrganizationalContactClient; import gov.nih.nci.coppa.services.structuralroles.oversightcommittee.client.OversightCommitteeClient; import gov.nih.nci.coppa.services.structuralroles.patient.client.PatientClient; import gov.nih.nci.coppa.services.structuralroles.researchorganization.client.ResearchOrganizationClient; import gov.nih.nci.iso21090.extensions.Bl; import gov.nih.nci.iso21090.Constants; import gov.nih.nci.iso21090.extensions.Id; import java.rmi.RemoteException; import java.util.Scanner; import gov.nih.nci.coppa.po.CorrelationNode; import org.apache.axis.types.URI.MalformedURIException; import org.globus.gsi.GlobusCredential;
- Add the whatID method that will allow you to choose the ISO21090 ID to query against.
public static String ORG_ROOT = Constants.NCI_OID + ".2"; public static String ORG_IDENTIFIER_NAME = "NCI organization entity identifier"; public static Id whatID() { String ORG_ROOT = Constants.NCI_OID + ".2"; String ORG_IDENTIFIER_NAME = "NCI organization entity identifier"; Scanner keyboard=new Scanner(System.in); Id id = new Id(); id.setRoot(ORG_ROOT); id.setIdentifierName(ORG_IDENTIFIER_NAME); System.out.println("Which Id number to query with?"); String userInput=keyboard.nextLine(); id.setExtension(userInput); return id; }
- Add the whatBusinessID method that will allow you to choose the ISO21090 ID to query against the business service
public static Id whatBusinessID() { Scanner keyboard=new Scanner(System.in); Id id = new Id(); id.setRoot(HealthCareProviderClient.HEALTH_CARE_PROVIDER_ROOT); id.setIdentifierName(HealthCareProviderClient.HEALTH_CARE_PROVIDER_IDENTIFIER_NAME); System.out.println("Which Id number to query with?"); String userInput=keyboard.nextLine(); id.setExtension(userInput); return id; }
- Add the main method
public static void main(int userInput, String url, GlobusCredential cred) throws MalformedURIException, RemoteException { if (userInput ==1) { url+="Person"; PersonClient p_client = new PersonClient(url,cred); Person result=p_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==2) { url+="Organization"; OrganizationClient o_client = new OrganizationClient(url,cred); Organization result = o_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==3) { url+="HealthCareFacility"; HealthCareFacilityClient hcf_client = new HealthCareFacilityClient(url,cred); HealthCareFacility result = hcf_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==4) { url+="ClinicalResearchStaff"; ClinicalResearchStaffClient crs_client = new ClinicalResearchStaffClient(url,cred); ClinicalResearchStaff result = crs_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==5) { url+="HealthCareProvider"; HealthCareProviderClient hcp_client = new HealthCareProviderClient(url,cred); HealthCareProvider result = hcp_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==6) { url+="IdentifiedOrganization"; IdentifiedOrganizationClient io_client = new IdentifiedOrganizationClient(url,cred); IdentifiedOrganization result = io_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==7) { url+="IdentifiedPerson"; IdentifiedPersonClient ip_client = new IdentifiedPersonClient(url,cred); IdentifiedPerson result = ip_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==8) { url+="OrganizationalContact"; OrganizationalContactClient oc_client = new OrganizationalContactClient(url,cred); OrganizationalContact result = oc_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==9) { url+="OversightCommittee"; OversightCommitteeClient oc_client = new OversightCommitteeClient(url,cred); OversightCommittee result = oc_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==10) { url+="ResearchOrganization"; ResearchOrganizationClient ro_client = new ResearchOrganizationClient(url,cred); ResearchOrganization result = ro_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==11) { url+="Patient"; PatientClient pc_client = new PatientClient(url,cred); Patient result = pc_client.getById(whatID()); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } else if (userInput ==12) { url+="Business"; BusinessClient bc_client = new BusinessClient(url,cred); Id[] ids = new Id[1]; ids[0] = whatBusinessID(); Bl myTrue = new Bl(); myTrue.setValue(true); CorrelationNode[] result = bc_client.getCorrelationsByIdsWithEntities(ids, myTrue, myTrue); System.out.println("----getCorrelationsByIdsEntityNode top level----"); if(result!=null){ClientUtils.print(result);} else{System.out.println("No records found");} } }
- Save the File.
Update the GridClient Class
Add the necessary code to the Grid Client to allow the user to discover the COPPA PO services and query against them.
- Open GridClient.java.
- add imports
import gov.nih.nci.cagrid.metadata.exceptions.RemoteResourcePropertyRetrievalException; import gov.nih.nci.cagrid.metadata.exceptions.QueryInvalidException; import gov.nih.nci.cagrid.metadata.exceptions.ResourcePropertyRetrievalException;
- Add code to the method to search and invoke COPPA PO services.
private void invokeCOPPAPO() { // if haven't logged in, make the user log in if (this.cred == null) loginUser(); // ask which COPPA URL to query String indexServiceUrl = props.getProperty(DEFAULT_INDEX_SERVICE_URL_PROP); System.out.println("Searching for COPPAPO URLs..."); DiscoveryActions discActions; try { discActions = new DiscoveryActions(indexServiceUrl); EndpointReferenceType[] serviceEndpoints = discActions.searchServices("CoreServices"); if (null != serviceEndpoints && serviceEndpoints.length > 0) { for (int i = 0; i < serviceEndpoints.length; i++) { System.out.println(" " + (i + 1) + ": " + serviceEndpoints[i].getAddress().toString()); } } String msg1 = "Which COPPAPO URL would you like to query?"; int userInput1 = UserInteraction.getIntegerFromUser(msg1, 1, serviceEndpoints.length); String url = serviceEndpoints[userInput1 - 1].getAddress().toString().substring(0, serviceEndpoints[userInput1 - 1].getAddress().toString().length() - 12); System.out.println("You chose " + url); // ask the user which COPPA service they want to use System.out.println("--------------------------"); System.out.println("1 : Person Service"); System.out.println("2 : Organization Service"); System.out.println("3 : HealthCareFacility Service"); System.out.println("4 : ClinicalResearchStaff Service"); System.out.println("5 : HealthCareProvider Service"); System.out.println("6 : IdentifiedOrganization Service"); System.out.println("7 : IdentifiedPerson Service"); System.out.println("8 : OrganizationalContact Service"); System.out.println("9 : OversightCommittee Service"); System.out.println("10: ResearchOrganization Service"); System.out.println("11: Patient Service"); System.out.println("12: Business Service"); String message = "Select COPPA PO Service: "; int userInput = UserInteraction.getIntegerFromUser(message, 1, 12); System.out.println(); CoppaPO.main(userInput, url, cred); } catch (RemoteException e){e.printStackTrace();} catch (MalformedURIException e){e.printStackTrace();} catch (RemoteResourcePropertyRetrievalException e){e.printStackTrace();} catch (QueryInvalidException e){e.printStackTrace();} catch (ResourcePropertyRetrievalException e){e.printStackTrace();} }
- In the main method, add the call to the invokeCOPPAPO method where we are evaluating the use input of the value 9.
client.invokeCOPPAPO();
- Save the file.
Build the Application
- Build the project
> cd GRID_CLIENT_HOME > ant all
- Fix all compilation errors.
Step 3: Test the Client
| You should login with COPPA credentials in order to use COPPA PO services Username:coppagridtest Password:Coppa#12345 |
- Open a command prompt.
- Change directory to your caGridClient location
- Type ant run. This will build and execute the project
- When prompted, type 9 to invoke the COPPA PO services.
- If you haven't logged in you will be rerouted to the login method.
- You should see the following:
[java] -------------------------- [java] 1 : Sync with Trust Fabric [java] 2 : Register Grid Account [java] 3 : Login to Grid [java] 4 : Search for Services [java] 5 : List All Services [java] 6 : Query a Data Service [java] 7 : Invoke Bootcamp Services [java] 8 : Get Grouper Groups for User [java] 9 : Invoke COPPA PO Service [java] 10: Quit [java] Select client action: [1..10] : 9 [java] [java] Searching for COPPAPO URLs... [java] Searching for 'CoreServices' services [java] 1: https://ctms-services-po-3-2-demo.nci.nih.gov:1522/wsrf/services/cagrid/CoreServices [java] 2: http://ctms-services-po-3-0-demo.nci.nih.gov:80/wsrf/services/cagrid/CoreServices [java] 3: https://ec2-184-73-11-90.compute-1.amazonaws.com:39143/wsrf/services/cagrid/CoreServices [java] 4: https://outcomes.healthcit.com:39143/wsrf/services/cagrid/CoreServices [java] Which COPPAPO URL would you like to query? [1..4] :
- Choose the COPPA PO URL
3 [java] You chose https://ec2-184-73-11-90.compute-1.amazonaws.com:39143/wsrf/services/cagrid/ [java] -------------------------- [java] 1 : Person Service [java] 2 : Organization Service [java] 3 : HealthCareFacility Service [java] 4 : ClinicalResearchStaff Service [java] 5 : HealthCareProvider Service [java] 6 : IdentifiedOrganization Service [java] 7 : IdentifiedPerson Service [java] 8 : OrganizationalContact Service [java] 9 : OversightCommittee Service [java] 10: ResearchOrganization Service [java] 11: Patient Service [java] 12: Business Service [java] Select COPPA PO Service: [1..12] :
- Choose the COPPA PO Service
10 [java] Which Id number to query with?
- Choose the ISO21090 ID you want to query with. If the URL is not functional, you will get a stack trace. Otherwise you will get the results in XML format or the following if the results are null.
10 [java] No records found [java]





