Search in sources :

Example 36 with PartData

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

the class EntryLinks method get.

/**
     * Retrieves entry links that are parents or children depending on specified type
     *
     * @param type specified type of links to return
     * @return list of links that match specified type. These are filtered based on user permissions
     */
public List<PartData> get(LinkType type) {
    List<Entry> entries;
    if (type == LinkType.CHILD) {
        entries = new ArrayList<>(this.entry.getLinkedEntries());
    } else {
        entries = this.entryDAO.getParents(this.entry.getId());
    }
    // get sequence and other summary information
    List<PartData> results = new ArrayList<>(entries.size());
    for (Entry entry : entries) {
        if (!this.entryAuthorization.canRead(this.userId, entry))
            continue;
        PartData partData = new PartData(EntryType.nameToType(entry.getRecordType()));
        partData.setId(entry.getId());
        partData.setName(entry.getName());
        partData.setPartId(entry.getPartNumber());
        partData.setShortDescription(entry.getShortDescription());
        boolean hasSequence = sequenceDAO.hasSequence(entry.getId());
        partData.setHasSequence(hasSequence);
        boolean hasOriginalSequence = sequenceDAO.hasOriginalSequence(entry.getId());
        partData.setHasOriginalSequence(hasOriginalSequence);
        Optional<String> sequenceString = sequenceDAO.getSequenceString(entry);
        if (sequenceString.isPresent()) {
            String sequence = sequenceString.get();
            int featureCount = sequenceFeatureDAO.getFeatureCount(entry);
            partData.setBasePairCount(sequence.trim().length());
            partData.setFeatureCount(featureCount);
        } else {
            partData.setBasePairCount(0);
        }
        results.add(partData);
    }
    return results;
}
Also used : Entry(org.jbei.ice.storage.model.Entry) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 37 with PartData

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

the class FolderContents method addToRemoteFolder.

// transfer entries to remote partner and add to folder
protected void addToRemoteFolder(Account account, Folder folder, List<Long> entries) {
    RemoteAccessModel remoteAccessModel = remoteAccessModelDAO.getByFolder(account, folder);
    if (remoteAccessModel == null) {
        Logger.error("Could not retrieve remote access for folder " + folder.getId());
        return;
    }
    RemotePartner remotePartner = remoteAccessModel.getRemoteClientModel().getRemotePartner();
    RemoteTransfer remoteTransfer = new RemoteTransfer();
    List<PartData> results = remoteTransfer.getPartsForTransfer(entries);
    List<Long> remoteIds = remoteTransfer.transferEntries(remotePartner.getId(), results);
    FolderDetails remoteFolder = new FolderDetails();
    remoteFolder.setId(Long.decode(remoteAccessModel.getIdentifier()));
    // add transferred entries to the folder
    EntrySelection selection = new EntrySelection();
    selection.getEntries().addAll(remoteIds);
    selection.getDestination().add(remoteFolder);
    selection.setSelectionType(EntrySelectionType.FOLDER);
    String token = remoteAccessModel.getToken();
    remoteContact.addTransferredEntriesToFolder(remotePartner.getUrl(), account.getEmail(), selection, remoteFolder.getId(), token, remotePartner.getApiKey());
}
Also used : EntrySelection(org.jbei.ice.lib.entry.EntrySelection) RemoteTransfer(org.jbei.ice.lib.net.RemoteTransfer) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Example 38 with PartData

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

the class Strain method toDataTransferObject.

@Override
public PartData toDataTransferObject() {
    PartData data = super.toDataTransferObject();
    StrainData strainData = new StrainData();
    strainData.setGenotypePhenotype(genotypePhenotype);
    strainData.setHost(host);
    data.setStrainData(strainData);
    return data;
}
Also used : StrainData(org.jbei.ice.lib.dto.entry.StrainData) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 39 with PartData

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

the class Request method toDataTransferObject.

