Package edu.isi.karma.controller.update

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


  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    // TODO Auto-generated method stub
    UpdateContainer c =  new UpdateContainer();
    JSONArray predicatesincomingarray = new JSONArray(predicateIncoming);
    JSONArray predicatesoutgoingarray = new JSONArray(predicateOutgoing);
    if (predicatesincomingarray.length() > 0)
      incoming.doIt(workspace);
    if (predicatesoutgoingarray.length() > 0)
      outgoing.doIt(workspace);
    c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return c;
  }
View Full Code Here


    return c;
  }

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    UpdateContainer c =  new UpdateContainer();
    JSONArray predicatesincomingarray = new JSONArray(predicateIncoming);
    JSONArray predicatesoutgoingarray = new JSONArray(predicateOutgoing);
    if (predicatesincomingarray.length() > 0)
      incoming.undoIt(workspace);
    if (predicatesoutgoingarray.length() > 0)
      outgoing.undoIt(workspace);
    c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return c;
  }
View Full Code Here

        if (classNodeLabel == null) {
          String errorMessage = "Error while setting a classLink. MetaPropertyUri '"
              + metaPropertyUri
              + "' should be in the Ontology Manager, but it is not.";
          logger.error(errorMessage);
          return new UpdateContainer(new ErrorUpdate(errorMessage));
        }
        classNode = alignment.addInternalNode(classNodeLabel);
      }

      LabeledLink newLink = alignment.addClassInstanceLink(classNode, columnNode,
          LinkKeyInfo.UriOfInstance);
      alignment.changeLinkStatus(newLink.getId(),
          LinkStatus.ForcedByUser);
     
      // Create the semantic type object
      newType = new SemanticType(hNodeId,
          ClassInstanceLink.getFixedLabel(), classNode.getLabel(),
          SemanticType.Origin.User, 1.0);
    } else if (metaPropertyName
        .equals(METAPROPERTY_NAME.isSpecializationForEdge)) {
      LabeledLink propertyLink = alignment.getLinkById(metaPropertyId);
      if (propertyLink == null) {
        String errorMessage = "Error while specializing a link. The DefaultLink '"
            + metaPropertyId
            + "' should already be in the alignment, but it is not.";
        logger.error(errorMessage);
        return new UpdateContainer(new ErrorUpdate(errorMessage));
      }

      Node classInstanceNode = alignment.getNodeById(LinkIdFactory
          .getLinkSourceId(metaPropertyId));
      if (semanticTypeAlreadyExists) {
        clearOldSemanticTypeLink(oldIncomingLinkToColumnNode,
            oldDomainNode, alignment, classInstanceNode);
      }

      if (propertyLink instanceof DataPropertyLink) {
        String targetHNodeId = ((ColumnNode) propertyLink.getTarget())
            .getHNodeId();
        LabeledLink newLink = alignment.addDataPropertyOfColumnLink(classInstanceNode,
            columnNode, targetHNodeId, propertyLink.getId());
        alignment.changeLinkStatus(newLink.getId(),
            LinkStatus.ForcedByUser);
       
        // Create the semantic type object
        newType = new SemanticType(hNodeId,
            DataPropertyOfColumnLink.getFixedLabel(),
            classInstanceNode.getLabel(), SemanticType.Origin.User,
            1.0);
      } else if (propertyLink instanceof ObjectPropertyLink) {
        LabeledLink newLink = alignment.addObjectPropertySpecializationLink(
            classInstanceNode, columnNode, propertyLink.getId());
        alignment.changeLinkStatus(newLink.getId(),
            LinkStatus.ForcedByUser);

        // Create the semantic type object
        newType = new SemanticType(hNodeId,
            ObjectPropertySpecializationLink.getFixedLabel(),
            classInstanceNode.getLabel(), SemanticType.Origin.User,
            1.0);
      }

    } else if (metaPropertyName.equals(METAPROPERTY_NAME.isSubclassOfClass)) {
      Node classNode = alignment.getNodeById(metaPropertyId);
      if (semanticTypeAlreadyExists) {
        clearOldSemanticTypeLink(oldIncomingLinkToColumnNode,
            oldDomainNode, alignment, classNode);
      }

      if (classNode == null) {
        Label classNodeLabel = ontMgr.getUriLabel(metaPropertyUri);
        if (classNodeLabel == null) {
          String errorMessage = "Error while setting an advances subclass. MetaPropertyValue '"
              + metaPropertyUri
              + "' should be in the Ontology Manager, but it is not.";
          logger.error(errorMessage);
          return new UpdateContainer(new ErrorUpdate(errorMessage));
        }
        classNode = alignment.addInternalNode(classNodeLabel);
      }
      LabeledLink newLink = alignment.addColumnSubClassOfLink(classNode, columnNode);
      alignment.changeLinkStatus(newLink.getId(),
          LinkStatus.ForcedByUser);
     
      // Create the semantic type object
      newType = new SemanticType(hNodeId,
          ColumnSubClassLink.getFixedLabel(), classNode.getLabel(),
          SemanticType.Origin.User, 1.0);
    }

    columnNode.setUserSelectedSemanticType(newType);

    // Update the alignment
    if(!this.isExecutedInBatch())
      alignment.align();


    UpdateContainer c = new UpdateContainer();

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

    oldSynonymTypes = worksheet.getSemanticTypes()
        .getSynonymTypesForHNodeId(newType.getHNodeId());

    // Update the SemanticTypes data structure for the worksheet
    worksheet.getSemanticTypes().addType(newType);

    // Update the synonym semanticTypes
    // worksheet.getSemanticTypes().addSynonymTypesForHNodeId(newType.getHNodeId(),
    // newSynonymTypes);

    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

    // alignment.removeNode(oldDomainNode.getId());
  }

  @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);
    // 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

  }

  @Override
  public UpdateContainer showPreview(HttpServletRequest request)
      throws CommandException {
    UpdateContainer c = new UpdateContainer(new CSVImportPreviewUpdate(
        delimiter, quoteCharacter, escapeCharacter, encoding,
        maxNumLines, getFile(), headerRowIndex, dataStartRowIndex, id));
    return c;
  }
