Package edu.isi.karma.rep

Examples of edu.isi.karma.rep.Worksheet


    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    CSVFileExport csvFileExport = new CSVFileExport(worksheet);
   
    MDBFileExport mdbFileExport = new MDBFileExport(worksheet);

    try {
View Full Code Here


  public UpdateContainer doIt(Workspace workspace) throws CommandException {
   
    savePreferences(workspace);
   

    Worksheet worksheet = workspace.getWorksheet(worksheetId);

    //for now don't save a nested table (we may want to save it as multiple tables with foreign keys)
    if (worksheet.getHeaders().hasNestedTables()) {
      return new UpdateContainer(new ErrorUpdate("Saving of nested tables not supported!"));       
    }
   
    Connection conn = null;
    try{
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    inputColumns.clear();
    outputColumns.clear();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory factory = workspace.getFactory();
    SuperSelection superSel = this.getSuperSelection(worksheet);
    HTable hTable = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    Selection currentSel = superSel.getSelection(hTable.getId());
    Selection anotherSel = null;
    if (!operation.equalsIgnoreCase(Operation.Invert.name())) {
      anotherSel = new MiniSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), pythonCode, onError);
      worksheet.getSelectionManager().addSelection(anotherSel);
    }
    if (currentSel == null && operation.equalsIgnoreCase(Operation.Invert.name()) ) {
      return getErrorUpdate("No defined Selection");
    }
    if (currentSel == null) {
      currentSel = new MiniSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), SelectionManager.defaultCode, onError);
      worksheet.getSelectionManager().addSelection(currentSel);
    }
    try {
      Operation operation = Operation.valueOf(Operation.class, this.operation);
      Selection t = new LargeSelection(workspace, worksheetId, hTable.getId(), factory.getNewId("SEL"), superSel.getName(), currentSel, anotherSel, operation);
      worksheet.getSelectionManager().addSelection(t);
      outputColumns.addAll(t.getInputColumns());
      previousSelection = superSel.getSelection(t.getHTableId());
      if (previousSelection != null)
        superSel.removeSelection(previousSelection);
      superSel.addSelection(t);
View Full Code Here

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    inputColumns.clear();
    outputColumns.clear();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection superSel = getSuperSelection(worksheet);
    HNode hNode = workspace.getFactory().getHNode(hNodeId);
    Selection currentSel = superSel.getSelection(hNode.getHTableId());
    if (previousSelection != null) {
      superSel.addSelection(previousSelection);
      outputColumns.addAll(previousSelection.getInputColumns());
    }
    if (currentSel != null) {
      worksheet.getSelectionManager().removeSelection(currentSel);
      superSel.removeSelection(currentSel);
    }
    WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
    UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel)
    uc.add(new WorksheetSuperSelectionListUpdate(worksheetId));
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    inputColumns.clear();
    outputColumns.clear();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory factory = workspace.getFactory();
    SuperSelection superSel = this.getSuperSelection(worksheet);
    HTable hTable = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    if (type.equals("Column")) {
      Selection currentSel = superSel.getSelection(hTable.getId());
      if (currentSel != null) {
        outputColumns.addAll(currentSel.getInputColumns());
        oldSelections.put(currentSel.getHTableId(), currentSel);
        worksheet.getSelectionManager().removeSelection(currentSel);
        superSel.removeSelection(currentSel);
      }
    }
    if (type.equals("All")) {
      for (Selection sel : superSel.getAllSelection()) {
        if (sel != null) {
          oldSelections.put(sel.getHTableId(), sel);
          worksheet.getSelectionManager().removeSelection(sel);
          superSel.removeSelection(sel);
        }
      }
    }
    WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
View Full Code Here

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    inputColumns.clear();
    outputColumns.clear();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection superSel = getSuperSelection(worksheet);
    for (Entry<String, Selection> entry : oldSelections.entrySet()) {
      outputColumns.addAll(entry.getValue().getInputColumns());
      superSel.addSelection(entry.getValue());
      worksheet.getSelectionManager().addSelection(entry.getValue());
    }
    WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
    UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel);
    uc.add(new WorksheetSuperSelectionListUpdate(worksheetId));
    return uc;
