Package edu.isi.karma.rep.alignment

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


      logger.debug("exit>");   
      return true;
    }
     
    // update the corresponding lists and hashmaps
    LabeledLink labeledLink = null;
//    if (link instanceof LabeledLink)
    labeledLink = (LabeledLink)link;
   
    this.idToLinkMap.put(labeledLink.getId(), labeledLink);
   
    Set<LabeledLink> linksWithSameUri = uriToLinksMap.get(labeledLink.getUri());
    if (linksWithSameUri == null) {
      linksWithSameUri = new HashSet<LabeledLink>();
      uriToLinksMap.put(labeledLink.getUri(), linksWithSameUri);
    }
    linksWithSameUri.add(labeledLink);
       
    Set<LabeledLink> linksWithSameType = typeToLinksMap.get(labeledLink.getType());
    if (linksWithSameType == null) {
      linksWithSameType = new HashSet<LabeledLink>();
      typeToLinksMap.put(labeledLink.getType(), linksWithSameType);
    }
    linksWithSameType.add(labeledLink);
   
    if (labeledLink.getStatus() != LinkStatus.Normal) {
      Set<LabeledLink> linksWithSameStatus = statusToLinksMap.get(labeledLink.getStatus());
      if (linksWithSameStatus == null) {
        linksWithSameStatus = new HashSet<LabeledLink>();
        statusToLinksMap.put(labeledLink.getStatus(), linksWithSameStatus);
      }
    }

    if (source instanceof InternalNode && target instanceof ColumnNode) {

      ((ColumnNode)target).setDomainNode((InternalNode)source);
      ((ColumnNode)target).setDomainLink(labeledLink);
     
      String key = source.getId() + link.getUri();
      Integer count = this.nodeDataPropertyCount.get(key);
      if (count == null) this.nodeDataPropertyCount.put(key, 1);
      else this.nodeDataPropertyCount.put(key, count.intValue() + 1);
     
      Set<Node> dataPropertyColumnNodes = this.nodeDataProperties.get(key);
      if (dataPropertyColumnNodes == null) {
        dataPropertyColumnNodes = new HashSet<Node>();
        this.nodeDataProperties.put(key, dataPropertyColumnNodes);
      }
      dataPropertyColumnNodes.add(target);
     
      key = source.getUri() + link.getUri();
      Set<SemanticTypeMapping> SemanticTypeMappings = this.semanticTypeMatches.get(key);
      if (SemanticTypeMappings == null) {
        SemanticTypeMappings = new HashSet<SemanticTypeMapping>();
        this.semanticTypeMatches.put(key, SemanticTypeMappings);
      }
      SemanticTypeMappings.add(new SemanticTypeMapping(null, null, (InternalNode)source, labeledLink, (ColumnNode)target));
    }
       
    if (labeledLink.getModelIds() != null) {
      this.modelIds.addAll(labeledLink.getModelIds());
      this.numberOfModelLinks++;
    }
   
    this.updateLinkCountMap(link);
   
View Full Code Here


     
      ColumnNode cn = (ColumnNode)n;
           
      Set<LabeledLink> incomingLinks = this.graph.incomingEdgesOf(n);
      if (incomingLinks != null && incomingLinks.size() == 1) {
        LabeledLink link = incomingLinks.toArray(new LabeledLink[0])[0];
        Node domain = link.getSource();
        SemanticType st = new SemanticType(cn.getHNodeId(), link.getLabel(), domain.getLabel(), Origin.User, 1.0);
        cn.setUserSelectedSemanticType(st);
      } else
        logger.debug("The column node " + ((ColumnNode)n).getColumnName() + " does not have any domain or it has more than one domain.");
    }
  }
View Full Code Here

      for (LabeledLink l : forcedLinks) {
        if (l.getStatus() == LinkStatus.ForcedByUser) {
          Node source = l.getSource();
          Node target = l.getTarget();
          if (!this.graphBuilder.addLink(source, target, l)) {
            LabeledLink existingLink = this.graphBuilder.getIdToLinkMap().get(l.getId());
            if (existingLink != null) { // the link already exist, but it may not be forced by user
              this.graphBuilder.changeLinkStatus(existingLink, LinkStatus.ForcedByUser);
            }
          }
        }
View Full Code Here

        ColumnNode target = new ColumnNode(nodeId, nodeId, sourceColumn.getColumnName(), null);
        if (!this.graphBuilder.addNode(target)) continue;;
        addedNodes.add(target);

        String linkId = LinkIdFactory.getLinkId(propertyUri, source.getId(), target.getId())
        LabeledLink link = new DataPropertyLink(linkId, new Label(propertyUri));
        if (!this.graphBuilder.addLink(source, target, link)) continue;;

        SemanticTypeMapping mp = new SemanticTypeMapping(sourceColumn, semanticType, (InternalNode)source, link, target);
        mappings.add(mp);
      }
