Search in sources :

Example 6 with EntryCreator

use of org.jbei.ice.lib.entry.EntryCreator 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 7 with EntryCreator

use of org.jbei.ice.lib.entry.EntryCreator in project ice by JBEI.

the class TestEntryCreator method createTestPlasmid.

public static Plasmid createTestPlasmid(Account account) throws Exception {
    Plasmid plasmid = new Plasmid();
    plasmid.setBackbone("plasmid backone");
    plasmid.setOriginOfReplication("None");
    plasmid.setBioSafetyLevel(1);
    plasmid.setShortDescription("plasmid description");
    plasmid.setName("pLasmid");
    plasmid = (Plasmid) new EntryCreator().createEntry(account, plasmid, null);
    return plasmid;
}
Also used : Plasmid(org.jbei.ice.storage.model.Plasmid) EntryCreator(org.jbei.ice.lib.entry.EntryCreator)

Example 8 with EntryCreator

use of org.jbei.ice.lib.entry.EntryCreator in project ice by JBEI.

the class SelectionMarkerDAOTest method testGetMatchingSelectionMarkers.

@Test
public void testGetMatchingSelectionMarkers() throws Exception {
    String email = "testGetMatchingSelectionMarkers";
    Account account = AccountCreator.createTestAccount(email, false);
    Assert.assertNotNull(account);
    Strain strain = new Strain();
    strain.setName("sTrain");
    strain.setBioSafetyLevel(BioSafetyOption.LEVEL_ONE.ordinal());
    strain.setShortDescription("test strain");
    SelectionMarker marker = new SelectionMarker();
    marker.setName("xkcd");
    SelectionMarker marker2 = new SelectionMarker();
    marker2.setName("test");
    Set<SelectionMarker> markerSet = new HashSet<>();
    markerSet.add(marker);
    markerSet.add(marker2);
    strain.setSelectionMarkers(markerSet);
    EntryCreator creator = new EntryCreator();
    strain = (Strain) creator.createEntry(account, strain, null);
    Assert.assertNotNull(strain);
    Assert.assertEquals(2, strain.getSelectionMarkers().size());
    List<String> results = dao.getMatchingSelectionMarkers("xkcd", 5);
    Assert.assertEquals(1, results.size());
    List<String> res = dao.getMatchingSelectionMarkers("tes", 5);
    Assert.assertEquals(1, res.size());
    Assert.assertEquals("test", res.get(0));
}
Also used : Account(org.jbei.ice.storage.model.Account) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) SelectionMarker(org.jbei.ice.storage.model.SelectionMarker) Strain(org.jbei.ice.storage.model.Strain) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with EntryCreator

use of org.jbei.ice.lib.entry.EntryCreator 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 10 with EntryCreator

use of org.jbei.ice.lib.entry.EntryCreator 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)13 Account (org.jbei.ice.storage.model.Account)10 Entry (org.jbei.ice.storage.model.Entry)8 Test (org.junit.Test)8 Part (org.jbei.ice.storage.model.Part)6 ArrayList (java.util.ArrayList)5 Folder (org.jbei.ice.storage.model.Folder)5 PartData (org.jbei.ice.lib.dto.entry.PartData)3 Strain (org.jbei.ice.storage.model.Strain)3 HashSet (java.util.HashSet)1 TestEntryCreator (org.jbei.ice.lib.TestEntryCreator)1 PageParameters (org.jbei.ice.lib.dto.common.PageParameters)1 PlasmidData (org.jbei.ice.lib.dto.entry.PlasmidData)1 SearchQuery (org.jbei.ice.lib.dto.search.SearchQuery)1 SearchResults (org.jbei.ice.lib.dto.search.SearchResults)1 Plasmid (org.jbei.ice.storage.model.Plasmid)1 SelectionMarker (org.jbei.ice.storage.model.SelectionMarker)1