Search in sources :

Example 11 with FolderDetails

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

the class FolderController method getUserFolders.

public ArrayList<FolderDetails> getUserFolders(String userId) {
    Account account = getAccount(userId);
    List<Folder> folders = dao.getFoldersByOwner(account);
    ArrayList<FolderDetails> folderDetails = new ArrayList<>();
    for (Folder folder : folders) {
        if (!folder.getOwnerEmail().equalsIgnoreCase(userId))
            continue;
        FolderDetails details = new FolderDetails(folder.getId(), folder.getName());
        long folderSize = dao.getFolderSize(folder.getId(), null, true);
        details.setCount(folderSize);
        details.setType(folder.getType());
        if (folder.getCreationTime() != null)
            details.setCreationTime(folder.getCreationTime().getTime());
        details.setCanEdit(true);
        folderDetails.add(details);
    }
    return folderDetails;
}
Also used : Account(org.jbei.ice.storage.model.Account) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder)

Example 12 with FolderDetails

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

the class Folder method toDataTransferObject.

@Override
public FolderDetails toDataTransferObject() {
    FolderDetails details = new FolderDetails(id, name);
    details.setType(type);
    details.setDescription(description);
    if (parent != null) {
        details.setParent(parent.toDataTransferObject());
    }
    if (getCreationTime() != null)
        details.setCreationTime(getCreationTime().getTime());
    details.setPropagatePermission(this.isPropagatePermissions());
    return details;
}
Also used : FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Example 13 with FolderDetails

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

the class FolderControllerTest method testGetPublicFolders.

@Test
public void testGetPublicFolders() throws Exception {
    Account account = AccountCreator.createTestAccount("testGetPublicFolders", false);
    Assert.assertNotNull(account);
    String userId = account.getEmail();
    FolderDetails details = new FolderDetails();
    details.setName("test1");
    details = controller.createPersonalFolder(userId, details);
    Assert.assertNotNull(details);
    PermissionsController permissionsController = new PermissionsController();
    AccessPermission accessPermission = new AccessPermission();
    accessPermission.setArticle(AccessPermission.Article.GROUP);
    long publicGroupId = new GroupController().createOrRetrievePublicGroup().getId();
    accessPermission.setArticleId(publicGroupId);
    accessPermission.setType(AccessPermission.Type.READ_FOLDER);
    accessPermission.setTypeId(details.getId());
    permissionsController.addPermission(userId, accessPermission);
    ArrayList<FolderDetails> results = controller.getPublicFolders();
    Assert.assertFalse(results.isEmpty());
    Assert.assertEquals(details.getName(), results.get(0).getName());
}
Also used : Account(org.jbei.ice.storage.model.Account) GroupController(org.jbei.ice.lib.group.GroupController) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) PermissionsController(org.jbei.ice.lib.access.PermissionsController) Test(org.junit.Test)

Example 14 with FolderDetails

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

the class FolderControllerTest method testCreateNewFolder.

@Test
public void testCreateNewFolder() throws Exception {
    Account account = AccountCreator.createTestAccount("testCreateNewFolder", false);
    String userId = account.getEmail();
    FolderDetails folderDetails = new FolderDetails();
    folderDetails.setName("test");
    FolderDetails folder = controller.createPersonalFolder(userId, folderDetails);
    Assert.assertNotNull(folder);
    Folder f = DAOFactory.getFolderDAO().get(folder.getId());
    Assert.assertNotNull(f);
    Assert.assertEquals("test", f.getName());
}
Also used : Account(org.jbei.ice.storage.model.Account) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 15 with FolderDetails

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

the class FolderContentsTest method createPersonalFolder.

public FolderDetails createPersonalFolder(String userId, FolderDetails folderDetails) {
    if (folderDetails.getName() == null)
        return null;
    Folder folder = new Folder(folderDetails.getName());
    folder.setOwnerEmail(userId);
    folder.setType(FolderType.PRIVATE);
    folder.setCreationTime(new Date());
    folder = DAOFactory.getFolderDAO().create(folder);
    FolderDetails details = folder.toDataTransferObject();
    details.setCanEdit(true);
    return details;
}
Also used : FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder)

Aggregations

FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)35 Folder (org.jbei.ice.storage.model.Folder)11 PartData (org.jbei.ice.lib.dto.entry.PartData)8 Account (org.jbei.ice.storage.model.Account)8 PermissionException (org.jbei.ice.lib.access.PermissionException)6 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)5 Test (org.junit.Test)5 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)4 GroupController (org.jbei.ice.lib.group.GroupController)4 ArrayList (java.util.ArrayList)3 BulkUploadInfo (org.jbei.ice.lib.bulkupload.BulkUploadInfo)3 EntrySelection (org.jbei.ice.lib.entry.EntrySelection)3 Group (org.jbei.ice.storage.model.Group)3 RemotePartner (org.jbei.ice.storage.model.RemotePartner)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 TokenHash (org.jbei.ice.lib.account.TokenHash)2 Entries (org.jbei.ice.lib.entry.Entries)2 Entry (org.jbei.ice.storage.model.Entry)2 HashSet (java.util.HashSet)1