Search in sources :

Example 11 with Query

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;
    }
}
Also used : Query(io.divide.shared.transitory.query.Query) QueryBuilder(io.divide.shared.transitory.query.QueryBuilder) TransientObject(io.divide.shared.transitory.TransientObject)

Example 12 with Query

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);
    }
}
Also used : Query(io.divide.shared.transitory.query.Query) QueryBuilder(io.divide.shared.transitory.query.QueryBuilder) TransientObject(io.divide.shared.transitory.TransientObject)

Aggregations

Query (io.divide.shared.transitory.query.Query)12 QueryBuilder (io.divide.shared.transitory.query.QueryBuilder)12 TransientObject (io.divide.shared.transitory.TransientObject)9 Test (org.junit.Test)3 BackendObject (io.divide.client.BackendObject)2 DAOException (io.divide.shared.server.DAO.DAOException)2 AuthTokenUtils (io.divide.shared.util.AuthTokenUtils)2 Collection (java.util.Collection)2 Handler (android.os.Handler)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 OnClick (butterknife.OnClick)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)1 BackendUser (io.divide.client.BackendUser)1