Search in sources :

Example 21 with PartData

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

the class FolderContents method getRemotelySharedContents.

// remote request for shared contents
public FolderDetails getRemotelySharedContents(String remoteUserId, String token, RegistryPartner partner, long folderId, PageParameters pageParameters) {
    RemotePartner remotePartner = DAOFactory.getRemotePartnerDAO().getByUrl(partner.getUrl());
    if (remotePartner == null) {
        Logger.error("Cannot retrieve remote partner " + partner.getUrl());
        return null;
    }
    Folder folder = folderDAO.get(folderId);
    if (folder == null) {
        Logger.error("Cannot retrieve folder with id " + folderId);
        return null;
    }
    RemoteShareModelDAO shareModelDAO = DAOFactory.getRemoteShareModelDAO();
    RemoteShareModel shareModel = shareModelDAO.get(remoteUserId, remotePartner, folder);
    if (shareModel == null) {
        Logger.error("Could not retrieve share model");
        return null;
    }
    //verify access
    TokenHash tokenHash = new TokenHash();
    String secret = tokenHash.encrypt(folderId + remotePartner.getUrl() + remoteUserId, token);
    if (!secret.equals(shareModel.getSecret())) {
        Logger.error("Authorization failed for remote folder retrieve");
        return null;
    }
    boolean canEdit = shareModel.getPermission().isCanWrite();
    // todo : move everything above to folder permissions and folder authorization
    FolderDetails details = folder.toDataTransferObject();
    details.setCanEdit(canEdit);
    long folderSize = folderDAO.getFolderSize(folderId, pageParameters.getFilter(), true);
    details.setCount(folderSize);
    // retrieve folder contents
    List<Entry> results = folderDAO.retrieveFolderContents(folderId, pageParameters, true);
    for (Entry entry : results) {
        PartData info = ModelToInfoFactory.createTableViewData(null, entry, false);
        info.setCanEdit(canEdit);
        details.getEntries().add(info);
    }
    return details;
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) TokenHash(org.jbei.ice.lib.account.TokenHash)

Example 22 with PartData

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

the class BlastPlus method parseBlastOutputLine.

/**
     * Parses a blast output that represents a single hit
     *
     * @param line blast output for hit
     * @return object wrapper around details of the hit
     */
private static SearchResult parseBlastOutputLine(String[] line) {
    // extract part information
    PartData view = new PartData(EntryType.nameToType(line[1]));
    view.setId(Long.decode(line[0]));
    view.setName(line[2]);
    view.setPartId(line[3]);
    String summary = DAOFactory.getEntryDAO().getEntrySummary(view.getId());
    view.setShortDescription(summary);
    //search result object
    SearchResult searchResult = new SearchResult();
    searchResult.setEntryInfo(view);
    searchResult.seteValue(line[9]);
    searchResult.setScore(Float.valueOf(line[11]));
    searchResult.setAlignment(line[13]);
    searchResult.setQueryLength(Integer.parseInt(line[12]));
    searchResult.setNident(Integer.parseInt(line[13]));
    return searchResult;
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData) SearchResult(org.jbei.ice.lib.dto.search.SearchResult)

Example 23 with PartData

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

the class BulkUploadResource method createEntry.

/**
     * @param uploadId
     * @param data
     * @return Response with created part data
     */
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entry")
public Response createEntry(@PathParam("id") long uploadId, PartData data) {
    String userId = getUserId();
    Logger.info(userId + ": adding entry to upload \"" + uploadId + "\"");
    PartData result = creator.createEntry(userId, uploadId, data);
    return respond(result);
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 24 with PartData

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

the class BulkUploadResource method updateEntry.

/**
     * @param uploadId
     * @param entryId
     * @param data
     * @return Response with updated part data
     */
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entry/{entryId}")
public Response updateEntry(@PathParam("id") long uploadId, @PathParam("entryId") long entryId, PartData data) {
    String userId = getUserId();
    Logger.info(userId + ": updating entry \"" + entryId + "\" for upload \"" + uploadId + "\"");
    PartData result = creator.updateEntry(userId, uploadId, entryId, data);
    return respond(result);
}
Also used : PartData(org.jbei.ice.lib.dto.entry.PartData)

Example 25 with PartData

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

the class WebResource 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();
    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)

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