Search in sources :

Example 16 with GroupController

use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.

the class OwnerEntries method retrieveOwnerEntries.

public List<PartData> retrieveOwnerEntries(ColumnField sort, boolean asc, int start, int limit, String filter, List<String> fields) {
    List<Long> entries;
    if (this.isAdmin || this.isSelf) {
        entries = entryDAO.retrieveOwnerEntries(this.ownerAccount.getEmail(), sort, asc, start, limit, filter);
    } else {
        Set<Group> accountGroups = new HashSet<>(account.getGroups());
        GroupController controller = new GroupController();
        Group everybodyGroup = controller.createOrRetrievePublicGroup();
        accountGroups.add(everybodyGroup);
        // retrieve entries for user that can be read by others
        entries = entryDAO.retrieveUserEntries(account, this.ownerAccount.getEmail(), accountGroups, sort, asc, start, limit, filter);
    }
    ArrayList<PartData> data = new ArrayList<>();
    for (Long id : entries) {
        PartData info = ModelToInfoFactory.createTableView(id, fields);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) GroupController(org.jbei.ice.lib.group.GroupController) PartData(org.jbei.ice.lib.dto.entry.PartData) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 17 with GroupController

use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.

the class OwnerEntries method getNumberOfOwnerEntries.

public long getNumberOfOwnerEntries() {
    if (this.isAdmin || this.isSelf) {
        return entryDAO.ownerEntryCount(ownerAccount.getEmail());
    }
    Set<Group> accountGroups = new HashSet<>(account.getGroups());
    GroupController controller = new GroupController();
    Group everybodyGroup = controller.createOrRetrievePublicGroup();
    accountGroups.add(everybodyGroup);
    return entryDAO.ownerEntryCount(account, ownerAccount.getEmail(), accountGroups);
}
Also used : Group(org.jbei.ice.storage.model.Group) GroupController(org.jbei.ice.lib.group.GroupController) HashSet(java.util.HashSet)

Example 18 with GroupController

use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.

the class Annotations method filter.

public Results<DNAFeature> filter(int offset, int limit, String filter) {
    Account account = accountDAO.getByEmail(userId);
    List<Group> groups = new GroupController().getAllGroups(account);
    List<SequenceFeature> features = sequenceFeatureDAO.getSequenceFeatures(this.userId, groups, filter, offset, limit);
    int count = sequenceFeatureDAO.getSequenceFeaturesCount(this.userId, groups, filter);
    Results<DNAFeature> results = new Results<>();
    results.setResultCount(count);
    for (SequenceFeature feature : features) {
        DNAFeature dnaFeature = feature.toDataTransferObject();
        Entry entry = feature.getSequence().getEntry();
        dnaFeature.setIdentifier(entry.getPartNumber());
        DNAFeatureLocation location = new DNAFeatureLocation();
        location.setGenbankStart(feature.getUniqueGenbankStart());
        location.setEnd(feature.getUniqueEnd());
        dnaFeature.getLocations().add(location);
        dnaFeature.getEntries().add(entry.getId());
        results.getData().add(dnaFeature);
    }
    return results;
}
Also used : Results(org.jbei.ice.lib.dto.common.Results) GroupController(org.jbei.ice.lib.group.GroupController) DNAFeatureLocation(org.jbei.ice.lib.dto.DNAFeatureLocation) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 19 with GroupController

use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.

the class SharedEntries method getNumberOfEntries.

public long getNumberOfEntries(String filter) {
    GroupController groupController = new GroupController();
    Group publicGroup = groupController.createOrRetrievePublicGroup();
    Set<Group> accountGroups = account.getGroups();
    accountGroups.remove(publicGroup);
    return this.entryDAO.sharedEntryCount(account, accountGroups, filter);
}
Also used : Group(org.jbei.ice.storage.model.Group) GroupController(org.jbei.ice.lib.group.GroupController)

Example 20 with GroupController

use of org.jbei.ice.lib.group.GroupController in project ice by JBEI.

the class SharedEntries method getEntries.

public List<PartData> getEntries(ColumnField field, boolean asc, int start, int limit, String filter, List<String> fields) {
    GroupController groupController = new GroupController();
    Group publicGroup = groupController.createOrRetrievePublicGroup();
    Set<Group> accountGroups = account.getGroups();
    accountGroups.remove(publicGroup);
    List<Long> entries = this.entryDAO.sharedWithUserEntries(account, accountGroups, field, asc, start, limit, filter);
    ArrayList<PartData> data = new ArrayList<>();
    for (Long id : entries) {
        PartData info = ModelToInfoFactory.createTableView(id, fields);
        data.add(info);
    }
    return data;
}
Also used : Group(org.jbei.ice.storage.model.Group) GroupController(org.jbei.ice.lib.group.GroupController) PartData(org.jbei.ice.lib.dto.entry.PartData) ArrayList(java.util.ArrayList)

Aggregations

GroupController (org.jbei.ice.lib.group.GroupController)25 Group (org.jbei.ice.storage.model.Group)12 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)8 PartData (org.jbei.ice.lib.dto.entry.PartData)8 HashSet (java.util.HashSet)6 Entry (org.jbei.ice.storage.model.Entry)6 ArrayList (java.util.ArrayList)5 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)4 Account (org.jbei.ice.storage.model.Account)4 CSVWriter (com.opencsv.CSVWriter)3 Path (java.nio.file.Path)3 AccountController (org.jbei.ice.lib.account.AccountController)3 EntryDAO (org.jbei.ice.storage.hibernate.dao.EntryDAO)3 ZipEntry (java.util.zip.ZipEntry)2 PermissionException (org.jbei.ice.lib.access.PermissionException)2 EntryFieldLabel (org.jbei.ice.lib.dto.entry.EntryFieldLabel)2 RebuildBlastIndexTask (org.jbei.ice.lib.search.blast.RebuildBlastIndexTask)2 ZipOutputStream (java.util.zip.ZipOutputStream)1 PermissionsController (org.jbei.ice.lib.access.PermissionsController)1 ConfigurationSettings (org.jbei.ice.lib.config.ConfigurationSettings)1