Search in sources :

Example 26 with PartData

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);
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 27 with PartData

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

Example 28 with PartData

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

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

Example 30 with PartData

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

Aggregations

PartData (org.jbei.ice.lib.dto.entry.PartData)62 Entry (org.jbei.ice.storage.model.Entry)22 Account (org.jbei.ice.storage.model.Account)18 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)8 Results (org.jbei.ice.lib.dto.common.Results)5 EntryField (org.jbei.ice.lib.dto.entry.EntryField)4 Group (org.jbei.ice.storage.model.Group)4 Strain (org.jbei.ice.storage.model.Strain)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 PermissionException (org.jbei.ice.lib.access.PermissionException)3 SearchResult (org.jbei.ice.lib.dto.search.SearchResult)3 SearchResults (org.jbei.ice.lib.dto.search.SearchResults)3 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)3 GroupController (org.jbei.ice.lib.group.GroupController)3 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)3 Plasmid (org.jbei.ice.storage.model.Plasmid)3 RemotePartner (org.jbei.ice.storage.model.RemotePartner)3