use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderController method getPublicFolders.
/**
* Retrieves folders that are shared shared publicly. Note that this is different from
* featured folders that have a type of PUBLIC
*
* @return list of public folders on this site
*/
public ArrayList<FolderDetails> getPublicFolders() {
Group publicGroup = groupController.createOrRetrievePublicGroup();
List<Folder> folders = permissionDAO.getFolders(publicGroup);
ArrayList<FolderDetails> list = new ArrayList<>();
for (Folder folder : folders) {
FolderDetails details = folder.toDataTransferObject();
long folderSize = dao.getFolderSize(folder.getId(), null, true);
details.setCount(folderSize);
list.add(details);
}
Collections.sort(list);
return list;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderContents method addRemoteEntries.
/**
* @param remoteEntries list of entries that map to entries on other ICE instances. It contains enough information
* for the table view (as a cache)
* @param folders list of folders that the remote entries are to be added to
* @return List of folders that the specified entries were added to
*/
protected List<FolderDetails> addRemoteEntries(String userId, List<PartData> remoteEntries, List<FolderDetails> folders) {
// nothing adding to destination
if (remoteEntries == null)
return new ArrayList<>();
// nothing to add
if (remoteEntries.isEmpty())
return folders;
EntryDAO entryDAO = DAOFactory.getEntryDAO();
List<Entry> entryModelList = new ArrayList<>(remoteEntries.size());
for (PartData partData : remoteEntries) {
Entry entry = entryDAO.getByRecordId(partData.getRecordId());
if (entry == null) {
switch(partData.getType()) {
case PART:
default:
entry = new Part();
break;
case STRAIN:
entry = new Strain();
break;
case PLASMID:
entry = new Plasmid();
break;
case ARABIDOPSIS:
entry = new ArabidopsisSeed();
break;
}
entry.setRecordId(partData.getRecordId());
entry.setVersionId(partData.getRecordId());
entry.setRecordType(partData.getType().getDisplay());
entry.setName(partData.getName());
entry.setShortDescription(partData.getShortDescription());
entry.setStatus(partData.getStatus());
entry.setVisibility(Visibility.REMOTE.getValue());
entry.setPartNumber(partData.getPartId());
String sequence = partData.isHasSequence() ? "sequence" : "text";
entry.setLongDescriptionType(sequence);
entry.setBioSafetyLevel(partData.getBioSafetyLevel());
entry.setCreationTime(new Date(partData.getCreationTime()));
entry = entryDAO.create(entry);
}
entryModelList.add(entry);
}
for (FolderDetails details : folders) {
Folder folder = folderDAO.get(details.getId());
if (folder == null) {
Logger.warn("Could not add entries to folder " + details.getId() + " which doesn't exist");
continue;
}
if (!folderAuthorization.canWrite(userId, folder)) {
Logger.warn(userId + " lacks write privileges on folder " + folder.getId());
continue;
}
folderDAO.addFolderContents(folder, entryModelList);
details.setCount(folderDAO.getFolderSize(folder.getId(), null, true));
}
return folders;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderController method getBulkUploadDrafts.
public ArrayList<FolderDetails> getBulkUploadDrafts(String userId) {
ArrayList<FolderDetails> folders = new ArrayList<>();
ArrayList<BulkUploadInfo> list = bulkUploadController.retrieveByUser(userId, userId);
for (BulkUploadInfo info : list) {
FolderDetails details = new FolderDetails();
details.setName(info.getName());
details.setCount(info.getCount());
details.setId(info.getId());
details.setCanEdit(true);
details.setType(FolderType.UPLOAD);
folders.add(details);
}
return folders;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderController method getAvailableFolders.
/**
* Retrieves folders that have been "promoted" by an administrator to
* imply that they are to be made available to everyone on the site
*
* @param userId unique user identifier
* @return list of folders that are contained under the "Available" section
*/
public ArrayList<FolderDetails> getAvailableFolders(String userId) {
Set<Folder> folders = new HashSet<>();
folders.addAll(dao.getFoldersByType(FolderType.PUBLIC));
boolean isAdmin = accountController.isAdministrator(userId);
ArrayList<FolderDetails> list = new ArrayList<>();
for (Folder folder : folders) {
FolderDetails details = folder.toDataTransferObject();
long folderSize = dao.getFolderSize(folder.getId(), null, true);
details.setCount(folderSize);
details.setType(FolderType.PUBLIC);
details.setCanEdit(isAdmin);
list.add(details);
}
Collections.sort(list);
return list;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class RemoteTransfer method transferFolder.
public FolderDetails transferFolder(long remoteId, FolderDetails folderDetails, List<Long> remoteIds) {
RemotePartner partner = this.remotePartnerDAO.get(remoteId);
if (partner == null)
throw new IllegalArgumentException("Invalid remote host id: " + remoteId);
FolderDetails details = remoteContact.transferFolder(partner.getUrl(), folderDetails);
if (folderDetails == null) {
Logger.error("Could not create remote folder");
return null;
}
if (remoteIds == null || remoteIds.isEmpty()) {
Logger.info("Skipping transfer of entries. List is empty");
return details;
}
// move entries to the transferred entries
EntrySelection entrySelection = new EntrySelection();
entrySelection.getEntries().addAll(remoteIds);
entrySelection.getDestination().add(details);
entrySelection.setSelectionType(EntrySelectionType.FOLDER);
remoteContact.addTransferredEntriesToFolder(partner.getUrl(), entrySelection);
return details;
}
Aggregations