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());
}
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);
}
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();
}
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());
}
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);
}
}
Aggregations