Package edu.isi.karma.rep.sources

Examples of edu.isi.karma.rep.sources.Table


   
    InvocationManager invocatioManager;
    try {
      invocatioManager = new InvocationManager(null, requestURLString);
      logger.info("Requesting data with includeURL=" + true + ",includeInput=" + true + ",includeOutput=" + true);
      Table serviceTable = invocatioManager.getServiceData(false, false, true);
      logger.debug(serviceTable.getPrintInfo());
      logger.info("The service " + service.getUri() + " has been invoked successfully.");
      return serviceTable;

    } catch (MalformedURLException e) {
      logger.error("Malformed service request URL.");
View Full Code Here


    Map<String, String> outputAttNameToAttIds = new HashMap<String, String>();
    Map<String, String> outputAttValues = new HashMap<String, String>();
   
    if (blankInput) { // service without input parameter
      String invocationURL = getUrlString(service, new HashMap<String, String>());
      Table table = invokeWebAPI(invocationURL);

      if (table == null || table.getHeaders() == null) {
        logger.info("Error in invoking " + invocationURL);
      } else {
     
        // creating a mapping from attribute names (table headers) to attribute Ids
        outputAttNameToAttIds.clear();
        for (Attribute header : table.getHeaders()) {
          String name = header.getName();
          Attribute serviceAtt = service.getOutputAttributeByName(name);
          if (serviceAtt == null) {
            logger.info("Could not find the attribute " + name + " in service output attributes.");
            continue;
          }
          outputAttNameToAttIds.put(name, serviceAtt.getId());
        }
       
        // iterating over the rows to create the output RDF
        outputAttValues.clear();
        for (List<String> values : table.getValues()) {
          for (int i = 0; i < table.getColumnsCount(); i++) {
            String attId = outputAttNameToAttIds.get(table.getHeaders().get(i).getName());
            if (attId == null) continue;
            String value = values.get(i);
            outputAttValues.put(attId, value);
          }
          addStatementsToJenaModel(this.service, this.outputJenaModel, new HashMap<String, String>(), outputAttValues);
        }
      }
    } else if (listOfInputAttValues == null) {
      getResponse().setContentType(MimeType.TEXT_PLAIN);
      pw.write("Cannot extract the input values from the service input model. ");
      return;
    } else {
      for (Map<String,String> inputAttValues : listOfInputAttValues) {
       
        // invoking the Web API and load the response in a table
        String invocationURL = getUrlString(service, inputAttValues);
        Table table = invokeWebAPI(invocationURL);
 
        if (table == null || table.getHeaders() == null) {
          logger.info("Error in invoking " + invocationURL);
          continue;
        }
       
        // creating a mapping from attribute names (table headers) to attribute Ids
        outputAttNameToAttIds.clear();
        for (Attribute header : table.getHeaders()) {
          String name = header.getName();
          Attribute serviceAtt = service.getOutputAttributeByName(name);
          if (serviceAtt == null) {
            logger.info("Could not find the attribute " + name + " in service output attributes.");
            continue;
          }
          outputAttNameToAttIds.put(name, serviceAtt.getId());
        }
       
        // iterating over the rows to create the output RDF
        outputAttValues.clear();
        for (List<String> values : table.getValues()) {
          for (int i = 0; i < table.getColumnsCount(); i++) {
            String attId = outputAttNameToAttIds.get(table.getHeaders().get(i).getName());
            if (attId == null) continue;
            String value = values.get(i);
            outputAttValues.put(attId, value);
          }
          addStatementsToJenaModel(this.service, this.outputJenaModel, inputAttValues, outputAttValues);
View Full Code Here

    try {
      invocatioManager = new InvocationManager(getUrlColumnName(wk), requestIds, requestURLStrings, encoding);
      logger.info("Requesting data with includeURL=" + false + ",includeInput=" + true + ",includeOutput=" + true);
     
      // This generate a flat table of the json results
      Table serviceTable = invocatioManager.getServiceData(false, true, true);
      ServiceTableUtil.populateWorksheet(serviceTable, wk, workspace.getFactory(), selection);
     
      // FIXME
//      String json = invocatioManager.getServiceJson(true);
      invocatioManager.getServiceJson(true);
View Full Code Here

   
    public static void getJsonFlat(String json, List<String> columns, List<List<String>> values) {
     
      Element element = JsonManager.getJsonElements(json);
      element.updateHeaders();
      Table t = element.getFlatTable();

      if (columns == null)
        columns = new ArrayList<String>();
     
      if (values == null)
        values = new ArrayList<List<String>>();
     
      if (t.getColumnsCount() > 0) {
        for (Attribute att : t.getHeaders())
          columns.add(att.getName());
       
        for (List<String> v : t.getValues())
          if (v != null)
            values.add(v);
      }
     
//      t.print();
View Full Code Here

    InvocationManager invocatioManager;
    try {
      String encoding = wk.getEncoding();
      invocatioManager = new InvocationManager(getUrlColumnName(wk), requestIds, requestURLStrings, encoding);
      logger.info("Requesting data with includeURL=" + true + ",includeInput=" + true + ",includeOutput=" + true);
      Table serviceTable = invocatioManager.getServiceData(false, false, true);
//      logger.debug(serviceTable.getPrintInfo());
      ServiceTableUtil.populateWorksheet(serviceTable, wk, workspace.getFactory(), selection);
      logger.info("The service " + service.getUri() + " has been invoked successfully.");

View Full Code Here

        updateHeaders(children, root.key);
      }
    }
   
    public Table getFlatTable() {
      Table t = new Table();
      this.getFlatTable(this, t);
      return t;
    }
View Full Code Here

      return t;
    }
   
    private void getFlatTable(Element root, Table t) {
   
      Table innerT = new Table();
     
      if (root.valueType == ValueType.SINGLE) {
        innerT.getHeaders().add(new Attribute(root.getKey(), root.getKey()));
        List<String> v = new ArrayList<String>();
        v.add(((SingleValue)root.getValue()).getValueString());
        innerT.getValues().add(v);
        t.cartesianProductOrUnionIfSameHeaders(innerT);
        return;
      } else {
        List<String> v = new ArrayList<String>();
      for (Element child : ((ArrayValue)root.getValue()).getElements())
      {
        if (child.valueType == ValueType.SINGLE) {
            innerT.getHeaders().add(new Attribute(child.getKey(), child.getKey()));
            v.add(((SingleValue)child.getValue()).getValueString());
        }
      }
      if (v.size() > 0) {
        innerT.getValues().add(v);
        t.cartesianProductOrUnionIfSameHeaders(innerT);
      }   
     
      Table unionT = new Table();
      for (Element child : ((ArrayValue)root.getValue()).getElements())
      {
        if (child.valueType == ValueType.ARRAY) {
          innerT = new Table();
            getFlatTable(child, innerT);
            unionT.cartesianProductOrUnionIfSameHeaders(innerT);
        }
      }
      if (unionT.getColumnsCount() > 0)
        t.cartesianProductOrUnionIfSameHeaders(unionT);
    }
    }
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.sources.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.