use of io.divide.shared.transitory.query.Query in project divide by HiddenStage.
the class AuthServerLogic method validateAccount.
/**
* Validate a user account
* @param token
*/
public boolean validateAccount(String token) throws DAOException {
Query q = new QueryBuilder().select().from(Credentials.class).where("validation", OPERAND.EQ, token).build();
TransientObject to = ObjectUtils.get1stOrNull(dao.query(q));
if (to != null) {
ServerCredentials creds = new ServerCredentials(to);
creds.setValidation("1");
dao.save(creds);
return true;
} else {
return false;
}
}
use of io.divide.shared.transitory.query.Query in project divide by HiddenStage.
the class DaoUtils method getUserById.
/**
* Convience method to do a Credentials query against an user id.
* @param serverDao dao object to query against.
* @param userId user id used in query.
* @return Credentials object found or null.
* @throws io.divide.shared.server.DAO.DAOException
*/
public static Credentials getUserById(DAO serverDao, String userId) throws DAO.DAOException {
Query query = new QueryBuilder().select().from(Credentials.class).where(Credentials.OWNER_ID_KEY, OPERAND.EQ, userId).build();
TransientObject to = (TransientObject) ObjectUtils.get1stOrNull(serverDao.query(query));
if (to == null) {
return null;
} else {
return to(Credentials.class, to);
}
}
Aggregations