Search in sources :

Example 6 with Results

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

the class RemoteEntries method getPublicEntries.

public PartnerEntries getPublicEntries(long remoteId, int offset, int limit, String sort, boolean asc) {
    if (!hasRemoteAccessEnabled())
        return null;
    RemotePartner partner = this.remotePartnerDAO.get(remoteId);
    if (partner == null)
        return null;
    FolderDetails details;
    try {
        HashMap<String, Object> queryParams = new HashMap<>();
        queryParams.put("offset", offset);
        queryParams.put("limit", limit);
        queryParams.put("asc", asc);
        queryParams.put("sort", sort);
        details = this.remoteContact.getFolderEntries(partner.getUrl(), queryParams, partner.getApiKey());
        if (details == null)
            return null;
    } catch (Exception e) {
        Logger.error(e);
        return null;
    }
    Results<PartData> results = new Results<>();
    results.setData(details.getEntries());
    results.setResultCount(details.getCount());
    return new PartnerEntries(partner.toDataTransferObject(), results);
}
Also used : HashMap(java.util.HashMap) Results(org.jbei.ice.lib.dto.common.Results) RemotePartner(org.jbei.ice.storage.model.RemotePartner) PartData(org.jbei.ice.lib.dto.entry.PartData) PartnerEntries(org.jbei.ice.lib.dto.web.PartnerEntries) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) PermissionException(org.jbei.ice.lib.access.PermissionException)

Example 7 with Results

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

the class CollectionEntries method getSampleEntries.

private Results<PartData> getSampleEntries(ColumnField field, boolean asc, int offset, int limit, String filter, List<String> fields) {
    SampleEntries entries = new SampleEntries(this.userId);
    final List<PartData> list = entries.get(field, asc, offset, limit, filter, fields);
    final long count = entries.getCount(filter);
    Results<PartData> results = new Results<>();
    results.setResultCount(count);
    results.setData(list);
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) PartData(org.jbei.ice.lib.dto.entry.PartData) SampleEntries(org.jbei.ice.lib.entry.SampleEntries)

Example 8 with Results

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

the class CollectionEntries method getEntriesByVisibility.

/**
 * Retrieves entries by the specified visibility. {@link Visibility} is used to create
 * collections of entries
 *
 * @param visibility visibility to retrieve entries by
 * @param field      sort field
 * @param asc        sort order
 * @param offset     paging start
 * @param limit      maximum number of entries to retrieve
 * @param user       additional user filter
 * @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
 */
private Results<PartData> getEntriesByVisibility(Visibility visibility, ColumnField field, boolean asc, int offset, int limit, String user, String filter, List<String> fields) {
    List<Long> entries = entryDAO.getByVisibility(user, visibility, field, asc, offset, limit, filter);
    Results<PartData> results = new Results<>();
    for (Long id : entries) {
        PartData info = ModelToInfoFactory.createTableView(id, fields);
        results.getData().add(info);
    }
    results.setResultCount(entryDAO.getByVisibilityCount(user, visibility, filter));
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 9 with Results

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

the class CollectionEntries method getAvailableEntries.

/**
 * Retrieves entries available to user. "Availability" is determined by any permissions set on the entries
 *
 * @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
 */
private Results<PartData> getAvailableEntries(ColumnField field, boolean asc, int offset, int limit, String filter, List<String> fields) {
    VisibleEntries visibleEntries = new VisibleEntries(userId);
    List<PartData> entries = visibleEntries.getEntries(field, asc, offset, limit, filter, fields);
    long count = visibleEntries.getEntryCount(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) VisibleEntries(org.jbei.ice.lib.entry.VisibleEntries)

Example 10 with Results

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

the class Groups method get.

public Results<UserGroup> get(GroupType groupType, int offset, int limit) {
    List<Group> groupList = dao.getGroupsByType(groupType, offset, limit);
    Results<UserGroup> results = new Results<>();
    results.setResultCount(dao.getGroupsByTypeCount(groupType));
    for (Group group : groupList) {
        UserGroup userGroup = group.toDataTransferObject();
        long memberCount = dao.getMemberCount(group.getUuid());
        userGroup.setMemberCount(memberCount);
        results.getData().add(userGroup);
    }
    return results;
}
Also used : Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Results(org.jbei.ice.lib.dto.common.Results) UserGroup(org.jbei.ice.lib.dto.group.UserGroup)

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