Package org.bson.types

Examples of org.bson.types.ObjectId


    }

    public void getChunk(Message<JsonObject> message, final JsonObject jsonObject) {

        ObjectId id = getObjectId(message, jsonObject, "files_id");

        Integer n = getRequiredInt("n", message, jsonObject, 0);
        if (n == null) {
            return;
        }
View Full Code Here


        if (idString == null) {
            return null;
        }

        try {
            return new ObjectId(idString);
        } catch (Exception e) {
            sendError(message, fieldName + " " + idString + " is not a valid ObjectId", e);
            return null;
        }
View Full Code Here

     * Remove the _id field, otherwise we get a:
     * org.codehaus.jackson.map.exc.UnrecognizedPropertyException:
     * Unrecognized field "_id" (Class uk.ac.ncl.mucosa.genomepool.data.Organism),
     * not marked as ignorable
     */
    ObjectId idField = (ObjectId) object.removeField("_id");
    T bean =
        jsonMapper.readValue(JSON.serialize(object), expectedType);
    if (bean instanceof DbBean)
    {
      ((DbBean) bean).setId(idField);
View Full Code Here

    if (object == null)
    {
      return null;
    }

    ObjectId idField = (ObjectId) object.get("_id");
    if (!keepDbId)
    {
      /*
       * Remove the _id field, otherwise we get a:
       * org.codehaus.jackson.map.exc.UnrecognizedPropertyException:
 
View Full Code Here

            RepositoryDocument rd = new RepositoryDocument();
            if (Logging.connectors.isDebugEnabled()) {
                Logging.connectors.debug("GridFS: Processing document _id = " + _id);
            }

            GridFSDBFile document = gfs.findOne(new ObjectId(_id));

            if (document == null) {
                activities.deleteDocument(_id);
                i++;
                continue;
View Full Code Here

        getSession();
        int i = 0;
        while (i < versions.length) {
            String _id = documentIdentifiers[i];
            GridFS gridfs = new GridFS(session, bucket);
            GridFSDBFile document = gridfs.findOne(new ObjectId(_id));
            if (document == null) {
                versions[i] = null;
            } else {
                DBObject metadata = document.getMetaData();
                versions[i] = document.getMD5() + "+" + metadata != null
View Full Code Here

    String userId = fromLongToId(Long.parseLong(userID));
    String itemId = fromLongToId(Long.parseLong(itemID));
    if (isUserItemInDB(userId, itemId)) {
      mongoTimestamp = new Date();
      BasicDBObject query = new BasicDBObject();
      query.put(mongoUserID, userIsObject ? new ObjectId(userId) : userId);
      query.put(mongoItemID, itemIsObject ? new ObjectId(itemId) : itemId);
      if (mongoFinalRemove) {
        log.info(collection.remove(query).toString());
      } else {
        BasicDBObject update = new BasicDBObject();
        update.put("$set", new BasicDBObject("deleted_at", mongoTimestamp));
View Full Code Here

    String userId = fromLongToId(Long.parseLong(userID));
    String itemId = fromLongToId(Long.parseLong(itemID));
    if (!isUserItemInDB(userId, itemId)) {
      mongoTimestamp = new Date();
      BasicDBObject user = new BasicDBObject();
      Object userIdObject = userIsObject ? new ObjectId(userId) : userId;
      Object itemIdObject = itemIsObject ? new ObjectId(itemId) : itemId;
      user.put(mongoUserID, userIdObject);
      user.put(mongoItemID, itemIdObject);
      user.put(mongoPreference, preferenceIsString ? preferenceValue : Double.parseDouble(preferenceValue));
      user.put("created_at", mongoTimestamp);
      collection.insert(user);
View Full Code Here

    }
  }

  private boolean isUserItemInDB(String userID, String itemID) {
    BasicDBObject query = new BasicDBObject();
    Object userId = userIsObject ? new ObjectId(userID) : userID;
    Object itemId = itemIsObject ? new ObjectId(itemID) : itemID;
    query.put(mongoUserID, userId);
    query.put(mongoItemID, itemId);
    return collection.findOne(query) != null;
  }
View Full Code Here

    @RequestMapping(value = "/deleteuser", method = RequestMethod.POST)
    public String deleteUser(
            @RequestParam(value = "id") String id,
            Model model) {

        userRepository.delete(new ObjectId(id));
        List<User> users = userService.readAll();
        model.addAttribute("users", users);
        return "redirect:home";
    }
View Full Code Here

TOP

Related Classes of org.bson.types.ObjectId

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.