use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class WebResource method getWebEntry.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries/{entryId}")
public Response getWebEntry(@PathParam("id") final long partnerId, @PathParam("entryId") final long entryId) {
final String userId = super.getUserId();
final PartData result = remoteEntries.getPublicEntry(userId, partnerId, entryId);
return super.respond(Response.Status.OK, result);
}
use of org.jbei.ice.lib.dto.entry.PartData 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.lib.dto.entry.PartData in project ice by JBEI.
the class BulkEntryCreatorTest method testCreateEntry.
@Test
public void testCreateEntry() throws Exception {
Account account = AccountCreator.createTestAccount("testCreateEntry", false);
long uploadId = creator.createBulkUpload(account.getEmail(), EntryType.PLASMID);
PartData partData = new PartData(EntryType.PLASMID);
partData.setShortDescription("test summary");
partData.setName("plasmid");
partData.setBioSafetyLevel(1);
partData = creator.createEntry(account.getEmail(), uploadId, partData);
Assert.assertNotNull(partData);
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class TransferredPartsTest method testReceiveTransferredEntry.
@Test
public void testReceiveTransferredEntry() throws Exception {
Account account = AccountCreator.createTestAccount("testReceivedTransferredEntry", false);
Strain strain = createStrainObject(account);
Plasmid plasmid = createPlasmidObject(account);
// link the two
PartData strainData = strain.toDataTransferObject();
PartData plasmidData = plasmid.toDataTransferObject();
strainData.getLinkedParts().add(plasmidData);
strainData = parts.receiveTransferredEntry(strainData);
Assert.assertNotNull(strainData);
strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
Assert.assertNotNull(strain);
Assert.assertTrue(strain.getVisibility() == Visibility.TRANSFERRED.getValue());
plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
Assert.assertNotNull(plasmid);
Assert.assertTrue(plasmid.getVisibility() == Visibility.TRANSFERRED.getValue());
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
// create new plasmid
Plasmid plasmid2 = createPlasmidObject(account);
strainData.getLinkedParts().add(plasmid2.toDataTransferObject());
Assert.assertEquals(2, strainData.getLinkedParts().size());
// transfer strain (with 2 linked plasmids)
PartData received = parts.receiveTransferredEntry(strainData);
Assert.assertNotNull(received);
// check return
strain = (Strain) DAOFactory.getEntryDAO().get(strainData.getId());
Assert.assertNotNull(strain);
plasmid = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(0).getId());
Assert.assertNotNull(plasmid);
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid));
plasmid2 = (Plasmid) DAOFactory.getEntryDAO().get(strainData.getLinkedParts().get(1).getId());
Assert.assertNotNull(plasmid2);
Assert.assertTrue(strain.getLinkedEntries().contains(plasmid2));
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class EntryDAOTest method testGetByUniqueName.
@Test
public void testGetByUniqueName() throws Exception {
Account account = AccountCreator.createTestAccount("testGetByUniqueName", false);
PartData data = new PartData(EntryType.PART);
data.setShortDescription("summary for test");
String uniqueName = "pTest" + account.getEmail();
data.setName(uniqueName);
data.setBioSafetyLevel(1);
EntryCreator creator = new EntryCreator();
creator.createPart(account.getEmail(), data);
List<Entry> entries = entryDAO.getByName("pTest");
Assert.assertTrue(entries == null || entries.isEmpty());
entries = entryDAO.getByName(uniqueName);
Assert.assertNotNull(entries);
}
Aggregations