Package edu.isi.karma.rep.alignment

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


        reader.skipValue();
      }
    }
      reader.endObject();
     
      ColumnNode cn = new ColumnNode(id, hNodeId, columnName, null);
      return cn;
  }
View Full Code Here


    nodeId = nodeIdFactory.getNodeId(domainUri);
    source = new InternalNode(nodeId, new Label(domainUri));
    if (!this.graphBuilder.addNodeAndUpdate(source, addedNodes)) return null;

    nodeId = new RandomGUID().toString();
    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);
View Full Code Here

    /*** Add the appropriate nodes and links in alignment graph ***/
    newType = null;

    /** 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(),
          SemanticType.Origin.User, 1.0);
    }

    columnNode.setUserSelectedSemanticType(newType);

    // Update the alignment
    if(!this.isExecutedInBatch())
      alignment.align();

View Full Code Here

          }
        }


        String nodeId = new RandomGUID().toString();
        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

    nodeId = nodeIdFactory.getNodeId(domainUri);
    source = new InternalNode(nodeId, new Label(domainUri));
    if (!this.graphBuilder.addNodeAndUpdate(source, addedNodes)) return null;

    nodeId = new RandomGUID().toString();
    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);
View Full Code Here

    else writeLabel(writer, node.getLabel());
   
    writer.name("type").value(node.getType().toString());
//    SemanticTypeUtil semUtil = new SemanticTypeUtil();
    if (node instanceof ColumnNode) {
      ColumnNode cn = (ColumnNode) node;
      writer.name("hNodeId").value(cn.getHNodeId());
      writer.name("columnName").value(cn.getColumnName());
      writer.name("rdfLiteralType");
      if (cn.getRdfLiteralType() == null) writer.value(nullStr);
      else writeLabel(writer, cn.getRdfLiteralType());
      writer.name("userSelectedSemanticType");
      if (cn.getUserSelectedSemanticType() == null) writer.value(nullStr);
      else writeSemanticType(writer, cn.getUserSelectedSemanticType());
      writer.name("suggestedSemanticTypes");
      if (cn.getSuggestedSemanticTypes() == null) writer.value(nullStr);
//      ArrayList<SemanticType> semTypes = null;
//      semTypes = semUtil.getColumnSemanticSuggestions(workspace, worksheet, cn, 4);
//      if (semTypes == null) writer.value(nullStr);
      else {
        writer.beginArray();
        for (SemanticType semanticType : cn.getSuggestedSemanticTypes())
          writeSemanticType(writer, semanticType);
        writer.endArray();
      }
    }
    if (node instanceof LiteralNode) {
View Full Code Here

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

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

    Alignment alignment = AlignmentManager.Instance().getAlignment(workspace.getId(), worksheetId);
    oldAlignment = alignment.getAlignmentClone();
    oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
   
    // Remove it from the alignment
    ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
    columnNode.setForced(false);
    if (columnNode != null) {
      Set<LabeledLink> links =  alignment.getCurrentIncomingLinksToNode(columnNode.getId());
      if(links == null)
      {
        logger.error("No semantic type to unassign!");
        return new UpdateContainer(new ErrorUpdate("No semantic type to unassign!"));
      }
View Full Code Here

  // AddNode methods
 
  public ColumnNode addColumnNode(String hNodeId, String columnName, Label rdfLiteralType) {
   
    // use hNodeId as id of the node
    ColumnNode node = new ColumnNode(hNodeId, hNodeId, columnName, rdfLiteralType);
    if (this.graphBuilder.addNodeAndUpdate(node)) {
      this.sourceColumnNodes.add(node);
      return node;
    }
    return null;
View Full Code Here

TOP

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

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.