Package edu.isi.karma.modeling.alignment

Examples of edu.isi.karma.modeling.alignment.Alignment


        return new UpdateContainer(new ErrorUpdate("No history found in R2RML Model!"));
      }
      WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor(
          worksheetId, workspace);
      AlignmentManager alignMgr = AlignmentManager.Instance();
      Alignment alignment = alignMgr.getAlignment(workspace.getId(), worksheetId);
      if (override || alignment == null || alignment.GetTreeRoot() == null) {
        String alignmentId = alignMgr.constructAlignmentId(workspace.getId(), worksheetId);
        alignMgr.removeAlignment(alignmentId);
        alignMgr.getAlignmentOrCreateIt(workspace.getId(), worksheetId, workspace.getOntologyManager());
        editor.deleteExistingTransformationCommands();
        historyJson = editor.getHistoryJSON();
View Full Code Here


  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    final boolean modelExist;
    Alignment alignment = AlignmentManager.Instance().getAlignment(workspace.getId(), worksheetId);
    if (alignment == null || alignment.GetTreeRoot() == null)
      modelExist = false;
    else
      modelExist = true;
    return new UpdateContainer(new AbstractUpdate() {
View Full Code Here

  }
 
  // TODO break this method up. 
  public UpdateContainer computeAlignmentAndSemanticTypesAndCreateUpdates(Workspace workspace, HNodePath path)
  {
    Alignment alignment = getAlignmentOrCreateIt(workspace);
    return WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace, alignment);
  }
View Full Code Here

  }
   
  // TODO break this method up. 
  public UpdateContainer computeAlignmentAndSemanticTypesAndCreateUpdates(Workspace workspace)
  {
    Alignment alignment = getAlignmentOrCreateIt(workspace);
    return WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace, alignment);
  }
