Package edu.isi.karma.controller.command.selection

Examples of edu.isi.karma.controller.command.selection.Selection


    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")) {
View Full Code Here


  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory factory = workspace.getFactory();
    SuperSelection superSel = getSuperSelection(worksheet);
    HTable hTable = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    Selection currentSel = superSel.getSelection(hTable.getId());
    if (currentSel != null) {
      currentSel.updateSelection();
    }
    CommandHistory history = workspace.getCommandHistory();
    List<Command> tmp = gatherAllOperateSelectionCommands(history.getCommandsFromWorksheetId(worksheetId), workspace);
    if (tmp.size() > 0) {
      JSONArray inputJSON = new JSONArray();
View Full Code Here

      HTable ht = workspace.getFactory().getHTable(sel.getHTableId());
      selections.add(new SelectionWithPriority(sel, hTableDepth(ht, workspace.getFactory())));
    }
    Collections.sort(selections);
    for (SelectionWithPriority s : selections) {
      Selection sel = s.sel;
      JSONArray inputJSON = new JSONArray();
      HTable ht = workspace.getFactory().getHTable(sel.getHTableId());
      Iterator<String> itr = ht.getHNodeIds().iterator();
      inputJSON.put(CommandInputJSONUtil.createJsonObject("worksheetId", worksheetId, ParameterType.worksheetId));
      inputJSON.put(CommandInputJSONUtil.createJsonObject("hNodeId", itr.next(), ParameterType.hNodeId));
      inputJSON.put(CommandInputJSONUtil.createJsonObject("selectionName", currentSel.getName(), ParameterType.other));
      try {
View Full Code Here

    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);
     
    }catch (Exception e) {
View Full Code Here

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

  public void testSelection1() throws IOException {
   
    StringBuilder pythonCode = new StringBuilder();
    pythonCode.append("if getValue(\"title\") == \"Prof\": \n");
    pythonCode.append("   return True \n");
    Selection sel = new MiniSelection(workspace, worksheet.getId(),
        worksheet.getHeaders().getId(), workspace.getFactory().getNewId("SEL"), null,
        pythonCode.toString(), true);
    assertEquals(sel != null, true);
    Table t = worksheet.getDataTable();
    for (Row r : t.getRows(0, t.getNumRows(), SuperSelectionManager.DEFAULT_SELECTION)) {
      boolean t1 = sel.isSelected(r);
      if (r.getNeighborByColumnName("title", workspace.getFactory()).getValue().asString().equals("Prof"))
        assertTrue(t1);
      else
        assertFalse(t1);
    }
View Full Code Here

  @Test
  public void testSelection2() throws IOException, KarmaException {
    StringBuilder pythonCode = new StringBuilder();
    pythonCode.append("if getValue(\"title\") == \"Prof\": \n");
    pythonCode.append("   return True \n");
    Selection sel = new MiniSelection(workspace, worksheet.getId(),
        worksheet.getHeaders().getId(), workspace.getFactory().getNewId("SEL"), "test",
        pythonCode.toString(), true);
    R2RMLMappingIdentifier modelIdentifier = new R2RMLMappingIdentifier(
        "people-model", getTestResource(
             "people-model.ttl"));
View Full Code Here

    hNodeObj.put(JsonKeys.columnName.name(), columnName);
    hNodeObj.put(JsonKeys.columnClass.name(), getColumnClass(hNode.getId()));
    hNodeObj.put(JsonKeys.hNodeId.name(), hNode.getId());
    HNode t = workspace.getFactory().getHNode(hNode.getId());
    if (t.hasNestedTable()) {
      Selection sel = selection.getSelection(t.getNestedTable().getId());
      if (sel != null)
        hNodeObj.put(JsonKeys.status.name(), sel.getStatus().name());
    }
    hNodeObj.put(JsonKeys.hNodeType.name(), t.getHNodeType().name());
    Integer colLength = colMeta.getColumnPreferredLength(hNode.getId());
    if (colLength == null || colLength == 0) {
      hNodeObj.put(JsonKeys.characterLength.name(), WorksheetCleaningUpdate.DEFAULT_COLUMN_LENGTH);
View Full Code Here

TOP

Related Classes of edu.isi.karma.controller.command.selection.Selection

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.