Search in sources :

Example 6 with PartData

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

the class VisibleEntries method getEntries.

public List<PartData> getEntries(ColumnField field, boolean asc, int start, int limit, String filter) {
    List<Entry> results;
    if (isAdmin) {
        // no filters
        results = dao.retrieveAllEntries(field, asc, start, limit, filter);
    } else {
        // retrieve groups for account and filter by permission
        Set<Group> accountGroups = new HashSet<>(account.getGroups());
        accountGroups.add(everybodyGroup);
        results = dao.retrieveVisibleEntries(account, accountGroups, field, asc, start, limit, filter);
    }
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : results) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData) HashSet(java.util.HashSet)

Example 7 with PartData

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

the class OwnerEntries method retrieveOwnerEntries.

public List<PartData> retrieveOwnerEntries(ColumnField sort, boolean asc, int start, int limit, String filter) {
    List<Entry> entries;
    if (this.isAdmin || this.isSelf) {
        entries = entryDAO.retrieveOwnerEntries(this.ownerAccount.getEmail(), sort, asc, start, limit, filter);
    } else {
        Set<Group> accountGroups = new HashSet<>(account.getGroups());
        GroupController controller = new GroupController();
        Group everybodyGroup = controller.createOrRetrievePublicGroup();
        accountGroups.add(everybodyGroup);
        // retrieve entries for user that can be read by others
        entries = entryDAO.retrieveUserEntries(account, this.ownerAccount.getEmail(), accountGroups, sort, asc, start, limit, filter);
    }
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : entries) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData) HashSet(java.util.HashSet)

Example 8 with PartData

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

the class SharedEntries method getEntries.

public List<PartData> getEntries(ColumnField field, boolean asc, int start, int limit, String filter) {
    GroupController groupController = new GroupController();
    Group publicGroup = groupController.createOrRetrievePublicGroup();
    Set<Group> accountGroups = account.getGroups();
    accountGroups.remove(publicGroup);
    List<Entry> entries = this.entryDAO.sharedWithUserEntries(account, accountGroups, field, asc, start, limit, filter);
    ArrayList<PartData> data = new ArrayList<>();
    for (Entry entry : entries) {
        PartData info = ModelToInfoFactory.createTableViewData(account.getEmail(), entry, false);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) ArrayList(java.util.ArrayList) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 9 with PartData

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

use of org.jbei.ice.lib.dto.entry.PartData 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)

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