Search in sources :

Example 1 with SequenceFormat

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

the class SequenceDAO method getSequenceFormat.

/**
 * Retrieves the sequence format of the specified entry, if there is one available.
 * Typically, the format is not available if there is no sequence associated with the entry
 *
 * @param entryId unique identifier for entry
 * @return container containing sequence format, if one is found, or null otherwise
 * @throws DAOException on hibernate exception
 */
public Optional<SequenceFormat> getSequenceFormat(long entryId) {
    try {
        CriteriaQuery<SequenceFormat> query = getBuilder().createQuery(SequenceFormat.class);
        Root<Sequence> from = query.from(Sequence.class);
        Join<Sequence, Entry> entry = from.join("entry");
        query.select(from.get("format")).where(getBuilder().equal(entry.get("id"), entryId));
        return currentSession().createQuery(query).uniqueResultOptional();
    } catch (HibernateException he) {
        Logger.error(he);
        throw new DAOException(he);
    }
}
Also used : DAOException(org.jbei.ice.storage.DAOException) SequenceFormat(org.jbei.ice.lib.entry.sequence.SequenceFormat) Entry(org.jbei.ice.storage.model.Entry) HibernateException(org.hibernate.HibernateException) Sequence(org.jbei.ice.storage.model.Sequence)

Example 2 with SequenceFormat

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

the class PartResource method customExport.

@POST
@Path("/custom")
@Produces(MediaType.APPLICATION_JSON)
public Response customExport(@QueryParam("sequenceFormat") String sequenceFormat, @DefaultValue("true") @QueryParam("onePerFolder") boolean onePerFolder, EntrySelection selection) {
    String userId = super.requireUserId();
    SequenceFormat format = SequenceFormat.fromString(sequenceFormat.toUpperCase());
    CustomExportTask task = new CustomExportTask(userId, selection, format, onePerFolder);
    IceExecutorService.getInstance().runTask(task);
    return super.respond(true);
}
Also used : SequenceFormat(org.jbei.ice.lib.entry.sequence.SequenceFormat) CustomExportTask(org.jbei.ice.lib.entry.export.CustomExportTask)

Aggregations

SequenceFormat (org.jbei.ice.lib.entry.sequence.SequenceFormat)2 HibernateException (org.hibernate.HibernateException)1 CustomExportTask (org.jbei.ice.lib.entry.export.CustomExportTask)1 DAOException (org.jbei.ice.storage.DAOException)1 Entry (org.jbei.ice.storage.model.Entry)1 Sequence (org.jbei.ice.storage.model.Sequence)1