Package com.erudika.para.core

Examples of com.erudika.para.core.ParaObject


          return getStatusResponse(Response.Status.BAD_REQUEST,
              "Request is too large - the maximum is 1MB.");
        }
        List<Map<String, Object>> items = Utils.getJsonReader(List.class).readValue(is);
        for (Map<String, Object> object : items) {
          ParaObject pobj = Utils.setAnnotatedFields(object);
          if (pobj != null && Utils.isValidObject(pobj)) {
            pobj.setAppid(app.getAppIdentifier());
            pobj.setShardKey(app.isShared() ? app.getAppIdentifier() : null);
            objects.add(pobj);
          }
        }

        Para.getDAO().createAll(app.getAppIdentifier(), objects);
View Full Code Here


        }
        List<Map<String, Object>> items = Utils.getJsonReader(List.class).readValue(is);
        // WARN: objects will not be validated here as this would require them to be read first
        for (Map<String, Object> item : items) {
          if (item != null && item.containsKey(Config._ID) && item.containsKey(Config._TYPE)) {
            ParaObject pobj = Utils.setAnnotatedFields(null, item, Locked.class);
            if (pobj != null) {
              pobj.setId((String) item.get(Config._ID));
              pobj.setType((String) item.get(Config._TYPE));
              pobj.setShardKey(app.isShared() ? app.getAppIdentifier() : null);
              objects.add(pobj);
            }
          }
        }
        Para.getDAO().updateAll(app.getAppIdentifier(), objects);
View Full Code Here

  private void initCoreTypes() {
    Set<Class<? extends ParaObject>> coreClasses = new HashSet<Class<? extends ParaObject>>();
    RestUtils.scanForDomainClasses(coreClasses);
    try {
      for (Class<? extends ParaObject> clazz : coreClasses) {
        ParaObject p = clazz.newInstance();
        coreTypes.put(p.getPlural(), p.getType());
      }
    } catch (Exception ex) {
      logger.error(null, ex);
    }
  }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> readHandler(final String type) {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        ParaObject obj = Utils.toObject(type);
        obj.setId(ctx.getUriInfo().getPathParameters().getFirst(Config._ID));
        return RestUtils.getReadResponse(dao.read(obj.getId()));
      }
    };
  }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> updateHandler(final String type) {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        ParaObject obj = Utils.toObject(type);
        obj.setType(type);
        obj.setId(ctx.getUriInfo().getPathParameters().getFirst(Config._ID));
        return RestUtils.getUpdateResponse(dao.read(obj.getId()), ctx.getEntityStream());
      }
    };
  }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> deleteHandler(final String type) {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        ParaObject obj = Utils.toObject(type);
        obj.setType(type);
        obj.setId(ctx.getUriInfo().getPathParameters().getFirst(Config._ID));
        return RestUtils.getDeleteResponse(obj);
      }
    };
  }
View Full Code Here

   * @param type type of the object to create (not used)
   * @param is entity input stream
   * @return a status code 201 or 400
   */
  public static Response getCreateResponse(String type, InputStream is) {
    ParaObject content = null;
    try {
      if (is != null && is.available() > 0) {
        Map<String, Object> newContent = Utils.getJsonReader(Map.class).readValue(is);
        content = Utils.setAnnotatedFields(newContent);
      }
View Full Code Here

  @Override
  public <P extends ParaObject> void update(String appid, P so) {
    if (so != null && !StringUtils.isBlank(appid)) {
      so.setUpdated(Utils.timestamp());
      ParaObject soUpdated = getMap(appid).get(so.getId());
      Utils.setAnnotatedFields(soUpdated, Utils.getAnnotatedFields(so), Locked.class);
      getMap(appid).put(so.getId(), soUpdated);
      logger.debug("DAO.update() {}", so.getId());
    }
  }
View Full Code Here

    register(UnavailableExceptionMapper.class);

    // core objects CRUD API
    try {
      for (Class<? extends ParaObject> clazz : coreClasses) {
        ParaObject p = clazz.newInstance();
        registerCrudApi(p.getPlural(), crudHandler(Utils.type(clazz)));
      }
    } catch (Exception ex) {
      logger.error(null, ex);
    }
View Full Code Here

  }

  private Inflector<ContainerRequestContext, Response> readHandler(final String type) {
    return new Inflector<ContainerRequestContext, Response>() {
      public Response apply(ContainerRequestContext ctx) {
        ParaObject obj = Utils.toObject(type);
        obj.setId(ctx.getUriInfo().getPathParameters().getFirst(Config._ID));
        return RestUtils.getReadResponse(dao.read(obj.getId()));
      }
    };
  }
View Full Code Here

TOP

Related Classes of com.erudika.para.core.ParaObject

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.