Search in sources :

Example 6 with Profile

use of io.bastillion.manage.model.Profile in project KeyBox by skavanagh.

the class ProfileDB method getAllProfiles.

/**
 * returns all profile information
 *
 * @return list of profiles
 */
public static List<Profile> getAllProfiles() throws SQLException, GeneralSecurityException {
    ArrayList<Profile> profileList = new ArrayList<>();
    Connection con = DBUtils.getConn();
    PreparedStatement stmt = con.prepareStatement("select * from  profiles order by nm asc");
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
        Profile profile = new Profile();
        profile.setId(rs.getLong("id"));
        profile.setNm(rs.getString("nm"));
        profile.setDesc(rs.getString("desc"));
        profileList.add(profile);
    }
    DBUtils.closeRs(rs);
    DBUtils.closeStmt(stmt);
    DBUtils.closeConn(con);
    return profileList;
}
Also used : ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Profile(io.bastillion.manage.model.Profile)

Example 7 with Profile

use of io.bastillion.manage.model.Profile in project KeyBox by skavanagh.

the class UserProfileDB method getProfilesByUser.

/**
 * return a list of profiles for user
 *
 * @param userId user id
 * @return profile list
 */
public static List<Profile> getProfilesByUser(Connection con, Long userId) throws SQLException {
    ArrayList<Profile> profileList = new ArrayList<>();
    PreparedStatement stmt = con.prepareStatement("select * from  profiles g, user_map m where g.id=m.profile_id and m.user_id=? order by nm asc");
    stmt.setLong(1, userId);
    ResultSet rs = stmt.executeQuery();
    while (rs.next()) {
        Profile profile = new Profile();
        profile.setId(rs.getLong("id"));
        profile.setNm(rs.getString("nm"));
        profile.setDesc(rs.getString("desc"));
        profileList.add(profile);
    }
    DBUtils.closeRs(rs);
    DBUtils.closeStmt(stmt);
    return profileList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Profile(io.bastillion.manage.model.Profile)

Aggregations

Profile (io.bastillion.manage.model.Profile)7 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)3 HostSystem (io.bastillion.manage.model.HostSystem)1