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;
}
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;
}
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());
}
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());
}
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;
}
Aggregations