Package edu.isi.karma.rep.alignment

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


    for (int j = 0; j < newEdges.length(); j++) {
      JSONObject newEdge = newEdges.getJSONObject(j);

      String sourceId = newEdge.has(JsonKeys.edgeSourceId.name()) ? newEdge.getString(JsonKeys.edgeSourceId.name()) : null;
     
      Node sourceNode = null;
      Node targetNode = null;
      if(sourceId != null) {
        if(sourceId.endsWith(" (add)"))
          sourceId = sourceId.substring(0, sourceId.length()-5).trim();
        sourceNode = alignment.getNodeById(sourceId);
      }
View Full Code Here


            targetId);

        // alignment.changeLinkStatus(linkId, LinkStatus.Normal);
        alignment.removeLink(linkId);
       
        Node node = alignment.getNodeById(targetId);
        if(node instanceof ColumnNode) {
          ColumnNode cNode = (ColumnNode)node;
          worksheet.getSemanticTypes().unassignColumnSemanticType(cNode.getHNodeId());
        }
//      }
View Full Code Here

        // or an existing class instance should be used (this is the case when just the class is chosen as a sem type).
//        Label domainName = null;
       
        boolean isClassSemanticType = false;
        boolean semanticTypeAlreadyExists = false;
        Node domain = null;
        String domainUriOrId;
        Label linkLabel;
       
        // if domain value is empty, semantic type is a class semantic type
        if (domainValue.equals("")) {
          isClassSemanticType = true;
          domainUriOrId = fullTypeValue;
          linkLabel = ClassInstanceLink.getFixedLabel();
        } else {
          isClassSemanticType = false;
          domainUriOrId = domainValue;
          linkLabel = ontMgr.getUriLabel(fullTypeValue);
          if (linkLabel == null) {
            logger.error("URI/ID does not exist in the ontology or model: " + fullTypeValue);
            continue;
          }
        }
       
        if(domainUriOrId.endsWith(" (add)"))
          domainUriOrId = domainUriOrId.substring(0, domainUriOrId.length()-5).trim();
       
        domain = alignment.getNodeById(domainUriOrId);
        logger.info("Got domain for domainUriOrId:" + domainUriOrId + " ::" + domain);
        if (domain == null) {
          Label label = ontMgr.getUriLabel(domainUriOrId);
//          if (label == null) {
//            logger.error("URI/ID does not exist in the ontology or model: " + domainUriOrId);
//            continue;
//          }
          if (label == null) {
            if(type.has(ClientJsonKeys.DomainUri.name())) {
              label = new Label(type.getString(ClientJsonKeys.DomainUri.name()));
            } else {
              //This part of the code is for backward compatibility. Newer models should have domainUri
              int len = domainValue.length();
              if ((len > 1) && Character.isDigit(domainValue.charAt(len-1))) {
                String newDomainValue = domainValue.substring(0, len-1);
                label = ontMgr.getUriLabel(newDomainValue);
              }
              if (label == null) {
                logger.error("No graph node found for the node: " + domainValue);
                return new UpdateContainer(new ErrorUpdate("" +
                "Error occured while setting semantic type!"));
              }
            }
          }
          domain = alignment.addInternalNode(label);
        }
         
        // Check if a semantic type already exists for the column
        ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
        columnNode.setRdfLiteralType(rdfLiteralType);
        List<LabeledLink> columnNodeIncomingLinks = alignment.getIncomingLinks(columnNode.getId());
        LabeledLink oldIncomingLinkToColumnNode = null;
        Node oldDomainNode = null;
        if (columnNodeIncomingLinks != null && !columnNodeIncomingLinks.isEmpty()) { // SemanticType already assigned
          semanticTypeAlreadyExists = true;
          oldIncomingLinkToColumnNode = columnNodeIncomingLinks.get(0);
          oldDomainNode = oldIncomingLinkToColumnNode.getSource();
        }