View Full Code Here

    ColumnNode target = new ColumnNode(nodeId, nodeId, sourceColumn.getColumnName(), null);
    if (!this.graphBuilder.addNode(target)) return null;
    addedNodes.add(target);

    String linkId = LinkIdFactory.getLinkId(propertyUri, source.getId(), target.getId())
    LabeledLink link;
    if (propertyUri.equalsIgnoreCase(ClassInstanceLink.getFixedLabel().getUri()))
      link = new ClassInstanceLink(linkId);
    else {
      Label label = this.ontologyManager.getUriLabel(propertyUri);
      link = new DataPropertyLink(linkId, label);
View Full Code Here

    /** Check if a semantic type already exists for the column **/
    ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
    columnNode.setRdfLiteralType(rdfLiteralType);
    boolean semanticTypeAlreadyExists = false;
    LabeledLink oldIncomingLinkToColumnNode = null;
    Node oldDomainNode = null;
    List<LabeledLink> columnNodeIncomingLinks = alignment
        .getIncomingLinks(columnNode.getId());
    if (columnNodeIncomingLinks != null
        && !columnNodeIncomingLinks.isEmpty()) { // SemanticType already
                              // assigned
      semanticTypeAlreadyExists = true;
      oldIncomingLinkToColumnNode = columnNodeIncomingLinks.get(0);
      oldDomainNode = oldIncomingLinkToColumnNode.getSource();
    }

    if(metaPropertyId.endsWith(" (add)"))
      metaPropertyId = metaPropertyId.substring(0, metaPropertyId.length()-5).trim();
   
  if (metaPropertyName.equals(METAPROPERTY_NAME.isUriOfClass)) {
      Node classNode = alignment.getNodeById(metaPropertyId);
      if (semanticTypeAlreadyExists) {
        clearOldSemanticTypeLink(oldIncomingLinkToColumnNode,
            oldDomainNode, alignment, classNode);
      }

      if (classNode == null) {
        Label classNodeLabel = ontMgr.getUriLabel(metaPropertyUri);
        if (classNodeLabel == null) {
          String errorMessage = "Error while setting a classLink. MetaPropertyUri '"
              + metaPropertyUri
              + "' should be in the Ontology Manager, but it is not.";
          logger.error(errorMessage);
          return new UpdateContainer(new ErrorUpdate(errorMessage));
        }
        classNode = alignment.addInternalNode(classNodeLabel);
      }

      LabeledLink newLink = alignment.addClassInstanceLink(classNode, columnNode,
          LinkKeyInfo.UriOfInstance);
      alignment.changeLinkStatus(newLink.getId(),
          LinkStatus.ForcedByUser);
     
      // Create the semantic type object
      newType = new SemanticType(hNodeId,
          ClassInstanceLink.getFixedLabel(), classNode.getLabel(),
          SemanticType.Origin.User, 1.0);
    } else if (metaPropertyName
        .equals(METAPROPERTY_NAME.isSpecializationForEdge)) {
      LabeledLink propertyLink = alignment.getLinkById(metaPropertyId);
      if (propertyLink == null) {
        String errorMessage = "Error while specializing a link. The DefaultLink '"
            + metaPropertyId
            + "' should already be in the alignment, but it is not.";
        logger.error(errorMessage);
        return new UpdateContainer(new ErrorUpdate(errorMessage));
      }

      Node classInstanceNode = alignment.getNodeById(LinkIdFactory
          .getLinkSourceId(metaPropertyId));
      if (semanticTypeAlreadyExists) {
        clearOldSemanticTypeLink(oldIncomingLinkToColumnNode,
            oldDomainNode, alignment, classInstanceNode);
      }

      if (propertyLink instanceof DataPropertyLink) {
        String targetHNodeId = ((ColumnNode) propertyLink.getTarget())
            .getHNodeId();
        LabeledLink newLink = alignment.addDataPropertyOfColumnLink(classInstanceNode,
            columnNode, targetHNodeId, propertyLink.getId());
        alignment.changeLinkStatus(newLink.getId(),
            LinkStatus.ForcedByUser);
       
        // Create the semantic type object
        newType = new SemanticType(hNodeId,
            DataPropertyOfColumnLink.getFixedLabel(),
            classInstanceNode.getLabel(), SemanticType.Origin.User,
            1.0);
      } else if (propertyLink instanceof ObjectPropertyLink) {
        LabeledLink newLink = alignment.addObjectPropertySpecializationLink(
            classInstanceNode, columnNode, propertyLink.getId());
        alignment.changeLinkStatus(newLink.getId(),
            LinkStatus.ForcedByUser);

        // Create the semantic type object
        newType = new SemanticType(hNodeId,
            ObjectPropertySpecializationLink.getFixedLabel(),
            classInstanceNode.getLabel(), SemanticType.Origin.User,
            1.0);
      }

    } else if (metaPropertyName.equals(METAPROPERTY_NAME.isSubclassOfClass)) {
      Node classNode = alignment.getNodeById(metaPropertyId);
      if (semanticTypeAlreadyExists) {
        clearOldSemanticTypeLink(oldIncomingLinkToColumnNode,
            oldDomainNode, alignment, classNode);
      }

      if (classNode == null) {
        Label classNodeLabel = ontMgr.getUriLabel(metaPropertyUri);
        if (classNodeLabel == null) {
          String errorMessage = "Error while setting an advances subclass. MetaPropertyValue '"
              + metaPropertyUri
              + "' should be in the Ontology Manager, but it is not.";
          logger.error(errorMessage);
          return new UpdateContainer(new ErrorUpdate(errorMessage));
        }
        classNode = alignment.addInternalNode(classNodeLabel);
      }
      LabeledLink newLink = alignment.addColumnSubClassOfLink(classNode, columnNode);
      alignment.changeLinkStatus(newLink.getId(),
          LinkStatus.ForcedByUser);
     
      // Create the semantic type object
      newType = new SemanticType(hNodeId,
          ColumnSubClassLink.getFixedLabel(), classNode.getLabel(),
View Full Code Here

        ColumnNode target = new ColumnNode(nodeId, nodeId, sourceColumn.getColumnName(), null);
        if (!this.graphBuilder.addNode(target)) continue;;
        addedNodes.add(target);

        String linkId = LinkIdFactory.getLinkId(propertyUri, source.getId(), target.getId())
        LabeledLink link = new DataPropertyLink(linkId, new Label(propertyUri));
        if (!this.graphBuilder.addLink(source, target, link)) continue;;

        SemanticTypeMapping mp = new SemanticTypeMapping(sourceColumn, semanticType, (InternalNode)source, link, target);
        mappings.add(mp);
      }
View Full Code Here

    ColumnNode target = new ColumnNode(nodeId, nodeId, sourceColumn.getColumnName(), null);
    if (!this.graphBuilder.addNode(target)) return null;
    addedNodes.add(target);

    String linkId = LinkIdFactory.getLinkId(propertyUri, source.getId(), target.getId())
    LabeledLink link;
    if (propertyUri.equalsIgnoreCase(ClassInstanceLink.getFixedLabel().getUri()))
      link = new ClassInstanceLink(linkId);
    else {
      Label label = this.ontologyManager.getUriLabel(propertyUri);
      link = new DataPropertyLink(linkId, label);
View Full Code Here

    }

    for (DefaultLink link : oldLinks)
      this.graphBuilder.getGraph().removeEdge(link);

    LabeledLink newLink;
    for (int i = 0; i < newLinks.size(); i++) {
      newLink = newLinks.get(i);
      this.graphBuilder.addLink(sources.get(i), targets.get(i), newLink);
      this.graphBuilder.changeLinkWeight(newLink, weights.get(i));
    }
View Full Code Here

          continue;
       
        // removeEdge method should always be called before addEdge because the new edge has the same id
        // and JGraph does not add the duplicate link
//        Label label = new Label(inLink.getLabel().getUri(), inLink.getLabel().getNs(), inLink.getLabel().getPrefix());
        LabeledLink reverseLink = inLink.clone(); //new Link(inLink.getId(), label);
        tree.removeEdge(inLink);
        tree.addEdge(target, source, reverseLink);
        tree.setEdgeWeight(reverseLink, inLink.getWeight());
       
        // Save the reversed links information
View Full Code Here

TOP

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

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.