@Override
public SampleRequest toDataTransferObject() {
    SampleRequest sampleRequest = new SampleRequest();
    sampleRequest.setId(getId());
    sampleRequest.setRequestType(getType());
    sampleRequest.setStatus(getStatus());
    if (growthTemperature != null)
        sampleRequest.setGrowthTemperature(growthTemperature);
    sampleRequest.setPlateDescription(plateDescription);
    EntryType type = EntryType.nameToType(entry.getRecordType());
    PartData data = new PartData(type);
    data.setId(entry.getId());
    data.setPartId(entry.getPartNumber());
    data.setSelectionMarkers(EntryUtil.getSelectionMarkersAsList(entry.getSelectionMarkers()));
    data.setName(entry.getName());
    sampleRequest.setPartData(data);
    sampleRequest.setRequester(getAccount().toDataTransferObject());
    sampleRequest.setRequestTime(getRequested().getTime());
    sampleRequest.setUpdateTime(getUpdated() == null ? sampleRequest.getRequestTime() : getUpdated().getTime());
    return sampleRequest;
}
Also used : EntryType(org.jbei.ice.lib.dto.entry.EntryType) PartData(org.jbei.ice.lib.dto.entry.PartData) SampleRequest(org.jbei.ice.lib.dto.sample.SampleRequest)

Example 40 with PartData

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

the class FolderContentsTest method testGetContents.

@Test
public void testGetContents() throws Exception {
    FolderContents folderContents = new FolderContents();
    // test with null id
    folderContents.getContents(null, 0, new PageParameters(0, 10, ColumnField.PART_ID, false, null));
    Account account = AccountCreator.createTestAccount("testRetrieveFolderContents", false);
    String userId = account.getEmail();
    FolderDetails folderDetails = new FolderDetails();
    folderDetails.setName("test");
    // create folder
    FolderDetails folder = createPersonalFolder(userId, folderDetails);
    Assert.assertNotNull(folder);
    final short size = 105;
    // create 100 test strains
    HashMap<String, Entry> parts = new HashMap<>();
    List<Long> entryList = new ArrayList<>();
    for (int i = 0; i < size; i += 1) {
        Strain strain = TestEntryCreator.createTestStrain(account);
        Assert.assertNotNull(strain);
        parts.put(strain.getPartNumber(), strain);
        entryList.add(strain.getId());
    }
    Assert.assertEquals(size, parts.size());
    // add to folder
    List<FolderDetails> foldersToAdd = new ArrayList<>();
    foldersToAdd.add(folder);
    foldersToAdd = folderContents.addEntriesToFolders(account.getEmail(), entryList, foldersToAdd);
    Assert.assertNotNull(foldersToAdd);
    // keep track to find duplicates
    HashSet<Long> set = new HashSet<>();
    // retrieve (supported sort types created, status, name, part_id, type)
    FolderDetails details = folderContents.getContents(account.getEmail(), folder.getId(), new PageParameters(0, 15, ColumnField.PART_ID, false, null));
    Assert.assertNotNull(details);
    short pageSize = 15;
    int it = 1;
    while (!details.getEntries().isEmpty()) {
        Assert.assertEquals(pageSize, details.getEntries().size());
        for (PartData partData : details.getEntries()) {
            Assert.assertNotNull(parts.remove(partData.getPartId()));
            Assert.assertFalse(set.contains(partData.getId()));
            set.add(partData.getId());
        }
        // check remaining
        Assert.assertEquals((size - (it * pageSize)), parts.size());
        details = folderContents.getContents(account.getEmail(), folder.getId(), new PageParameters(pageSize * it, pageSize, ColumnField.PART_ID, false, null));
        it += 1;
    }
}
Also used : Account(org.jbei.ice.storage.model.Account) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) PageParameters(org.jbei.ice.lib.dto.common.PageParameters) Strain(org.jbei.ice.storage.model.Strain) Entry(org.jbei.ice.storage.model.Entry) 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