Package edu.isi.karma.modeling.alignment

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


    final String rdfFileName = workspace.getCommandPreferencesId() + worksheetId + ".ttl";
    final String rdfFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.RDF_PUBLISH_DIR)
        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


  }
 
  @Override
  public void saveHistory(String workspaceId, String worksheetId,
      JSONArray history) throws Exception {
    Alignment alignment = AlignmentManager.Instance().getAlignment(workspaceId, worksheetId);
    this.saveAlignment(alignment, history);
   
  }
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    final Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
    final Set<LabeledLink> incomingLinks = alignment.getCurrentIncomingLinksToNode(nodeId);
    final Set<LabeledLink> outgoingLinks = alignment.getCurrentOutgoingLinksToNode(nodeId);
   
    UpdateContainer upd = new UpdateContainer(new AbstractUpdate() {
      @Override
      public void generateJson(String prefix, PrintWriter pw,
          VWorkspace vWorkspace) {
        JSONObject obj = new JSONObject();
        JSONArray edgesArray = new JSONArray();

        try {
          obj.put(JsonKeys.updateType.name(), "GetCurrentLinks");
         
          /** Add the incoming links **/
          if (incomingLinks != null && !incomingLinks.isEmpty()) {
            for (LabeledLink inLink:incomingLinks) {
                addLink(inLink, LINK_DIRECTION.incoming, edgesArray);
            }
          }
         
          /** Add the outgoing links **/
          if (outgoingLinks != null && !outgoingLinks.isEmpty()) {
            for (LabeledLink outLink:outgoingLinks) {
              if (!(outLink.getTarget() instanceof ColumnNode)) {
                addLink(outLink, LINK_DIRECTION.outgoing, edgesArray);
              }
            }
          }
         
          obj.put(JsonKeys.edges.name(), edgesArray);
          pw.println(obj.toString());
        } catch (JSONException e) {
          e.printStackTrace();
        }
      }
     
      private void addLink(LabeledLink link, LINK_DIRECTION direction, JSONArray edgesArray)
          throws JSONException {
        String linkLabel = link.getLabel().getDisplayName();
       
        Node edgeSource = alignment.getNodeById(LinkIdFactory.
            getLinkSourceId(link.getId()));
        Node edgeTarget = alignment.getNodeById(LinkIdFactory.
            getLinkTargetId(link.getId()));
       
        String edgeSourceLabel = edgeSource.getDisplayId();
        String edgeSourceId = edgeSource.getId();
        String edgeSourceUri = edgeSource.getUri();
View Full Code Here

   
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(worksheet);
    RepFactory f = workspace.getFactory();
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        AlignmentManager.Instance().constructAlignmentId(workspace.getId(),
            worksheetId));
    OntologyManager ontMgr = workspace.getOntologyManager();
    // Set the prefix and namespace to be used while generating RDF
    fetchRdfPrefixAndNamespaceFromPreferences(workspace);
View Full Code Here


    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(worksheet);
    RepFactory f = workspace.getFactory();
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        AlignmentManager.Instance().constructAlignmentId(workspace.getId(),
            worksheetId));
    OntologyManager ontMgr = workspace.getOntologyManager();
    // Set the prefix and namespace to be used while generating RDF
    fetchRdfPrefixAndNamespaceFromPreferences(workspace);
View Full Code Here

    SemanticTypes types = worksheet.getSemanticTypes();
    oldSemanticType = types.getSemanticTypeForHNodeId(hNodeId);
    types.unassignColumnSemanticType(hNodeId);

    // Save the original alignment for undo
    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!"));
      }
      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);
     
    }
    if(!this.isExecutedInBatch())
      alignment.align();
   
    // Get the column name
    HNodePath currentPath = null;
    List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
    for (HNodePath path : columnPaths) {
View Full Code Here

                break;
        case "data": uc.add(new WorksheetDataUpdate(worksheetId, sel));
                break;
        case "alignment":
        {
          Alignment alignment = AlignmentManager.Instance().getAlignmentOrCreateIt(
              workspace.getId(), worksheetId, workspace.getOntologyManager());
          uc.add(new AlignmentSVGVisualizationUpdate(worksheetId, alignment));
          break;
        }
        case "semanticTypes":
        {
          Alignment alignment = AlignmentManager.Instance().getAlignmentOrCreateIt(
              workspace.getId(), worksheetId, workspace.getOntologyManager());
          uc.add(new SemanticTypesUpdate(workspace.getWorksheet(worksheetId), worksheetId, alignment));
          break;
        }
        case "regenerate":
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
   
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    if(alignment == null || alignment.isEmpty()) {
      logger.error("Alignment cannot be null before calling this command since the alignment is created while " +
          "setting the semantic types.");
      return new UpdateContainer(new ErrorUpdate("Error occured while generating the model for the source."));
    }
    // Save the original alignment for undo
    oldAlignment = alignment.getAlignmentClone();
    oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
   
    // Set the other links to the target node to normal
    LinkIdFactory.getLinkTargetId(edgeId);
    Set<LabeledLink> currentLinks = alignment.getCurrentIncomingLinksToNode(LinkIdFactory.getLinkTargetId(edgeId));
    if (currentLinks != null && !currentLinks.isEmpty()) {
      for (LabeledLink currentLink: currentLinks) {
        //if (currentLink.getSource().getId().equals(newLink.getSource().getId()))
          alignment.changeLinkStatus(currentLink.getId(), LinkStatus.Normal);
      }
    }
   
    // Change the status of the user selected edge
    alignment.changeLinkStatus(edgeId, LinkStatus.ForcedByUser);
    if(!this.isExecutedInBatch())
      alignment.align();
   
    return getAlignmentUpdateContainer(alignment, worksheet, workspace);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    logCommand(logger, workspace);
 
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        alignmentId);

    // Save the original alignment for undo
    oldAlignment = alignment.getAlignmentClone();
    oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
        .getGraph().clone();

    UpdateContainer uc = new UpdateContainer();
    try {
      if(nodeId == null) {
        final LiteralNode ln = alignment.addLiteralNode(literalValue, literalType, isUri);
        uc.add(new AbstractUpdate() {

          @Override
          public void generateJson(String prefix, PrintWriter pw,
              VWorkspace vWorkspace) {
            try {
              JSONStringer jsonStr = new JSONStringer();
             
              JSONWriter writer = jsonStr.object();
              writer.key("worksheetId").value(worksheetId);
              writer.key("updateType").value("AddLiteralNodeUpdate")
              writer.key("hNodeId").value(ln.getId());
              writer.key("uri").value(literalValue);
              writer.endObject();
              pw.print(writer.toString());
            } catch (JSONException e) {
              logger.error("Error occured while writing to JSON!", e);
             
            }
           
          }
         
        });
      } else {
        alignment.updateLiteralNode(nodeId, literalValue, literalType, isUri);
      }
     
      if(!this.isExecutedInBatch())
        alignment.align();
     
    } catch (Exception e) {
      logger.error("Error adding Literal Node:" , e);
      uc.add(new ErrorUpdate("Error adding Literal Node"));
      return uc;
View Full Code Here

      return new UpdateContainer(new ErrorUpdate("PublishRDFCellCommand is currently not supported"));
    }
    //Worksheet worksheet = workspace.getWorksheet(worksheetId);

    // Get the alignment for this worksheet
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        AlignmentManager.Instance().constructAlignmentId(workspace.getId(),
            worksheetId));
   
    if (alignment == null || alignment.isEmpty()) {
      logger.info("Alignment is NULL for " + worksheetId);
      return new UpdateContainer(
          new ErrorUpdate("Worksheet not modeled!"));
    }
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.