Package org.persvr.data

Examples of org.persvr.data.Persistable


    }
    long found;
    @Override
    public Persistable nextObject() throws IOException {
      while(true){
        Persistable potential = sortedTraverser.nextObject();
        if(potential == null)
          return null;
        try{
          if(operand.matches(potential)){
            found++;
View Full Code Here


      String acceptHeader = httpRequest.getHeader("Accept");
      if(acceptHeader != null) {
        int collectionIndex = acceptHeader.indexOf("collection=");
        if(collectionIndex > -1){
          String collectionProperty = acceptHeader.replaceAll("(.*collection=)(\\w+)(.*)", "$2");
          Persistable newRoot = Persevere.newObject();
          newRoot.set(collectionProperty, value);
          boolean sizeEstimated = value instanceof QueryCollection;
          int size = sizeEstimated ? (int) ((QueryCollection)value).estimatedSize(20) : ((List)value).size();
          newRoot.set("totalCount", size);
          return newRoot;
        }
      }
    }
    return value;
View Full Code Here

        if(!((List)value).isEmpty()){
          value = ((List)value).get(0);
        }
      }
      if(value instanceof Persistable){
        Persistable clazz = ((Persistable)value).getSchema();
        if(clazz != null) {
          ObjectId classId = clazz.getId();
          if(classId.subObjectId != null){
            if("Class".equals(classId.subObjectId))
              response.setContentType(response.getContentType() + ";schema=" + request.idString(classId) + ";schema=http://json-schema.org/hyper-schema");
            else
              response.setContentType(response.getContentType() + ";schema=" + request.idString(classId));
View Full Code Here

    public Request request;
    String getDisplayId(Persistable obj){
      ObjectId objId = obj.getId();
      if(objId.source == null || !objId.hidden())
        return request.idString(obj.getId());
      Persistable parent = obj.getParent();
      if (parent != null) {
       
        if(parent instanceof List){
          if(!(parent instanceof QueryCollection)){
            for(int i = 0; i < ((List)parent).size();i++){
              if(obj == ((List)parent).get(i))
                return getDisplayId(parent) + '.' + i;
            }
          }
        }
          for (Map.Entry<String,Object> entry: parent.entrySet(0)) {
          if(obj == entry.getValue()){
            String startingId = getDisplayId(parent);
            return startingId + (startingId.indexOf('#') == -1 ? '#' : '.') + entry.getKey();
          }
        }
View Full Code Here

          }
          else{
            if(commaNeeded){
              parentHasId = true;
            }
            Persistable schema = obj.getSchema()
            Set<Map.Entry<String,Object>> entries= obj.entrySet(4);
            boolean security = PersistableObject.isSecurityEnabled();
            PersistableObject.enableSecurity(false);
            Object propsObject = schema == null ? null : schema.get("properties");
            boolean objectStarted = false;
            try{
              Persistable properties = propsObject instanceof Persistable ? (Persistable) propsObject : null;
              if(objId.subObjectId == null && objId.source instanceof ClassDataSource)
                objId = null; // this causes the output for root to still serialize identifi
              PersistableObject.enableSecurity(security);
                for (Map.Entry<String,Object> entry: entries) {
                  if(!objectStarted) {
                  writer.write(buffer.toString());
                  objectStarted = true;
                  }
                  String key = entry.getKey();
                  Object value = entry.getValue();
                try {
                  if (!key.startsWith(":") && !("id".equals(key) && obj.getId().source != null))// || request.includeMetaData)
                  {
                    PersistableObject.enableSecurity(false);
                    Object propDef = properties == null ? null : properties.get(key);
                    Object lazyObject = propDef instanceof Persistable ?  ((Persistable)propDef).get("lazy") : null;
                    lazy = lazyObject instanceof Boolean ? (Boolean) lazyObject : null;
                    Object conditional = propDef instanceof Persistable ?  ((Persistable)propDef).get("shouldSerialize") : null;
                    if(conditional instanceof Function){
                      if(!ScriptRuntime.toBoolean(((Function)conditional).call(Context.enter(), GlobalData.getGlobalScope(), obj, new Object[]{}))){
View Full Code Here

  static long rpcId = 1;

  public Object executeRPC(ObjectId target, String methodName, Object[] args){
    // fire off a JSON-RPC request
      PostMethod method = new PostMethod(target.toString());
    Persistable request = new PersistableObject();
    request.put("id", request, rpcId++);
   
    request.put("method",request, methodName);
    request.put("params",request, new PersistableArray(args));
    Client.IndividualRequest clientRequest = new Client("server-request").getIndividualRequest(null, null);
    clientRequest.setRequestedPath(target.toString(), target);
    String jsonRpcMessage = clientRequest.serialize(request);
      method.setRequestBody(jsonRpcMessage);
      try {
View Full Code Here

      }
    }
    if(schemaUrl != null) {
      if(DataSourceManager.getSource(tableUrl) == null && loadingSources.get(tableUrl) == null){
        loadingSources.put(tableUrl, true);
        Persistable schemaForData = (Persistable) Identification.idForRelativeString(url, schemaUrl).getTarget();
        // use a transaction to make the class not really run
        PersistableClass classForData = new PersistableClass();
        classForData.persist = false
        for(Map.Entry<String,Object> entry : schemaForData.entrySet(0)){
          classForData.put(entry.getKey(), classForData, entry.getValue());
        }
        try {
          Map config = new HashMap();
          config.put("name", tableUrl);
View Full Code Here

TOP

Related Classes of org.persvr.data.Persistable

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.