Examples of UpdateContainer


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

      System.setProperty("KARMA_USER_HOME",
          karmaUserHome.getAbsolutePath());
    }
    KarmaMetadataManager userMetadataManager;
    userMetadataManager = new KarmaMetadataManager();
    UpdateContainer uc = new UpdateContainer();
    userMetadataManager.register(new UserPreferencesMetadata(), uc);
    userMetadataManager.register(new UserConfigMetadata(), uc);
    userMetadataManager.register(new PythonTransformationMetadata(), uc);
    PythonRepository.disableReloadingLibrary();
  }
View Full Code Here

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

      }
      if (t != null)
        history._getHistory().add(t);
      history._getHistory().addAll(tmp);
    }
    UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel);
    uc.add(new HistoryUpdate(history));
    return uc;
  }
View Full Code Here

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

  public UpdateContainer undoIt(Workspace workspace) {
    return null;
  }

  public UpdateContainer getErrorUpdate(String msg) {
    return new UpdateContainer(new ErrorUpdate(msg));
  }
View Full Code Here

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

  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    SuperSelection selection = getSuperSelection(workspace);
    return new UpdateContainer(new AdditionalRowsUpdate(worksheetId, tableId, selection));
   
  }
View Full Code Here

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

                String newDomainValue = domainValue.substring(0, len-1);
                label = ontMgr.getUriLabel(newDomainValue);
              }
              if (label == null) {
                logger.error("No graph node found for the node: " + domainValue);
                return new UpdateContainer(new ErrorUpdate("" +
                "Error occured while setting semantic type!"));
              }
            }
          }
          domain = alignment.addInternalNode(label);
        }
         
        // Check if a semantic type already exists for the column
        ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
        columnNode.setRdfLiteralType(rdfLiteralType);
        List<LabeledLink> columnNodeIncomingLinks = alignment.getIncomingLinks(columnNode.getId());
        LabeledLink oldIncomingLinkToColumnNode = null;
        Node oldDomainNode = null;
        if (columnNodeIncomingLinks != null && !columnNodeIncomingLinks.isEmpty()) { // SemanticType already assigned
          semanticTypeAlreadyExists = true;
          oldIncomingLinkToColumnNode = columnNodeIncomingLinks.get(0);
          oldDomainNode = oldIncomingLinkToColumnNode.getSource();
        }

        if (type.getBoolean(ClientJsonKeys.isPrimary.name())) {
         
          if (isClassSemanticType) {
            if (semanticTypeAlreadyExists && oldDomainNode == domain) {
              newLink = oldIncomingLinkToColumnNode;
              // do nothing;
            } else if (semanticTypeAlreadyExists) {
              alignment.removeLink(oldIncomingLinkToColumnNode.getId());
//              alignment.removeNode(oldDomainNode.getId());
              newLink = alignment.addClassInstanceLink(domain, columnNode, LinkKeyInfo.None);
            } else {
              newLink = alignment.addClassInstanceLink(domain, columnNode, LinkKeyInfo.None);
            }
          }
          // Property semantic type
          else {

            // When only the link changes between the class node and the internal node (domain)
            if (semanticTypeAlreadyExists && oldDomainNode == domain) {
              alignment.removeLink(oldIncomingLinkToColumnNode.getId());
              newLink = alignment.addDataPropertyLink(domain, columnNode, linkLabel);
            }
            // When there was an existing semantic type and the new domain is a new node in the graph and semantic type already existed
            else if (semanticTypeAlreadyExists) {
              alignment.removeLink(oldIncomingLinkToColumnNode.getId());
//              alignment.removeNode(oldDomainNode.getId());
              newLink = alignment.addDataPropertyLink(domain, columnNode, linkLabel);
            } else {
              newLink = alignment.addDataPropertyLink(domain, columnNode, linkLabel);
            }           
          }
        } else { // Synonym semantic type
          SemanticType synType = new SemanticType(hNodeId, linkLabel, domain.getLabel(), SemanticType.Origin.User, 1.0);
          typesList.add(synType);
        }
       
        // Create the semantic type object
        newType = new SemanticType(hNodeId, linkLabel, domain.getLabel(), SemanticType.Origin.User, 1.0);
