Changeset 515 for trunk/src/groovy/dbnp/rest/CCMCommunicationManager.groovy
- Timestamp:
- Jun 3, 2010, 9:48:33 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/groovy/dbnp/rest/CCMCommunicationManager.groovy
r491 r515 11 11 12 12 13 14 /** CCMCommunicationManager 15 * 16 * This class implements a REST client to fetch data from the Clinical Chemistry Module (CCM). 17 * The communicatino manager provides methods for accessing each resources. 18 * Every REST resource corresponds to exactly one method in this class that makes 19 * the communication with the resource available. 20 * 21 * For instance, the getSearchable() method calls the getMeasurements resource of the CCM 22 * by passing arguments to it and returning the result of the calling that resource. 23 */ 24 25 13 26 class CCMCommunicationManager implements CleanDataLayer { 14 27 28 29 /** ServerULR contains a string that represents the URL of the 30 * rest resources that this communication manager connects to. 31 */ 32 def static ServerURL = "http://nbx5.nugo.org:8182/ClinicalChemistry/rest"; 15 33 //def static ServerURL = "http://localhost:8080/gscf/rest"; 16 def static ServerURL = "http://nbx5.nugo.org:8182/ClinicalChemistry/rest";17 34 18 35 … … 43 60 44 61 45 46 47 48 62 /** 49 63 * Testing REST. Remove when connection to nbx5 is established. … … 52 66 */ 53 67 public Object getFeatures() { 54 def url = new URL( ServerURL + "/features" )55 return JSON.parse(url.newReader())68 // return request( "features" ) 69 return getStudiesForKeyword("ldl") 56 70 } 57 71 58 72 59 73 /** 60 * Testing REST. Remove when connection to nbx5 is established. 74 * For a string for the searchable plugin. 75 * This works for one keyeword, but protection should be built in using 76 * the methods that searchable uses for building query strings. 61 77 * 62 78 * @return list of ClinicalFloatData 63 79 */ 64 80 private String getSearchable( keyword ) { 65 return "submit=Query&q=" + keyword81 return "?submit=Query&q=" + keyword 66 82 } 67 83 68 84 69 85 /** 70 * Testing REST. Remove when connection to nbx5 is established.86 * Get all meassurements that contain a given keyword as feature. 71 87 * 88 * @param keyword, the keyword used 72 89 * @return list of ClinicalFloatData 73 90 */ 74 91 public String getStudiesForKeyword( String keyword ) { 92 def resource = "getMeasurementsForValue" 93 request( resource + getSearchable(keyword) ) 75 94 } 76 95 77 96 97 /** 98 * Get all meassurements that contain a given keyword as feature. 99 * 100 * @param keyword, the keyword used 101 * @return list of ClinicalFloatData 102 */ 78 103 public Object getMeasurementsResource( String keyword ) { 79 104 def url = new URL( ServerURL + "/" + getSearchable(keyword) ) … … 94 119 95 120 121 122 123 124 96 125 /** Send a request for the REST resource to the server and deliver the 97 * resulting JSON object. 126 * resulting JSON object. (This is just a convenience method.) 98 127 * 99 128 * @param resource: the name of the resource including parameters 100 129 * @return JSON object 101 130 */ 102 private Object reques Service( String resource ) {131 private Object request( String resource ) { 103 132 def url = new URL( ServerURL + "/" + resource ); 104 133 return JSON.parse( url.newReader() ); 105 134 } 106 135 136 137 138 139 107 140 }
Note: See TracChangeset
for help on using the changeset viewer.