Search in sources :

Example 16 with PartData

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

the class TransferredParts method saveTransferred.

private Entry saveTransferred(PartData part) {
    Entry entry = dao.getByRecordId(part.getRecordId());
    if (entry != null) {
        Logger.info("Transferred entry found locally " + part.getRecordId());
        part.setId(entry.getId());
    } else {
        entry = InfoToModelFactory.infoToEntry(part);
        entry.setVisibility(Visibility.TRANSFERRED.getValue());
        entry = dao.create(entry);
        part.setId(entry.getId());
        part.setRecordId(entry.getRecordId());
    }
    // transfer and linked
    for (PartData data : part.getLinkedParts()) {
        Entry linked = saveTransferred(data);
        data.setId(linked.getId());
        data.setRecordId(linked.getRecordId());
        entry.getLinkedEntries().add(linked);
        dao.update(entry);
    }
    return entry;
}
Also used : Entry(org.jbei.ice.storage.model.Entry) PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 17 with PartData

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

the class PartnerResource method getWebEntryTooltip.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries/{entryId}/tooltip")
public Response getWebEntryTooltip(@PathParam("id") final long partnerId, @PathParam("entryId") final long entryId) {
    final String userId = super.getUserId();
    RemoteEntries remoteEntries = new RemoteEntries();
    final PartData result = remoteEntries.getPublicEntryTooltip(userId, partnerId, entryId);
    return super.respond(Response.Status.OK, result);
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 18 with PartData

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

the class BulkEntryCreator method createOrUpdateEntries.

public BulkUploadInfo createOrUpdateEntries(String userId, long draftId, List<PartData> data) {
    BulkUpload draft = dao.get(draftId);
    if (draft == null)
        return null;
    // check permissions
    authorization.expectWrite(userId, draft);
    BulkUploadInfo uploadInfo = draft.toDataTransferObject();
    for (PartData datum : data) {
        if (datum == null)
            continue;
        int index = datum.getIndex();
        Entry entry = entryDAO.get(datum.getId());
        if (entry != null) {
            if (draft.getStatus() != BulkUploadStatus.BULK_EDIT)
                entry.setVisibility(Visibility.DRAFT.getValue());
            datum = doUpdate(userId, entry, datum);
        } else
            datum = createEntryForUpload(userId, datum, draft);
        if (datum == null)
            return null;
        datum.setIndex(index);
        uploadInfo.getEntryList().add(datum);
    }
    return uploadInfo;
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 19 with PartData

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

the class FolderContents method getContents.

/**
     * Retrieves the folder specified in the parameter and contents
     *
     * @param userId         unique identifier for user making request. If null, folder must have public read privs
     * @param folderId       unique identifier for folder to be retrieved
     * @param pageParameters paging parameters
     * @return wrapper around list of folder entries if folder is found, null otherwise
     * @throws PermissionException if user does not have read permissions on folder
     */
public FolderDetails getContents(String userId, long folderId, PageParameters pageParameters) {
    Folder folder = folderDAO.get(folderId);
    if (folder == null)
        return null;
    // should have permission to read folder
    folderAuthorization.expectRead(userId, folder);
    if (folder.getType() == FolderType.REMOTE)
        return getRemoteContents(userId, folder, pageParameters);
    boolean visibleOnly = folder.getType() != FolderType.TRANSFERRED;
    FolderDetails details = folder.toDataTransferObject();
    // all local entries at this point
    long folderSize = folderDAO.getFolderSize(folderId, pageParameters.getFilter(), visibleOnly);
    details.setCount(folderSize);
    if (userId != null) {
        List<AccessPermission> permissions = getAndFilterFolderPermissions(userId, folder);
        details.setAccessPermissions(permissions);
        boolean canEdit = permissionsController.hasWritePermission(userId, folder);
        details.setCanEdit(canEdit);
    }
    details.setPublicReadAccess(permissionsController.isPublicVisible(folder));
    Account owner = DAOFactory.getAccountDAO().getByEmail(folder.getOwnerEmail());
    if (owner != null)
        details.setOwner(owner.toDataTransferObject());
    // retrieve folder contents
    List<Entry> results = folderDAO.retrieveFolderContents(folderId, pageParameters, visibleOnly);
    for (Entry entry : results) {
        PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
        details.getEntries().add(info);
    }
    return details;
}
Also used : AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Example 20 with PartData

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

the class FolderController method getPublicEntries.

/**
     * Retrieves entries that are made available publicly
     *
     * @param sort   order of retrieval for the entries
     * @param offset start of retrieval
     * @param limit  maximum number of entries to retrieve
     * @param asc    whether to retrieve the entries in ascending order
     * @return wrapper around the retrieved entries
     */
public FolderDetails getPublicEntries(ColumnField sort, int offset, int limit, boolean asc) {
    Group publicGroup = new GroupController().createOrRetrievePublicGroup();
    Set<Group> groups = new HashSet<>();
    groups.add(publicGroup);
    EntryDAO entryDAO = DAOFactory.getEntryDAO();
    List<Entry> results = entryDAO.retrieveVisibleEntries(null, groups, sort, asc, offset, limit, null);
    long visibleCount = entryDAO.visibleEntryCount(null, groups, null);
    FolderDetails details = new FolderDetails();
    details.setCount(visibleCount);
    for (Entry entry : results) {
        try {
            PartData info = ModelToInfoFactory.createTableViewData(null, entry, false);
            info.setPublicRead(true);
            details.getEntries().add(info);
        } catch (Exception e) {
            Logger.error(e);
        }
    }
    return details;
}
Also used : Group(org.jbei.ice.storage.model.Group) Entry(org.jbei.ice.storage.model.Entry) GroupController(org.jbei.ice.lib.group.GroupController) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) PermissionException(org.jbei.ice.lib.access.PermissionException) EntryDAO(org.jbei.ice.storage.hibernate.dao.EntryDAO)

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