//        newType = new SemanticType(hNodeId, classNode.getLabel(), null, SemanticType.Origin.User, 1.0,isPartOfKey);
        columnNode.setUserSelectedSemanticType(newType);
       
        if(newLink != null) {
          alignment.changeLinkStatus(newLink.getId(),
              LinkStatus.ForcedByUser);
        }
        // Update the alignment
        if(!this.isExecutedInBatch())
          alignment.align();

      } catch (JSONException e) {
        logger.error("JSON Exception occured", e);
      }
    }
   
    UpdateContainer c = new UpdateContainer();

    // Save the old SemanticType object and CRF Model for undo
    oldType = worksheet.getSemanticTypes().getSemanticTypeForHNodeId(hNodeId);
    oldSynonymTypes = worksheet.getSemanticTypes().getSynonymTypesForHNodeId(hNodeId);

    if (newType != null) {
      // Update the SemanticTypes data structure for the worksheet
      worksheet.getSemanticTypes().addType(newType);

      // Update the synonym semanticTypes
      newSynonymTypes = new SynonymSemanticTypes(typesList);
      worksheet.getSemanticTypes().addSynonymTypesForHNodeId(newType.getHNodeId(), newSynonymTypes);
    }

    // Identify the outliers if the semantic type exists in the crfmodel
//    List<String> existingLabels = new ArrayList<String>();
//    crfModelHandler.getLabels(existingLabels);
//    if (existingLabels.contains(newType.getCrfModelLabelString())) {
//      identifyOutliers(worksheet, vWorkspace, crfModelHandler, newType);
//      c.add(new TagsUpdate());
//    }
   
    if(trainAndShowUpdates) {
      new SemanticTypeUtil().trainOnColumn(workspace, worksheet, newType, selection);
    }
   
    c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
    c.add(new AlignmentSVGVisualizationUpdate(worksheetId,
        alignment));     
    return c;
  }
View Full Code Here

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

//    return columnNode;
//  }

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    UpdateContainer c = new UpdateContainer();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    if (oldType == null) {
      worksheet.getSemanticTypes().unassignColumnSemanticType(newType.getHNodeId());
    } else {
      worksheet.getSemanticTypes().addType(oldType);
      worksheet.getSemanticTypes().addSynonymTypesForHNodeId(newType.getHNodeId(), oldSynonymTypes);
    }

    // Replace the current alignment with the old alignment
    String alignmentId = AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId);
    AlignmentManager.Instance().addAlignmentToMap(alignmentId, oldAlignment);
    oldAlignment.setGraph(oldGraph);
   
//    logger.trace("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
//    GraphUtil.printGraph(oldAlignment.getGraph());
//    GraphUtil.printGraph(oldAlignment.getSteinerTree());
   
    // Get the alignment update if any
    try {
      c.add(new SemanticTypesUpdate(worksheet, worksheetId, oldAlignment));
      c.add(new AlignmentSVGVisualizationUpdate(worksheetId, oldAlignment));
    } catch (Exception e) {
      logger.error("Error occured while unsetting the semantic type!", e);
      return new UpdateContainer(new ErrorUpdate(
          "Error occured while unsetting the semantic type!"));
    }
    return c;
  }
View Full Code Here

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

   
   
    WorksheetProperties props = worksheet.getMetadataContainer().getWorksheetProperties();
    try {
      final JSONObject propsJson = props.getJSONRepresentation();
      return new UpdateContainer(new AbstractUpdate() {
       
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject obj = new JSONObject();
          try {
            obj.put(JsonKeys.updateType.name(), "ExistingWorksheetProperties");
            obj.put(JsonKeys.properties.name(), propsJson);
           
            pw.println(obj.toString());
          } catch (JSONException e) {
            logger.error("Error occurred while fetching worksheet properties!", e);
          }
        }
      });
    } catch (JSONException e) {
      logger.error("Error occurred while fetching worksheet properties!", e);
      return new UpdateContainer(new ErrorUpdate("Error occurred while fetching " +
          "worksheet properties!"));
    }
  }