View Full Code Here

        /*** Add the links ***/
        Set<LabeledLink> links = alignmentGraph.edgeSet();
        for (LabeledLink link : links) {

          Node source = link.getSource();
          Integer sourceIndex = verticesIndex.get(source);
          Node target = link.getTarget();
          Integer targetIndex = verticesIndex.get(target);
          Set<LabeledLink> outEdges = alignmentGraph
              .outgoingEdgesOf(target);

          if (sourceIndex == null || targetIndex == null) {
            logger.error("Edge vertex index not found!");
            continue;
          }

          JSONObject linkObj = new JSONObject();
          linkObj.put(JsonKeys.source.name(), sourceIndex);
          linkObj.put(JsonKeys.target.name(), targetIndex);
          linkObj.put(JsonKeys.sourceNodeId.name(), source.getId());
          linkObj.put(JsonKeys.targetNodeId.name(), target.getId());

          linkObj.put(JsonKeys.label.name(), link.getLabel()
              .getLocalName());
          linkObj.put(JsonKeys.id.name(), link.getId() + "");
          linkObj.put(JsonKeys.linkStatus.name(), link.getStatus()
              .name());
          linkObj.put(JsonKeys.linkUri.name(), link.getLabel()
              .getUri());

          if (target.getType() == NodeType.ColumnNode
              && outEdges.isEmpty()) {
            linkObj.put(JsonKeys.linkType.name(),
                JsonValues.holderLink.name());
          }

View Full Code Here

          verticesIndex.put(node, nodesIndexcounter++);
        }
        /*** Add the links ***/
        Set<LabeledLink> links = alignmentGraph.edgeSet();
        for (LabeledLink link : links) {
          Node source = link.getSource();
          Integer sourceIndex = verticesIndex.get(source);
          Node target = link.getTarget();
          Integer targetIndex = verticesIndex.get(target);
          Set<LabeledLink> outEdges = alignmentGraph
              .outgoingEdgesOf(target);
          if (sourceIndex == null || targetIndex == null) {
            logger.error("Edge vertex index not found!");
            continue;
          }
          JSONObject linkObj = new JSONObject();
          linkObj.put(JsonKeys.source.name(), sourceIndex);
          linkObj.put(JsonKeys.target.name(), targetIndex);
          linkObj.put(JsonKeys.sourceNodeId.name(), source.getId());
          linkObj.put(JsonKeys.targetNodeId.name(), target.getId());
          linkObj.put(JsonKeys.label.name(), link.getLabel()
              .getLocalName());
          linkObj.put(JsonKeys.id.name(), link.getId() + "");
          linkObj.put(JsonKeys.linkStatus.name(), link.getStatus()
              .name());
          linkObj.put(JsonKeys.linkUri.name(), link.getLabel()
              .getUri());
          if (target.getType() == NodeType.ColumnNode
              && outEdges.isEmpty()) {
            linkObj.put(JsonKeys.linkType.name(),
                JsonValues.holderLink.name());
          }
          linksArr.put(linkObj);
          if (link.getType() == LinkType.ClassInstanceLink
              && target instanceof ColumnNode) {
            ColumnNode cNode = (ColumnNode) target;
            // Add the holder vertex object and the link that
            // attaches nodes to the columns
            JSONArray hNodeIdsCoveredByVertex_holder = new JSONArray();
            hNodeIdsCoveredByVertex_holder.put(cNode.getHNodeId());

            JSONObject vertObj_holder = getNormalLayoutNodeJsonObject(
                JsonValues.key.name(), source.getId()
                    + "_holder",
                NodeType.ColumnNode.name(), 0, false,
                hNodeIdsCoveredByVertex_holder,
                cNode.getHNodeId(), cNode.getLabel().getUri(), false);

            nodesArr.put(vertObj_holder);
            nodesIndexcounter++;
            // Add the holder link
            JSONObject linkObj_holder = getNormalLayoutLinkJsonObject(
                JsonValues.key.name(), "", nodesIndexcounter,
                nodesIndexcounter - 1, "", "", "", "");
            linksArr.put(linkObj_holder);
          }
          if (link.getType() == LinkType.DataPropertyOfColumnLink) {
            DataPropertyOfColumnLink dpLink = (DataPropertyOfColumnLink) link;
            String startHNodeId = dpLink
                .getSpecializedColumnHNodeId();
            // Get height of the class instance node
            int height = maxTreeHeight
                - nodeHeightsMap.get(link.getSource());
            // Add 2 more holder nodes
            // Start node
            JSONArray hNodeIdsCoveredByVertex_holder = new JSONArray();
            boolean isSUri = false;
            if(source instanceof LiteralNode) {
              isSUri = ((LiteralNode)source).isUri();
            }
             
            hNodeIdsCoveredByVertex_holder.put(startHNodeId);

            JSONObject startNode = getNormalLayoutNodeJsonObject("",
                source.getId() + "_holder",
                JsonValues.DataPropertyOfColumnHolder.name(),
                height - 0.35, false,
                hNodeIdsCoveredByVertex_holder, startHNodeId,
                source.getLabel().getUri(), isSUri);

            nodesArr.put(startNode);
            nodesIndexcounter++;
            // End node
            String endHNodeId = ((ColumnNode) link.getTarget())
                .getHNodeId();
            JSONArray hNodeIdsCoveredByVertex_holder_2 = new JSONArray();
            hNodeIdsCoveredByVertex_holder_2.put(endHNodeId);

            boolean isTUri = false;
            if(target instanceof LiteralNode) {
              isTUri = ((LiteralNode)target).isUri();
            }
           
            JSONObject endNode = getNormalLayoutNodeJsonObject("",
                target.getId() + "_holder",
                JsonValues.DataPropertyOfColumnHolder.name(),
                height - 0.35, false,
                hNodeIdsCoveredByVertex_holder_2, endHNodeId,
                target.getLabel().getUri(), isTUri);

            nodesArr.put(endNode);
            nodesIndexcounter++;
            // Add the horizontal link
            JSONObject linkObj_holder = getNormalLayoutLinkJsonObject("", "",
                nodesIndexcounter - 2, nodesIndexcounter - 1,
                JsonValues.horizontalDataPropertyLink.name(),
                "", "", "");
            linksArr.put(linkObj_holder);
          } else if (link.getType() == LinkType.ObjectPropertySpecializationLink) {
            ObjectPropertySpecializationLink opLink = (ObjectPropertySpecializationLink) link;
            String specializedLinkId = opLink
                .getSpecializedLinkId();
            // Get height of the class instance node
            Node specializedLinkTarget = this.alignment
                .getNodeById(LinkIdFactory
                    .getLinkTargetId(specializedLinkId));
            int height = nodeHeightsMap.get(specializedLinkTarget);
            // Add 2 more holder nodes
            // Start node
View Full Code Here

      if (node.getLabel() != null) {
        nodeIdFactory.getNodeId(node.getUri());
      }           
    }
   
    Node source;
    Node target;
   
    for (DefaultLink link : graph.edgeSet()) {
     
      source = link.getSource();
      target = link.getTarget();
View Full Code Here

    if (!this.addNode(newNode)) {
      logger.error("could not add the new node " + newNode.getId());
      return null;
    }
   
    Node source , target;
    String newId;
    Set<DefaultLink> incomingLinks = this.getGraph().incomingEdgesOf(node);
    if (incomingLinks != null) {
      for (DefaultLink l : incomingLinks) {
        source = l.getSource();
        if (source instanceof ColumnNode) continue;
        target = newNode;
        newId = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId());
        DefaultLink copyLink = l.getCopy(newId);
        this.addLink(source, target, copyLink, l.getWeight());
      }
    }
   
    Set<DefaultLink> outgoingLinks = this.getGraph().outgoingEdgesOf(node);
    if (outgoingLinks != null) {
      for (DefaultLink l : outgoingLinks) {
        source = newNode;
        target = l.getTarget();
        if (!copyLinksToColumnNodes && target instanceof ColumnNode) continue; // skip links to column nodes
        newId = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId());
        DefaultLink copyLink = l.getCopy(newId);
        this.addLink(source, target, copyLink, l.getWeight());
      }
    }
   
