Package dovetaildb.apiservice

Examples of dovetaildb.apiservice.ApiService


//          throw new RuntimeException(e);
//        }
//      }
    }
    Object returnVal = null;
    ApiService api = repo.newSession(req.db);
    if (req.action == "call") { // double equals ok here (both sides are from literal strings)
      List arguments = (List)Util.jsonDecode(req.request.getParameter("arguments"));
      returnVal = repo.invokeFunction(req.db, req.methodName, arguments.toArray());
    } else if (req.action == "execute") {
      String code = req.request.getParameter("code");
      ArrayList<Pair<String,String>> codeFiles = new ArrayList<Pair<String,String>>(1);
      codeFiles.set(0, new Pair<String, String>("<execute code>", code));
      Map<String,Object> env = Util.literalMap().p("dovetaildb", api);
      returnVal = (new UniversalScriptBridge()).evaluateExpression(req.scriptLanguage+":"+codeFiles, env);
    } else if (req.action == "query") {
      String query = req.request.getParameter("query");
      returnVal = api.query(req.bagName, (List)Util.jsonDecode(query), null);
    } else if (req.action == "insert") {
      Map<String,Object> entry = (Map<String,Object>)Util.jsonDecode(req.request.getParameter("entry"));
      if (req.id != null) {
        entry.put("id", req.id);
      }
      api.insert(req.bagName, entry);
    } else if (req.action == "update") {
      Map<String,Object> entry = (Map<String,Object>)Util.jsonDecode(req.request.getParameter("entry"));
      api.update(req.bagName, req.id, entry);
    } else if (req.action == "remove") {
      api.remove(req.bagName, req.id);
    }
    return returnVal;
  }
View Full Code Here


  ConcurrentHashMap<String, DbRecord> repo;

 
  public ApiService newSession(String db) {
    DbRecord rec = repo.get(db);
    ApiService api = new ChangesetBuffer(rec.db, rec.coordinator);
    if (rec.apiServiceWrapperFn != null)
      api = rec.apiServiceWrapperFn.wrapApiService(api);
    return api;
  }
View Full Code Here

TOP

Related Classes of dovetaildb.apiservice.ApiService

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.