use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class Entries method updateVisibility.
public boolean updateVisibility(List<Long> entryIds, Visibility visibility) {
Account account = accountDAO.getByEmail(userId);
List<Group> accountGroups = new GroupController().getAllGroups(account);
if (!new AccountController().isAdministrator(userId) && !permissionDAO.canWrite(account, accountGroups, entryIds))
return false;
for (long entryId : entryIds) {
Entry entry = dao.get(entryId);
if (entry.getVisibility() == visibility.getValue())
continue;
entry.setVisibility(visibility.getValue());
dao.update(entry);
}
return true;
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class RequestRetriever method updateStatus.
public SampleRequest updateStatus(String userId, long requestId, SampleRequestStatus newStatus) {
Request request = dao.get(requestId);
if (request == null)
return null;
Account account = DAOFactory.getAccountDAO().getByEmail(userId);
if (!request.getAccount().getEmail().equalsIgnoreCase(userId) && account.getType() != AccountType.ADMIN) {
throw new PermissionException("No permissions for request");
}
if (request.getStatus() == newStatus)
return request.toDataTransferObject();
request.setStatus(newStatus);
request.setUpdated(new Date());
return dao.update(request).toDataTransferObject();
}
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));
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class TestEntryCreator method createTestAccountAndStrain.
public static Strain createTestAccountAndStrain(String userId) throws Exception {
Account account = AccountCreator.createTestAccount(userId, false);
Assert.assertNotNull(account);
Strain strain = new Strain();
strain.setName("sTrain");
strain.setBioSafetyLevel(BioSafetyOption.LEVEL_ONE.ordinal());
strain.setShortDescription("test strain");
strain = (Strain) new EntryCreator().createEntry(account, strain, null);
return strain;
}
Aggregations