Exemplo n.º 1
0
 private void loadServiceMetadataFromFile() {
   try {
     File dataFile =
         new File(
             ContainerConfig.getBaseDirectory()
                 + File.separator
                 + getConfiguration().getServiceMetadataFile());
     this.serviceMetadataMD =
         (gov.nih.nci.cagrid.metadata.ServiceMetadata)
             Utils.deserializeDocument(
                 dataFile.getAbsolutePath(), gov.nih.nci.cagrid.metadata.ServiceMetadata.class);
   } catch (Exception e) {
     logger.error("ERROR: problem populating metadata from file: " + e.getMessage(), e);
   }
 }
Exemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    args =
        new String[] {
          "-gsh", "http://ccis1716.duhs.duke.edu/wsrf/services/cagrid/RPData",
          // "-gsh", "http://localhost:8080/wsrf/services/cagrid/RPData",
          // "-gsh", "http://140.254.80.99:8080/wsrf/services/cagrid/RPData",
          "-query", "queries\\scanFeatures_query3.xml",
          "-printXml"
        };

    Options options = getOptions();
    CommandLine cmd = null;
    try {
      cmd = new BasicParser().parse(options, args);
    } catch (ParseException e) {
      System.out.println("Error parsing arguments: " + e.getMessage());
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp("RPDataClient", options);
      System.exit(-1);
      return;
    }
    RPDataClient client = new RPDataClient(cmd.getOptionValue("gsh"));

    CQLQueryType query =
        (CQLQueryType) Utils.deserializeDocument(cmd.getOptionValue("query"), CQLQueryType.class);

    gov.nih.nci.cagrid.cql.CQLQueryResultsType results = client.query(query);
    gov.nih.nci.cagrid.cql.CQLQueryResultType[] resultsArray = results.getCQLQueryResult();
    if (resultsArray != null) {
      System.out.println("Got " + resultsArray.length + " result(s)");

      for (int i = 0; i < resultsArray.length; i++) {
        gov.nih.nci.cagrid.cql.CQLQueryResultType result = resultsArray[i];

        // Deserialize and print out each element........
        MessageElement[] msgs = result.get_any();
        for (int j = 0; j < msgs.length; j++) {
          StringWriter output = new StringWriter();
          TransformerFactory.newInstance()
              .newTransformer()
              .transform(new DOMSource(msgs[j]), new StreamResult(output));
          if (cmd.hasOption("printXml")) System.out.println(output.toString());
        }
      }
    }
  }