Search in sources :

Example 1 with Account

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;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) AccountController(org.jbei.ice.lib.account.AccountController)

Example 2 with Account

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();
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Account(org.jbei.ice.storage.model.Account) Request(org.jbei.ice.storage.model.Request)

Example 3 with 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;
        }
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) PartData(org.jbei.ice.lib.dto.entry.PartData) Test(org.junit.Test)

Example 4 with Account

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));
}
Also used : Account(org.jbei.ice.storage.model.Account) Test(org.junit.Test)

Example 5 with Account

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;
}
Also used : Account(org.jbei.ice.storage.model.Account) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Strain(org.jbei.ice.storage.model.Strain)

Aggregations

Account (org.jbei.ice.storage.model.Account)207 Test (org.junit.Test)123 HibernateRepositoryTest (org.jbei.ice.storage.hibernate.HibernateRepositoryTest)62 PartData (org.jbei.ice.lib.dto.entry.PartData)31 Entry (org.jbei.ice.storage.model.Entry)30 Strain (org.jbei.ice.storage.model.Strain)27 Group (org.jbei.ice.storage.model.Group)26 ArrayList (java.util.ArrayList)24 Plasmid (org.jbei.ice.storage.model.Plasmid)22 Folder (org.jbei.ice.storage.model.Folder)21 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)17 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)16 PermissionException (org.jbei.ice.lib.access.PermissionException)12 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)12 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)11 Sequence (org.jbei.ice.storage.model.Sequence)11 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)10 DAOException (org.jbei.ice.storage.DAOException)9 Date (java.util.Date)8 HashSet (java.util.HashSet)8