Examples of UpdateContainer


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

    uc.add(new WorksheetSuperSelectionListUpdate(worksheetId));
    return uc;
  }
 
  public UpdateContainer getErrorUpdate(String msg) {
    return new UpdateContainer(new ErrorUpdate(msg));
  }
View Full Code Here

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

    OntologyManager om= workspace.getOntologyManager();
    WorksheetToFeatureCollection geo = new WorksheetToFeatureCollection(worksheet, om, selection);//ying
    //WorksheetToFeatureCollections geo = new WorksheetToFeatureCollections(worksheet);
    // Send an error update if no geospatial data found!
    if (geo.hasNoGeospatialData()) {
      return new UpdateContainer(new ErrorUpdate(
          "No geospatial data found in the worksheet!"));
    }

    try {
      //final File file = geo.SaveSpatialData();
      // Transfer the file to a public server
      final String kmlFileName = geo.SaveSpatialDataAndReturnKMLString();//new RandomGUID().toString(); // save this line for using networkLink in GE plugin (see geospatial.js)
      final String zippedSpatialDataPath = geo.getZippedSpatialDataPath();
      final boolean transfer = true;//transferFileToPublicServer(kmlFileName,file); // save this line for using networkLink in GE plugin (see geospatial.js)
      //if (!transfer) { // save this line for using networkLink in GE plugin (see geospatial.js)
      //  logger.error("Published KML file could not be moved to a public server to display on Google Maps!");
      //}

      return new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject outputObject = new JSONObject();
          try {
            outputObject.put(JsonKeys.updateType.name(),
                "PublishKMLUpdate");
            outputObject.put(JsonKeys.fileName.name(),
                kmlFileName);
                //publicKMLAddress + kmlFileName+".kml"); // save this line for using networkLink in GE plugin (see geospatial.js)
            outputObject.put(JsonKeys.transferSuccessful.name(),
                transfer);
            outputObject.put(JsonKeys.localFileName.name(),
                "publish/SpatialData/" + zippedSpatialDataPath);
            pw.println(outputObject.toString(4));
          } catch (JSONException e) {
            logger.error("Error occured while generating JSON!");
          }
        }
      });
    } catch (FileNotFoundException e) {
      logger.error("KML File not found!", e);
      return new UpdateContainer(new ErrorUpdate(
          "Error occurred while publishing KML layer!"));
    } catch (Exception shapfileException) {
      // TODO Auto-generated catch block
      shapfileException.printStackTrace();
      return new UpdateContainer(new ErrorUpdate(
          "Error occurred while saving Shapefile!"));
    }
   
  }
View Full Code Here

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

    OntologyManager om= workspace.getOntologyManager();
    WorksheetToFeatureCollection geo = new WorksheetToFeatureCollection(worksheet, om, selection);//ying
   
    // Send an error update if no geospatial data found!
    if (geo.hasNoGeospatialData()) {
      return new UpdateContainer(new ErrorUpdate(
          "No geospatial data found in the worksheet!"));
    }

    try {
     
      geo.SaveSpatialDataAndReturnKMLString();
      final String zippedSpatialDataPath = geo.getZippedSpatialDataPath();

      return new UpdateContainer(new AbstractUpdate() {
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject outputObject = new JSONObject();
          try {
            outputObject.put(JsonKeys.updateType.name(),
                "PublishSpatialDataUpdate");
            outputObject.put(JsonKeys.fileUrl.name(),
                "publish/SpatialData/" + zippedSpatialDataPath);
            outputObject.put(JsonKeys.worksheetId.name(),
                worksheetId);
            pw.println(outputObject.toString(4));
           
          } catch (JSONException e) {
            logger.error("Error occured while generating JSON!");
          }
        }
      });
    } catch (FileNotFoundException e) {
      logger.error("Spatial data folder not found!", e);
      return new UpdateContainer(new ErrorUpdate(
          "Error occurred while exporting spatial data!"));
    }catch (Exception shapfileException) {
      // TODO Auto-generated catch block
      shapfileException.printStackTrace();
      return new UpdateContainer(new ErrorUpdate(
          "Error occurred while saving Shapefile!"));
    }
   
  }
View Full Code Here

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

    logCommand(logger, workspace);
 
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        alignmentId);

    final UpdateContainer uc = new UpdateContainer();
    Node node = alignment.getNodeById(nodeId);
    if(node instanceof LiteralNode) {
      final LiteralNode lNode = (LiteralNode)node;
      uc.add(new AbstractUpdate() {

        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          try {
            JSONStringer jsonStr = new JSONStringer();
           
            JSONWriter writer = jsonStr.object();
            writer.key("worksheetId").value(worksheetId);
            writer.key("updateType").value("LiteralNodeUpdate")
            writer.key("node");
           
            writer.object();
            writer.key("value").value(lNode.getValue())
            String type = lNode.getDatatype().getLocalName();
            if(type != null && type.length() > 0)
              type = lNode.getDatatype().getDisplayName();
            else
              type = "";
            writer.key("type").value(type);
            writer.key("isUri").value(lNode.isUri());
            writer.endObject();
           
            writer.endObject();
 
            pw.print(writer.toString());
          } catch (JSONException e) {
            logger.error("Error occured while writing to JSON!", e);
            uc.add(new ErrorUpdate("Error occured while writing to JSON"));
          }
        }
       
      });
    } else {
      uc.add(new ErrorUpdate("Node does not exist in the Alignment"));
    }

    return uc;
  }
