Search in sources :

Example 1 with Part

use of org.jbei.ice.storage.model.Part in project ice by JBEI.

the class FolderDAOTest method testGetFolderSize.

@Test
public void testGetFolderSize() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetFolderSize", false);
    String email = account.getEmail();
    // create test folder
    Folder folder = createFolderObject("testGetFolderSize");
    folder = dao.create(folder);
    Assert.assertNotNull(folder);
    List<Entry> entries = new ArrayList<>();
    EntryCreator creator = new EntryCreator();
    // create 10 entries
    for (int i = 0; i < 10; i += 1) {
        Part part = new Part();
        part.setName("name" + i);
        part.setOwnerEmail(email);
        part.setAlias("alias" + i);
        part.setShortDescription("short description");
        Entry entry = creator.createEntry(account, part, null);
        entries.add(entry);
    }
    // add entries to folder
    folder = dao.addFolderContents(folder, entries);
    Assert.assertEquals(10, dao.getFolderSize(folder.getId(), null, true).intValue());
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 2 with Part

use of org.jbei.ice.storage.model.Part in project ice by JBEI.

the class FolderDAOTest method testGetFolderContents.

@Test
public void testGetFolderContents() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetFolderContents", false);
    String email = account.getEmail();
    // create test folder
    Folder folder = createFolderObject("testGetFolderContents");
    folder = dao.create(folder);
    Assert.assertNotNull(folder);
    List<Entry> entries = new ArrayList<>();
    EntryCreator creator = new EntryCreator();
    // create 10 entries
    for (int i = 0; i < 10; i += 1) {
        Part part = new Part();
        part.setName("name" + i);
        part.setOwnerEmail(email);
        part.setAlias("alias" + i);
        part.setShortDescription("short description");
        Entry entry = creator.createEntry(account, part, null);
        entries.add(entry);
    }
    // add entries to folder
    folder = dao.addFolderContents(folder, entries);
    Assert.assertNotNull(folder);
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 3 with Part

use of org.jbei.ice.storage.model.Part in project ice by JBEI.

the class SBOLParser method createNewEntry.

protected long createNewEntry(TopLevel moduleDefinition, SBOLDocument document) {
    String identity = moduleDefinition.getIdentity().toString();
    String description = moduleDefinition.getDescription();
    String name = moduleDefinition.getName();
    Part part = new Part();
    part.setOwner(partData.getOwner());
    part.setOwnerEmail(partData.getOwnerEmail());
    part.setCreator(partData.getCreator());
    part.setCreatorEmail(partData.getCreatorEmail());
    part.setPrincipalInvestigator(partData.getPrincipalInvestigator());
    part.setPrincipalInvestigatorEmail(partData.getPrincipalInvestigatorEmail());
    part.setBioSafetyLevel(partData.getBioSafetyLevel());
    part.setStatus(partData.getStatus());
    description = StringUtils.isEmpty(description) ? partData.getShortDescription() : description;
    name = StringUtils.isEmpty(name) ? moduleDefinition.getDisplayId() : name;
    part.setShortDescription(description);
    part.setName(name);
    EntryCreator entryCreator = new EntryCreator();
    Account account = DAOFactory.getAccountDAO().getByEmail(part.getCreatorEmail());
    Entry entry = entryCreator.createEntry(account, part, null);
    parseToGenBank(document, entry.getName(), entry, moduleDefinition.getIdentity().toString());
    identityEntryMap.put(identity, entry.getId());
    return entry.getId();
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) Part(org.jbei.ice.storage.model.Part) EntryCreator(org.jbei.ice.lib.entry.EntryCreator)

Example 4 with Part

use of org.jbei.ice.storage.model.Part in project ice by JBEI.

the class FolderDAOTest method testRemoveFolderEntries.

@Test
public void testRemoveFolderEntries() throws Exception {
    Account account = AccountCreator.createTestAccount("testRemoveFolderEntries", false);
    String email = account.getEmail();
    // create test folder
    Folder folder = createFolderObject("testRemoveFolderEntries");
    folder = dao.create(folder);
    Assert.assertNotNull(folder);
    List<Entry> entries = new ArrayList<>();
    EntryCreator creator = new EntryCreator();
    // create 10 entries
    for (int i = 0; i < 10; i += 1) {
        Part part = new Part();
        part.setName("name" + i);
        part.setOwnerEmail(email);
        part.setAlias("alias" + i);
        part.setShortDescription("short description");
        Entry entry = creator.createEntry(account, part, null);
        entries.add(entry);
    }
    // add entries to folder
    folder = dao.addFolderContents(folder, entries);
    // remove entries from folder
    List<Long> entriesToRemove = new ArrayList<>();
    entriesToRemove.add(entries.get(2).getId());
    entriesToRemove.add(entries.get(8).getId());
    entriesToRemove.add(entries.get(1).getId());
    entriesToRemove.add(entries.get(3).getId());
    dao.removeFolderEntries(folder, entriesToRemove);
    folder = dao.get(folder.getId());
    Assert.assertNotNull(folder);
    Assert.assertEquals(6, folder.getContents().size());
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 5 with Part

use of org.jbei.ice.storage.model.Part in project ice by JBEI.

the class FolderDAOTest method testRetrieveFolderContents.

@Test
public void testRetrieveFolderContents() throws Exception {
    Account account = AccountCreator.createTestAccount("FolderDAOTest.testRetrieveFolderContents", false);
    String email = account.getEmail();
    Folder folder = createFolderObject(email);
    folder = dao.create(folder);
    Assert.assertNotNull(folder);
    // add entries to folder
    EntryCreator creator = new EntryCreator();
    List<Entry> entries = new ArrayList<>();
    for (int i = 1; i <= 9; i += 1) {
        Part part = new Part();
        part.setName("name" + i);
        part.setOwnerEmail(email);
        part.setAlias("alias" + i);
        part.setShortDescription("short description");
        Entry entry = creator.createEntry(account, part, null);
        entries.add(entry);
    }
    // add to folder
    folder = dao.addFolderContents(folder, entries);
    Assert.assertNotNull(folder);
    List<Entry> result = dao.retrieveFolderContents(folder.getId(), new PageParameters(0, 15, ColumnField.NAME, true, null), false);
    Assert.assertNotNull(result);
    for (int i = 1; i <= 9; i += 1) {
        Entry entry = result.get(i - 1);
        Assert.assertEquals(entry.getName(), "name" + i);
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) PageParameters(org.jbei.ice.lib.dto.common.PageParameters) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Aggregations

EntryCreator (org.jbei.ice.lib.entry.EntryCreator)6 Account (org.jbei.ice.storage.model.Account)6 Entry (org.jbei.ice.storage.model.Entry)6 Part (org.jbei.ice.storage.model.Part)6 ArrayList (java.util.ArrayList)5 Folder (org.jbei.ice.storage.model.Folder)5 Test (org.junit.Test)5 PageParameters (org.jbei.ice.lib.dto.common.PageParameters)1