Package edu.isi.karma.controller.update

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


    final String fileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.REPORT_PUBLISH_DIR)
        fileName;
    final String relFilename = ServletContextParameterMap.getParameterValue(ContextParameter.REPORT_PUBLISH_RELATIVE_DIR) + fileName;
    final Workspace finalWorkspace = workspace;
   
    UpdateContainer uc = new UpdateContainer(new AbstractUpdate() {
      public void generateJson(String prefix, PrintWriter pw,
          VWorkspace vWorkspace) {
        try {
          File f = new File(fileLocalPath);
          File parentDir = f.getParentFile();
View Full Code Here


//      logger.error("Error occured while copying the history file to server!", e1);
//      return new UpdateContainer(new ErrorUpdate("Error occured while publishing history for worksheet!"));
//    }
   
   
    return new UpdateContainer(new AbstractUpdate() {
      @Override
      public void generateJson(String prefix, PrintWriter pw,
          VWorkspace vWorkspace) {
        JSONObject outputObject = new JSONObject();
        try {
View Full Code Here

      return uc;
    final Workspace workspace = WorkspaceManager.getInstance().createWorkspace();
    Import imp = createImport(workspace, 1000);
    try {
      final Worksheet worksheet = imp.generateWorksheet();           
      uc.add(new AbstractUpdate() {       
        @Override
        public void generateJson(String prefix, PrintWriter pw,
            VWorkspace vWorkspace) {
          JSONObject response = new JSONObject();
          response.put(AbstractUpdate.GenericJsonKeys.updateType.name(),
View Full Code Here

    final String jsonFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_DIR)
        jsonFileName;
    PrintWriter printWriter = new PrintWriter(jsonFileLocalPath);
    printWriter.println(new JSONArray(columnsJson).toString(4));
    printWriter.close();
    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(),
View Full Code Here

      if(HistoryJsonUtil.getParameterType(inpP) == ParameterType.hNodeId) {
        JSONArray hNodeJSONRep = new JSONArray(inpP.get(ClientJsonKeys.value.name()).toString());
        for (int j=0; j<hNodeJSONRep.length(); j++) {
          JSONObject cNameObj = (JSONObject) hNodeJSONRep.get(j);
          if(hTable == null) {
            AbstractUpdate update = new TrivialErrorUpdate("null HTable while normalizing JSON input for the command " + commandName);
            if (uc == null)
              uc = new UpdateContainer(update);
            else
              uc.add(update);
            continue;
          }
          String nameObjColumnName = cNameObj.getString("columnName");
          logger.debug("Column being normalized: "+ nameObjColumnName);
          HNode node = hTable.getHNodeFromColumnName(nameObjColumnName);
          if(node == null) { //Because add column can happen even if the column after which it is to be added is not present
            AbstractUpdate update = new TrivialErrorUpdate(nameObjColumnName + " does not exist, using empty values");
            if (uc == null)
              uc = new UpdateContainer(update);
            else
              uc.add(update);
            if (addIfNonExist) {
              node = hTable.addHNode(nameObjColumnName, HNodeType.Regular, workspace.getWorksheet(worksheetId), workspace.getFactory());   
            }
            else {
              continue;
            }
          }

          if (j == hNodeJSONRep.length()-1) {    // Found!
            if(node != null)
              inpP.put(ClientJsonKeys.value.name(), node.getId());
            else {
              //Get the id of the last node in the table
              ArrayList<String> allNodeIds = hTable.getOrderedNodeIds();
              //TODO check for allNodeIds.size == 0
              String lastNodeId = allNodeIds.get(allNodeIds.size()-1);
              inpP.put(ClientJsonKeys.value.name(), lastNodeId);
            }
            hTable = workspace.
                getWorksheet(worksheetId).getHeaders();
          } else if(node != null) {
            hTable = node.getNestedTable();
            if (hTable == null && addIfNonExist) {
              hTable = node.addNestedTable("NestedTable", workspace.getWorksheet(worksheetId), workspace.getFactory());
            }
          }
        }
      } else if(HistoryJsonUtil.getParameterType(inpP) == ParameterType.worksheetId) {
        inpP.put(ClientJsonKeys.value.name(), worksheetId);
      } else if (HistoryJsonUtil.getParameterType(inpP) == ParameterType.hNodeIdList) {
        JSONArray hNodes = new JSONArray(inpP.get(ClientJsonKeys.value.name()).toString());
        for (int k = 0; k < hNodes.length(); k++) {
          JSONObject hnodeJSON = hNodes.getJSONObject(k);
          JSONArray hNodeJSONRep = new JSONArray(hnodeJSON.get(ClientJsonKeys.value.name()).toString());
          for (int j=0; j<hNodeJSONRep.length(); j++) {
            JSONObject cNameObj = (JSONObject) hNodeJSONRep.get(j);
            if(hTable == null) {
              AbstractUpdate update = new TrivialErrorUpdate("null HTable while normalizing JSON input for the command " + commandName);
              if (uc == null)
                uc = new UpdateContainer(update);
              else
                uc.add(update);
              continue;
            }
            String nameObjColumnName = cNameObj.getString("columnName");
            logger.debug("Column being normalized: "+ nameObjColumnName);
            HNode node = hTable.getHNodeFromColumnName(nameObjColumnName);
            if(node == null) { //Because add column can happen even if the column after which it is to be added is not present
              AbstractUpdate update = new TrivialErrorUpdate(nameObjColumnName + " does not exist, using empty values");
              if (uc == null)
                uc = new UpdateContainer(update);
              else
                uc.add(update);
              if (addIfNonExist) {
View Full Code Here

TOP

Related Classes of edu.isi.karma.controller.update.AbstractUpdate

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.