Search in sources :

Example 1 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
     */
protected Results<PartData> getSharedEntries(ColumnField field, boolean asc, int offset, int limit, String filter) {
    SharedEntries sharedEntries = new SharedEntries(this.userId);
    List<PartData> entries = sharedEntries.getEntries(field, asc, offset, limit, filter);
    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 2 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
     */
protected Results<PartData> getEntriesByVisibility(Visibility visibility, ColumnField field, boolean asc, int offset, int limit, String user, String filter) {
    List<Entry> entries = entryDAO.getByVisibility(user, visibility, field, asc, offset, limit, filter);
    Results<PartData> results = new Results<>();
    for (Entry entry : entries) {
        PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
        results.getData().add(info);
    }
    results.setResultCount(entryDAO.getByVisibilityCount(user, visibility, filter));
    return results;
}
Also used : Entry(org.jbei.ice.storage.model.Entry) Results(org.jbei.ice.lib.dto.common.Results) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 3 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
     */
protected Results<PartData> getAvailableEntries(ColumnField field, boolean asc, int offset, int limit, String filter) {
    VisibleEntries visibleEntries = new VisibleEntries(userId);
    List<PartData> entries = visibleEntries.getEntries(field, asc, offset, limit, filter);
    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 4 with Results

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

the class Manuscripts method get.

public Results<Manuscript> get(String sort, boolean asc, int offset, int size, String filter) {
    Results<Manuscript> results = new Results<>();
    results.setResultCount(dao.getTotalCount(filter));
    List<ManuscriptModel> list = dao.list(sort, asc, offset, size, filter);
    if (!list.isEmpty()) {
        for (ManuscriptModel manuscriptModel : list) results.getData().add(manuscriptModel.toDataTransferObject());
    }
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) ManuscriptModel(org.jbei.ice.storage.model.ManuscriptModel)

Example 5 with Results

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

the class Messages method get.

public Results<MessageInfo> get(int start, int limit) {
    Account account = accountDAO.getByEmail(this.userId);
    List<Group> groups = DAOFactory.getGroupDAO().retrieveMemberGroups(account);
    List<Message> messages = new ArrayList<>(dao.retrieveMessages(account, groups, start, limit));
    Results<MessageInfo> results = new Results<>();
    for (Message message : messages) {
        Account from = accountDAO.getByEmail(message.getFromEmail());
        if (from == null)
            continue;
        MessageInfo info = new MessageInfo();
        info.setId(message.getId());
        // get from details
        AccountTransfer accountTransfer = new AccountTransfer();
        accountTransfer.setEmail(from.getEmail());
        accountTransfer.setFirstName(account.getFirstName());
        accountTransfer.setLastName(account.getLastName());
        info.setFrom(accountTransfer);
        info.setTitle(message.getTitle());
        info.setRead(message.isRead());
        info.setSent(message.getDateSent().getTime());
        results.getData().add(info);
    }
    int totalSize = dao.retrieveMessageCount(account, groups);
    results.setResultCount(totalSize);
    return results;
}
Also used : Account(org.jbei.ice.storage.model.Account) Group(org.jbei.ice.storage.model.Group) UserGroup(org.jbei.ice.lib.dto.group.UserGroup) Message(org.jbei.ice.storage.model.Message) Results(org.jbei.ice.lib.dto.common.Results) ArrayList(java.util.ArrayList) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer) MessageInfo(org.jbei.ice.lib.dto.message.MessageInfo)

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