View Full Code Here

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

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    UpdateContainer uc = new UpdateContainer();
 
    File dir = new File(directory);
    if(dir.exists()) {
      ServletContextParameterMap.setParameterValue(ContextParameter.USER_DIRECTORY_PATH, directory);
      Preferences preferences = Preferences.userRoot().node("WebKarma");
      preferences.put("KARMA_USER_HOME", directory);
     
     
      uc.add(new InfoUpdate("Successfully changed Karma Home Directory"));
      uc.add(new AbstractUpdate() {
 
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject obj = new JSONObject();
          obj.put(GenericJsonKeys.updateType.name(), "ReloadPageUpdate");
          pw.println(obj.toString());
        }
       
      });
    } else {
      uc.add(new ErrorUpdate("Karma home could not be changed. The specified directory does not exist"));
    }
    return uc;
  }
View Full Code Here

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

      worksheetExists = true;
      workspace.removeWorksheet(worksheetId);     
      workspace.getFactory().removeWorksheet(worksheetId, workspace.getCommandHistory());       
    }
   
    UpdateContainer update = new UpdateContainer();
    update.add(new WorksheetListUpdate());
    if(worksheetExists) {
      update.add(new WorksheetDeleteUpdate(worksheetId));
      update.add(new HistoryUpdate(workspace.getCommandHistory()));
    }
    return update;
  }
View Full Code Here

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

    logger.info("done after {}", (System.currentTimeMillis() - l));
    logger.info("RDF published at: " + outputFilePath);
  }

  private void setupKarmaMetadata() throws KarmaException {
    UpdateContainer uc = new UpdateContainer();
    KarmaMetadataManager userMetadataManager = new KarmaMetadataManager();
    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

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
   
    boolean result = TripleStoreUtil.clearContexts(tripleStoreUrl, graphUrl);
    if (!result) {
      return new UpdateContainer(new ErrorUpdate("Error occured while clearing R2RML model!"));
    }
    UpdateContainer uc = new UpdateContainer();
    uc.add(new AbstractUpdate() {
      public void generateJson(String prefix, PrintWriter pw, 
          VWorkspace vWorkspace) {
        JSONObject outputObject = new JSONObject();
        try {
          outputObject.put(JsonKeys.updateType.name(), "ClearGraph");
View Full Code Here

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

    // create new column command
    String Msg = String.format("submit end, Time,%d, Worksheet,%s",
        System.currentTimeMillis(), worksheetId);
    logger.info(Msg);
    String colnameString = "";
    UpdateContainer c = new UpdateContainer();
    HNodePath selectedPath = null;
    try {
      // obtain transformed results
      HashMap<String, String> rows = new HashMap<String, String>();
      colnameString = obtainTransformedResultsAndFindNewColumnName(
          workspace, rows);
      createAndExecuteNewAddColumnCommand(workspace, colnameString);
      Worksheet wk = workspace.getWorksheet(worksheetId);
      selectedPath = findPathForNewColumn(workspace, colnameString);
      DataPreProcessor dpp = (DataPreProcessor) wk.getDpp();
      if(dpp == null)
      {
        dpp = new DataPreProcessor(rows.values());
      }
      Messager msg = (Messager) wk.getMsg();
      if(msg == null)
      {
        msg = new Messager();
      }
      RamblerTransformationOutput rtf = applyRamblerTransformation(rows,dpp,msg);
      if (rtf.getTransformations().keySet().size() <= 0) {
        c.append(WorksheetUpdateFactory
            .createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
        c.add(new InfoUpdate("No Result Submitted"));
        return c;
      }


      ValueCollection rvco = getValueCollectionFromRamblerTranformationOutput(rtf);
     
      findNewHNodeIdAndHNodeAsDerived(workspace, selectedPath);
      // create edit multiple cells command
      createAndExecuteMultiCellCmd(workspace, selectedPath, rvco);
    } catch (Exception e) {
      logger.error("Unable to complete processing of cleaning command", e);
      c.add(new ErrorUpdate(
          "Unable to complete processing of cleaning command"));
      // TODO do we need to clean up?
    }

    if (selectedPath != null) {
      c.append(WorksheetUpdateFactory
          .createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
      /** Add the alignment update **/
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(
          workspace, selectedPath));
    }

    c.add(new InfoUpdate("Column transformation complete"));
    return c;
  }
View Full Code Here

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

    HTable currentTable = workspace.getFactory().getHTable(hTableId);
    // remove the new column
    currentTable.removeHNode(newHNodeId, worksheet);

    UpdateContainer c = (WorksheetUpdateFactory
        .createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
    // TODO is it necessary to compute alignment and semantic types for
    // everything?
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return c;
  }
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.