Package edu.isi.karma.controller.update

Examples of edu.isi.karma.controller.update.ErrorUpdate


    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) {
      if (path.getLeaf().getId().equals(hNodeId)) {
        currentPath = path;
        columnName = path.getLeaf().getColumnName();
        break;
      }
    }

    // Remove the nodes (if any) from the outlier tag
    Collection<edu.isi.karma.rep.Node> nodes = new ArrayList<edu.isi.karma.rep.Node>();
    //TODO What does that mean?
    worksheet.getDataTable().collectNodes(currentPath, nodes, SuperSelectionManager.DEFAULT_SELECTION);
    Set<String> nodeIds = new HashSet<String>();
    for (edu.isi.karma.rep.Node node : nodes) {
      nodeIds.add(node.getId());
    }
    workspace.getTagsContainer().getTag(TagName.Outlier)
        .removeNodeIds(nodeIds);

    // Update the container
    UpdateContainer c = new UpdateContainer();
   
    c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
    // Add the alignment update
    try {
      c.add(new AlignmentSVGVisualizationUpdate(worksheetId, alignment));
    } catch (Exception e) {
      logger.error("Error occured while unassigning the semantic type!",e);
      return new UpdateContainer(new ErrorUpdate("Error occured while unassigning the semantic type!"));
    }
    c.add(new TagsUpdate());
   
    return c;
  }
View Full Code Here


    try {
      c.add(new SemanticTypesUpdate(worksheet, worksheetId, oldAlignment));
      c.add(new AlignmentSVGVisualizationUpdate(worksheetId, oldAlignment));
    } catch (Exception e) {
      logger.error("Error occured during undo of unassigning the semantic type!", e);
      return new UpdateContainer(new ErrorUpdate("Error occured during undo of unassigning the semantic type!"));
    }
    return c;
  }
View Full Code Here

  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    TripleStoreUtil util = new TripleStoreUtil();
    try {
      util.deleteMappingFromTripleStore(tripleStoreURL, context, mappingURI);
    } catch (KarmaException e) {
      return new UpdateContainer(new ErrorUpdate("Error occured while deleting R2RML model!"));
    }
    UpdateContainer uc = new UpdateContainer();
    uc.add(new AbstractUpdate() {
      public void generateJson(String prefix, PrintWriter pw, 
          VWorkspace vWorkspace) {
View Full Code Here

          }
        }
      });
    }
    catch(Exception e) {
      return new UpdateContainer(new ErrorUpdate("Unable to get mappings with metadata: "+ e.getMessage()));
    }
  }
View Full Code Here

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

      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;
    }

    uc.append(WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace, alignment));
    return uc;
View Full Code Here

   
    try {
      JSONArray historyJson  = extractHistoryFromModel(workspace, c);
      HistoryJSONEditor editor = new HistoryJSONEditor(new JSONArray(historyJson.toString()), workspace, worksheetId);
      if (null == historyJson || historyJson.length() == 0) {
        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();
      }
      else {
        editor.deleteExistingTransformationAndModelingCommands();
        historyJson = editor.getHistoryJSON();
      }
      System.out.println(editor.getHistoryJSON().toString(4));
      UpdateContainer hc = histExecutor.executeAllCommands(historyJson);
      if(hc != null) {
        hc.removeUpdateByClass(HistoryAddCommandUpdate.class);
        hc.removeUpdateByClass(InfoUpdate.class);
        hc.removeUpdateByClass(ErrorUpdate.class);
        hc.removeUpdateByClass(AlignmentSVGVisualizationUpdate.class);
        c.append(hc);
      }
      alignment = alignMgr.getAlignment(workspace.getId(), worksheetId);
      if(alignment != null)
        c.add(new AlignmentSVGVisualizationUpdate(worksheetId, alignment));
    } catch (Exception e) {
      String msg = "Error occured while applying history!";
      logger.error(msg, e);
      return new UpdateContainer(new ErrorUpdate(msg));
    }
    c.add(new InfoUpdate("Model successfully applied!"));
    c.add(new AbstractUpdate() {

      @Override
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
   
    if(isDeprecated())
    {
      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!"));
    }

    try {
      // Generate the KR2RML data structures for the RDF generation
      /*final ErrorReport errorReport = new ErrorReport();
      KR2RMLMappingGenerator mappingGen = new KR2RMLMappingGenerator(
          workspace, worksheet,
          alignment, worksheet.getSemanticTypes(), rdfSourcePrefix, rdfSourceNamespace,
          false, errorReport);
      KR2RMLMapping mapping = mappingGen.getKR2RMLMapping();
      KR2RMLWorksheetRDFGenerator rdfGen = new KR2RMLWorksheetRDFGenerator(worksheet,
          workspace.getFactory(), workspace.getOntologyManager(),
          pw, mapping, errorReport, false);
     
      // Create empty data structures
      Set<String> existingTopRowTriples = new HashSet<String>();
      Set<String> predicatesCovered = new HashSet<String>();
      Map<String, ReportMessage> predicatesFailed = new HashMap<String, ReportMessage>();
      Set<String> predicatesSuccessful = new HashSet<String>();
     
      Node node = workspace.getFactory().getNode(nodeId);
      rdfGen.generateTriplesForCell(node, existingTopRowTriples, node.getHNodeId(),
        predicatesCovered, predicatesFailed, predicatesSuccessful);*/
     
      return new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject outputObject = new JSONObject();
         
          try {
            outputObject.put(JsonKeys.updateType.name(),
                "PublishCellRDFUpdate");
            String rdfCellEscapeString = StringEscapeUtils
                .escapeHtml(outRdf.toString());
            outputObject.put(JsonKeys.cellRdf.name(),
                rdfCellEscapeString.replaceAll("\\n", "<br />"));
            outputObject.put(JsonKeys.worksheetId.name(),
                worksheetId);
            pw.println(outputObject.toString(4));
          } catch (JSONException e) {
            logger.error("Error occured while generating JSON!");
          }
        }
      });
    } catch (Exception e) {
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
    }
  }
View Full Code Here

      return c;
    } catch (Exception e) {
      logger.error("Error in UnfoldCommand" + e.toString());
      e.printStackTrace();
      Util.logException(logger, e);
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
    }
  }
View Full Code Here

    worksheetName = worksheet.getTitle();

    // Generate the semantic types for the worksheet
    OntologyManager ontMgr = workspace.getOntologyManager();
    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());
     
      // Add the visualization update
      c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
      c.add(new AlignmentSVGVisualizationUpdate(
          worksheetId, alignment));
    } catch (Exception e) {
      logger.error("Error occured while generating the model Reason:.", e);
      return new UpdateContainer(new ErrorUpdate(
          "Error occured while generating the model for the source."));
    }
    c.add(new TagsUpdate());
   
    return c;
View Full Code Here

TOP

Related Classes of edu.isi.karma.controller.update.ErrorUpdate

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.