예제 #1
0
  /**
   * Constructs the DataLink Parameters from an URL string containing a VOTable with DataLink
   * information The VOTABLE must contain only Datalink info! ????? or?
   *
   * @throws IOException
   */
  public DataLinkParams(String dataLinksrc) throws IOException {
    id_source = null;
    request = null;
    accessURL = null;
    contentType = null;
    service = new ArrayList<DataLinkService>();
    DataLinkService thisService = new DataLinkService();

    URL dataLinkURL = new URL(dataLinksrc);
    DataSource datsrc = new URLDataSource(dataLinkURL);

    StarTable starTable =
        new VOTableBuilder().makeStarTable(datsrc, true, StoragePolicy.getDefaultPolicy());

    int ncol = starTable.getColumnCount();

    for (int k = 0; k < ncol; k++) {
      ColumnInfo colInfo = starTable.getColumnInfo(k);

      //   String utype = colInfo.getUtype();
      String name = colInfo.getName();
      if (name != null) thisService.addParam(name, (String) starTable.getCell(0, k));

      //  if ( utype != null ) {
      //     utype = utype.toLowerCase();
      //     if ( utype.endsWith( "datalink.accessurl" ) ) {
      //        thisService.addParam("accessURL", (String) starTable.getCell(0, k));
      //     }
      //     if ( utype.endsWith( "datalink.contenttype" ) ) {
      //         thisService.addParam("contentType", (String) starTable.getCell(0, k));
      // }
    }
    service.add(thisService);
  }
예제 #2
0
  public void addService(
      VOElement serviceEl) // TO DO - how to check which service is wanted????????
      {
    DataLinkService thisService = new DataLinkService();

    // handle the PARAM elements
    VOElement[] voels = serviceEl.getChildrenByName("PARAM"); // the param elements
    int i = 0;
    while (i < voels.length) {
      ParamElement pel = (ParamElement) voels[i];
      thisService.addParam(pel.getAttribute("name"), pel.getAttribute("value"));
      i++;
    }

    i = 0;

    // handle the GROUP with name=InputParams element and its parameters
    VOElement[] grpels =
        serviceEl.getChildrenByName("GROUP" /*, "name", "inputParams"*/); // the GROUP Element
    VOElement grpel = null;
    while (i < grpels.length && grpel == null) {
      VOElement gel = grpels[i];
      String name = gel.getAttribute("name");

      if (name.equalsIgnoreCase("InputParams")) {
        grpel = gel;
      }
      i++;
    }

    if (grpel != null) {
      VOElement[] grpParams = grpel.getChildrenByName("PARAM"); // the param elements
      // handle the group  PARAM elements
      int size = grpParams.length;
      for (int j = 0; j < size; j++) {
        ParamElement pel = (ParamElement) grpParams[j];
        if (pel.getAttribute("name").equals("ID")) {
          VOElement el = pel.getChildByName("LINK"); // link inside a group element
          if (el.getAttribute("content-role").equals("ddl:id-source"))
            id_source = el.getAttribute("value");
          thisService.addParam("idSource", el.getAttribute("value"));
        } else {
          thisService.addGroupParam(pel);
          queryIndex = j;
        }
      }

      service.add(thisService);
    }
  }