Package edu.isi.karma.rep.sources

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


     
        // 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()) {
View Full Code Here


    Map<String, String> attIdToValue = null;
    for (int i = 0; i < rows.size(); i++) {
      attIdToValue = new HashMap<String, String>();
      for (String serviceAttId : serviceToSourceAttMapping.keySet()) {
        String sourceAttId = serviceToSourceAttMapping.get(serviceAttId);
        Attribute sourceAtt = source.getAttribute(sourceAttId);
        if (sourceAtt == null) {
//          logger.debug("Cannot find the source attribute with the id " + sourceAttId);
          continue;
        }
        String hNodeId = sourceAtt.gethNodeId();
        if (hNodeId == null || hNodeId.trim().length() == 0) {
          logger.debug("The attribute with the id " + sourceAttId + " does not have a hNodeId.");
          continue;
        }
       
View Full Code Here

    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);
View Full Code Here

      att_groundedIn = node.asLiteral().getString();
      logger.debug("attribute grounded in: " + att_groundedIn);
    } else
      logger.debug("attribute does not have agroundedIn value.");

    Attribute att = null;
    if (att_groundedIn.length() > 0)
      att = new Attribute(att_id, att_resource.getNameSpace(), att_name, ioType, requirement, att_groundedIn );
    else
      att = new Attribute(att_id, att_resource.getNameSpace(), att_name, ioType, requirement);
   
    return att;

  }
View Full Code Here

      if (service.getInputAttributes().size() > 0) {
        my_input.addProperty(rdf_type, input_resource);
      }
      for (int i = 0; i < service.getInputAttributes().size(); i++) {
       
        Attribute att = service.getInputAttributes().get(i);
        Resource my_attribute = model.createResource(baseNS + att.getId());
       
        if (includeAttributeDetails)
          addAttributeDetails(model, my_attribute, att);
       
        if (att.getRequirement() == AttributeRequirement.NONE)
          my_input.addProperty(has_attribute, my_attribute);
        else if (att.getRequirement() == AttributeRequirement.MANDATORY)
          my_input.addProperty(has_mandatory_attribute, my_attribute);
        else if (att.getRequirement() == AttributeRequirement.OPTIONAL)
          my_input.addProperty(has_optional_attribute, my_attribute);

      }

      addModelPart(model, my_input, service.getInputModel());
View Full Code Here

      if (service.getOutputAttributes().size() > 0) {
        my_output.addProperty(rdf_type, output_resource);
      }
      for (int i = 0; i < service.getOutputAttributes().size(); i++) {
       
        Attribute att = service.getOutputAttributes().get(i);
        Resource my_attribute = model.createResource(baseNS + att.getId());
       
        if (includeAttributeDetails)
          addAttributeDetails(model, my_attribute, att);

        if (att.getRequirement() == AttributeRequirement.NONE)
          my_output.addProperty(has_attribute, my_attribute);
        else if (att.getRequirement() == AttributeRequirement.MANDATORY)
          my_output.addProperty(has_mandatory_attribute, my_attribute);
        else if (att.getRequirement() == AttributeRequirement.OPTIONAL)
          my_output.addProperty(has_optional_attribute, my_attribute);

      }
      addModelPart(model, my_output, service.getOutputModel());
    }
View Full Code Here

    }

    if (this.source.getAttributes() != null) {
      for (int i = 0; i < this.source.getAttributes().size(); i++) {
       
        Attribute att = this.source.getAttributes().get(i);
        Resource my_attribute = model.createResource(baseNS + att.getId());
       
        my_source.addProperty(has_attribute, my_attribute);
        my_attribute.addProperty(rdf_type, attribute_resource);
        my_attribute.addProperty(has_name, att.getName());
        my_attribute.addProperty(has_columnName, factory.getHNode(att.gethNodeId()).getColumnName());

      }
      addModelPart(model, my_source, this.source.getModel());
    }
    // Add source information if any present
View Full Code Here

  private static List<String> addHeaders(List<Attribute> tableHeader, Worksheet worksheet, RepFactory factory) {
    HTable headers = worksheet.getHeaders();
    List<String> headersList = new ArrayList<String>();
   
    for (int i = 0; i < tableHeader.size(); i++) {
      Attribute att = tableHeader.get(i);
      HNode hNode = headers.addHNode(att.getName(), HNodeType.Regular, worksheet, factory);
      headersList.add(hNode.getId());
     
      // very important
      // update the hNodeId of the input/output attributes
      att.sethNodeId(hNode.getId());
    }
    return headersList;
  }
View Full Code Here

TOP

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

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.