Search in sources :

Example 16 with Results

use of org.jbei.ice.lib.dto.common.Results in project ice by JBEI.

the class Features method get.

public Results<DNAFeature> get(int start, int count) {
    Entry entry = super.getEntry(this.sequenceIdentifier);
    List<SequenceFeature> list = dao.pageSequenceFeatures(entry, start, count);
    long number = dao.countSequenceFeatures(entry);
    Sequence sequence = new Sequence();
    sequence.setEntry(entry);
    FeaturedDNASequence featuredDNASequence = SequenceUtil.sequenceToDNASequence(sequence, list);
    Results<DNAFeature> results = new Results<>();
    results.setResultCount(number);
    results.setData(featuredDNASequence.getFeatures());
    return results;
}
Also used : HasEntry(org.jbei.ice.lib.entry.HasEntry) Entry(org.jbei.ice.storage.model.Entry) Results(org.jbei.ice.lib.dto.common.Results) SequenceFeature(org.jbei.ice.storage.model.SequenceFeature) Sequence(org.jbei.ice.storage.model.Sequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence)

Example 17 with Results

use of org.jbei.ice.lib.dto.common.Results in project ice by JBEI.

the class Annotations method get.

/**
 * Retrieves list of annotations that are available
 *
 * @param offset paging start
 * @param limit  maximum number of annotations to return
 * @param sort   paging sort
 * @return available annotations that conform to parameters along with the total number that are available
 * @throws PermissionException if the requesting user's account does not have administrative privileges
 */
public Results<DNAFeatures> get(int offset, int limit, String sort) {
    if (!isAdministrator())
        throw new PermissionException("Administrative privileges required to retrieve features");
    long count = this.featureDAO.getFeaturesGroupByCount();
    Results<DNAFeatures> results = new Results<>();
    results.setResultCount(count);
    Map<String, List<Feature>> map = this.featureDAO.getFeaturesGroupBy(offset, limit);
    for (String key : map.keySet()) {
        DNAFeatures features = new DNAFeatures(key);
        for (Feature feature : map.get(key)) {
            DNAFeature dnaFeature = feature.toDataTransferObject();
            dnaFeature.setSequence(feature.getSequence());
            List<Long> entries = this.sequenceFeatureDAO.getEntryIdsByFeature(feature);
            if (entries != null)
                dnaFeature.getEntries().addAll(entries);
            features.getFeatures().add(dnaFeature);
        }
        results.getData().add(features);
    }
    return results;
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) DNAFeatures(org.jbei.ice.lib.dto.DNAFeatures) Results(org.jbei.ice.lib.dto.common.Results) List(java.util.List) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 18 with Results

use of org.jbei.ice.lib.dto.common.Results in project ice by JBEI.

the class Annotations method filter.

public Results<DNAFeature> filter(int offset, int limit, String filter) {
    Account account = accountDAO.getByEmail(userId);
    List<Group> groups = new GroupController().getAllGroups(account);
    List<SequenceFeature> features = sequenceFeatureDAO.getSequenceFeatures(this.userId, groups, filter, offset, limit);
    int count = sequenceFeatureDAO.getSequenceFeaturesCount(this.userId, groups, filter);
    Results<DNAFeature> results = new Results<>();
    results.setResultCount(count);
    for (SequenceFeature feature : features) {
        DNAFeature dnaFeature = feature.toDataTransferObject();
        Entry entry = feature.getSequence().getEntry();
        dnaFeature.setIdentifier(entry.getPartNumber());
        DNAFeatureLocation location = new DNAFeatureLocation();
        location.setGenbankStart(feature.getUniqueGenbankStart());
        location.setEnd(feature.getUniqueEnd());
        dnaFeature.getLocations().add(location);
        dnaFeature.getEntries().add(entry.getId());
        results.getData().add(dnaFeature);
    }
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) GroupController(org.jbei.ice.lib.group.GroupController) DNAFeatureLocation(org.jbei.ice.lib.dto.DNAFeatureLocation) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 19 with Results

use of org.jbei.ice.lib.dto.common.Results in project ice by JBEI.

the class CollectionEntries method getSharedEntries.

/**
 * Retrieves entries shared with user.
 *
 * @param field  sort field
 * @param asc    sort order ascending if true, descending if false
 * @param offset paging parameter start
 * @param limit  maximum number of entries to retrieve
 * @param filter optional text to filter entries by
 * @return wrapper around list of parts matching the parameters along with the maximum number of entries
 * available
 */
private Results<PartData> getSharedEntries(ColumnField field, boolean asc, int offset, int limit, String filter, List<String> fields) {
    SharedEntries sharedEntries = new SharedEntries(this.userId);
    List<PartData> entries = sharedEntries.getEntries(field, asc, offset, limit, filter, fields);
    final long count = sharedEntries.getNumberOfEntries(filter);
    Results<PartData> results = new Results<>();
    results.setResultCount(count);
    results.setData(entries);
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) PartData(org.jbei.ice.lib.dto.entry.PartData) SharedEntries(org.jbei.ice.lib.entry.SharedEntries)

Example 20 with Results

use of org.jbei.ice.lib.dto.common.Results in project ice by JBEI.

the class CollectionEntries method getPersonalEntries.

/**
 * Retrieves entries owned by user
 *
 * @param field  sort field
 * @param asc    sort order
 * @param offset paging start
 * @param limit  maximum number of entries to retrieve
 * @param filter optional text to filter entries by
 * @return wrapper around list of parts that conform to the parameters and the maximum number
 * of such entries that are available
 * @throws PermissionException on null user id which is required for owner entries
 */
private Results<PartData> getPersonalEntries(ColumnField field, boolean asc, int offset, int limit, String filter, List<String> fields) {
    if (userId == null || userId.isEmpty())
        throw new PermissionException("User id is required to retrieve owner entries");
    OwnerEntries ownerEntries = new OwnerEntries(userId, userId);
    final List<PartData> entries = ownerEntries.retrieveOwnerEntries(field, asc, offset, limit, filter, fields);
    final long count = ownerEntries.getNumberOfOwnerEntries();
    Results<PartData> results = new Results<>();
    results.setResultCount(count);
    results.setData(entries);
    return results;
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Results(org.jbei.ice.lib.dto.common.Results) PartData(org.jbei.ice.lib.dto.entry.PartData) OwnerEntries(org.jbei.ice.lib.entry.OwnerEntries)

Aggregations

Results (org.jbei.ice.lib.dto.common.Results)21 PartData (org.jbei.ice.lib.dto.entry.PartData)10 PermissionException (org.jbei.ice.lib.access.PermissionException)5 Account (org.jbei.ice.storage.model.Account)4 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)3 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)3 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)3 Group (org.jbei.ice.storage.model.Group)3 TraceSequenceAnalysis (org.jbei.ice.lib.dto.entry.TraceSequenceAnalysis)2 OwnerEntries (org.jbei.ice.lib.entry.OwnerEntries)2 SharedEntries (org.jbei.ice.lib.entry.SharedEntries)2 VisibleEntries (org.jbei.ice.lib.entry.VisibleEntries)2 Entry (org.jbei.ice.storage.model.Entry)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AccountController (org.jbei.ice.lib.account.AccountController)1 DNAFeatureLocation (org.jbei.ice.lib.dto.DNAFeatureLocation)1 DNAFeatures (org.jbei.ice.lib.dto.DNAFeatures)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1