Package edu.isi.karma.rep.alignment

Examples of edu.isi.karma.rep.alignment.Node


     
      private void addLink(LabeledLink link, LINK_DIRECTION direction, JSONArray edgesArray)
          throws JSONException {
        String linkLabel = link.getLabel().getDisplayName();
       
        Node edgeSource = alignment.getNodeById(LinkIdFactory.
            getLinkSourceId(link.getId()));
        Node edgeTarget = alignment.getNodeById(LinkIdFactory.
            getLinkTargetId(link.getId()));
       
        String edgeSourceLabel = edgeSource.getDisplayId();
        String edgeSourceId = edgeSource.getId();
        String edgeSourceUri = edgeSource.getUri();
        String edgeTargetLabel = edgeTarget.getDisplayId();
        String edgeTargetId = edgeTarget.getId();
        String edgeTargetUri = edgeTarget.getUri();
       
        Label srcNodeLabel = edgeSource.getLabel();
        if (srcNodeLabel.getUri() !=null && srcNodeLabel.getNs() != null
            && srcNodeLabel.getUri().equalsIgnoreCase(srcNodeLabel.getNs())) {
          edgeSourceLabel = edgeSource.getId();
        }
        Label trgNodeLabel = edgeTarget.getLabel();
        if (trgNodeLabel.getUri() !=null && trgNodeLabel.getNs() != null
            && trgNodeLabel.getUri().equalsIgnoreCase(trgNodeLabel.getNs())) {
          edgeTargetLabel = edgeTarget.getId();
        }
         
        JSONObject edgeObj = new JSONObject();
        edgeObj.put(JsonKeys.edgeId.name(), link.getLabel().getUri());
        edgeObj.put(JsonKeys.edgeLabel.name(), linkLabel);
View Full Code Here


    if (visitedNodes.contains(node)) // prevent having loop in the tree
      return;
   
    visitedNodes.add(node);
   
    Node source, target;
   
    Set<DefaultLink> incomingLinks = tree.incomingEdgesOf(node);
    if (incomingLinks != null) {
      LabeledLink[] incomingLinksArr = incomingLinks.toArray(new LabeledLink[0]);
      for (LabeledLink inLink : incomingLinksArr) {
View Full Code Here

      predicateStr = getUri(predicateStr);
      objStr = getUri(objStr);

      if (predicateStr.equalsIgnoreCase(typePredicate)) {
       
        Node classNode = new InternalNode(objStr, new Label(objStr));
        uri2Classes.put(subjStr, classNode);
        graph.addVertex(classNode);
       
      }
    }
   
//    int countOfLiterals = 0;
    String id;
    for (Statement st : statements) {
     
      String subjStr = st.getSubject();
      String predicateStr = st.getPredicate();
      String objStr = st.getObject();
     
      subjStr = getUri(subjStr);
      predicateStr = getUri(predicateStr);
      objStr = getUri(objStr);

      if (predicateStr.equalsIgnoreCase(typePredicate))
        continue;
     
      Node subj = uri2Classes.get(subjStr);
      if (subj == null) {
        subj = new InternalNode(subjStr, new Label(subjStr));
        graph.addVertex(subj);
      }

      Node obj = uri2Classes.get(objStr);
      if (obj == null) {
        if (objStr.startsWith(attPrefix)) {
          id = new RandomGUID().toString();
          obj = new ColumnNode(id, objStr, objStr, null);
          SemanticType semanticType = new SemanticType(((ColumnNode)obj).getHNodeId(),
              new Label(predicateStr),
              subj.getLabel(),
              Origin.User,
              1.0);
          ((ColumnNode)obj).setUserSelectedSemanticType(semanticType);

        } else if (objStr.indexOf(":") == -1 && objStr.indexOf("\"") != -1) {
//          String literalId = "lit:" + serviceId + "_l" + String.valueOf(countOfLiterals);
          obj = new LiteralNode(objStr, objStr, null, false);
//          countOfLiterals ++;
        } else
          obj = new InternalNode(objStr, new Label(objStr));
       
        graph.addVertex(obj);
      }
     
      LabeledLink e;
      if (obj instanceof InternalNode)
        e = new ObjectPropertyLink(LinkIdFactory.getLinkId(predicateStr, subj.getId(), obj.getId()), new Label(predicateStr), ObjectPropertyType.None);
      else
        e = new DataPropertyLink(LinkIdFactory.getLinkId(predicateStr, subj.getId(), obj.getId()), new Label(predicateStr));
      graph.addEdge(subj, obj, e);
     
    }
   
    return graph;
View Full Code Here

  public static DirectedWeightedMultigraph<Node, DefaultLink> readGraph(JsonReader reader) throws IOException {
   
    DirectedWeightedMultigraph<Node, DefaultLink> graph =
        new DirectedWeightedMultigraph<Node, DefaultLink>(LabeledLink.class);
   
    Node n, source, target;
    DefaultLink l;
    Double[] weight = new Double[1];
    HashMap<String, Node> idToNodes = new HashMap<String, Node>();
   
    reader.beginObject();
      while (reader.hasNext()) {
        String key = reader.nextName();
      if (key.equals("nodes") && reader.peek() != JsonToken.NULL) {
        reader.beginArray();
          while (reader.hasNext()) {
            n = readNode(reader);
            if (n != null) {
              idToNodes.put(n.getId(), n);
              graph.addVertex(n);
            }
          }
          reader.endArray();
      } else if (key.equals("links") && reader.peek() != JsonToken.NULL) {
View Full Code Here

        reader.skipValue();
      }
    }
      reader.endObject();
     
      Node n = null;
      if (type == NodeType.InternalNode) {
        n = new InternalNode(id, label);
      } else if (type == NodeType.ColumnNode) {
        n = new ColumnNode(id, hNodeId, columnName, rdfLiteralType);
        ((ColumnNode)n).setUserSelectedSemanticType(userSelectedSemanticType);
        ((ColumnNode)n).setSuggestedSemanticTypes(suggestedSemanticTypes);
      } else if (type == NodeType.LiteralNode) {
        n = new LiteralNode(id, value, datatype, isUri);
      } else {
        logger.error("cannot instanciate a node from the type: " + type.toString());
        return null;
      }
     
    n.setModelIds(modelIds);
     
      return n;
  }
View Full Code Here

//    return this.linkIdFactory.lastIndexOf(uri);
//  }

  public ColumnNode getColumnNodeByHNodeId(String hNodeId) {

    Node n = this.graphBuilder.getIdToNodeMap().get(hNodeId);
    if (n != null && n instanceof ColumnNode)   
      return (ColumnNode)n;
    else
      return null;
   
View Full Code Here

    node.setValue(value);
    node.setUri(isUri);
  }
 
  public void deleteForcedInternalNode(String nodeId) {
    Node node = getNodeById(nodeId);
    if(node != null) {
      this.graphBuilder.removeNode(node);
    }
  }
View Full Code Here

    logger.debug("changing the status of link " + linkId + " to " + newStatus.name());
    LabeledLink link = this.getLinkById(linkId);
    if (link == null) {
      if (newStatus == LinkStatus.ForcedByUser) {
        Node source = this.getNodeById(LinkIdFactory.getLinkSourceId(linkId));
        Node target = this.getNodeById(LinkIdFactory.getLinkTargetId(linkId));
        String linkUri = LinkIdFactory.getLinkUri(linkId);
        LabeledLink newLink;
        if (linkUri.equalsIgnoreCase(Uris.RDFS_SUBCLASS_URI))
          newLink = new SubClassLink(linkId);
        else
          newLink = new ObjectPropertyLink(linkId,
              this.graphBuilder.getOntologyManager().getUriLabel(linkUri),
              this.graphBuilder.getOntologyManager().getObjectPropertyType(source.getLabel().getUri(), target.getLabel().getUri(), linkUri));
       
        newLink.setStatus(LinkStatus.ForcedByUser);
        this.graphBuilder.addLink(source, target, newLink);
      }
    } else
View Full Code Here

    return false;
  }
 
  public Set<LabeledLink> getCurrentIncomingLinksToNode(String nodeId) {
   
    Node node = this.getNodeById(nodeId);
    if (node == null) return null;
    if (this.steinerTree == null || !this.steinerTree.containsVertex(node)) return null;
     
    return this.steinerTree.incomingEdgesOf(node);
  }
View Full Code Here

    return this.steinerTree.incomingEdgesOf(node);
  }
 
  public Set<LabeledLink> getCurrentOutgoingLinksToNode(String nodeId) {
   
    Node node = this.getNodeById(nodeId);
    if (node == null) return null;
    if (this.steinerTree == null || !this.steinerTree.containsVertex(node)) return null;
     
    return this.steinerTree.outgoingEdgesOf(node);
  }
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.alignment.Node

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.