use of org.jbei.ice.lib.dto.History in project ice by JBEI.
the class EntryHistory method get.
public Results<History> get(int limit, int offset, boolean asc, String sort) {
entryAuthorization.expectWrite(userId, entry);
List<Audit> list = dao.getAuditsForEntry(entry, limit, offset, asc, sort);
Results<History> results = new Results<>();
AccountDAO accountDAO = DAOFactory.getAccountDAO();
for (Audit audit : list) {
History history = audit.toDataTransferObject();
if (history.getPartner() == null) {
Account account = accountDAO.getByEmail(history.getUserId());
if (account != null)
history.setAccount(account.toDataTransferObject());
}
results.getData().add(history);
}
long count = dao.getHistoryCount(this.entry);
results.setResultCount(count);
return results;
}
use of org.jbei.ice.lib.dto.History in project ice by JBEI.
the class EntryHistoryTest method testDelete.
@Test
public void testDelete() throws Exception {
Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDelete", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteReader", false);
EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
entryHistory.add();
entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
Results<History> history = entryHistory.get(20, 0, true, null);
Assert.assertNotNull(history);
Assert.assertTrue(entryHistory.delete(history.getData().get(0).getId()));
history = entryHistory.get(20, 0, true, null);
Assert.assertEquals(0, history.getResultCount());
}
use of org.jbei.ice.lib.dto.History in project ice by JBEI.
the class EntryHistoryTest method testGet.
@Test
public void testGet() throws Exception {
Account account = AccountCreator.createTestAccount("EntryHistoryTest.testGet", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testGetReader", false);
EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
entryHistory.add();
entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
Results<History> history = entryHistory.get(20, 0, true, null);
Assert.assertNotNull(history);
Assert.assertEquals(1, history.getResultCount());
History object = history.getData().get(0);
Assert.assertEquals(reader.getEmail(), object.getAccount().getEmail());
}
use of org.jbei.ice.lib.dto.History in project ice by JBEI.
the class EntryHistoryTest method testDeleteAll.
@Test
public void testDeleteAll() throws Exception {
Account account = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAll", false);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Account reader = AccountCreator.createTestAccount("EntryHistoryTest.testDeleteAllReader", false);
EntryHistory entryHistory = new EntryHistory(reader.getEmail(), plasmid.getId());
entryHistory.add();
entryHistory = new EntryHistory(account.getEmail(), plasmid.getId());
Results<History> history = entryHistory.get(20, 0, true, null);
Assert.assertNotNull(history);
Assert.assertEquals(1, entryHistory.deleteAll());
history = entryHistory.get(20, 0, true, null);
Assert.assertEquals(0, history.getResultCount());
}
use of org.jbei.ice.lib.dto.History in project ice by JBEI.
the class Audit method toDataTransferObject.
@Override
public History toDataTransferObject() {
History history = new History();
history.setId(id);
history.setAction(action);
history.setTime(time.getTime());
history.setUserId(userId);
if (remoteClientModel != null) {
history.setPartner(remoteClientModel.getRemotePartner().toDataTransferObject());
}
return history;
}
Aggregations