Search in sources :

Example 1 with DNAFeatures

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

the class Annotations method get.

/**
 * Retrieves list of annotations that are available
 *
 * @param offset paging start
 * @param limit  maximum number of annotations to return
 * @param sort   paging sort
 * @return available annotations that conform to parameters along with the total number that are available
 * @throws PermissionException if the requesting user's account does not have administrative privileges
 */
public Results<DNAFeatures> get(int offset, int limit, String sort) {
    if (!isAdministrator())
        throw new PermissionException("Administrative privileges required to retrieve features");
    long count = this.featureDAO.getFeaturesGroupByCount();
    Results<DNAFeatures> results = new Results<>();
    results.setResultCount(count);
    Map<String, List<Feature>> map = this.featureDAO.getFeaturesGroupBy(offset, limit);
    for (String key : map.keySet()) {
        DNAFeatures features = new DNAFeatures(key);
        for (Feature feature : map.get(key)) {
            DNAFeature dnaFeature = feature.toDataTransferObject();
            dnaFeature.setSequence(feature.getSequence());
            List<Long> entries = this.sequenceFeatureDAO.getEntryIdsByFeature(feature);
            if (entries != null)
                dnaFeature.getEntries().addAll(entries);
            features.getFeatures().add(dnaFeature);
        }
        results.getData().add(features);
    }
    return results;
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) DNAFeatures(org.jbei.ice.lib.dto.DNAFeatures) Results(org.jbei.ice.lib.dto.common.Results) List(java.util.List) DNAFeature(org.jbei.ice.lib.dto.DNAFeature) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Aggregations

List (java.util.List)1 PermissionException (org.jbei.ice.lib.access.PermissionException)1 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)1 DNAFeatures (org.jbei.ice.lib.dto.DNAFeatures)1 Results (org.jbei.ice.lib.dto.common.Results)1