View Full Code Here

   
    // Add Thing to the Graph
    if (ModelingConfiguration.getThingNode()) {
      String id = nodeIdFactory.getNodeId(Uris.THING_URI);
      Label label = new Label(Uris.THING_URI, Namespaces.OWL, Prefixes.OWL);
      Node thing = new InternalNode(id, label);
      addNode(thing);
    }
   
    logger.debug("exit>");
  }
View Full Code Here

  private void updateLinkCountMap(DefaultLink link) {

    String key, sourceUri, targetUri, linkUri;
    Integer count;
    Node source, target;
   
    source = link.getSource();
    target = link.getTarget();
   
    sourceUri = source.getUri();
    targetUri = target.getUri();
    linkUri = link.getUri();

//    if (link instanceof DataPropertyLink) return;
View Full Code Here

    Set<String> uriClosure = computeUriClosure(uri);

    for (String c : uriClosure) {
      Set<Node> nodesOfSameUri = this.uriToNodesMap.get(c);
      if (nodesOfSameUri == null || nodesOfSameUri.size() == 0) { // the internal node is not added to the graph before
        Node nn = new InternalNode(nodeIdFactory.getNodeId(c),
            ontologyManager.getUriLabel(c));
        if (addNode(nn)) newAddedNodes.add(nn);
      }
    }
   
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.