Package edu.isi.karma.rep.alignment

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


    List<LabeledLink> possibleLinks  = new ArrayList<LabeledLink>();
    List<DefaultLink> tempDefault = null;
    List<LabeledLink> tempLabeled = null;
    HashSet<DefaultLink> allLinks = new HashSet<DefaultLink>();

    Node node = this.getNodeById(nodeId);
    if (node == null) return possibleLinks;
   
    Set<DefaultLink> incomingLinks = this.graphBuilder.getGraph().incomingEdgesOf(node);
    if (incomingLinks != null) {
      tempDefault = Arrays.asList(incomingLinks.toArray(new DefaultLink[0]));
View Full Code Here


    List<LabeledLink> possibleLinks  = new ArrayList<LabeledLink>();
    List<DefaultLink> tempDefault = null;
    List<LabeledLink> tempLabeled = null;
    HashSet<DefaultLink> allLinks = new HashSet<DefaultLink>();

    Node node = this.getNodeById(nodeId);
    if (node == null || node instanceof ColumnNode) return possibleLinks;
   
    Set<DefaultLink> incomingLinks = this.graphBuilder.getGraph().incomingEdgesOf(node);
    if (incomingLinks != null) {
      tempDefault = Arrays.asList(incomingLinks.toArray(new DefaultLink[0]));
View Full Code Here

          tree.addVertex(cn);
        }
      }
    }
   
    Node source, target;
    for (LabeledLink l : model.getGraph().edgeSet()) {
     
      if (!(l.getSource() instanceof InternalNode)) {
        logger.error("column node cannot have an outgoing link!");
        return;
      }

      source = modelToAlignmentNode.get(l.getSource());
      target = modelToAlignmentNode.get(l.getTarget());
     
      if (source == null || target == null)
        continue;

      String id = LinkIdFactory.getLinkId(l.getUri(), source.getId(), target.getId());
      LabeledLink newLink = l.copy(id);
     
        if (newLink == null) continue;
     
      this.getGraphBuilder().addLink(source, target, newLink); // returns false if link already exists
      tree.addEdge(source, target, newLink);
           
      if (target instanceof ColumnNode) {
        SemanticType st = new SemanticType(((ColumnNode)target).getHNodeId(),
            newLink.getLabel(), source.getLabel(), SemanticType.Origin.User, 1.0);
        semanticTypes.add(st);
      }
     
    }
