Search in sources :

Example 21 with TransientObject

use of io.divide.shared.transitory.TransientObject 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

TransientObject (io.divide.shared.transitory.TransientObject)21 QueryBuilder (io.divide.shared.transitory.query.QueryBuilder)10 Query (io.divide.shared.transitory.query.Query)9 Test (org.junit.Test)6 OTransaction (com.orientechnologies.orient.core.tx.OTransaction)3 NotImplementedException (sun.reflect.generics.reflectiveObjects.NotImplementedException)3 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 ServerTest (io.divide.server.ServerTest)2 DAOException (io.divide.shared.server.DAO.DAOException)2 Credentials (io.divide.shared.transitory.Credentials)2 AuthTokenUtils (io.divide.shared.util.AuthTokenUtils)2 PublicKey (java.security.PublicKey)2 ArrayList (java.util.ArrayList)2 JerseyTest (org.glassfish.jersey.test.JerseyTest)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeLiteral (com.google.inject.TypeLiteral)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 CommitExpection (iBoxDB.LocalServer.E.CommitExpection)1 MockKeyManager (io.divide.client.auth.MockKeyManager)1