Ejemplo n.º 1
0
 // Updating the info from an existing user.
 public void updateUsuario(UsuarioSiar usuarioSiar) throws Exception {
   UsuarioSiar existingUser =
       siarmongoTemplate.findById(usuarioSiar.getId(), UsuarioSiar.class, "usuarioSiarTable");
   if (existingUser == null) {
     throw new Exception("User not found");
   }
   siarmongoTemplate.save(usuarioSiar, "usuarioSiarTable");
 }
Ejemplo n.º 2
0
 // Removes an user from the repository.
 public void removeUsuario(String id) throws Exception {
   UsuarioSiar existingUser =
       siarmongoTemplate.findById(new ObjectId(id), UsuarioSiar.class, "usuarioSiarTable");
   if (existingUser == null) {
     throw new Exception("User not found");
   }
   siarmongoTemplate.remove(existingUser, "usuarioSiarTable");
 }
 /**
  * retrieves the {@link Account} of given id
  *
  * @param accountId the user storage account id
  * @return the Account
  * @throws NotFoundException if Account doesn't exist
  */
 public Account findById(String accountId) throws NotFoundException {
   Account account = db.findById(accountId, Account.class);
   if (account == null) {
     logger.error("Account not found: " + accountId);
     throw new NotFoundException();
   }
   return account;
 }
  @Override
  public UniversalRecord find(String id) {
    return template.findById(id, UniversalRecord.class, docCollectionName);

    //        QUniversalRecord universalRecord = QUniversalRecord.universalRecord;
    //        List<UniversalRecord> list =
    // from(universalRecord).where(universalRecord.id.eq(id)).list(universalRecord);
    //        return list.get(0);
  }
 /**
  * saves a new account
  *
  * @param account the user storage account to save
  * @return the account saved with id field populated
  * @throws AlreadyStoredException if account is already stored
  */
 public Account save(Account account) throws AlreadyStoredException {
   if (account.getId() != null && db.findById(account.getId(), Account.class) != null) {
     logger.error("Account already stored, " + account.getId());
     throw new AlreadyStoredException();
   }
   if (account.getId() == null || account.getId().trim().length() == 0) {
     account.setId(new ObjectId().toString());
   }
   db.save(account);
   return account;
 }
Ejemplo n.º 6
0
  @Override
  public DocumentDAO findById(String id) {

    return mongoTemplate.findById(id, DocumentDAO.class);
  }
Ejemplo n.º 7
0
 @Override
 public Passgrid findOne(String id) {
   Passgrid result = mongoTemplate.findById(id, Passgrid.class, COLLECTION_NAME);
   return result;
 }
Ejemplo n.º 8
0
 // Finds an user by its id in the repository.
 public UsuarioSiar findUsuarioById(String id) {
   return siarmongoTemplate.findById(new ObjectId(id), UsuarioSiar.class, "usuarioSiarTable");
 }
Ejemplo n.º 9
0
 public boolean exists(Serializable id) {
   return null == mongoTemplate.findById(id, entityClass);
 }
Ejemplo n.º 10
0
 public T findById(Serializable id) {
   return mongoTemplate.findById(id, entityClass);
 }