View Full Code Here

      }
    }
    /**
     * 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

      //hNodeId = hnodes.get(0).getId();
      cmd = factory.createCommand(input, workspace, hNodeId, worksheetId, hTableId, worksheet.getHeaders().getNewColumnName("fold"), HNodeType.Transformation, selection.getName());
      cmd.doIt(workspace);
      outputColumns.addAll(cmd.getOutputColumns());
      WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
      UpdateContainer c =  new UpdateContainer();   
      c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      return c;
    } catch (Exception e) {
      logger.error("Error in FoldCommand" + e.toString());
      Util.logException(logger, e);
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
    }
  }
View Full Code Here

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    cmd.undoIt(workspace);
    //remove the new column
    //currentTable.removeHNode(newHNodeId, worksheet);
    UpdateContainer c =  new UpdateContainer();   
    c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return c;
  }
View Full Code Here

    //this.previousPythonTransformationCommand = ctrl.getWorkspace().getCommandHistory().getCommand(previousCommandId);
    this.saveOrResetColumnValues(workspace, ctrl);
   
    try
    {
      UpdateContainer c = applyPythonTransformation(workspace, worksheet, f,
        hNode, ctrl, targetHNodeId);
      WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
      return c;
    }
    catch (Exception e )
    {
      logger.error("Error occured during python transformation.",e);
      return new UpdateContainer(new ErrorUpdate("Error occured while creating applying Python transformation to the column."));
    }
  }
View Full Code Here

      {
        SubmitPythonTransformationCommand prevCommand = (SubmitPythonTransformationCommand)previousPythonTransformationCommand;
        //Previous python command exists, lets reset the values, and then start again
        prevCommand.resetColumnValues(workspace);
      }
      UpdateContainer uc = previousPythonTransformationCommand.doIt(workspace);
      return uc;
    } catch (CommandException e) {
      return new UpdateContainer(new ErrorUpdate("Error occured while  applying previous Python transformation to the column."));
   
    }
  }
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.