View Full Code Here

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

  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet wk = workspace.getWorksheet(worksheetId);
    UpdateContainer c = new UpdateContainer();
    SuperSelection selection = getSuperSelection(wk);
    // Get the HNode
    HNode hNode = workspace.getFactory().getHNode(hNodeId);
    columnName = hNode.getColumnName();
    // The column should not have a nested table but check to make sure!
    if (hNode.hasNestedTable()) {
      c.add(new ErrorUpdate("Cannot split column with nested table!"));
      return c;
    }
   
    if (columnName.equals(newColName)) {
      splitCommaCommand = new SplitByCommaCommand(workspace.getFactory().getNewId("C"), worksheetId, hNodeId, delimiter, selectionId);
      return splitCommaCommand.doIt(workspace);
    }

    logger.info("SplitValuesCommand:" + newColName + ", columnName:" + columnName);
   
    HNode newhNode = null;
    if(newHNodeId != null && newHNodeId.length() > 0)
      newhNode = workspace.getFactory().getHNode(newHNodeId);
    boolean isUpdate = false;
    if(newhNode == null) {
      HTable hTable = workspace.getFactory().getHTable(hNode.getHTableId());
      newhNode = hTable.getHNodeFromColumnName(newColName);
      if(newhNode == null)
      {
        newhNode = hTable.addHNode(newColName, HNodeType.Transformation, wk, workspace.getFactory());
      }
      if(newhNode.getNestedTable() == null)
      {
        HTable newTable = newhNode.addNestedTable("Comma Split Values", wk, workspace.getFactory());
        newTable.addHNode("Values", HNodeType.Transformation, wk, workspace.getFactory());
      }
      newHNodeId = newhNode.getId();
      hNode.addAppliedCommand("SplitValuesCommand", newhNode);
    } else {
      logger.info("Column names are same, re-compute the split values");
      isUpdate = true;
    }
   
   
   
    SplitColumnByDelimiter split = new SplitColumnByDelimiter(hNodeId, newhNode.getId(), wk, delimiter, workspace, selection);
    try {
      if(isUpdate)
        split.empty();
      split.split();
    } catch (IOException e) {
      c.add(new ErrorUpdate("Cannot split column! csv reader error"));
      return c;
    }
    c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, selection));

    /** Add the alignment update **/
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));

    return c;
  }
View Full Code Here

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

     
      JSONArray bindings = res.getJSONObject(sparqlKeys.results.name())
          .getJSONArray(sparqlKeys.bindings.name());
     
      if (bindings.length() == 0) {
        return new UpdateContainer(new ErrorUpdate("No history found in the " +
            "selected model!"));
      }
     
      String history = bindings.getJSONObject(0).getJSONObject(
          sparqlKeys.history.name()).getString(sparqlKeys.value.name());
     
 
      // Execute the history
      WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor(
          worksheetId, workspace);


      if (history.isEmpty()) {
        return new UpdateContainer(new ErrorUpdate("No history found in R2RML Model!"));
      }
     
      JSONArray historyJson = new JSONArray(history);
      histExecutor.executeAllCommands(historyJson);
     
      // Add worksheet updates that could have resulted out of the transformation commands
      UpdateContainer c = WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, SuperSelectionManager.DEFAULT_SELECTION);
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      c.add(new InfoUpdate("Model successfully applied!"));
      return c;
     
    } catch (Exception e) {
      logger.error("Error applying model from triple store!", e);
      return new UpdateContainer(new ErrorUpdate("Error applying model from triple store!"));
    }
  }
View Full Code Here

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

      nodeSet = getClassesWithProperty(workspace, propertyURI);
    }
    else if (range == INTERNAL_NODES_RANGE.allClassesRaw) {
      final OntologyManager ontMgr = workspace.getOntologyManager();
      final HashMap<String, Label> allClasses = ontMgr.getClasses();
      UpdateContainer upd = new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONArray nodesArray = new JSONArray();
          JSONObject obj = new JSONObject();
          for (Entry<String, Label> entry : allClasses.entrySet()) {
            JSONObject nodeObj = new JSONObject();
            Label label = entry.getValue();
            nodeObj.put(JsonKeys.nodeLabel.name(), label.getDisplayName());
            nodeObj.put(JsonKeys.nodeId.name(), label.getUri());
            nodeObj.put(JsonKeys.nodeUri.name(), label.getUri());
            nodesArray.put(nodeObj);
          }
          obj.put(JsonKeys.nodes.name(), nodesArray);
          pw.println(obj.toString());
        }
      });
      return upd;
    }

    if (nodeSet == null) {
      nodeSet = new HashSet<Node>();
    }
    final Set<Node> finalNodeSet = nodeSet;

    UpdateContainer upd = new UpdateContainer(new AbstractUpdate() {
      @Override
      public void generateJson(String prefix, PrintWriter pw,
          VWorkspace vWorkspace) {
        JSONObject obj = new JSONObject();
        JSONArray nodesArray = new JSONArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.