TSRole manager = commonDao.findByProperty(TSRole.class, "roleCode",
"manager").get(0);
List<TSUser> user = commonDao.loadAll(TSUser.class);
for (int i = 0; i < user.size(); i++) {
if (user.get(i).getEmail() != null) {
TSRoleUser roleuser = new TSRoleUser();
roleuser.setTSUser(user.get(i));
roleuser.setTSRole(manager);
commonDao.saveOrUpdate(roleuser);
} else {
TSRoleUser roleuser = new TSRoleUser();
roleuser.setTSUser(user.get(i));
roleuser.setTSRole(admin);
commonDao.saveOrUpdate(roleuser);
}
if (user.get(i).getSignatureFile() != null) {
TSRoleUser roleuser = new TSRoleUser();
roleuser.setTSUser(user.get(i));
roleuser.setTSRole(admin);
commonDao.saveOrUpdate(roleuser);
}
}
}