public User mapRow(ResultSet rs, int rowNum) throws SQLException { long id = rs.getLong("userId"); if (isCacheEnabled() && lookupCache(cacheManager) != null) { Element element; if ((element = lookupCache(cacheManager).get(DbUtils.hashCodeCacheKeyFor(id))) != null) { log.debug("Cache hit on map for User " + id); return (User) element.getObjectValue(); } } User user = new UserImpl(); user.setUserId(id); user.setActive(rs.getBoolean("active")); user.setAdmin(rs.getBoolean("admin")); user.setExternal(rs.getBoolean("external")); user.setFullName(rs.getString("fullName")); user.setInternal(rs.getBoolean("internal")); user.setLoginName(rs.getString("loginName")); user.setPassword(rs.getString("password")); user.setEmail(rs.getString("email")); try { Blob roleblob = rs.getBlob("roles"); if (roleblob != null) { if (roleblob.length() > 0) { byte[] rbytes = roleblob.getBytes(1, (int) roleblob.length()); String s1 = new String(rbytes); String[] roles = s1.split(","); user.setRoles(roles); } } if (!isLazy()) { user.setGroups(listGroupsByUserId(id)); } } catch (IOException e) { e.printStackTrace(); } if (isCacheEnabled() && lookupCache(cacheManager) != null) { lookupCache(cacheManager).put(new Element(DbUtils.hashCodeCacheKeyFor(id), user)); } return user; }
@Test public void testImportBulkInputXLS() { try { InputStream in = FormUtilsTests.class.getClassLoader().getResourceAsStream("test-bulk_input.xlsx"); LimsUtils.writeFile(in, testSampleBulkInputXlsFile); User u = new UserImpl(); u.setLoginName("testBulkImportUser"); List<Sample> samples = FormUtils.importSampleInputSpreadsheet( testSampleBulkInputXlsFile, u, new MockFormTestRequestManager(), new DefaultLibraryNamingScheme()); log.info("Imported :: " + LimsUtils.join(samples, " | ")); } catch (Exception e) { e.printStackTrace(); TestCase.fail(); } finally { testSampleBulkInputXlsFile.delete(); } }