Package edu.isi.karma.controller.update

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


  }

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
   
    UpdateContainer c = new UpdateContainer();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    OntologyManager ontologyManager = workspace.getOntologyManager();
    if(ontologyManager.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) {
      logger.info("Alignment is NULL for " + worksheetId);
      return new UpdateContainer(new ErrorUpdate(
          "Please align the worksheet before generating R2RML Model!"));
    }

//    Set<ColumnNode> alignmentColumnNodes = alignment.getSourceColumnNodes();
//    if (alignmentColumnNodes != null) {
//      for (ColumnNode cn : alignmentColumnNodes) {
//        if (!cn.hasUserType())
//          worksheet.getSemanticTypes().unassignColumnSemanticType(cn.getHNodeId());
//      }
//    }

    alignment = initialAlignment;
    alignment.setGraph(initialGraph);
    if(!this.isExecutedInBatch())
      alignment.align();
    AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
   

    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


    @Override
    public UpdateContainer doIt(Workspace workspace) throws CommandException {
        //save the preferences

        UpdateContainer c = new UpdateContainer();

        List<String> urls = new ArrayList<String>();
        urls.add(serviceUrl);
        List<String> ids = new ArrayList<String>();
        ids.add("1");
        try {
            InvocationManager invocatioManager = new InvocationManager(null, ids, urls, encoding);
            String json = invocatioManager.getServiceJson(includeInputAttributes);
      logger.debug(json);
            Import imp = new JsonImport(json, worksheetName, workspace, encoding, -1);

            Worksheet wsht = imp.generateWorksheet();
            c.add(new ImportServiceCommandPreferencesUpdate(serviceUrl, worksheetName));

            c.add(new WorksheetListUpdate());
            c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(wsht.getId(), SuperSelectionManager.DEFAULT_SELECTION));
            return c;
        } catch (Exception e) {
            logger.error("Error occured while creating worksheet from web-service: " + serviceUrl);
            return new UpdateContainer(new ErrorUpdate("Error creating worksheet from web-service"));
        }
    }
View Full Code Here

    try {
      final boolean success = ontManager.doImportAndUpdateCache(
          getFile(), encoding);
      logger.debug("Done loading ontology: "
          + getFile().getAbsolutePath());
      return new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          pw.println("{");
          pw.println("  \"" + GenericJsonKeys.updateType.name()
              + "\": \""
              + ImportOntologyCommand.class.getSimpleName()
              + "\",");
          pw.println("  \"" + JsonKeys.Import.name() + "\":" + success);
          pw.println("}");
        }
      });
    } catch (Exception e) {
      UpdateContainer uc = new UpdateContainer();
      uc.add(new TrivialErrorUpdate("Error importing Ontology "
          + getFile().getName()));
      return uc;
    }
  }
View Full Code Here

    setEncoding(strEncoding);

    /**
     * Send response based on the interaction type *
     */
    UpdateContainer c = null;
    ImportFileInteractionType type = ImportFileInteractionType
        .valueOf(request.getParameter("interactionType"));
    switch (type) {
    case generatePreview: {
      try {
View Full Code Here

  @Override
  public UpdateContainer showPreview(HttpServletRequest request)
      throws CommandException {

    UpdateContainer c = new UpdateContainer();
    c.add(new ImportPropertiesUpdate(getFile(), encoding, -1, id));
    return c;

  }
View Full Code Here

    }
  }

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    UpdateContainer c = new UpdateContainer();
    if (this.newWorksheetId != null) {
      workspace.removeWorksheet(newWorksheetId);
      workspace.getFactory().removeWorksheet(newWorksheetId, workspace.getCommandHistory());
      c.add(new WorksheetListUpdate());
      c.add(new WorksheetDeleteUpdate(newWorksheetId));
    }
    if (this.newHNodeId != null) {
      Worksheet worksheet = workspace.getWorksheet(worksheetId);
      HNode ndid = workspace.getFactory().getHNode(newHNodeId);
      HTable currentTable = workspace.getFactory().getHTable(ndid.getHTableId());
      ndid.removeNestedTable();
      //remove the new column
      currentTable.removeHNode(newHNodeId, worksheet);
      c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    }
    return c;
  }
View Full Code Here

    commandHistory.removeCommands(workspace, worksheetId);
    JSONArray redoCommandsArray = new JSONArray();
    for (Command refined : commands)
      redoCommandsArray.put(workspace.getCommandHistory().getCommandJSON(workspace, refined));
    commands.clear();
    UpdateContainer uc = new UpdateContainer();
    commands.addAll(getCommandsFromHistoryJSON(redoCommandsArray, uc));
    return uc;
  }
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    String hNodeId = gethNodeId(alignmentId, columnUri);
    final String copy = hNodeId;
    return new UpdateContainer(new AbstractUpdate() {
     
      @Override
      public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
        JSONObject obj = new JSONObject();
        obj.put("HNodeId", copy);
View Full Code Here

        ht = hNode.getNestedTable();
      else
        ht = parentHT;
    }
    if (ht == null) {
      return new UpdateContainer();
    }
    final JSONArray array = new JSONArray();
    for (HNode hn : ht.getHNodes()) {
      if (!commandName.equals("Unfold") || (!hn.hasNestedTable() && !hn.getId().equals(hNodeId)) ) {
        JSONObject obj = new JSONObject();
        obj.put("ColumnName", hn.getColumnName());
        obj.put("HNodeId", hn.getId());
        HashMap<String, HashSet<HNode>> appliedCommands = hn.getAppliedCommands();
        JSONArray commands = new JSONArray();
        for(String command : appliedCommands.keySet()) {
          JSONObject com = new JSONObject();
          com.put("CommandName", command);
          HashSet<HNode> cNodes = appliedCommands.get(command);
          JSONArray cols = new JSONArray();
          for(HNode cNode : cNodes) {
            JSONObject col = new JSONObject();
            col.put("HNodeId", cNode.getId());
            col.put("ColumnName", cNode.getColumnName());
            cols.put(col);
          }
          com.put("Columns", cols);
          commands.put(com);
        }
        obj.put("appliedCommands", commands);
        array.put(obj);
      }
    }
    try {
      return new UpdateContainer(new AbstractUpdate() {

        @Override
        public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
          pw.print(array.toString());
        }
      });
    } catch (Exception e) {
      logger.error("Error occurred while fetching graphs!", e);
      return new UpdateContainer(new ErrorUpdate("Error occurred while fetching graphs!"));
    }
  }
View Full Code Here

  // TODO this is in worksheetcommand
  private UpdateContainer getAlignmentUpdateContainer(Alignment alignment,
      Worksheet worksheet, Workspace workspace) {
    // Add the visualization update
    UpdateContainer c = new UpdateContainer();
    c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
    c.add(new AlignmentSVGVisualizationUpdate(worksheetId, alignment));
    return c;
  }
View Full Code Here

TOP

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

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.