View Full Code Here

      data = dbUtil.getSQLQueryDataForLimitedRows(dbType, hostname,
              portnumber, username, password, query, dBorSIDName, 1000);
       return generateWorksheet(dbUtil, data);
    } catch (SQLException | ClassNotFoundException e) {
      //If data could not be imported, delete the empty worksheet
      Worksheet ws = getWorksheet();
      if(ws != null)
        workspace.removeWorksheet(ws.getId());
     
      throw new KarmaException("Unable to get data for the SQL Query: " + e.getMessage());
    }
    }
View Full Code Here

  public Command createCommand(JSONArray inputJson, Workspace workspace)
      throws JSONException, KarmaException {

    String worksheetId = HistoryJsonUtil.getStringValue(
        Arguments.worksheetId.name(), inputJson);
    Worksheet worksheet = workspace.getWorksheet(worksheetId);

    AutoOntology autoOntology = new AutoOntology(worksheet);
    String path = ServletContextParameterMap
        .getParameterValue(ContextParameter.PRELOADED_ONTOLOGY_DIRECTORY)
         + worksheet.getTitle() + ".owl";
    try {
      autoOntology.Build(path);
    } catch (IOException e) {
      logger.error("Error occured while creating auto model!", e);
    }

    OntologyManager ontMgr = workspace.getOntologyManager();
    File autoOtologyFile = new File(path);
    logger.info("Loading ontology: " + autoOtologyFile.getAbsolutePath());
    String encoding = EncodingDetector.detect(autoOtologyFile);
    try {
      ontMgr.doImportAndUpdateCache(autoOtologyFile, encoding);
      logger.info("Done loading ontology: "
          + autoOtologyFile.getAbsolutePath());
    } catch(Exception e) {
      logger.error("Error importing auto ontology file: " + autoOtologyFile.getAbsolutePath());
    }
   
    SuggestAutoModelCommand comm = new SuggestAutoModelCommand(
        getNewId(workspace), worksheet.getId());
    // Add the semantic types that have saved into the history
    for (int i = 2; i < inputJson.length(); i++) {
      JSONObject hnodeObj = (JSONObject) inputJson.get(i);
      String hNodeId = (String) hnodeObj.get(ClientJsonKeys.value
          .name());

      JSONObject typeObj = (JSONObject) inputJson.get(++i);
      JSONObject value = (JSONObject) typeObj
          .get(ClientJsonKeys.value.name());

      SemanticType type = null;
      String domain = (String) value
          .get(SemanticType.ClientJsonKeys.DomainUri.name());
      String fullType = (String) value
          .get(SemanticType.ClientJsonKeys.FullType.name());
     
      Label typeName = ontMgr.getUriLabel(fullType);
      Label domainName = null;
      if (domain != null && !domain.trim().equals(""))
        domainName = ontMgr.getUriLabel(domain);

      if (typeName != null) {
        type = new SemanticType(hNodeId, typeName, domainName,
            Origin.User, 1.00);
        worksheet.getSemanticTypes().addType(type);
      }
    }
    return comm;
  }
View Full Code Here

    return CommandType.notUndoable;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(
        worksheetId);
   
    try{
      worksheet.addRow(workspace.getFactory());
      UpdateContainer c =  new UpdateContainer();   
      c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, SuperSelectionManager.DEFAULT_SELECTION));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      return c;
    } catch (Exception e) {
View Full Code Here

    return CommandType.undoable;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(worksheet);
   
    String[] entities = entitiesToBeExt.split(",");
    HashSet<String> entitiesReqd = new HashSet<String>();
   
    entitiesReqd.addAll(Arrays.asList(entities));

    JSONArray array = new JSONArray();
    AddValuesCommand cmd;

    RepFactory repFactory = workspace.getFactory();
    HTable ht = repFactory.getHTable(repFactory.getHNode(hNodeId).getHTableId());
   
    List<Table> tables = new ArrayList<Table>();
   
    CloneTableUtils.getDatatable(worksheet.getDataTable(), ht, tables, selection);
    for(Table table : tables) {
      ArrayList<Row> rows = table.getRows(0, table.getNumRows(), selection);
   
        for (Row row : rows) {
          String id = row.getId();
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.Worksheet

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.