use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class GroupDAO method getMemberCount.
public long getMemberCount(String uuid) {
try {
CriteriaQuery<Long> query = getBuilder().createQuery(Long.class);
Root<Group> from = query.from(Group.class);
Join<Group, Account> member = from.join("members");
query.select(getBuilder().countDistinct(member.get("id")));
query.where(getBuilder().equal(from.get("uuid"), uuid));
return currentSession().createQuery(query).uniqueResult();
} catch (HibernateException e) {
Logger.error(e);
throw new DAOException(e);
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class GroupDAO method retrieveMemberGroups.
public List<Group> retrieveMemberGroups(Account account) {
try {
CriteriaQuery<Group> query = getBuilder().createQuery(Group.class).distinct(true);
Root<Group> from = query.from(Group.class);
Join<Group, Account> members = from.join("members", JoinType.LEFT);
query.where(getBuilder().or(getBuilder().equal(from.get("owner"), account), getBuilder().equal(members.get("email"), account.getEmail())));
return currentSession().createQuery(query).list();
} catch (HibernateException he) {
Logger.error(he);
throw new DAOException(he);
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class AccountCreator method createTestAccount.
public static Account createTestAccount(String testName, boolean admin) throws Exception {
String email = testName + "@TESTER";
AccountDAO dao = DAOFactory.getAccountDAO();
Account account = dao.getByEmail(email);
if (account != null)
throw new Exception("duplicate account");
AccountTransfer accountTransfer = new AccountTransfer();
accountTransfer.setFirstName("TEST_FNAME");
accountTransfer.setLastName("TEST");
accountTransfer.setEmail(email);
accountTransfer = new AccountController().createNewAccount(accountTransfer, false);
Assert.assertNotNull(accountTransfer.getPassword());
account = dao.getByEmail(email);
Assert.assertNotNull(account);
if (admin) {
account.setType(AccountType.ADMIN);
dao.update(account);
}
return account;
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class BulkUploadControllerTest method testGetBulkImport.
@Test
public void testGetBulkImport() throws Exception {
Account account = AccountCreator.createTestAccount("testGetBulkImport", false);
BulkEntryCreator creator = new BulkEntryCreator();
// create bulk upload
long id = creator.createBulkUpload(account.getEmail(), EntryType.PART);
Assert.assertTrue(id > 0);
int count = 100;
for (int i = 0; i < count; i += 1) {
PartData partData = new PartData(EntryType.PLASMID);
partData.setBioSafetyLevel(1);
partData.setShortDescription("part description");
partData.setName("part" + i);
partData = creator.createEntry(account.getEmail(), id, partData);
Assert.assertNotNull(partData);
// add to bulk upload
}
BulkUploadInfo info = controller.getBulkImport(account.getEmail(), id, 0, 100);
Assert.assertNotNull(info);
Assert.assertEquals(info.getEntryList().size(), 100);
// test retrieval in order
for (int i = 0; i < 100; i += 10) {
info = controller.getBulkImport(account.getEmail(), id, i, 10);
Assert.assertNotNull(info);
Assert.assertEquals(info.getEntryList().size(), 10);
ArrayList<PartData> list = info.getEntryList();
int j = i;
for (PartData data : list) {
Assert.assertEquals(data.getName(), "part" + j);
j += 1;
}
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class BulkUploadControllerTest method testDeleteDraftById.
@Test
public void testDeleteDraftById() throws Exception {
Account account = AccountCreator.createTestAccount("testDeleteDraftById", false);
BulkUploadAutoUpdate autoUpdate = new BulkUploadAutoUpdate(EntryType.PLASMID);
autoUpdate.getKeyValue().put(EntryField.SUMMARY, "plasmid summary");
autoUpdate.getKeyValue().put(EntryField.NAME, "plasmid name");
autoUpdate.getKeyValue().put(EntryField.PI, "plasmid principal investigator");
autoUpdate.getKeyValue().put(EntryField.SELECTION_MARKERS, "plasmid select markers");
autoUpdate = controller.autoUpdateBulkUpload(account.getEmail(), autoUpdate, EntryType.PLASMID);
Assert.assertNotNull(autoUpdate);
// delete bulk upload
BulkUploadDeleteTask task = new BulkUploadDeleteTask(account.getEmail(), autoUpdate.getBulkUploadId());
task.execute();
Assert.assertNull(controller.getBulkImport(account.getEmail(), autoUpdate.getBulkUploadId(), 0, 0));
}
Aggregations