Search in sources :

Example 1 with OwnerEntries

use of org.jbei.ice.lib.entry.OwnerEntries 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
     */
protected Results<PartData> getPersonalEntries(ColumnField field, boolean asc, int offset, int limit, String filter) {
    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);
    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)

Example 2 with OwnerEntries

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

the class UserResource method getProfileEntries.

/**
     * @return collection for user's part entries
     */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries")
public FolderDetails getProfileEntries(@PathParam("id") long userId, @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("15") @QueryParam("limit") int limit, @DefaultValue("created") @QueryParam("sort") String sort, @DefaultValue("false") @QueryParam("asc") boolean asc, @DefaultValue("") @QueryParam("filter") String filter) {
    String userIdString = getUserId();
    ColumnField field = ColumnField.valueOf(sort.toUpperCase());
    OwnerEntries ownerEntries = new OwnerEntries(userIdString, userId);
    List<PartData> entries = ownerEntries.retrieveOwnerEntries(field, asc, offset, limit, filter);
    long count = ownerEntries.getNumberOfOwnerEntries();
    FolderDetails details = new FolderDetails();
    details.getEntries().addAll(entries);
    details.setCount(count);
    return details;
}
Also used : ColumnField(org.jbei.ice.lib.shared.ColumnField) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) OwnerEntries(org.jbei.ice.lib.entry.OwnerEntries)

Aggregations

PartData (org.jbei.ice.lib.dto.entry.PartData)2 OwnerEntries (org.jbei.ice.lib.entry.OwnerEntries)2 PermissionException (org.jbei.ice.lib.access.PermissionException)1 Results (org.jbei.ice.lib.dto.common.Results)1 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)1 ColumnField (org.jbei.ice.lib.shared.ColumnField)1