View Full Code Here

    if(ontMgr.isEmpty())
      return new UpdateContainer(new ErrorUpdate("No ontology loaded."));


    String alignmentId = AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId);
    Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
    if (alignment == null) {
      alignment = new Alignment(ontMgr);
      AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
    }
   
    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){
      String columnName = hNode.getColumnName().trim().replaceAll(" ", "_");
      ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNode.getId());
     
      List<LabeledLink> columnNodeIncomingLinks = alignment.getIncomingLinks(columnNode.getId());
      if (columnNodeIncomingLinks == null || columnNodeIncomingLinks.isEmpty()) { // SemanticType not yet assigned
        Label propertyLabel = new Label(ns + columnName, ns, "karma");
        alignment.addDataPropertyLink(classNode, columnNode, propertyLabel);
       
        // Create a semantic type object
        SemanticType type = new SemanticType(hNode.getId(), propertyLabel, internalNodeLabel, SemanticType.Origin.User, 1.0);
        worksheet.getSemanticTypes().addType(type);
        columnNode.setUserSelectedSemanticType(type);
      } else {
        // User-defined: do nothing
      }
    }
    if(!this.isExecutedInBatch())
      alignment.align();
   
    try {
      // Save the semantic types in the input parameter JSON
      saveSemanticTypesInformation(worksheet, workspace, worksheet.getSemanticTypes().getListOfTypes());
     
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    final Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
//    OntologyManager ontMgr = workspace.getOntologyManager();
   
    Map<String, Label> linkList = new HashMap<String, Label>();
    if (linksRange == ALTERNATIVE_LINKS_RANGE.allObjectProperties) {
      linkList = workspace.
          getOntologyManager().getObjectProperties();
     
    } else if (linksRange == ALTERNATIVE_LINKS_RANGE.compatibleLinks) {
     
      List<LabeledLink> compatibleLinks = alignment.getLinks(sourceNodeId, targetNodeId);
      if (compatibleLinks != null) {
        for (LabeledLink link : compatibleLinks) {
          if (link.getLabel() != null)
            linkList.put(link.getLabel().getUri(), link.getLabel());
        }
View Full Code Here

      Map<String, Label> linkList = ontMgr.getDataPropertiesByDomain(classURI, true);
      for(Label label : linkList.values()) {
        properties.add(new DataPropertyLink(label.getUri(), label));
      }
    } else if(propertiesRange == INTERNAL_PROP_RANGE.existingProperties) {
      Alignment alignment = AlignmentManager.Instance().getAlignmentOrCreateIt(workspace.getId(), worksheetId, ontMgr);
      Set<String> steinerTreeNodeIds = new HashSet<String>();
      if (alignment != null && !alignment.isEmpty()) {
        DirectedWeightedMultigraph<Node, LabeledLink> steinerTree = alignment.getSteinerTree();
        for (Node node: steinerTree.vertexSet()) {
          if (node.getType() == NodeType.InternalNode) {
            steinerTreeNodeIds.add(node.getId());
          }
        }
       
        List<LabeledLink> specializedLinks = new ArrayList<LabeledLink>();
        Set<LabeledLink> temp = null;
        temp = alignment.getLinksByType(LinkType.DataPropertyLink);
        if (temp != null) specializedLinks.addAll(temp);
        for (LabeledLink link:steinerTree.edgeSet())
          if (link instanceof ObjectPropertyLink)
            specializedLinks.add(link);
       
View Full Code Here

    } else
      service = wk.getMetadataContainer().getService();
   
    AlignmentManager mgr = AlignmentManager.Instance();
    String alignmentId = mgr.constructAlignmentId(workspace.getId(), worksheetId);
    Alignment al = mgr.getAlignment(alignmentId);
   
    if (al == null) {
      logger.error("The alignment model is null.");
      if (service == null)
        return new UpdateContainer(new ErrorUpdate(
          "Error occured while publishing the source. The alignment model is null."));
    }
   
    DirectedWeightedMultigraph<Node, LabeledLink> tree = null;
    if (al != null)
      tree = al.getSteinerTree();
   
    if (tree == null) {
      logger.error("The alignment tree is null.");
      if (service == null)
        return new UpdateContainer(new ErrorUpdate(
View Full Code Here

    final String graphUri = "http://localhost/"+workspace.getCommandPreferencesId() + "/" + worksheetId + "/" + ts;

    logger.info("Generating RDF for current worksheet - " + rdfFileName);
   
    // Get the alignment for this worksheet
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId));

    if (alignment == null) {
      logger.info("Alignment is NULL for " + worksheetId);
      return new UpdateContainer(new ErrorUpdate(
View Full Code Here

  private void writeSemanticTypes(Workspace workspace, Worksheet worksheet, PrintWriter pw) {
   
    pw.println("| Column | Property | Class |");
    pw.println("|  ----- | -------- | ----- |");

    Alignment alignment = AlignmentManager.Instance().getAlignment(workspace.getId(), worksheet.getId());
    if(alignment != null) {
       List<Node> columnNodes = Arrays.asList(alignment.getNodesByType(NodeType.ColumnNode).toArray(new Node[0]));
       Collections.sort(columnNodes, new Comparator<Node>() {
          @Override
          public int compare(Node n1, Node n2) {
            String l1name = getClassName(n1);
            String l2name = getClassName(n2);
            return l1name.compareTo(l2name);
          }
        });
      
       if(columnNodes != null) {
         for(Node node : columnNodes) {
           if(node instanceof ColumnNode) {
             ColumnNode columnNode = (ColumnNode)node;
             String columnName = getClassName(columnNode);
             List<LabeledLink> links = alignment.getIncomingLinks(node.getId());
             for(LabeledLink link : links) {
               String property = getPropertyName(link.getLabel());
               String classname = getClassName(link.getSource());
               pw.println("| _" + columnName + "_ | `" + property + "` | `" + classname + "`|");
             }
View Full Code Here

TOP

Related Classes of edu.isi.karma.modeling.alignment.Alignment

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.