Examples of LabeledLink


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

    /** 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

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

        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

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

    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

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

    }

    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

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

          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

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

    writer.name("weight").value(link.getWeight());
    writer.name("type").value(link.getType().toString());
    if (link instanceof CompactObjectPropertyLink)
      writer.name("objectPropertyType").value( ((CompactObjectPropertyLink)link).getObjectPropertyType().toString());
    else if (link instanceof LabeledLink) {
      LabeledLink l = (LabeledLink)link;
      writer.name("label");
      if (l.getLabel() == null) writer.value(nullStr);
      else writeLabel(writer, l.getLabel());
      if (l instanceof DataPropertyOfColumnLink)
        writer.name("hNodeId").value( ((DataPropertyOfColumnLink)l).getSpecializedColumnHNodeId());
      if (l instanceof ObjectPropertyLink)
        writer.name("objectPropertyType").value( ((ObjectPropertyLink)l).getObjectPropertyType().toString());
      if (l instanceof ObjectPropertySpecializationLink) {
        writer.name("specializedLink").value(((ObjectPropertySpecializationLink)l).getSpecializedLinkId());
      }
      writer.name("status").value(l.getStatus().toString());
      writer.name("keyInfo").value(l.getKeyType().toString());
      writer.name("modelIds");
      writeModelIds(writer, l.getModelIds());
    }
    writer.endObject();
  }
View Full Code Here

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

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

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

      if(links == null)
      {
        logger.error("No semantic type to unassign!");
        return new UpdateContainer(new ErrorUpdate("No semantic type to unassign!"));
      }
      LabeledLink currentLink = links.iterator().next();
//      String domainNodeId = currentLink.getSource().getId();
      // Remove the existing link
      alignment.removeLink(currentLink.getId());
      // Remove the column node
//      alignment.removeNode(columnNode.getId());
      // Remove the source node
//      alignment.removeNode(domainNodeId);
     
View Full Code Here

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

    return null
  }
 
  public void changeLinkWeight(String linkId, double weight) {
   
    LabeledLink link = this.getLinkById(linkId);
    if (link == null) {
      logger.error("Could not find the link with the id " + linkId);
      return;
    }
   
View Full Code Here

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

  }
 
  public void changeLinkStatus(String linkId, LinkStatus newStatus) {

    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
      this.graphBuilder.changeLinkStatus(link, newStatus);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.