View Full Code Here

      }
      if (onlyAddPatterns)
        if (modelIds == null || modelIds.isEmpty())
          continue;
     
      Node source = e.getSource();
      Node target = e.getTarget();
     
      org.kohsuke.graphviz.Node n = nodeIndex.get(source);
      String sourceId = source.getId();
      String sourceUri = sourceId;//source.getLabel().getUri();
      String sourceLocalName = getLocalName(sourceUri);
      String sourceLabel;
      if (n == null) {
        n = new org.kohsuke.graphviz.Node();
//        label = (uri == null || uri.trim().length() == 0?id:uri));
        sourceLabel = (sourceLocalName == null || sourceLocalName.trim().length() == 0?sourceId:sourceLocalName);
        if (showNodeMetaData) {
//          sourceLabel += metaDataSeparator + getModelIds(source.getModelIds());
        }
        n.attr("label", sourceLabel);
        nodeIndex.put(source, n);
     
        if (source instanceof ColumnNode// attribute
          gViz.nodeWith(parameterNodeStyle);
        else if (source instanceof LiteralNode// literal
          gViz.nodeWith(literalNodeStyle);
        else  // internal node
          gViz.nodeWith(internalNodeStyle);
         
        gViz.node(n);
      }

      n = nodeIndex.get(target);
      String targetId = target.getId();
      String targetUri = targetId;//target.getLabel().getUri();
      String targetLocalName = getLocalName(targetUri);
      String targetLabel;
      if (n == null) {
        n = new org.kohsuke.graphviz.Node();
View Full Code Here

          List<String> columnsCovered = new ArrayList<String>();
          Set<LabeledLink> links = dm.getOutgoingEdgesOf(treeNode);
          Iterator<LabeledLink> linkIterator = links.iterator();
          while(linkIterator.hasNext())
          {
            Node n = linkIterator.next().getTarget()
            if(n instanceof ColumnNode)
            {
              String columnName = translator.getColumnNameForHNodeId(((ColumnNode)n).getId());
              columnsCovered.add(columnName);
            }
View Full Code Here

        Set<LabeledLink> outgoingLinks = alignmentGraph.outgoingEdgesOf(node);
        for (LabeledLink link:outgoingLinks) {
         
          if (link instanceof ClassInstanceLink || link instanceof ColumnSubClassLink) {
            Node tNode = link.getTarget();
            if (tNode instanceof ColumnNode) {
              ColumnNode cnode = (ColumnNode) tNode;
              String hNodeId = cnode.getHNodeId();
              String columnName = translator.getColumnNameForHNodeId(hNodeId);
              ColumnTemplateTerm cnTerm = new ColumnTemplateTerm(columnName);
View Full Code Here

              || olink instanceof DataPropertyOfColumnLink 
              || olink instanceof ColumnSubClassLink)
            continue;
         
          PredicateObjectMap poMap = new PredicateObjectMap(PredicateObjectMap.getNewId(), subjTrMap);
          Node target = olink.getTarget();
         
          // Create an object property map
          if (target instanceof InternalNode) {
            // Get the RefObjMap object for the objectmap
            TriplesMap objTrMap = r2rmlMapping.getTriplesMapIndex().get(target.getId());
            RefObjectMap refObjMap = new RefObjectMap(RefObjectMap.getNewRefObjectMapId(), objTrMap);
            ObjectMap objMap = new ObjectMap(target.getId(), refObjMap);
            poMap.setObject(objMap);
           
            // Create the predicate
            Predicate pred = new Predicate(olink.getId());
           
            // Check if a specialization link exists
            LabeledLink specializedEdge = getSpecializationLinkIfExists(olink, node);
            if (specializedEdge != null) {
              Node specializedEdgeTarget = specializedEdge.getTarget();
              if (specializedEdgeTarget instanceof ColumnNode) {
                String columnName = translator.getColumnNameForHNodeId(((ColumnNode) specializedEdgeTarget).getHNodeId());
                ColumnTemplateTerm cnTerm =
                    new ColumnTemplateTerm(columnName);
                pred.getTemplate().addTemplateTermToSet(cnTerm);
              }
            } else {
              pred.getTemplate().addTemplateTermToSet(
                  new StringTemplateTerm(olink.getLabel().getUri(), true));
            }
            poMap.setPredicate(pred);
            if (generateInverse)
              addInversePropertyIfExists(subjMap, poMap, olink, subjTrMap);
           
            // Add the links in the graph links data structure
            TriplesMapLink link = new TriplesMapLink(subjTrMap, objTrMap, poMap)
            r2rmlMapping.getAuxInfo().getTriplesMapGraph().addLink(link);
          }
         
          else if(target instanceof LiteralNode) {
            LiteralNode lnode = (LiteralNode) target;
           
            //Create the object
            TemplateTermSet termSet = new TemplateTermSet();
            StringTemplateTerm literalTerm = new StringTemplateTerm(lnode.getValue(), lnode.isUri());
            termSet.addTemplateTermToSet(literalTerm);
           
            StringTemplateTerm rdfLiteralTypeTerm = new StringTemplateTerm(lnode.getLabel().getUri(), true);
            TemplateTermSet rdfLiteralTypeTermSet = new TemplateTermSet();
            rdfLiteralTypeTermSet.addTemplateTermToSet(rdfLiteralTypeTerm);
           
            ObjectMap objMap = new ObjectMap(target.getId(), termSet, rdfLiteralTypeTermSet);
            poMap.setObject(objMap);
           
            // Create the predicate
            Predicate pred = new Predicate(olink.getId());
            pred.getTemplate().addTemplateTermToSet(
                  new StringTemplateTerm(olink.getLabel().getUri(), true));
           
            poMap.setPredicate(pred);
            if (generateInverse)
              addInversePropertyIfExists(subjMap, poMap, olink, subjTrMap);
           
          }
         
          // Create a data property map
          else if(target instanceof ColumnNode) {
            // Create the object map
            ColumnNode cnode = (ColumnNode) target;
            String hNodeId = cnode.getHNodeId();
            String columnName = translator.getColumnNameForHNodeId(hNodeId);
            ColumnTemplateTerm cnTerm = new ColumnTemplateTerm(columnName);
            TemplateTermSet termSet = expandColumnTemplateTermForPyTransforms(
                hNodeId, cnTerm);
           
            String rdfLiteralUri =   cnode.getRdfLiteralType() == null? "" : cnode.getRdfLiteralType().getUri();
            StringTemplateTerm rdfLiteralTypeTerm = new StringTemplateTerm(rdfLiteralUri, true);
            TemplateTermSet rdfLiteralTypeTermSet = new TemplateTermSet();
            rdfLiteralTypeTermSet.addTemplateTermToSet(rdfLiteralTypeTerm);

            ObjectMap objMap = new ObjectMap(hNodeId, termSet, rdfLiteralTypeTermSet);
            poMap.setObject(objMap);
           
            // Create the predicate
            Predicate pred = new Predicate(olink.getId());
           
            // Check if a specialization link exists
            LabeledLink specializedEdge = getSpecializationLinkIfExists(olink, node);
            if (specializedEdge != null) {
              Node specializedEdgeTarget = specializedEdge.getTarget();
              if (specializedEdgeTarget instanceof ColumnNode) {
                String targetColumnName = translator.getColumnNameForHNodeId(((ColumnNode) specializedEdgeTarget).getHNodeId());
                ColumnTemplateTerm cnsplTerm =
                    new ColumnTemplateTerm(targetColumnName);
                pred.getTemplate().addTemplateTermToSet(cnsplTerm);
View Full Code Here

          return olink;
      }
      // Check for the data property specialization
      else if (olink instanceof DataPropertyOfColumnLink) {
        DataPropertyOfColumnLink dlink = (DataPropertyOfColumnLink) olink;
        Node target = link.getTarget();
        if (target instanceof ColumnNode) {
          ColumnNode cnode = (ColumnNode) target;
          if (dlink.getSpecializedColumnHNodeId().equals(cnode.getId()))
            return dlink;
        }
View Full Code Here

    }
   
    String ns = Namespaces.KARMA;
    // Create the internal node for worksheet
    Label internalNodeLabel = new Label(ns + worksheet.getTitle().trim().replaceAll(" ", "_"), ns, "karma");
    Node classNode = alignment.addInternalNode(internalNodeLabel);
   
    // Create column nodes for all columns
    List<HNode> sortedLeafHNodes = new ArrayList<HNode>();
    worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
    for (HNode hNode : sortedLeafHNodes){
View Full Code Here

            return l1name.compareTo(l2name);
          }
         
        });
        for (LabeledLink link : links) {
          Node target = link.getTarget();
          if(target instanceof ColumnNode) { //ALready covered in semantic types
            continue;
          }
         
          Node source = link.getSource();
          String property = getPropertyName(link.getLabel());
          String to = getClassName(target);
          String from = getClassName(source);
         
          pw.println("| `" + from + "` | `" + property + "` | `" + to + "`|");
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.